diff --git a/include/boost/algorithm/string/classification.hpp b/include/boost/algorithm/string/classification.hpp index a6724ae..0d21854 100644 --- a/include/boost/algorithm/string/classification.hpp +++ b/include/boost/algorithm/string/classification.hpp @@ -13,6 +13,7 @@ #include #include #include +#include /*! \file Classification predicates are included in the library to give @@ -215,6 +216,65 @@ namespace boost { { return detail::is_from_rangeF(From,To); } + + // predicate combinators ---------------------------------------------------// + + //! predicate 'and' composition predicate + /*! + Construct the \c class_and predicate. This predicate can be used + to logically combine two classification predicates. \c class_and holds, + if both predicates return true. + + \param Pred1 The first predicate + \param Pred2 The second predicate + \return An instance of the \c class_and predicate + */ + template + inline detail::pred_andF + operator&&( + const predicate_facade& Pred1, + const predicate_facade& Pred2 ) + { + return detail::pred_andF( + static_cast(Pred1), + static_cast(Pred2) ); + } + + //! predicate 'or' composition predicate + /*! + Construct the \c class_or predicate. This predicate can be used + to logically combine two classification predicates. \c class_or holds, + if one of the predicates return true. + + \param Pred1 The first predicate + \param Pred2 The second predicate + \return An instance of the \c class_or predicate + */ + template + inline detail::pred_orF + operator||( + const predicate_facade& Pred1, + const predicate_facade& Pred2 ) + { + return detail::pred_orF( + static_cast(Pred1), + static_cast(Pred2)); + } + + //! predicate negation operator + /*! + Construct the \c class_not predicate. This predicate represents a negation. + \c class_or holds, if of the predicates return false. + + \param Pred The predicate to be negated + \return An instance of the \c class_not predicate + */ + template + inline detail::pred_notF + operator!( const predicate_facade& Pred ) + { + return detail::pred_notF(static_cast(Pred)); + } } // namespace algorithm @@ -236,69 +296,4 @@ namespace boost { } // namespace boost - -// predicate combinators ---------------------------------------------------// -/* - * These operators must be declared in the global namespace, otherwise - * they are not resolved correctly. There will not a problem with a name-clash, - * since they are define only for internal types - */ - -//! predicate 'and' composition predicate -/*! - Construct the \c class_and predicate. This predicate can be used - to logically combine two classification predicates. \c class_and holds, - if both predicates return true. - - \param Pred1 The first predicate - \param Pred2 The second predicate - \return An instance of the \c class_and predicate -*/ -template -inline boost::algorithm::detail::pred_andF -operator&&( - const boost::algorithm::detail::predicate_facade& Pred1, - const boost::algorithm::detail::predicate_facade& Pred2 ) -{ - return boost::algorithm::detail::pred_andF( - static_cast(Pred1), - static_cast(Pred2) ); -} - -//! predicate 'or' composition predicate -/*! - Construct the \c class_or predicate. This predicate can be used - to logically combine two classification predicates. \c class_or holds, - if one of the predicates return true. - - \param Pred1 The first predicate - \param Pred2 The second predicate - \return An instance of the \c class_or predicate -*/ -template -inline boost::algorithm::detail::pred_orF -operator||( - const boost::algorithm::detail::predicate_facade& Pred1, - const boost::algorithm::detail::predicate_facade& Pred2 ) -{ - return boost::algorithm::detail::pred_orF( - static_cast(Pred1), - static_cast(Pred2)); -} - -//! predicate negation operator -/*! - Construct the \c class_not predicate. This predicate represents a negation. - \c class_or holds, if of the predicates return false. - - \param Pred The predicate to be negated - \return An instance of the \c class_not predicate -*/ -template -inline boost::algorithm::detail::pred_notF -operator!( const boost::algorithm::detail::predicate_facade& Pred ) -{ - return boost::algorithm::detail::pred_notF(static_cast(Pred)); -} - #endif // BOOST_STRING_PREDICATE_HPP diff --git a/include/boost/algorithm/string/detail/classification.hpp b/include/boost/algorithm/string/detail/classification.hpp index f750229..242e8e6 100644 --- a/include/boost/algorithm/string/detail/classification.hpp +++ b/include/boost/algorithm/string/detail/classification.hpp @@ -16,23 +16,13 @@ #include #include #include +#include #include namespace boost { namespace algorithm { namespace detail { - -// predicate facade ------------------------------------------------------// - - // Predicate facade - /* - This class allows to recognize classification - predicates, so that they can be combined using - composition operators. - */ - template - struct predicate_facade {}; - + // classification functors -----------------------------------------------// // is_classified functor diff --git a/include/boost/algorithm/string/predicate_facade.hpp b/include/boost/algorithm/string/predicate_facade.hpp new file mode 100644 index 0000000..37ac679 --- /dev/null +++ b/include/boost/algorithm/string/predicate_facade.hpp @@ -0,0 +1,41 @@ +// Boost string_algo library predicate_facade.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. Use, modification and +// distribution is subject to the Boost Software License, Version +// 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#ifndef BOOST_STRING_PREDICATE_FACADE_HPP +#define BOOST_STRING_PREDICATE_FACADE_HPP + +#include + +/* + \file boost/algorith/string/predicate_facade.hpp + This file containes predicate_facade definition. This template class is used + to identify classification predicates, so they can be combined using + composition operators. +*/ + +namespace boost { + namespace algorithm { + +// predicate facade ------------------------------------------------------// + + //! Predicate facade + /*! + This class allows to recognize classification + predicates, so that they can be combined using + composition operators. + Every classification predicate must be derived from this class. + */ + template + struct predicate_facade {}; + + } // namespace algorithm +} // namespace boost + + +#endif // BOOST_STRING_CLASSIFICATION_DETAIL_HPP