access.hpp 1018 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //
  2. // Copyright (c) 2019-2024 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_ACCESS_HPP
  8. #define BOOST_MYSQL_DETAIL_ACCESS_HPP
  9. #include <utility>
  10. namespace boost {
  11. namespace mysql {
  12. namespace detail {
  13. // Exposes access to the implementation of public access, which is sometimes
  14. // required by library internals.
  15. struct access
  16. {
  17. template <class T>
  18. static decltype(std::declval<T>().impl_)& get_impl(T& obj) noexcept
  19. {
  20. return obj.impl_;
  21. }
  22. template <class T>
  23. static const decltype(std::declval<T>().impl_)& get_impl(const T& obj) noexcept
  24. {
  25. return obj.impl_;
  26. }
  27. template <class T, class... Args>
  28. static T construct(Args&&... args)
  29. {
  30. return T(std::forward<Args>(args)...);
  31. }
  32. };
  33. } // namespace detail
  34. } // namespace mysql
  35. } // namespace boost
  36. #endif