mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 21:07:26 +02:00
@ -1,6 +1,7 @@
|
|||||||
Version 40
|
Version 40
|
||||||
|
|
||||||
* Add to_static_string
|
* Add to_static_string
|
||||||
|
* Consolidate get_lowest_layer in type_traits.hpp
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <beast/core/async_result.hpp>
|
#include <beast/core/async_result.hpp>
|
||||||
#include <beast/core/bind_handler.hpp>
|
#include <beast/core/bind_handler.hpp>
|
||||||
#include <beast/core/error.hpp>
|
#include <beast/core/error.hpp>
|
||||||
#include <beast/core/detail/get_lowest_layer.hpp>
|
#include <beast/core/detail/type_traits.hpp>
|
||||||
#include <beast/websocket/teardown.hpp>
|
#include <beast/websocket/teardown.hpp>
|
||||||
#include <beast/test/fail_counter.hpp>
|
#include <beast/test/fail_counter.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
#include <beast/core/error.hpp>
|
#include <beast/core/error.hpp>
|
||||||
#include <beast/core/stream_concepts.hpp>
|
#include <beast/core/stream_concepts.hpp>
|
||||||
#include <beast/core/multi_buffer.hpp>
|
#include <beast/core/multi_buffer.hpp>
|
||||||
#include <beast/core/detail/get_lowest_layer.hpp>
|
#include <beast/core/detail/type_traits.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_service.hpp>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
@ -13,39 +13,6 @@
|
|||||||
namespace beast {
|
namespace beast {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template<class T>
|
|
||||||
class has_lowest_layer
|
|
||||||
{
|
|
||||||
template<class U, class R =
|
|
||||||
typename U::lowest_layer_type>
|
|
||||||
static std::true_type check(int);
|
|
||||||
template<class>
|
|
||||||
static std::false_type check(...);
|
|
||||||
using type = decltype(check<T>(0));
|
|
||||||
public:
|
|
||||||
static bool constexpr value = type::value;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T, bool B>
|
|
||||||
struct maybe_get_lowest_layer
|
|
||||||
{
|
|
||||||
using type = T;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
struct maybe_get_lowest_layer<T, true>
|
|
||||||
{
|
|
||||||
using type = typename T::lowest_layer_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
// If T has a nested type lowest_layer_type,
|
|
||||||
// returns that, else returns T.
|
|
||||||
template<class T>
|
|
||||||
struct get_lowest_layer
|
|
||||||
{
|
|
||||||
using type = typename maybe_get_lowest_layer<T,
|
|
||||||
has_lowest_layer<T>::value>::type;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // detail
|
} // detail
|
||||||
} // beast
|
} // beast
|
||||||
|
@ -127,6 +127,39 @@ struct is_invocable<C, R(A...)>
|
|||||||
};
|
};
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
class has_lowest_layer
|
||||||
|
{
|
||||||
|
template<class U, class R =
|
||||||
|
typename U::lowest_layer_type>
|
||||||
|
static std::true_type check(int);
|
||||||
|
template<class>
|
||||||
|
static std::false_type check(...);
|
||||||
|
using type = decltype(check<T>(0));
|
||||||
|
public:
|
||||||
|
static bool constexpr value = type::value;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, bool B>
|
||||||
|
struct maybe_get_lowest_layer
|
||||||
|
{
|
||||||
|
using type = T;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct maybe_get_lowest_layer<T, true>
|
||||||
|
{
|
||||||
|
using type = typename T::lowest_layer_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Returns T::lowest_layer_type if it exists, else T
|
||||||
|
template<class T>
|
||||||
|
struct get_lowest_layer
|
||||||
|
{
|
||||||
|
using type = typename maybe_get_lowest_layer<T,
|
||||||
|
has_lowest_layer<T>::value>::type;
|
||||||
|
};
|
||||||
|
|
||||||
} // detail
|
} // detail
|
||||||
} // beast
|
} // beast
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#include <beast/core/async_result.hpp>
|
#include <beast/core/async_result.hpp>
|
||||||
#include <beast/core/buffered_read_stream.hpp>
|
#include <beast/core/buffered_read_stream.hpp>
|
||||||
#include <beast/core/string_view.hpp>
|
#include <beast/core/string_view.hpp>
|
||||||
#include <beast/core/detail/get_lowest_layer.hpp>
|
#include <beast/core/detail/type_traits.hpp>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
@ -40,7 +40,6 @@ unit-test core-tests :
|
|||||||
core/string_view.cpp
|
core/string_view.cpp
|
||||||
core/base64.cpp
|
core/base64.cpp
|
||||||
core/empty_base_optimization.cpp
|
core/empty_base_optimization.cpp
|
||||||
core/get_lowest_layer.cpp
|
|
||||||
core/sha1.cpp
|
core/sha1.cpp
|
||||||
core/type_traits.cpp
|
core/type_traits.cpp
|
||||||
;
|
;
|
||||||
|
@ -33,7 +33,6 @@ add_executable (core-tests
|
|||||||
string_view.cpp
|
string_view.cpp
|
||||||
base64.cpp
|
base64.cpp
|
||||||
empty_base_optimization.cpp
|
empty_base_optimization.cpp
|
||||||
get_lowest_layer.cpp
|
|
||||||
sha1.cpp
|
sha1.cpp
|
||||||
type_traits.cpp
|
type_traits.cpp
|
||||||
)
|
)
|
||||||
|
@ -1,74 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright (c) 2013-2017 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)
|
|
||||||
//
|
|
||||||
|
|
||||||
// Test that header file is self-contained.
|
|
||||||
#include <beast/core/detail/get_lowest_layer.hpp>
|
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
struct F1
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
struct F2
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class F>
|
|
||||||
struct F3
|
|
||||||
{
|
|
||||||
using next_layer_type =
|
|
||||||
typename std::remove_reference<F>::type;
|
|
||||||
|
|
||||||
using lowest_layer_type = typename
|
|
||||||
get_lowest_layer<next_layer_type>::type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class F>
|
|
||||||
struct F4
|
|
||||||
{
|
|
||||||
using next_layer_type =
|
|
||||||
typename std::remove_reference<F>::type;
|
|
||||||
|
|
||||||
using lowest_layer_type = typename
|
|
||||||
get_lowest_layer<next_layer_type>::type;
|
|
||||||
};
|
|
||||||
|
|
||||||
static_assert(! has_lowest_layer<F1>::value, "");
|
|
||||||
static_assert(! has_lowest_layer<F2>::value, "");
|
|
||||||
static_assert(has_lowest_layer<F3<F1>>::value, "");
|
|
||||||
static_assert(has_lowest_layer<F4<F3<F2>>>::value, "");
|
|
||||||
|
|
||||||
static_assert(std::is_same<
|
|
||||||
get_lowest_layer<F1>::type, F1>::value, "");
|
|
||||||
|
|
||||||
static_assert(std::is_same<
|
|
||||||
get_lowest_layer<F2>::type, F2>::value, "");
|
|
||||||
|
|
||||||
static_assert(std::is_same<
|
|
||||||
get_lowest_layer<F3<F1>>::type, F1>::value, "");
|
|
||||||
|
|
||||||
static_assert(std::is_same<
|
|
||||||
get_lowest_layer<F3<F2>>::type, F2>::value, "");
|
|
||||||
|
|
||||||
static_assert(std::is_same<
|
|
||||||
get_lowest_layer<F4<F1>>::type, F1>::value, "");
|
|
||||||
|
|
||||||
static_assert(std::is_same<
|
|
||||||
get_lowest_layer<F4<F2>>::type, F2>::value, "");
|
|
||||||
|
|
||||||
static_assert(std::is_same<
|
|
||||||
get_lowest_layer<F4<F3<F1>>>::type, F1>::value, "");
|
|
||||||
|
|
||||||
static_assert(std::is_same<
|
|
||||||
get_lowest_layer<F4<F3<F2>>>::type, F2>::value, "");
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
} // beast
|
|
@ -10,8 +10,13 @@
|
|||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
//
|
||||||
|
// is_invocable
|
||||||
|
//
|
||||||
|
|
||||||
struct is_invocable_udt1
|
struct is_invocable_udt1
|
||||||
{
|
{
|
||||||
void operator()(int) const;
|
void operator()(int) const;
|
||||||
@ -51,6 +56,68 @@ static_assert(! is_invocable<
|
|||||||
is_invocable_udt3 const, int(int)>::value, "");
|
is_invocable_udt3 const, int(int)>::value, "");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
//
|
||||||
|
// get_lowest_layer
|
||||||
|
//
|
||||||
|
|
||||||
|
struct F1
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
struct F2
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class F>
|
||||||
|
struct F3
|
||||||
|
{
|
||||||
|
using next_layer_type =
|
||||||
|
typename std::remove_reference<F>::type;
|
||||||
|
|
||||||
|
using lowest_layer_type = typename
|
||||||
|
get_lowest_layer<next_layer_type>::type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class F>
|
||||||
|
struct F4
|
||||||
|
{
|
||||||
|
using next_layer_type =
|
||||||
|
typename std::remove_reference<F>::type;
|
||||||
|
|
||||||
|
using lowest_layer_type = typename
|
||||||
|
get_lowest_layer<next_layer_type>::type;
|
||||||
|
};
|
||||||
|
|
||||||
|
static_assert(! has_lowest_layer<F1>::value, "");
|
||||||
|
static_assert(! has_lowest_layer<F2>::value, "");
|
||||||
|
static_assert(has_lowest_layer<F3<F1>>::value, "");
|
||||||
|
static_assert(has_lowest_layer<F4<F3<F2>>>::value, "");
|
||||||
|
|
||||||
|
static_assert(std::is_same<
|
||||||
|
get_lowest_layer<F1>::type, F1>::value, "");
|
||||||
|
|
||||||
|
static_assert(std::is_same<
|
||||||
|
get_lowest_layer<F2>::type, F2>::value, "");
|
||||||
|
|
||||||
|
static_assert(std::is_same<
|
||||||
|
get_lowest_layer<F3<F1>>::type, F1>::value, "");
|
||||||
|
|
||||||
|
static_assert(std::is_same<
|
||||||
|
get_lowest_layer<F3<F2>>::type, F2>::value, "");
|
||||||
|
|
||||||
|
static_assert(std::is_same<
|
||||||
|
get_lowest_layer<F4<F1>>::type, F1>::value, "");
|
||||||
|
|
||||||
|
static_assert(std::is_same<
|
||||||
|
get_lowest_layer<F4<F2>>::type, F2>::value, "");
|
||||||
|
|
||||||
|
static_assert(std::is_same<
|
||||||
|
get_lowest_layer<F4<F3<F1>>>::type, F1>::value, "");
|
||||||
|
|
||||||
|
static_assert(std::is_same<
|
||||||
|
get_lowest_layer<F4<F3<F2>>>::type, F2>::value, "");
|
||||||
|
|
||||||
|
} // (anonymous)
|
||||||
|
|
||||||
} // detail
|
} // detail
|
||||||
} // beast
|
} // beast
|
||||||
|
Reference in New Issue
Block a user