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