mirror of
https://github.com/boostorg/algorithm.git
synced 2025-07-03 07:46:49 +02:00
-predicate_facade moved to a separate header
-composition operators for classification predicates moved to the same namespace as predicate_facade [SVN r23382]
This commit is contained in:
@ -13,6 +13,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <boost/algorithm/string/detail/classification.hpp>
|
#include <boost/algorithm/string/detail/classification.hpp>
|
||||||
|
#include <boost/algorithm/string/predicate_facade.hpp>
|
||||||
|
|
||||||
/*! \file
|
/*! \file
|
||||||
Classification predicates are included in the library to give
|
Classification predicates are included in the library to give
|
||||||
@ -216,6 +217,65 @@ namespace boost {
|
|||||||
return detail::is_from_rangeF<CharT>(From,To);
|
return detail::is_from_rangeF<CharT>(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<typename Pred1T, typename Pred2T>
|
||||||
|
inline detail::pred_andF<Pred1T, Pred2T>
|
||||||
|
operator&&(
|
||||||
|
const predicate_facade<Pred1T>& Pred1,
|
||||||
|
const predicate_facade<Pred2T>& Pred2 )
|
||||||
|
{
|
||||||
|
return detail::pred_andF<Pred1T,Pred2T>(
|
||||||
|
static_cast<const Pred1T&>(Pred1),
|
||||||
|
static_cast<const Pred2T&>(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<typename Pred1T, typename Pred2T>
|
||||||
|
inline detail::pred_orF<Pred1T, Pred2T>
|
||||||
|
operator||(
|
||||||
|
const predicate_facade<Pred1T>& Pred1,
|
||||||
|
const predicate_facade<Pred2T>& Pred2 )
|
||||||
|
{
|
||||||
|
return detail::pred_orF<Pred1T,Pred2T>(
|
||||||
|
static_cast<const Pred1T&>(Pred1),
|
||||||
|
static_cast<const Pred2T&>(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<typename PredT>
|
||||||
|
inline detail::pred_notF<PredT>
|
||||||
|
operator!( const predicate_facade<PredT>& Pred )
|
||||||
|
{
|
||||||
|
return detail::pred_notF<PredT>(static_cast<const PredT&>(Pred));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace algorithm
|
} // namespace algorithm
|
||||||
|
|
||||||
// pull names to the boost namespace
|
// pull names to the boost namespace
|
||||||
@ -236,69 +296,4 @@ namespace boost {
|
|||||||
|
|
||||||
} // 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<typename Pred1T, typename Pred2T>
|
|
||||||
inline boost::algorithm::detail::pred_andF<Pred1T, Pred2T>
|
|
||||||
operator&&(
|
|
||||||
const boost::algorithm::detail::predicate_facade<Pred1T>& Pred1,
|
|
||||||
const boost::algorithm::detail::predicate_facade<Pred2T>& Pred2 )
|
|
||||||
{
|
|
||||||
return boost::algorithm::detail::pred_andF<Pred1T,Pred2T>(
|
|
||||||
static_cast<const Pred1T&>(Pred1),
|
|
||||||
static_cast<const Pred2T&>(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<typename Pred1T, typename Pred2T>
|
|
||||||
inline boost::algorithm::detail::pred_orF<Pred1T, Pred2T>
|
|
||||||
operator||(
|
|
||||||
const boost::algorithm::detail::predicate_facade<Pred1T>& Pred1,
|
|
||||||
const boost::algorithm::detail::predicate_facade<Pred2T>& Pred2 )
|
|
||||||
{
|
|
||||||
return boost::algorithm::detail::pred_orF<Pred1T,Pred2T>(
|
|
||||||
static_cast<const Pred1T&>(Pred1),
|
|
||||||
static_cast<const Pred2T&>(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<typename PredT>
|
|
||||||
inline boost::algorithm::detail::pred_notF<PredT>
|
|
||||||
operator!( const boost::algorithm::detail::predicate_facade<PredT>& Pred )
|
|
||||||
{
|
|
||||||
return boost::algorithm::detail::pred_notF<PredT>(static_cast<const PredT&>(Pred));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // BOOST_STRING_PREDICATE_HPP
|
#endif // BOOST_STRING_PREDICATE_HPP
|
||||||
|
@ -16,23 +16,13 @@
|
|||||||
#include <locale>
|
#include <locale>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <boost/algorithm/string/collection_traits.hpp>
|
#include <boost/algorithm/string/collection_traits.hpp>
|
||||||
|
#include <boost/algorithm/string/predicate_facade.hpp>
|
||||||
#include <boost/type_traits/remove_const.hpp>
|
#include <boost/type_traits/remove_const.hpp>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace algorithm {
|
namespace algorithm {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
// predicate facade ------------------------------------------------------//
|
|
||||||
|
|
||||||
// Predicate facade
|
|
||||||
/*
|
|
||||||
This class allows to recognize classification
|
|
||||||
predicates, so that they can be combined using
|
|
||||||
composition operators.
|
|
||||||
*/
|
|
||||||
template<typename Derived>
|
|
||||||
struct predicate_facade {};
|
|
||||||
|
|
||||||
// classification functors -----------------------------------------------//
|
// classification functors -----------------------------------------------//
|
||||||
|
|
||||||
// is_classified functor
|
// is_classified functor
|
||||||
|
41
include/boost/algorithm/string/predicate_facade.hpp
Normal file
41
include/boost/algorithm/string/predicate_facade.hpp
Normal file
@ -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 <boost/algorithm/string/config.hpp>
|
||||||
|
|
||||||
|
/*
|
||||||
|
\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<typename Derived>
|
||||||
|
struct predicate_facade {};
|
||||||
|
|
||||||
|
} // namespace algorithm
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
|
||||||
|
#endif // BOOST_STRING_CLASSIFICATION_DETAIL_HPP
|
Reference in New Issue
Block a user