Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add is_blank() string functor classification #112

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions include/boost/algorithm/string/classification.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions string/doc/quickref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,13 @@
<functionname>is_space()</functionname>
</entry>
</row>
<row>
<entry>is_blank</entry>
<entry>Recognize blanks</entry>
<entry>
<functionname>is_blank()</functionname>
</entry>
</row>
<row>
<entry>is_alnum</entry>
<entry>Recognize alphanumeric characters</entry>
Expand Down
7 changes: 6 additions & 1 deletion string/test/predicate_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );

Expand Down