// // Copyright (c) 2013-2016 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) // #ifndef BEAST_HTTP_TYPE_CHECK_HPP #define BEAST_HTTP_TYPE_CHECK_HPP #include #include #include #include namespace beast { namespace http { namespace detail { template class has_value_type { template static std::true_type check(int); template static std::false_type check(...); using type = decltype(check(0)); public: static bool constexpr value = type::value; }; template::value> struct extract_value_type { using type = void; }; template struct extract_value_type { using type = typename T::value_type; }; template class has_reader { template static std::true_type check(int); template static std::false_type check(...); public: using type = decltype(check(0)); }; template class has_writer { template static std::true_type check(int); template static std::false_type check(...); public: using type = decltype(check(0)); }; template struct is_Body { using type = std::integral_constant::value >; }; template class is_Parser { template().complete()), bool>> static R check1(int); template static std::false_type check1(...); using type1 = decltype(check1(0)); template().write( std::declval(), std::declval())), std::size_t>> static R check2(int); template static std::false_type check2(...); using type2 = decltype(check2(0)); template().write_eof(std::declval()), std::true_type{})> static R check3(int); template static std::false_type check3(...); using type3 = decltype(check3(0)); public: using type = std::integral_constant; }; } // detail /// Determine if `T` meets the requirements of `Body`. template #if GENERATING_DOCS struct is_Body : std::integral_constant{}; #else using is_Body = typename detail::is_Body::type; #endif /// Determine if `T` meets the requirements of `ReadableBody`. template #if GENERATING_DOCS struct is_ReadableBody : std::integral_constant{}; #else using is_ReadableBody = typename detail::has_reader::type; #endif /// Determine if `T` meets the requirements of `WritableBody`. template #if GENERATING_DOCS struct is_WritableBody : std::integral_constant{}; #else using is_WritableBody = typename detail::has_writer::type; #endif /// Determine if `T` meets the requirements of `Parser`. template #if GENERATING_DOCS struct is_Parser : std::integral_constant{}; #else using is_Parser = typename detail::is_Parser::type; #endif } // http } // beast #endif