static_const.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/beast
  8. //
  9. #ifndef BOOST_BEAST_DETAIL_STATIC_CONST_HPP
  10. #define BOOST_BEAST_DETAIL_STATIC_CONST_HPP
  11. /* This is a derivative work, original copyright:
  12. Copyright Eric Niebler 2013-present
  13. Use, modification and distribution is subject to the
  14. Boost Software License, Version 1.0. (See accompanying
  15. file LICENSE_1_0.txt or copy at
  16. http://www.boost.org/LICENSE_1_0.txt)
  17. Project home: https://github.com/ericniebler/range-v3
  18. */
  19. namespace boost {
  20. namespace beast {
  21. namespace detail {
  22. template<typename T>
  23. struct static_const
  24. {
  25. static constexpr T value {};
  26. };
  27. template<typename T>
  28. constexpr T static_const<T>::value;
  29. #define BOOST_BEAST_INLINE_VARIABLE(name, type) \
  30. namespace \
  31. { \
  32. constexpr auto& name = \
  33. ::boost::beast::detail::static_const<type>::value; \
  34. }
  35. } // detail
  36. } // beast
  37. } // boost
  38. #endif