is_constant_evaluated.hpp 686 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef BOOST_HASH2_DETAIL_IS_CONSTANT_EVALUATED_HPP_INCLUDED
  2. #define BOOST_HASH2_DETAIL_IS_CONSTANT_EVALUATED_HPP_INCLUDED
  3. // Copyright 2024 Peter Dimov
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // https://www.boost.org/LICENSE_1_0.txt
  6. #include <boost/hash2/detail/config.hpp>
  7. namespace boost
  8. {
  9. namespace hash2
  10. {
  11. namespace detail
  12. {
  13. constexpr bool is_constant_evaluated() noexcept
  14. {
  15. #if defined(BOOST_HASH2_HAS_BUILTIN_IS_CONSTANT_EVALUATED)
  16. return __builtin_is_constant_evaluated();
  17. #else
  18. return true;
  19. #endif
  20. }
  21. } // namespace detail
  22. } // namespace hash2
  23. } // namespace boost
  24. #endif // #ifndef BOOST_HASH2_DETAIL_IS_CONSTANT_EVALUATED_HPP_INCLUDED