integral_constant.hpp 1021 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. Copyright 2014-2016 Glen Joseph Fernandes
  3. (glenjofe@gmail.com)
  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. #else
  19. template<class T, T Value>
  20. struct integral_constant {
  21. typedef T value_type;
  22. typedef integral_constant type;
  23. BOOST_CONSTEXPR operator value_type() const BOOST_NOEXCEPT {
  24. return Value;
  25. }
  26. BOOST_CONSTEXPR value_type operator()() const BOOST_NOEXCEPT {
  27. return Value;
  28. }
  29. BOOST_STATIC_CONSTEXPR T value = Value;
  30. };
  31. template<class T, T Value>
  32. BOOST_CONSTEXPR_OR_CONST T integral_constant<T, Value>::value;
  33. #endif
  34. } /* detail */
  35. } /* alignment */
  36. } /* boost */
  37. #endif