File indexing completed on 2025-01-18 09:29:25
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_BEAST_DETAIL_STREAM_TRAITS_HPP
0011 #define BOOST_BEAST_DETAIL_STREAM_TRAITS_HPP
0012
0013 #include <boost/beast/core/error.hpp>
0014 #include <boost/asio/buffer.hpp>
0015 #include <boost/type_traits/make_void.hpp>
0016 #include <type_traits>
0017
0018 namespace boost {
0019 namespace beast {
0020 namespace detail {
0021
0022
0023
0024
0025
0026
0027
0028
0029 template <class T>
0030 std::false_type has_next_layer_impl(void*);
0031
0032 template <class T>
0033 auto has_next_layer_impl(decltype(nullptr)) ->
0034 decltype(std::declval<T&>().next_layer(), std::true_type{});
0035
0036 template <class T>
0037 using has_next_layer = decltype(has_next_layer_impl<T>(nullptr));
0038
0039 template<class T, bool = has_next_layer<T>::value>
0040 struct lowest_layer_type_impl
0041 {
0042 using type = typename std::remove_reference<T>::type;
0043 };
0044
0045 template<class T>
0046 struct lowest_layer_type_impl<T, true>
0047 {
0048 using type = typename lowest_layer_type_impl<
0049 decltype(std::declval<T&>().next_layer())>::type;
0050 };
0051
0052 template<class T>
0053 using lowest_layer_type = typename
0054 lowest_layer_type_impl<T>::type;
0055
0056 template<class T>
0057 T&
0058 get_lowest_layer_impl(
0059 T& t, std::false_type) noexcept
0060 {
0061 return t;
0062 }
0063
0064 template<class T>
0065 lowest_layer_type<T>&
0066 get_lowest_layer_impl(
0067 T& t, std::true_type) noexcept
0068 {
0069 return get_lowest_layer_impl(t.next_layer(),
0070 has_next_layer<typename std::decay<
0071 decltype(t.next_layer())>::type>{});
0072 }
0073
0074
0075
0076
0077
0078 template<class BufferType>
0079 struct BufferSequence
0080 {
0081 using value_type = BufferType;
0082 using const_iterator = BufferType const*;
0083 ~BufferSequence() = default;
0084 BufferSequence(BufferSequence const&) = default;
0085 const_iterator begin() const noexcept { return {}; }
0086 const_iterator end() const noexcept { return {}; }
0087 };
0088 using ConstBufferSequence =
0089 BufferSequence<net::const_buffer>;
0090 using MutableBufferSequence =
0091 BufferSequence<net::mutable_buffer>;
0092
0093
0094
0095
0096
0097 struct StreamHandler
0098 {
0099 StreamHandler(StreamHandler const&) = default;
0100 void operator()(error_code, std::size_t) {}
0101 };
0102 using ReadHandler = StreamHandler;
0103 using WriteHandler = StreamHandler;
0104
0105
0106
0107 }
0108 }
0109 }
0110
0111 #endif