From 1d9706feb796e955aabf115051ef91676a417fb6 Mon Sep 17 00:00:00 2001 From: glywk Date: Sat, 21 Jan 2023 00:42:52 +0100 Subject: [PATCH 1/3] Add is_blank classifier --- .../boost/algorithm/string/classification.hpp | 19 +++++++++++++++++++ string/doc/quickref.xml | 7 +++++++ string/test/predicate_test.cpp | 6 +++++- 3 files changed, 31 insertions(+), 1 deletion(-) 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..bc16e7bfa 100644 --- a/string/test/predicate_test.cpp +++ b/string/test/predicate_test.cpp @@ -138,7 +138,11 @@ 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" ); +#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" ); From 3401f0398fc7417a1db470a37db8fa151cf83be9 Mon Sep 17 00:00:00 2001 From: jiayuehua <3423893+jiayuehua@users.noreply.github.com> Date: Mon, 8 May 2023 11:06:15 +0800 Subject: [PATCH 2/3] fix range-base gather algorithm --- include/boost/algorithm/gather.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/boost/algorithm/gather.hpp b/include/boost/algorithm/gather.hpp index e777f8bd1..00f173397 100644 --- a/include/boost/algorithm/gather.hpp +++ b/include/boost/algorithm/gather.hpp @@ -1,4 +1,4 @@ -/* +/* Copyright 2008 Adobe Systems Incorporated Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -84,7 +84,7 @@ namespace boost { namespace algorithm { template < typename BidirectionalIterator, // models BidirectionalIterator typename Pred> // models UnaryPredicate -std::pair gather +std::pair gather ( BidirectionalIterator first, BidirectionalIterator last, BidirectionalIterator pivot, Pred pred ) { // The first call partitions everything up to (but not including) the pivot element, @@ -106,11 +106,11 @@ template < typename BidirectionalRange, // typename Pred> // Pred models UnaryPredicate std::pair< - typename boost::range_iterator::type, - typename boost::range_iterator::type> + typename boost::range_iterator::type, + typename boost::range_iterator::type> gather ( - const BidirectionalRange &range, - typename boost::range_iterator::type pivot, + BidirectionalRange &range, + typename boost::range_iterator::type pivot, Pred pred ) { return boost::algorithm::gather ( boost::begin ( range ), boost::end ( range ), pivot, pred ); From dc14b69189ae91ffb6bbbe96c60a9e3cdd41ab96 Mon Sep 17 00:00:00 2001 From: glywk Date: Thu, 27 Jul 2023 23:15:48 +0200 Subject: [PATCH 3/3] Add negative is_blank predicate tests --- string/test/predicate_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/string/test/predicate_test.cpp b/string/test/predicate_test.cpp index bc16e7bfa..2e1ebd7a6 100644 --- a/string/test/predicate_test.cpp +++ b/string/test/predicate_test.cpp @@ -141,6 +141,7 @@ void classification_test() #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 " );