Skip to content

silly question, I can't print the sprite name.... #1679

Closed Answered by rh101
rudiHammad asked this question in Q&A
Discussion options

You must be logged in to vote

what use then should we give to std::string_view?

Sorry, I don't understand what you mean by that.

In theory it is preferable to use it instead of std::string because it's light weight right?

It's not theory, but you're right that it's "light weight", since it's just a read-only reference to data, and doesn't actually hold a copy of the data. Plenty of info online about it.

In your specific use-case above, you're attempting to use a function (log) that accepts a null terminated character sequence, which has nothing to do with std::string or std::string_view. The need to convert the string_view to a string first is because the string_view does not have a null terminator at the end of t…

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@rh101
Comment options

rh101 Feb 13, 2024
Collaborator

Answer selected by rudiHammad
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@halx99
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants