// // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // Official repository: https://github.com/boostorg/beast // #ifndef BOOST_BEAST_HTTP_TYPE_TRAITS_HPP #define BOOST_BEAST_HTTP_TYPE_TRAITS_HPP #include #include #include #include #include #include #include #include namespace boost { namespace beast { namespace http { template class message; /** Determine if a type meets the Body named requirements. This alias template is `std::true_type` if `T` meets the requirements, otherwise it is `std::false_type`. @tparam T The type to test. @par Example @code template void check_body(message const&) { static_assert(is_body::value, "Body type requirements not met"); } @endcode */ template #if BOOST_BEAST_DOXYGEN using is_body = __see_below__; #else using is_body = detail::has_value_type; #endif /** Determine if a type has a nested BodyWriter. This alias template is `std::true_type` when: @li `T` has a nested type named `writer` @li `writer` meets the requirements of BodyWriter. @tparam T The body type to test. @par Example @code template void check_can_serialize(message const&) { static_assert(is_body_writer::value, "Cannot serialize Body, no reader"); } @endcode */ #if BOOST_BEAST_DOXYGEN template using is_body_writer = __see_below__; #else template struct is_body_writer : std::false_type {}; template struct is_body_writer().init(std::declval()), std::declval>&>() = std::declval().get(std::declval()) )>> : std::integral_constant::value && ( (std::is_constructible&, typename T::value_type&>::value && std::is_constructible&, typename T::value_type&>::value) ) > {}; #endif /** Determine if a type has a nested BodyWriter. This alias template is `std::true_type` when: @li `T` has a nested type named `writer` @li `writer` meets the requirements of BodyWriter. @tparam T The body type to test. */ #if BOOST_BEAST_DOXYGEN template using is_mutable_body_writer = __see_below__; #else template struct is_mutable_body_writer : std::false_type {}; template struct is_mutable_body_writer().init(std::declval()), std::declval>&>() = std::declval().get(std::declval()) )>> : std::integral_constant::value && (( std::is_constructible&, typename T::value_type&>::value && std::is_constructible&, typename T::value_type&>::value && ! std::is_constructible const&, typename T::value_type const&>::value && ! std::is_constructible const&, typename T::value_type const&>::value )) >{}; #endif /** Determine if a type has a nested BodyReader. This alias template is `std::true_type` when: @li `T` has a nested type named `reader` @li `reader` meets the requirements of BodyReader. @tparam T The body type to test. @par Example @code template void check_can_parse(message&) { static_assert(is_body_reader::value, "Cannot parse Body, no reader"); } @endcode */ #if BOOST_BEAST_DOXYGEN template using is_body_reader = __see_below__; #else template struct is_body_reader : std::false_type {}; template struct is_body_reader().init( boost::optional(), std::declval()), std::declval() = std::declval().put( std::declval(), std::declval()), std::declval().finish( std::declval()) )>> : std::integral_constant&, typename T::value_type&>::value && std::is_constructible&, typename T::value_type&>::value) > { }; #endif /** Determine if a type meets the Fields named requirements. This alias template is `std::true_type` if `T` meets the requirements, otherwise it is `std::false_type`. @tparam T The type to test. @par Example Use with `static_assert`: @code template void f(message const&) { static_assert(is_fields::value, "Fields type requirements not met"); ... @endcode Use with `std::enable_if` (SFINAE): @code template typename std::enable_if::value>::type f(message const&); @endcode */ #if BOOST_BEAST_DOXYGEN template using is_fields = __see_below__; #else template using is_fields = typename detail::is_fields_helper::type; #endif } // http } // beast } // boost #endif