This might be a simple question for some of you. But I was wondering if a std::string
is a container. By container I mean the containers like for example std::vector
, std::list
and std::deque
.
Since std::basic_string<>
accepts other types than integral characters, but also is being optimized by working with character arrays. It isn't really clear to me in which category it falls.
This will compile:
#include <string>
#include <iostream>
int main() {
std::basic_string<int> int_str;
int_str.push_back(14);
return 0;
}
But by adding this line:
std::cout << int_str << std::endl;
It won't. So by these facts I could conclude that an std::basic_string was not intended to work with other types than characters.
It might be a strange question for you. The reason I need to know this is because I'm working on a framework and I'm still not able to determine in which category a "string" would fall.
struct X
orfloat
. – TalaContainer
concept. That's about the best definition we can use for this question. – Placidofloat
? – Horsleychar_traits
that are used for strings aren't defined forfloat
types. [It would also be rather strange, what do you do with the character that is "between" A and B?] – Talachar_traits
is a default value, you can supply you own. "what do you do with the character that is "between" A and B?" I don't understand. – Horsleystring
to do something other than that -vector
is much more generic for "storing stuff"). With afloat
value, you need to consider that whatever two values you have, there could be something in between (unless the difference between the two values is 1/1677216th of the first value to the second value, assuming a 24 bit mantissa). – Tala