]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/log/utility/functional/in_range.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / log / utility / functional / in_range.hpp
1 /*
2 * Copyright Andrey Semashev 2007 - 2015.
3 * Distributed under the Boost Software License, Version 1.0.
4 * (See accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt)
6 */
7 /*!
8 * \file in_range.hpp
9 * \author Andrey Semashev
10 * \date 30.03.2008
11 *
12 * This header contains a predicate for checking if the provided value is within a half-open range.
13 */
14
15 #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_IN_RANGE_HPP_INCLUDED_
16 #define BOOST_LOG_UTILITY_FUNCTIONAL_IN_RANGE_HPP_INCLUDED_
17
18 #include <utility>
19 #include <boost/log/detail/config.hpp>
20 #include <boost/log/utility/functional/logical.hpp> // make_common_integral_type
21 #include <boost/log/detail/header.hpp>
22
23 #ifdef BOOST_HAS_PRAGMA_ONCE
24 #pragma once
25 #endif
26
27 namespace boost {
28
29 BOOST_LOG_OPEN_NAMESPACE
30
31 //! The in_range functor
32 struct in_range_fun
33 {
34 typedef bool result_type;
35
36 template< typename T, typename U >
37 bool operator() (T const& value, std::pair< U, U > const& rng) const
38 {
39 return op(value, rng, typename mpl::and_< is_integral< T >, is_integral< U > >::type());
40 }
41
42 private:
43 template< typename T, typename U >
44 static bool op(T const& value, std::pair< U, U > const& rng, mpl::false_ const&)
45 {
46 return (value >= rng.first && value < rng.second);
47 }
48 template< typename T, typename U >
49 static bool op(T const& value, std::pair< U, U > const& rng, mpl::true_ const&)
50 {
51 typedef typename aux::make_common_integral_type< T, U >::type common_integral_type;
52 return (static_cast< common_integral_type >(value) >= static_cast< common_integral_type >(rng.first))
53 && (static_cast< common_integral_type >(value) < static_cast< common_integral_type >(rng.second));
54 }
55 };
56
57 BOOST_LOG_CLOSE_NAMESPACE // namespace log
58
59 } // namespace boost
60
61 #include <boost/log/detail/footer.hpp>
62
63 #endif // BOOST_LOG_UTILITY_FUNCTIONAL_IN_RANGE_HPP_INCLUDED_