Skip to content

Commit 6eb48dd

Browse files
authored
Merge pull request #112 from glywk/develop
Add is_blank() string functor classification
2 parents 1395fe7 + dc14b69 commit 6eb48dd

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

include/boost/algorithm/string/classification.hpp

+19
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ namespace boost {
8585
return detail::is_classifiedF(std::ctype_base::alpha, Loc);
8686
}
8787

88+
#ifndef BOOST_NO_CXX11
89+
//! is_blank predicate
90+
/*!
91+
Construct the \c is_classified predicate for the \c ctype_base::blank category.
92+
93+
\param Loc A locale used for classification
94+
\return An instance of the \c is_classified predicate
95+
\since c++11
96+
*/
97+
inline detail::is_classifiedF
98+
is_blank(const std::locale& Loc=std::locale())
99+
{
100+
return detail::is_classifiedF(std::ctype_base::blank, Loc);
101+
}
102+
#endif
103+
88104
//! is_cntrl predicate
89105
/*!
90106
Construct the \c is_classified predicate for the \c ctype_base::cntrl category.
@@ -294,6 +310,9 @@ namespace boost {
294310
// pull names to the boost namespace
295311
using algorithm::is_classified;
296312
using algorithm::is_space;
313+
#ifndef BOOST_NO_CXX11
314+
using algorithm::is_blank;
315+
#endif
297316
using algorithm::is_alnum;
298317
using algorithm::is_alpha;
299318
using algorithm::is_cntrl;

string/doc/quickref.xml

+7
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,13 @@
667667
<functionname>is_space()</functionname>
668668
</entry>
669669
</row>
670+
<row>
671+
<entry>is_blank</entry>
672+
<entry>Recognize blanks</entry>
673+
<entry>
674+
<functionname>is_blank()</functionname>
675+
</entry>
676+
</row>
670677
<row>
671678
<entry>is_alnum</entry>
672679
<entry>Recognize alphanumeric characters</entry>

string/test/predicate_test.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,12 @@ void classification_test()
138138
TEST_CLASS( is_any_of( string("abc") ), "aaabbcc", "aaxb" );
139139
TEST_CLASS( is_any_of( "abc" ), "aaabbcc", "aaxb" );
140140
TEST_CLASS( is_from_range( 'a', 'c' ), "aaabbcc", "aaxb" );
141-
141+
142+
#ifndef BOOST_NO_CXX11
143+
TEST_CLASS( is_blank(), " \t", "\t \n\r" );
144+
TEST_CLASS( !is_blank(), "abc\n\v\f\r", "a x\t" );
145+
#endif
146+
142147
TEST_CLASS( !is_classified(std::ctype_base::space), "...", "..\n\r\t " );
143148
TEST_CLASS( ( !is_any_of("abc") && is_from_range('a','e') ) || is_space(), "d e", "abcde" );
144149

0 commit comments

Comments
 (0)