File indexing completed on 2025-01-18 09:39:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_LOGICAL_HPP_INCLUDED_
0022 #define BOOST_LOG_UTILITY_FUNCTIONAL_LOGICAL_HPP_INCLUDED_
0023
0024 #include <boost/type_traits/is_integral.hpp>
0025 #include <boost/type_traits/is_unsigned.hpp>
0026 #include <boost/type_traits/conditional.hpp>
0027 #include <boost/type_traits/integral_constant.hpp>
0028 #include <boost/log/detail/config.hpp>
0029 #include <boost/log/detail/header.hpp>
0030
0031 #ifdef BOOST_HAS_PRAGMA_ONCE
0032 #pragma once
0033 #endif
0034
0035 namespace boost {
0036
0037 BOOST_LOG_OPEN_NAMESPACE
0038
0039 namespace aux {
0040
0041
0042 template< typename T, typename U, unsigned int TSizeV = sizeof(T), unsigned int USizeV = sizeof(U), bool TSmallerThanU = (sizeof(T) < sizeof(U)) >
0043 struct make_common_integral_type
0044 {
0045 typedef T type;
0046 };
0047
0048
0049 template< typename T, typename U, unsigned int TSizeV, unsigned int USizeV >
0050 struct make_common_integral_type< T, U, TSizeV, USizeV, true >
0051 {
0052 typedef U type;
0053 };
0054
0055
0056 template< typename T, typename U, unsigned int SizeV >
0057 struct make_common_integral_type< T, U, SizeV, SizeV, false > :
0058 public boost::conditional<
0059 is_unsigned< T >::value,
0060 T,
0061 U
0062 >
0063 {
0064 };
0065
0066 }
0067
0068
0069 struct equal_to
0070 {
0071 typedef bool result_type;
0072
0073 template< typename T, typename U >
0074 bool operator() (T const& left, U const& right) const
0075 {
0076 return op(left, right, integral_constant< bool, is_integral< T >::value && is_integral< U >::value >());
0077 }
0078
0079 private:
0080 template< typename T, typename U >
0081 static bool op(T const& left, U const& right, false_type)
0082 {
0083 return (left == right);
0084 }
0085 template< typename T, typename U >
0086 static bool op(T const& left, U const& right, true_type)
0087 {
0088 typedef typename aux::make_common_integral_type< T, U >::type common_integral_type;
0089 return static_cast< common_integral_type >(left) == static_cast< common_integral_type >(right);
0090 }
0091 };
0092
0093
0094 struct not_equal_to
0095 {
0096 typedef bool result_type;
0097
0098 template< typename T, typename U >
0099 bool operator() (T const& left, U const& right) const
0100 {
0101 return op(left, right, integral_constant< bool, is_integral< T >::value && is_integral< U >::value >());
0102 }
0103
0104 private:
0105 template< typename T, typename U >
0106 static bool op(T const& left, U const& right, false_type)
0107 {
0108 return (left != right);
0109 }
0110 template< typename T, typename U >
0111 static bool op(T const& left, U const& right, true_type)
0112 {
0113 typedef typename aux::make_common_integral_type< T, U >::type common_integral_type;
0114 return static_cast< common_integral_type >(left) != static_cast< common_integral_type >(right);
0115 }
0116 };
0117
0118
0119 struct less
0120 {
0121 typedef bool result_type;
0122
0123 template< typename T, typename U >
0124 bool operator() (T const& left, U const& right) const
0125 {
0126 return op(left, right, integral_constant< bool, is_integral< T >::value && is_integral< U >::value >());
0127 }
0128
0129 private:
0130 template< typename T, typename U >
0131 static bool op(T const& left, U const& right, false_type)
0132 {
0133 return (left < right);
0134 }
0135 template< typename T, typename U >
0136 static bool op(T const& left, U const& right, true_type)
0137 {
0138 typedef typename aux::make_common_integral_type< T, U >::type common_integral_type;
0139 return static_cast< common_integral_type >(left) < static_cast< common_integral_type >(right);
0140 }
0141 };
0142
0143
0144 struct greater
0145 {
0146 typedef bool result_type;
0147
0148 template< typename T, typename U >
0149 bool operator() (T const& left, U const& right) const
0150 {
0151 return op(left, right, integral_constant< bool, is_integral< T >::value && is_integral< U >::value >());
0152 }
0153
0154 private:
0155 template< typename T, typename U >
0156 static bool op(T const& left, U const& right, false_type)
0157 {
0158 return (left > right);
0159 }
0160 template< typename T, typename U >
0161 static bool op(T const& left, U const& right, true_type)
0162 {
0163 typedef typename aux::make_common_integral_type< T, U >::type common_integral_type;
0164 return static_cast< common_integral_type >(left) > static_cast< common_integral_type >(right);
0165 }
0166 };
0167
0168
0169 struct less_equal
0170 {
0171 typedef bool result_type;
0172
0173 template< typename T, typename U >
0174 bool operator() (T const& left, U const& right) const
0175 {
0176 return op(left, right, integral_constant< bool, is_integral< T >::value && is_integral< U >::value >());
0177 }
0178
0179 private:
0180 template< typename T, typename U >
0181 static bool op(T const& left, U const& right, false_type)
0182 {
0183 return (left <= right);
0184 }
0185 template< typename T, typename U >
0186 static bool op(T const& left, U const& right, true_type)
0187 {
0188 typedef typename aux::make_common_integral_type< T, U >::type common_integral_type;
0189 return static_cast< common_integral_type >(left) <= static_cast< common_integral_type >(right);
0190 }
0191 };
0192
0193
0194 struct greater_equal
0195 {
0196 typedef bool result_type;
0197
0198 template< typename T, typename U >
0199 bool operator() (T const& left, U const& right) const
0200 {
0201 return op(left, right, integral_constant< bool, is_integral< T >::value && is_integral< U >::value >());
0202 }
0203
0204 private:
0205 template< typename T, typename U >
0206 static bool op(T const& left, U const& right, false_type)
0207 {
0208 return (left >= right);
0209 }
0210 template< typename T, typename U >
0211 static bool op(T const& left, U const& right, true_type)
0212 {
0213 typedef typename aux::make_common_integral_type< T, U >::type common_integral_type;
0214 return static_cast< common_integral_type >(left) >= static_cast< common_integral_type >(right);
0215 }
0216 };
0217
0218 BOOST_LOG_CLOSE_NAMESPACE
0219
0220 }
0221
0222 #include <boost/log/detail/footer.hpp>
0223
0224 #endif