1 // Copyright 2020 Peter Dimov 2 // Distributed under the Boost Software License, Version 1.0. 3 // https://www.boost.org/LICENSE_1_0.txt 4 5 #include <boost/endian/detail/is_scoped_enum.hpp> 6 #include <boost/core/lightweight_test_trait.hpp> 7 #include <boost/config.hpp> 8 9 enum E1 {}; 10 11 #if !defined(BOOST_NO_CXX11_SCOPED_ENUMS) 12 13 enum E2: long {}; 14 enum class E3 {}; 15 enum class E4: long {}; 16 17 #endif 18 19 struct X 20 { operator intX21 operator int() const { return 0; } 22 }; 23 24 struct Y; 25 test_true()26template<class T> void test_true() 27 { 28 using boost::endian::detail::is_scoped_enum; 29 30 BOOST_TEST_TRAIT_TRUE((is_scoped_enum<T>)); 31 BOOST_TEST_TRAIT_TRUE((is_scoped_enum<T const>)); 32 BOOST_TEST_TRAIT_TRUE((is_scoped_enum<T volatile>)); 33 BOOST_TEST_TRAIT_TRUE((is_scoped_enum<T const volatile>)); 34 } 35 test_false()36template<class T> void test_false() 37 { 38 using boost::endian::detail::is_scoped_enum; 39 40 BOOST_TEST_TRAIT_FALSE((is_scoped_enum<T>)); 41 BOOST_TEST_TRAIT_FALSE((is_scoped_enum<T const>)); 42 BOOST_TEST_TRAIT_FALSE((is_scoped_enum<T volatile>)); 43 BOOST_TEST_TRAIT_FALSE((is_scoped_enum<T const volatile>)); 44 } 45 main()46int main() 47 { 48 test_false<int>(); 49 test_false<bool>(); 50 test_false<X>(); 51 test_false<Y>(); 52 test_false<void>(); 53 test_false<int[]>(); 54 test_false<int[1]>(); 55 56 test_false<E1>(); 57 58 #if !defined(BOOST_NO_CXX11_SCOPED_ENUMS) 59 60 test_false<E2>(); 61 62 test_true<E3>(); 63 test_true<E4>(); 64 65 #endif 66 67 return boost::report_errors(); 68 } 69