diff --git a/include/boost/algorithm/string/classification.hpp b/include/boost/algorithm/string/classification.hpp index ca43602d4..83cdca529 100644 --- a/include/boost/algorithm/string/classification.hpp +++ b/include/boost/algorithm/string/classification.hpp @@ -85,6 +85,22 @@ namespace boost { return detail::is_classifiedF(std::ctype_base::alpha, Loc); } +#ifndef BOOST_NO_CXX11 + //! is_blank predicate + /*! + Construct the \c is_classified predicate for the \c ctype_base::blank category. + + \param Loc A locale used for classification + \return An instance of the \c is_classified predicate + \since c++11 + */ + inline detail::is_classifiedF + is_blank(const std::locale& Loc=std::locale()) + { + return detail::is_classifiedF(std::ctype_base::blank, Loc); + } +#endif + //! is_cntrl predicate /*! Construct the \c is_classified predicate for the \c ctype_base::cntrl category. @@ -294,6 +310,9 @@ namespace boost { // pull names to the boost namespace using algorithm::is_classified; using algorithm::is_space; +#ifndef BOOST_NO_CXX11 + using algorithm::is_blank; +#endif using algorithm::is_alnum; using algorithm::is_alpha; using algorithm::is_cntrl; diff --git a/string/doc/quickref.xml b/string/doc/quickref.xml index fe267e718..39a224b70 100644 --- a/string/doc/quickref.xml +++ b/string/doc/quickref.xml @@ -667,6 +667,13 @@ is_space() + + is_blank + Recognize blanks + + is_blank() + + is_alnum Recognize alphanumeric characters diff --git a/string/test/predicate_test.cpp b/string/test/predicate_test.cpp index ba1564e53..2e1ebd7a6 100644 --- a/string/test/predicate_test.cpp +++ b/string/test/predicate_test.cpp @@ -138,7 +138,12 @@ void classification_test() TEST_CLASS( is_any_of( string("abc") ), "aaabbcc", "aaxb" ); TEST_CLASS( is_any_of( "abc" ), "aaabbcc", "aaxb" ); TEST_CLASS( is_from_range( 'a', 'c' ), "aaabbcc", "aaxb" ); - + +#ifndef BOOST_NO_CXX11 + TEST_CLASS( is_blank(), " \t", "\t \n\r" ); + TEST_CLASS( !is_blank(), "abc\n\v\f\r", "a x\t" ); +#endif + TEST_CLASS( !is_classified(std::ctype_base::space), "...", "..\n\r\t " ); TEST_CLASS( ( !is_any_of("abc") && is_from_range('a','e') ) || is_space(), "d e", "abcde" );