Chris@16: /* Chris@101: * Copyright Andrey Semashev 2007 - 2015. Chris@16: * Distributed under the Boost Software License, Version 1.0. Chris@16: * (See accompanying file LICENSE_1_0.txt or copy at Chris@16: * http://www.boost.org/LICENSE_1_0.txt) Chris@16: */ Chris@16: /*! Chris@16: * \file in_range.hpp Chris@16: * \author Andrey Semashev Chris@16: * \date 30.03.2008 Chris@16: * Chris@16: * This header contains a predicate for checking if the provided value is within a half-open range. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_IN_RANGE_HPP_INCLUDED_ Chris@16: #define BOOST_LOG_UTILITY_FUNCTIONAL_IN_RANGE_HPP_INCLUDED_ Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include // make_common_integral_type Chris@16: #include Chris@16: Chris@16: #ifdef BOOST_HAS_PRAGMA_ONCE Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: BOOST_LOG_OPEN_NAMESPACE Chris@16: Chris@16: //! The in_range functor Chris@16: struct in_range_fun Chris@16: { Chris@16: typedef bool result_type; Chris@16: Chris@16: template< typename T, typename U > Chris@16: bool operator() (T const& value, std::pair< U, U > const& rng) const Chris@16: { Chris@16: return op(value, rng, typename mpl::and_< is_integral< T >, is_integral< U > >::type()); Chris@16: } Chris@16: Chris@16: private: Chris@16: template< typename T, typename U > Chris@16: static bool op(T const& value, std::pair< U, U > const& rng, mpl::false_ const&) Chris@16: { Chris@16: return (value >= rng.first && value < rng.second); Chris@16: } Chris@16: template< typename T, typename U > Chris@16: static bool op(T const& value, std::pair< U, U > const& rng, mpl::true_ const&) Chris@16: { Chris@16: typedef typename aux::make_common_integral_type< T, U >::type common_integral_type; Chris@16: return (static_cast< common_integral_type >(value) >= static_cast< common_integral_type >(rng.first)) Chris@16: && (static_cast< common_integral_type >(value) < static_cast< common_integral_type >(rng.second)); Chris@16: } Chris@16: }; Chris@16: Chris@16: BOOST_LOG_CLOSE_NAMESPACE // namespace log Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // BOOST_LOG_UTILITY_FUNCTIONAL_IN_RANGE_HPP_INCLUDED_