File indexing completed on 2025-04-09 08:28:00
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_MYSQL_DETAIL_ANY_RESUMABLE_REF_HPP
0009 #define BOOST_MYSQL_DETAIL_ANY_RESUMABLE_REF_HPP
0010
0011 #include <boost/mysql/detail/next_action.hpp>
0012
0013 #include <cstddef>
0014 #include <type_traits>
0015
0016 namespace boost {
0017 namespace mysql {
0018 namespace detail {
0019
0020 class any_resumable_ref
0021 {
0022 template <class T>
0023 static next_action do_resume(void* self, error_code ec, std::size_t bytes_transferred)
0024 {
0025 return static_cast<T*>(self)->resume(ec, bytes_transferred);
0026 }
0027
0028 using fn_t = next_action (*)(void*, error_code, std::size_t);
0029
0030 void* algo_{};
0031 fn_t fn_{};
0032
0033 public:
0034 template <class T, class = typename std::enable_if<!std::is_same<T, any_resumable_ref>::value>::type>
0035 explicit any_resumable_ref(T& op) noexcept : algo_(&op), fn_(&do_resume<T>)
0036 {
0037 }
0038
0039 next_action resume(error_code ec, std::size_t bytes_transferred)
0040 {
0041 return fn_(algo_, ec, bytes_transferred);
0042 }
0043 };
0044
0045 }
0046 }
0047 }
0048
0049 #endif