64,648
社区成员
发帖
与我相关
我的任务
分享
template < typename CharT >
class not_space
{
typedef std::ctype< CharT > char_type;
boost::shared_ptr< std::locale > the_loc_ptr;
char_type const * the_type_ptr;
public:
not_space ( std::locale const & r_loc = std::locale() )
: the_loc_ptr ( new std::locale ( r_loc ) )
, the_type_ptr ( &std::use_facet< char_type >( *the_loc_ptr ) )
{
}
bool operator() ( CharT chr )
{
return !( the_type_ptr->is(std::ctype_base::space,chr) );
}
};
//使用案例
strtxt.erase(
strtxt.begin(),
find_if( strtxt.begin(), strtxt.end(), not_space<char>() ) );