About 52 results
Open links in new tab
  1. How does the string class in c++ std work? - Stack Overflow

    22 std::string is actually a typedef to a std::basic_string<char>, and therein lies the answer to your #1 above. Its a template in order to make basic_string work with pretty much anything. char, unsigned …

  2. c++ - std::wstring VS std::string - Stack Overflow

    Dec 31, 2008 · 1180 string? wstring? std::string is a basic_string templated on a char, and std::wstring on a wchar_t. char vs. wchar_t char is supposed to hold a character, usually an 8-bit character. …

  3. c++ - std::string formatting like sprintf - Stack Overflow

    Feb 26, 2010 · I have to format std::string with sprintf and send it into file stream. How can I do this?

  4. Differences between C++ string == and compare ()?

    204 std::string::compare () returns an int: equal to zero if s and t are equal, less than zero if s is less than t, greater than zero if s is greater than t. If you want your first code snippet to be equivalent to the …

  5. C++ string declaration - Stack Overflow

    Nov 9, 2011 · The expression new std::string("foo") creates an std::string on the free store and returns a pointer to an std::string. It then attempts to assign the returned pointer of type std::string* to s of type …

  6. What's the difference between std::string and std::basic_string? And ...

    Nov 2, 2009 · A std::string is an instantiation of the std::basic_string template with a type of char. You need both so that you can make strings of things besides char, such a std::basic_string<wchar_t> for …

  7. Are the days of passing const std::string & as a parameter over?

    Apr 19, 2012 · Since the introduction of std::string_view there's never a good case for passing a reference to string. But given when you asked this question, that's probably not what you're looking for!

  8. std::string::assign vs std::string::operator= - Stack Overflow

    Dec 10, 2015 · Be careful not to include the trailing \0 from the C string in the std::string, this will bite you if you later try to append to it. In the example above, use a length of 11, not 12.

  9. c++ - How is std::string implemented? - Stack Overflow

    Sep 23, 2009 · I am curious to know how std::string is implemented and how does it differ from c string?If the standard does not specify any implementation then any implementation with explanation …

  10. How exactly is std::string_view faster than const std::string&?

    Oct 19, 2016 · std::string_view is faster in a few cases. First, std::string const& requires the data to be in a std::string, and not a raw C array, a char const* returned by a C API, a std::vector<char> produced …