initiation_base.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // detail/initiation_base.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_DETAIL_INITIATION_BASE_HPP
  11. #define BOOST_ASIO_DETAIL_INITIATION_BASE_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. #include <boost/asio/detail/push_options.hpp>
  18. namespace boost {
  19. namespace asio {
  20. namespace detail {
  21. template <typename Initiation, typename = void>
  22. class initiation_base : public Initiation
  23. {
  24. public:
  25. template <typename I>
  26. explicit initiation_base(I&& initiation)
  27. : Initiation(static_cast<I&&>(initiation))
  28. {
  29. }
  30. };
  31. template <typename Initiation>
  32. class initiation_base<Initiation, enable_if_t<!is_class<Initiation>::value>>
  33. {
  34. public:
  35. template <typename I>
  36. explicit initiation_base(I&& initiation)
  37. : initiation_(static_cast<I&&>(initiation))
  38. {
  39. }
  40. template <typename... Args>
  41. void operator()(Args&&... args) const
  42. {
  43. initiation_(static_cast<Args&&>(args)...);
  44. }
  45. private:
  46. Initiation initiation_;
  47. };
  48. } // namespace detail
  49. } // namespace asio
  50. } // namespace boost
  51. #include <boost/asio/detail/pop_options.hpp>
  52. #endif // BOOST_ASIO_DETAIL_INITIATION_BASE_HPP