1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#include <string>
#include <locale>
bool has( const std::string& str, std::ctype_base::mask mask )
{
static const std::locale default_locale ;
static const auto& ctype = std::use_facet< std::ctype<char> >(default_locale);
for( char ch : str ) if( ctype.is(mask,ch) ) return true ;
return false ;
}
bool has_alpha( const std::string& str ) { return has( str, std::ctype_base::alpha ) ; }
bool has_digit( const std::string& str ) { return has( str, std::ctype_base::digit ) ; }
bool has_space( const std::string& str ) { return has( str, std::ctype_base::space ) ; }
bool has_xdigit( const std::string& str ) { return has( str, std::ctype_base::xdigit ) ; }
bool has_alnum( const std::string& str ) { return has( str, std::ctype_base::alnum ) ; }
bool has_blank( const std::string& str ) { return has( str, std::ctype_base::blank ) ; }
bool has_upper( const std::string& str ) { return has( str, std::ctype_base::upper ) ; }
bool has_lower( const std::string& str ) { return has( str, std::ctype_base::lower ) ; }
bool has_punct( const std::string& str ) { return has( str, std::ctype_base::punct ) ; }
bool has_print( const std::string& str ) { return has( str, std::ctype_base::print ) ; }
bool has_cntrl( const std::string& str ) { return has( str, std::ctype_base::cntrl ) ; }
bool has_graph( const std::string& str ) { return has( str, std::ctype_base::graph ) ; }
|