Boost logo

Boost Users :

Subject: [Boost-users] boost::trim throwing std::bad_cast exeption with custom basic_string
From: Arash Abghari (arash.abghari_at_[hidden])
Date: 2011-01-21 14:15:24


Hi,

I have a custom basic_string as follows:

typedef basic_string<unsigned int> ustring;

so if I pass an instance of ustring to boost:trim it throws an
std::bad_cast exception.

ustring str;
boost::trim(str);

The exception comes from here:

include/boost/algorithm/string/detail/classification.hpp:45
return std::use_facet< std::ctype<CharT> >(m_Locale).is( m_Type, Ch );

It does not matter what character type I use for basic_string, It throws
the exception for anything but char and wchar_t. Document mentions "A
string is not restricted to std::basic_string and character does not
have to be char or wchar_t, although these are most common candidates",
So I assume, It must work with unsigned int or other types.

Here is the system spec:

boost: 1.40
gcc: 4.3.4
OS: Debian Lenny 64bit

Thanks


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net