template < size_t N > const char *bitset_string( const std::bitset<N>& bits, const char *const flagarray[] )
{
std::vector< std::string > flags;
static std::string flag_str;
for( size_t x = 0; x < N; ++x )
{
if( bits.test( x ) )
flags.push_back( flagarray[x] );
}
flag_str = join( flags, " " ); // or "," or whatever
return flag_str.c_str( );
}
I use it for turning a bitset into a string of flags on whatever the bitset is part of. Anyway, upon testing it crashes because the assert fails. And I can't for the life of me figure out why.
Here's the call:
The flag array is:
And the flags are defined as:
Now, as this is my first foray into using asserts, I'm not sure what's wrong, or how to fix it, so any insight is appreciated.