execution_concepts.hpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // Copyright (c) 2019-2025 Ruben Perez Hidalgo (rubenperez038 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. #ifndef BOOST_MYSQL_DETAIL_EXECUTION_CONCEPTS_HPP
  8. #define BOOST_MYSQL_DETAIL_EXECUTION_CONCEPTS_HPP
  9. #include <boost/mysql/string_view.hpp>
  10. #include <boost/mysql/detail/any_execution_request.hpp>
  11. #include <boost/mysql/detail/config.hpp>
  12. #include <type_traits>
  13. #ifdef BOOST_MYSQL_HAS_CONCEPTS
  14. namespace boost {
  15. namespace mysql {
  16. // Forward decls
  17. template <class... StaticRow>
  18. class static_execution_state;
  19. template <class... StaticRow>
  20. class static_results;
  21. class execution_state;
  22. class results;
  23. namespace detail {
  24. // Execution state
  25. template <class T>
  26. struct is_static_execution_state : std::false_type
  27. {
  28. };
  29. template <class... T>
  30. struct is_static_execution_state<static_execution_state<T...>> : std::true_type
  31. {
  32. };
  33. template <class T>
  34. concept execution_state_type = std::is_same_v<T, execution_state> || is_static_execution_state<T>::value;
  35. // Results
  36. template <class T>
  37. struct is_static_results : std::false_type
  38. {
  39. };
  40. template <class... T>
  41. struct is_static_results<static_results<T...>> : std::true_type
  42. {
  43. };
  44. template <class T>
  45. concept results_type = std::is_same_v<T, results> || is_static_results<T>::value;
  46. // Execution request
  47. template <class T>
  48. struct is_execution_request
  49. {
  50. static constexpr bool value = !std::is_base_of<
  51. no_execution_request_traits,
  52. execution_request_traits<typename std::decay<T>::type>>::value;
  53. };
  54. template <class T>
  55. concept execution_request = is_execution_request<T>::value;
  56. } // namespace detail
  57. } // namespace mysql
  58. } // namespace boost
  59. #define BOOST_MYSQL_EXECUTION_STATE_TYPE ::boost::mysql::detail::execution_state_type
  60. #define BOOST_MYSQL_RESULTS_TYPE ::boost::mysql::detail::results_type
  61. #define BOOST_MYSQL_EXECUTION_REQUEST ::boost::mysql::detail::execution_request
  62. #else
  63. #define BOOST_MYSQL_EXECUTION_STATE_TYPE class
  64. #define BOOST_MYSQL_RESULTS_TYPE class
  65. #define BOOST_MYSQL_EXECUTION_REQUEST class
  66. #endif
  67. #endif