5353#define boolean_CPP17_OR_GREATER ( boolean_CPLUSPLUS >= 201703L )
5454#define boolean_CPP20_OR_GREATER ( boolean_CPLUSPLUS >= 202000L )
5555
56- // C++ language version (represent 98 as 3):
57-
58- #define boolean_CPLUSPLUS_V ( boolean_CPLUSPLUS / 100 - (boolean_CPLUSPLUS > 200000 ? 2000 : 1994 ) )
59-
60- // half-open range [lo..hi):
61- #define boolean_BETWEEN ( v, lo, hi ) ( (lo) <= (v) && (v) < (hi) )
62-
63- // Compiler versions:
64-
65- // MSVC++ 6.0 _MSC_VER == 1200 boolean_COMPILER_MSVC_VERSION == 60 (Visual Studio 6.0)
66- // MSVC++ 7.0 _MSC_VER == 1300 boolean_COMPILER_MSVC_VERSION == 70 (Visual Studio .NET 2002)
67- // MSVC++ 7.1 _MSC_VER == 1310 boolean_COMPILER_MSVC_VERSION == 71 (Visual Studio .NET 2003)
68- // MSVC++ 8.0 _MSC_VER == 1400 boolean_COMPILER_MSVC_VERSION == 80 (Visual Studio 2005)
69- // MSVC++ 9.0 _MSC_VER == 1500 boolean_COMPILER_MSVC_VERSION == 90 (Visual Studio 2008)
70- // MSVC++ 10.0 _MSC_VER == 1600 boolean_COMPILER_MSVC_VERSION == 100 (Visual Studio 2010)
71- // MSVC++ 11.0 _MSC_VER == 1700 boolean_COMPILER_MSVC_VERSION == 110 (Visual Studio 2012)
72- // MSVC++ 12.0 _MSC_VER == 1800 boolean_COMPILER_MSVC_VERSION == 120 (Visual Studio 2013)
73- // MSVC++ 14.0 _MSC_VER == 1900 boolean_COMPILER_MSVC_VERSION == 140 (Visual Studio 2015)
74- // MSVC++ 14.1 _MSC_VER >= 1910 boolean_COMPILER_MSVC_VERSION == 141 (Visual Studio 2017)
75- // MSVC++ 14.2 _MSC_VER >= 1920 boolean_COMPILER_MSVC_VERSION == 142 (Visual Studio 2019)
56+ // MSVC version:
7657
7758#if defined(_MSC_VER ) && !defined(__clang__)
78- # define boolean_COMPILER_MSVC_VER (_MSC_VER )
79- # define boolean_COMPILER_MSVC_VERSION (_MSC_VER / 10 - 10 * ( 5 + (_MSC_VER < 1900 ) ) )
80- # define boolean_COMPILER_MSVC_VERSION_FULL (_MSC_VER - 100 * ( 5 + (_MSC_VER < 1900 ) ) )
81- #else
82- # define boolean_COMPILER_MSVC_VER 0
83- # define boolean_COMPILER_MSVC_VERSION 0
84- # define boolean_COMPILER_MSVC_VERSION_FULL 0
85- #endif
86-
87- #define boolean_COMPILER_VERSION ( major, minor, patch ) ( 10 * ( 10 * (major) + (minor) ) + (patch) )
88-
89- // AppleClang 7.0.0 __apple_build_version__ == 7000172 boolean_COMPILER_APPLECLANG_VERSION == 700 (Xcode 7.0, 7.0.1) (LLVM 3.7.0)
90- // AppleClang 7.0.0 __apple_build_version__ == 7000176 boolean_COMPILER_APPLECLANG_VERSION == 700 (Xcode 7.1) (LLVM 3.7.0)
91- // AppleClang 7.0.2 __apple_build_version__ == 7000181 boolean_COMPILER_APPLECLANG_VERSION == 702 (Xcode 7.2, 7.2.1) (LLVM 3.7.0)
92- // AppleClang 7.3.0 __apple_build_version__ == 7030029 boolean_COMPILER_APPLECLANG_VERSION == 730 (Xcode 7.3) (LLVM 3.8.0)
93- // AppleClang 7.3.0 __apple_build_version__ == 7030031 boolean_COMPILER_APPLECLANG_VERSION == 730 (Xcode 7.3.1) (LLVM 3.8.0)
94- // AppleClang 8.0.0 __apple_build_version__ == 8000038 boolean_COMPILER_APPLECLANG_VERSION == 800 (Xcode 8.0) (LLVM 3.9.0)
95- // AppleClang 8.0.0 __apple_build_version__ == 8000042 boolean_COMPILER_APPLECLANG_VERSION == 800 (Xcode 8.1, 8.2, 8.2.1) (LLVM 3.9.0)
96- // AppleClang 8.1.0 __apple_build_version__ == 8020038 boolean_COMPILER_APPLECLANG_VERSION == 810 (Xcode 8.3) (LLVM 3.9.0)
97- // AppleClang 8.1.0 __apple_build_version__ == 8020041 boolean_COMPILER_APPLECLANG_VERSION == 810 (Xcode 8.3.1) (LLVM 3.9.0)
98- // AppleClang 8.1.0 __apple_build_version__ == 8020042 boolean_COMPILER_APPLECLANG_VERSION == 810 (Xcode 8.3.2, 8.3.3) (LLVM 3.9.0)
99- // AppleClang 9.0.0 __apple_build_version__ == 9000037 boolean_COMPILER_APPLECLANG_VERSION == 900 (Xcode 9.0) (LLVM 4.0.0?)
100- // AppleClang 9.0.0 __apple_build_version__ == 9000038 boolean_COMPILER_APPLECLANG_VERSION == 900 (Xcode 9.1) (LLVM 4.0.0?)
101- // AppleClang 9.0.0 __apple_build_version__ == 9000039 boolean_COMPILER_APPLECLANG_VERSION == 900 (Xcode 9.2) (LLVM 4.0.0?)
102- // AppleClang 9.1.0 __apple_build_version__ == 9020039 boolean_COMPILER_APPLECLANG_VERSION == 910 (Xcode 9.3, 9.3.1) (LLVM 5.0.2?)
103- // AppleClang 9.1.0 __apple_build_version__ == 9020039 boolean_COMPILER_APPLECLANG_VERSION == 910 (Xcode 9.4, 9.4.1) (LLVM 5.0.2?)
104- // AppleClang 10.0.0 __apple_build_version__ == 10001145 boolean_COMPILER_APPLECLANG_VERSION == 1000 (Xcode 10.0, 10.1) (LLVM 6.0.1?)
105- // AppleClang 10.0.1 __apple_build_version__ == 10010046 boolean_COMPILER_APPLECLANG_VERSION == 1001 (Xcode 10.2, 10.2.1, 10.3) (LLVM 7.0.0?)
106- // AppleClang 11.0.0 __apple_build_version__ == 11000033 boolean_COMPILER_APPLECLANG_VERSION == 1100 (Xcode 11.1, 11.2, 11.3, 11.3.1) (LLVM 8.0.0?)
107- // AppleClang 11.0.3 __apple_build_version__ == 11030032 boolean_COMPILER_APPLECLANG_VERSION == 1103 (Xcode 11.4, 11.4.1, 11.5, 11.6) (LLVM 9.0.0?)
108-
109- #if defined( __apple_build_version__ )
110- # define boolean_COMPILER_APPLECLANG_VERSION boolean_COMPILER_VERSION ( __clang_major__, __clang_minor__, __clang_patchlevel__ )
111- # define boolean_COMPILER_CLANG_VERSION 0
112- #elif defined( __clang__ )
113- # define boolean_COMPILER_APPLECLANG_VERSION 0
114- # define boolean_COMPILER_CLANG_VERSION boolean_COMPILER_VERSION ( __clang_major__, __clang_minor__, __clang_patchlevel__ )
115- #else
116- # define boolean_COMPILER_APPLECLANG_VERSION 0
117- # define boolean_COMPILER_CLANG_VERSION 0
118- #endif
119-
120- #if defined(__GNUC__) && !defined(__clang__)
121- # define boolean_COMPILER_GNUC_VERSION boolean_COMPILER_VERSION ( __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__ )
59+ # define boolean_COMPILER_MSVC_VER (_MSC_VER )
12260#else
123- # define boolean_COMPILER_GNUC_VERSION 0
61+ # define boolean_COMPILER_MSVC_VER 0
12462#endif
12563
12664// Presence of language and library features:
12765
128- #define boolean_HAVE ( feature ) ( boolean_HAVE_##feature )
129-
130- #ifdef _HAS_CPP0X
131- # define boolean_HAS_CPP0X _HAS_CPP0X
132- #else
133- # define boolean_HAS_CPP0X 0
134- #endif
135-
136- #define boolean_CPP11_90 (boolean_CPP11_OR_GREATER || boolean_COMPILER_MSVC_VER >= 1500 )
137- #define boolean_CPP11_100 (boolean_CPP11_OR_GREATER || boolean_COMPILER_MSVC_VER >= 1600 )
138- #define boolean_CPP11_110 (boolean_CPP11_OR_GREATER || boolean_COMPILER_MSVC_VER >= 1700 )
13966#define boolean_CPP11_120 (boolean_CPP11_OR_GREATER || boolean_COMPILER_MSVC_VER >= 1800 )
14067#define boolean_CPP11_140 (boolean_CPP11_OR_GREATER || boolean_COMPILER_MSVC_VER >= 1900 )
14168
14572
14673#define boolean_HAVE_CONSTEXPR_11 boolean_CPP11_140
14774#define boolean_HAVE_NOEXCEPT boolean_CPP11_140
75+ #define boolean_HAVE_DEFAULT_FN_TPL_ARGS boolean_CPP11_120
14876#define boolean_HAVE_EXPLICIT_CONVERSION boolean_CPP11_120
149- #define boolean_HAVE_DEFAULT_FUNCTION_TEMPLATE_ARG boolean_CPP11_120
150- #define boolean_HAVE_STATIC_ASSERT boolean_CPP11_90
151-
152- // Presence of C++11 library features:
153-
154- #define boolean_HAVE_TYPE_TRAITS boolean_CPP11_90
155- #define boolean_HAVE_TR1_TYPE_TRAITS (!! boolean_COMPILER_GNUC_VERSION )
156-
157- #define boolean_HAVE_IS_SAME boolean_HAVE_TYPE_TRAITS
158- #define boolean_HAVE_IS_SAME_TR1 boolean_HAVE_TR1_TYPE_TRAITS
15977
16078// Presence of C++17 language features:
16179
187105# define boolean_explicit_cv /* explicit*/
188106#endif
189107
190- // Additional includes:
108+ # define boolean_CPP98_FALLBACK ( !boolean_HAVE_DEFAULT_FN_TPL_ARGS )
191109
192- #if boolean_HAVE( TYPE_TRAITS )
193- # include < type_traits>
194- #elif boolean_HAVE( TR1_TYPE_TRAITS )
195- # include < tr1/type_traits>
196- #endif
197-
198- #define boolean_CPP98_FALLBACK ( !boolean_CPP11_120 )
199-
200- namespace nonstd {
201- namespace boolean_lite {
110+ // Select between C++98 and C++11/later version of boolean_:
202111
203112#if ! boolean_CPP98_FALLBACK
204113
205- namespace std11 {
114+ // Additional includes:
206115
207- #if boolean_HAVE( TYPE_TRAITS )
208- using std::enable_if;
209- using std::is_same;
210- #elif boolean_HAVE( TR1_TYPE_TRAITS )
211- // using std::tr1::enable_if;
212- using std::tr1::is_same;
213- #endif
214- }
116+ #include < type_traits>
117+
118+ namespace nonstd {
119+ namespace boolean_lite {
215120
216121//
217- // class boolean_, C++11:
122+ // class boolean_, C++11 and later :
218123//
219124
220125class boolean_
@@ -226,26 +131,26 @@ class boolean_
226131 // [1] Converting constructor
227132
228133 template < typename T
229- , typename std11 ::enable_if< std11 ::is_same<T,bool >::value, int >::type = 0 >
134+ , typename std ::enable_if< std ::is_same<T,bool >::value, int >::type = 0 >
230135 /* explicit*/ boolean_constexpr boolean_ ( T v ) boolean_noexcept
231136 : value( v ) {}
232137
233138 template < typename T
234- , typename std11 ::enable_if< !std11 ::is_same<T,bool >::value, int >::type = 0 >
139+ , typename std ::enable_if< !std ::is_same<T,bool >::value, int >::type = 0 >
235140 explicit boolean_constexpr boolean_ ( T v ) boolean_noexcept
236141 : value( v ) {}
237142
238143 // [2] Conversion operator
239144
240145 template < typename T
241- , typename std11 ::enable_if< std11 ::is_same<T,bool >::value, int >::type = 0 >
146+ , typename std ::enable_if< std ::is_same<T,bool >::value, int >::type = 0 >
242147 boolean_nodiscard /* explicit*/ boolean_constexpr operator T () const boolean_noexcept
243148 {
244149 return T ( value );
245150 }
246151
247152 template < typename T
248- , typename std11 ::enable_if< !std11 ::is_same<T,bool >::value, int >::type = 0 >
153+ , typename std ::enable_if< !std ::is_same<T,bool >::value, int >::type = 0 >
249154 boolean_nodiscard boolean_explicit_cv boolean_constexpr operator T () const boolean_noexcept
250155 {
251156 return T ( value );
@@ -293,8 +198,13 @@ class boolean_
293198 }
294199};
295200
201+ }} // namespace nonstd::boolean_lite
202+
296203#else // boolean_CPP98_FALLBACK
297204
205+ namespace nonstd {
206+ namespace boolean_lite {
207+
298208//
299209// class boolean_, C++98:
300210//
@@ -369,9 +279,15 @@ class boolean_
369279 }
370280};
371281
282+ }} // namespace nonstd::boolean_lite
283+
372284#endif // boolean_CPP98_FALLBACK
373285
374- } // namespace boolean_lite
286+ //
287+ // Provide type boolean in namespace nonstd:
288+ //
289+
290+ namespace nonstd {
375291
376292using boolean_lite::boolean_;
377293
0 commit comments