query_static_constexpr_member.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // traits/query_static_constexpr_member.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef BOOST_ASIO_TRAITS_QUERY_STATIC_CONSTEXPR_MEMBER_HPP
  11. #define BOOST_ASIO_TRAITS_QUERY_STATIC_CONSTEXPR_MEMBER_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #include <boost/asio/detail/type_traits.hpp>
  17. #if defined(BOOST_ASIO_HAS_CONSTANT_EXPRESSION_SFINAE) \
  18. && defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
  19. # define BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT 1
  20. #endif // defined(BOOST_ASIO_HAS_CONSTANT_EXPRESSION_SFINAE)
  21. // && defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
  22. #include <boost/asio/detail/push_options.hpp>
  23. namespace boost {
  24. namespace asio {
  25. namespace traits {
  26. template <typename T, typename Property, typename = void>
  27. struct query_static_constexpr_member_default;
  28. template <typename T, typename Property, typename = void>
  29. struct query_static_constexpr_member;
  30. } // namespace traits
  31. namespace detail {
  32. struct no_query_static_constexpr_member
  33. {
  34. static constexpr bool is_valid = false;
  35. };
  36. template <typename T, typename Property, typename = void>
  37. struct query_static_constexpr_member_trait :
  38. conditional_t<
  39. is_same<T, decay_t<T>>::value
  40. && is_same<Property, decay_t<Property>>::value,
  41. no_query_static_constexpr_member,
  42. traits::query_static_constexpr_member<
  43. decay_t<T>,
  44. decay_t<Property>>
  45. >
  46. {
  47. };
  48. #if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
  49. template <typename T, typename Property>
  50. struct query_static_constexpr_member_trait<T, Property,
  51. enable_if_t<
  52. (static_cast<void>(T::query(Property{})), true)
  53. >>
  54. {
  55. static constexpr bool is_valid = true;
  56. using result_type = decltype(T::query(Property{}));
  57. static constexpr bool is_noexcept = noexcept(T::query(Property{}));
  58. static constexpr result_type value() noexcept(is_noexcept)
  59. {
  60. return T::query(Property{});
  61. }
  62. };
  63. #endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
  64. } // namespace detail
  65. namespace traits {
  66. template <typename T, typename Property, typename>
  67. struct query_static_constexpr_member_default :
  68. detail::query_static_constexpr_member_trait<T, Property>
  69. {
  70. };
  71. template <typename T, typename Property, typename>
  72. struct query_static_constexpr_member :
  73. query_static_constexpr_member_default<T, Property>
  74. {
  75. };
  76. } // namespace traits
  77. } // namespace asio
  78. } // namespace boost
  79. #include <boost/asio/detail/pop_options.hpp>
  80. #endif // BOOST_ASIO_TRAITS_QUERY_STATIC_CONSTEXPR_MEMBER_HPP