Remove dependency on boost::mpl from 'clamp' and 'is_sorted'

This commit is contained in:
Marshall Clow
2021-08-29 16:19:52 -07:00
parent c9077bd495
commit c5f6f52560
2 changed files with 12 additions and 12 deletions

View File

@ -26,14 +26,14 @@
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/range/begin.hpp> #include <boost/range/begin.hpp>
#include <boost/range/end.hpp> #include <boost/range/end.hpp>
#include <boost/mpl/identity.hpp> // for identity #include <boost/type_traits/type_identity.hpp> // for boost::type_identity
#include <boost/utility/enable_if.hpp> // for boost::disable_if #include <boost/utility/enable_if.hpp> // for boost::disable_if
namespace boost { namespace algorithm { namespace boost { namespace algorithm {
/// \fn clamp ( T const& val, /// \fn clamp ( T const& val,
/// typename boost::mpl::identity<T>::type const & lo, /// typename boost::type_identity<T>::type const & lo,
/// typename boost::mpl::identity<T>::type const & hi, Pred p ) /// typename boost::type_identity<T>::type const & hi, Pred p )
/// \return the value "val" brought into the range [ lo, hi ] /// \return the value "val" brought into the range [ lo, hi ]
/// using the comparison predicate p. /// using the comparison predicate p.
/// If p ( val, lo ) return lo. /// If p ( val, lo ) return lo.
@ -48,8 +48,8 @@ namespace boost { namespace algorithm {
/// ///
template<typename T, typename Pred> template<typename T, typename Pred>
BOOST_CXX14_CONSTEXPR T const & clamp ( T const& val, BOOST_CXX14_CONSTEXPR T const & clamp ( T const& val,
typename boost::mpl::identity<T>::type const & lo, typename boost::type_identity<T>::type const & lo,
typename boost::mpl::identity<T>::type const & hi, Pred p ) typename boost::type_identity<T>::type const & hi, Pred p )
{ {
// assert ( !p ( hi, lo )); // Can't assert p ( lo, hi ) b/c they might be equal // assert ( !p ( hi, lo )); // Can't assert p ( lo, hi ) b/c they might be equal
return p ( val, lo ) ? lo : p ( hi, val ) ? hi : val; return p ( val, lo ) ? lo : p ( hi, val ) ? hi : val;
@ -57,8 +57,8 @@ namespace boost { namespace algorithm {
/// \fn clamp ( T const& val, /// \fn clamp ( T const& val,
/// typename boost::mpl::identity<T>::type const & lo, /// typename boost::identity<T>::type const & lo,
/// typename boost::mpl::identity<T>::type const & hi ) /// typename boost::identity<T>::type const & hi )
/// \return the value "val" brought into the range [ lo, hi ]. /// \return the value "val" brought into the range [ lo, hi ].
/// If the value is less than lo, return lo. /// If the value is less than lo, return lo.
/// If the value is greater than "hi", return hi. /// If the value is greater than "hi", return hi.
@ -70,8 +70,8 @@ namespace boost { namespace algorithm {
/// ///
template<typename T> template<typename T>
BOOST_CXX14_CONSTEXPR T const& clamp ( const T& val, BOOST_CXX14_CONSTEXPR T const& clamp ( const T& val,
typename boost::mpl::identity<T>::type const & lo, typename boost::type_identity<T>::type const & lo,
typename boost::mpl::identity<T>::type const & hi ) typename boost::type_identity<T>::type const & hi )
{ {
return boost::algorithm::clamp ( val, lo, hi, std::less<T>()); return boost::algorithm::clamp ( val, lo, hi, std::less<T>());
} }

View File

@ -22,7 +22,7 @@
#include <boost/utility/enable_if.hpp> #include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_same.hpp> #include <boost/type_traits/is_same.hpp>
#include <boost/mpl/identity.hpp> #include <boost/type_traits/type_identity.hpp> // for boost::type_identity
namespace boost { namespace algorithm { namespace boost { namespace algorithm {
@ -127,7 +127,7 @@ namespace boost { namespace algorithm {
/// \param p A binary predicate that returns true if two elements are ordered. /// \param p A binary predicate that returns true if two elements are ordered.
/// ///
template <typename R, typename Pred> template <typename R, typename Pred>
BOOST_CXX14_CONSTEXPR typename boost::lazy_disable_if_c< boost::is_same<R, Pred>::value, boost::mpl::identity<bool> >::type BOOST_CXX14_CONSTEXPR typename boost::lazy_disable_if_c< boost::is_same<R, Pred>::value, boost::type_identity<bool> >::type
is_sorted ( const R &range, Pred p ) is_sorted ( const R &range, Pred p )
{ {
return boost::algorithm::is_sorted ( boost::begin ( range ), boost::end ( range ), p ); return boost::algorithm::is_sorted ( boost::begin ( range ), boost::end ( range ), p );