diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f1daf5c..35277846 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ 1.0.0-b37 * CMake hide command lines in .vcxproj Output windows" +* Rename to detail::is_invocable WebSocket: diff --git a/include/beast/core/detail/is_call_possible.hpp b/include/beast/core/detail/is_call_possible.hpp deleted file mode 100644 index bafc2a33..00000000 --- a/include/beast/core/detail/is_call_possible.hpp +++ /dev/null @@ -1,54 +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) -// - -#ifndef BEAST_DETAIL_IS_CALL_POSSIBLE_HPP -#define BEAST_DETAIL_IS_CALL_POSSIBLE_HPP - -#include - -namespace beast { -namespace detail { - -template -auto -is_call_possible_test(C&& c, int, A&& ...a) - -> decltype(std::is_convertible< - decltype(c(a...)), R>::value || - std::is_same::value, - std::true_type()); - -template -std::false_type -is_call_possible_test(C&& c, long, A&& ...a); - -/** Metafunction returns `true` if F callable as R(A...) - - Example: - - @code - is_call_possible - @endcode -*/ -/** @{ */ -template -struct is_call_possible - : std::false_type -{ -}; - -template -struct is_call_possible - : decltype(is_call_possible_test( - std::declval(), 1, std::declval()...)) -{ -}; -/** @} */ - -} // detail -} // beast - -#endif diff --git a/include/beast/core/detail/type_traits.hpp b/include/beast/core/detail/type_traits.hpp index 4b6acbd4..b667aa31 100644 --- a/include/beast/core/detail/type_traits.hpp +++ b/include/beast/core/detail/type_traits.hpp @@ -92,6 +92,41 @@ make_exception(char const* reason, char const* file, int line) n + ":" + std::to_string(line) + ")"}; } +template +auto +is_invocable_test(C&& c, int, A&& ...a) + -> decltype(std::is_convertible< + decltype(c(a...)), R>::value || + std::is_same::value, + std::true_type()); + +template +std::false_type +is_invocable_test(C&& c, long, A&& ...a); + +/** Metafunction returns `true` if F callable as R(A...) + + Example: + + @code + is_invocable + @endcode +*/ +/** @{ */ +template +struct is_invocable + : std::false_type +{ +}; + +template +struct is_invocable + : decltype(is_invocable_test( + std::declval(), 1, std::declval()...)) +{ +}; +/** @} */ + } // detail } // beast diff --git a/include/beast/core/handler_concepts.hpp b/include/beast/core/handler_concepts.hpp index 0f4fd9f2..0f535981 100644 --- a/include/beast/core/handler_concepts.hpp +++ b/include/beast/core/handler_concepts.hpp @@ -9,7 +9,7 @@ #define BEAST_HANDLER_CONCEPTS_HPP #include -#include +#include #include namespace beast { @@ -21,7 +21,7 @@ using is_CompletionHandler = std::integral_constant; #else using is_CompletionHandler = std::integral_constant::type>::value && - detail::is_call_possible::value>; + detail::is_invocable::value>; #endif } // beast diff --git a/include/beast/websocket/detail/type_traits.hpp b/include/beast/websocket/detail/type_traits.hpp index 58be3caf..7f3481f1 100644 --- a/include/beast/websocket/detail/type_traits.hpp +++ b/include/beast/websocket/detail/type_traits.hpp @@ -9,7 +9,7 @@ #define BEAST_WEBSOCKET_DETAIL_TYPE_TRAITS_HPP #include -#include +#include namespace beast { namespace websocket { @@ -17,12 +17,12 @@ namespace detail { template using is_RequestDecorator = - typename beast::detail::is_call_possible::type; template using is_ResponseDecorator = - typename beast::detail::is_call_possible::type; } // detail diff --git a/test/Jamfile b/test/Jamfile index 75f0d2fc..c9f49370 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -41,8 +41,8 @@ unit-test core-tests : core/base64.cpp core/empty_base_optimization.cpp core/get_lowest_layer.cpp - core/is_call_possible.cpp core/sha1.cpp + core/type_traits.cpp ; unit-test http-tests : diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index cf1e24cf..1413262f 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -34,8 +34,8 @@ add_executable (core-tests base64.cpp empty_base_optimization.cpp get_lowest_layer.cpp - is_call_possible.cpp sha1.cpp + type_traits.cpp ) if (NOT WIN32) diff --git a/test/core/is_call_possible.cpp b/test/core/is_call_possible.cpp deleted file mode 100644 index 5849793d..00000000 --- a/test/core/is_call_possible.cpp +++ /dev/null @@ -1,56 +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 - -namespace beast { -namespace detail { -namespace { - -struct is_call_possible_udt1 -{ - void operator()(int) const; -}; - -struct is_call_possible_udt2 -{ - int operator()(int) const; -}; - -struct is_call_possible_udt3 -{ - int operator()(int); -}; - -#ifndef __INTELLISENSE__ -// VFALCO Fails to compile with Intellisense -static_assert(is_call_possible< - is_call_possible_udt1, void(int)>::value, ""); - -static_assert(! is_call_possible< - is_call_possible_udt1, void(void)>::value, ""); - -static_assert(is_call_possible< - is_call_possible_udt2, int(int)>::value, ""); - -static_assert(! is_call_possible< - is_call_possible_udt2, int(void)>::value, ""); - -static_assert(! is_call_possible< - is_call_possible_udt2, void(void)>::value, ""); - -static_assert(is_call_possible< - is_call_possible_udt3, int(int)>::value, ""); - -static_assert(! is_call_possible< - is_call_possible_udt3 const, int(int)>::value, ""); -#endif - -} -} // detail -} // beast diff --git a/test/core/type_traits.cpp b/test/core/type_traits.cpp new file mode 100644 index 00000000..0f57b040 --- /dev/null +++ b/test/core/type_traits.cpp @@ -0,0 +1,56 @@ +// +// 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 + +namespace beast { +namespace detail { +namespace { + +struct is_invocable_udt1 +{ + void operator()(int) const; +}; + +struct is_invocable_udt2 +{ + int operator()(int) const; +}; + +struct is_invocable_udt3 +{ + int operator()(int); +}; + +#ifndef __INTELLISENSE__ +// VFALCO Fails to compile with Intellisense +static_assert(is_invocable< + is_invocable_udt1, void(int)>::value, ""); + +static_assert(! is_invocable< + is_invocable_udt1, void(void)>::value, ""); + +static_assert(is_invocable< + is_invocable_udt2, int(int)>::value, ""); + +static_assert(! is_invocable< + is_invocable_udt2, int(void)>::value, ""); + +static_assert(! is_invocable< + is_invocable_udt2, void(void)>::value, ""); + +static_assert(is_invocable< + is_invocable_udt3, int(int)>::value, ""); + +static_assert(! is_invocable< + is_invocable_udt3 const, int(int)>::value, ""); +#endif + +} +} // detail +} // beast