is_scoped_enum.hpp 843 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef BOOST_ENDIAN_DETAIL_IS_SCOPED_ENUM_HPP_INCLUDED
  2. #define BOOST_ENDIAN_DETAIL_IS_SCOPED_ENUM_HPP_INCLUDED
  3. // Copyright 2020 Peter Dimov
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // https://www.boost.org/LICENSE_1_0.txt
  7. #include <boost/type_traits/conditional.hpp>
  8. #include <boost/type_traits/is_enum.hpp>
  9. #include <boost/type_traits/is_convertible.hpp>
  10. namespace boost
  11. {
  12. namespace endian
  13. {
  14. namespace detail
  15. {
  16. template<class T> struct negation: boost::integral_constant<bool, !T::value> {};
  17. template<class T> struct is_scoped_enum:
  18. boost::conditional<
  19. boost::is_enum<T>::value,
  20. negation< boost::is_convertible<T, int> >,
  21. boost::false_type
  22. >::type
  23. {
  24. };
  25. } // namespace detail
  26. } // namespace endian
  27. } // namespace boost
  28. #endif // BOOST_ENDIAN_DETAIL_IS_SCOPED_ENUM_HPP_INCLUDED