integral_constant.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. Copyright 2014-2016 Glen Joseph Fernandes
  3. ([email protected])
  4. Distributed under the Boost Software License, Version 1.0.
  5. (http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. #ifndef BOOST_ALIGN_DETAIL_INTEGRAL_CONSTANT_HPP
  8. #define BOOST_ALIGN_DETAIL_INTEGRAL_CONSTANT_HPP
  9. #include <boost/config.hpp>
  10. #if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
  11. #include <type_traits>
  12. #endif
  13. namespace boost {
  14. namespace alignment {
  15. namespace detail {
  16. #if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
  17. using std::integral_constant;
  18. using std::true_type;
  19. using std::false_type;
  20. #else
  21. template<class T, T Value>
  22. struct integral_constant {
  23. typedef T value_type;
  24. typedef integral_constant type;
  25. BOOST_CONSTEXPR operator value_type() const BOOST_NOEXCEPT {
  26. return Value;
  27. }
  28. BOOST_CONSTEXPR value_type operator()() const BOOST_NOEXCEPT {
  29. return Value;
  30. }
  31. BOOST_STATIC_CONSTEXPR T value = Value;
  32. };
  33. template<class T, T Value>
  34. BOOST_CONSTEXPR_OR_CONST T integral_constant<T, Value>::value;
  35. typedef integral_constant<bool, true> true_type;
  36. typedef integral_constant<bool, false> false_type;
  37. #endif
  38. } /* detail */
  39. } /* alignment */
  40. } /* boost */
  41. #endif