type_traits.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco 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. // Official repository: https://github.com/boostorg/beast
  8. //
  9. #ifndef BOOST_BEAST_TYPE_TRAITS_HPP
  10. #define BOOST_BEAST_TYPE_TRAITS_HPP
  11. #ifndef BOOST_BEAST_DOXYGEN
  12. #include <boost/beast/core/detail/config.hpp>
  13. #include <boost/beast/core/detail/is_invocable.hpp>
  14. #include <boost/config/pragma_message.hpp>
  15. #include <type_traits.hpp>
  16. BOOST_PRAGMA_MESSAGE("<boost/beast/core/type_traits.hpp> is DEPRECATED and will be removed in a future release.")
  17. namespace boost {
  18. namespace beast {
  19. /** Determine if `T` meets the requirements of <em>CompletionHandler</em>.
  20. This trait checks whether a type meets the requirements for a completion
  21. handler, and is also callable with the specified signature.
  22. Metafunctions are used to perform compile time checking of template
  23. types. This type will be `std::true_type` if `T` meets the requirements,
  24. else the type will be `std::false_type`.
  25. @par Example
  26. Use with `static_assert`:
  27. @code
  28. struct handler
  29. {
  30. void operator()(error_code&);
  31. };
  32. static_assert(is_completion_handler<handler, void(error_code&)>::value,
  33. "Not a completion handler");
  34. @endcode
  35. */
  36. template<class T, class Signature>
  37. #if BOOST_BEAST_DOXYGEN
  38. using is_completion_handler = __see_below__
  39. #else
  40. using is_completion_handler = std::integral_constant<bool,
  41. std::is_move_constructible<typename std::decay<T>::type>::value &&
  42. detail::is_invocable<T, Signature>::value>;
  43. #endif
  44. } // beast
  45. } // boost
  46. #endif
  47. #endif