I need a fixed size string type for certain requirements. For now I've been doing a simple
I am assuming that you want to hold the small string in-place, avoiding allocation on heap and indirection when accessing it. In that case, have a look at
small_vector from Boost.
typedef boost::container::small_vector<char> small_string;
This would work as the string you want.
UPDATE: It seems that many implementations of standard C++ library use the small string optimization (SSO) for
std::string. It means that as long as your string is small enough (for example 22 characters on 64 bit architecture) it will be stored in-place. I strongly suggest you to use standard