// query.hpp
// ~~~~~~~~~
//
-// Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff 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)
#else // defined(GENERATING_DOCUMENTATION)
-namespace asio_query_fn {
+namespace boost_asio_query_fn {
+using boost::asio::conditional;
using boost::asio::decay;
using boost::asio::declval;
using boost::asio::enable_if;
ill_formed
};
-template <typename T, typename Properties, typename = void>
+template <typename Impl, typename T, typename Properties,
+ typename = void, typename = void, typename = void, typename = void>
struct call_traits
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = ill_formed);
typedef void result_type;
};
-template <typename T, typename Property>
-struct call_traits<T, void(Property),
+template <typename Impl, typename T, typename Property>
+struct call_traits<Impl, T, void(Property),
typename enable_if<
- (
- is_applicable_property<
- typename decay<T>::type,
- typename decay<Property>::type
- >::value
- &&
- static_query<T, Property>::is_valid
- )
+ is_applicable_property<
+ typename decay<T>::type,
+ typename decay<Property>::type
+ >::value
+ >::type,
+ typename enable_if<
+ static_query<T, Property>::is_valid
>::type> :
static_query<T, Property>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = static_value);
};
-template <typename T, typename Property>
-struct call_traits<T, void(Property),
+template <typename Impl, typename T, typename Property>
+struct call_traits<Impl, T, void(Property),
+ typename enable_if<
+ is_applicable_property<
+ typename decay<T>::type,
+ typename decay<Property>::type
+ >::value
+ >::type,
+ typename enable_if<
+ !static_query<T, Property>::is_valid
+ >::type,
typename enable_if<
- (
- is_applicable_property<
- typename decay<T>::type,
- typename decay<Property>::type
- >::value
- &&
- !static_query<T, Property>::is_valid
- &&
- query_member<T, Property>::is_valid
- )
+ query_member<typename Impl::template proxy<T>::type, Property>::is_valid
>::type> :
- query_member<T, Property>
+ query_member<typename Impl::template proxy<T>::type, Property>
{
BOOST_ASIO_STATIC_CONSTEXPR(overload_type, overload = call_member);
};
-template <typename T, typename Property>
-struct call_traits<T, void(Property),
+template <typename Impl, typename T, typename Property>
+struct call_traits<Impl, T, void(Property),
+ typename enable_if<
+ is_applicable_property<
+ typename decay<T>::type,
+ typename decay<Property>::type
+ >::value
+ >::type,
+ typename enable_if<
+ !static_query<T, Property>::is_valid
+ >::type,
typename enable_if<
- (
- is_applicable_property<
- typename decay<T>::type,
- typename decay<Property>::type
- >::value
- &&
- !static_query<T, Property>::is_valid
- &&
- !query_member<T, Property>::is_valid
- &&
- query_free<T, Property>::is_valid
- )
+ !query_member<typename Impl::template proxy<T>::type, Property>::is_valid
+ >::type,
+ typename enable_if<
+ query_free<T, Property>::is_valid
>::type> :
query_free<T, Property>
{
struct impl
{
+ template <typename T>
+ struct proxy
+ {
+#if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
+ struct type
+ {
+ template <typename P>
+ auto query(BOOST_ASIO_MOVE_ARG(P) p)
+ noexcept(
+ noexcept(
+ declval<typename conditional<true, T, P>::type>().query(
+ BOOST_ASIO_MOVE_CAST(P)(p))
+ )
+ )
+ -> decltype(
+ declval<typename conditional<true, T, P>::type>().query(
+ BOOST_ASIO_MOVE_CAST(P)(p))
+ );
+ };
+#else // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
+ typedef T type;
+#endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
+ };
+
template <typename T, typename Property>
BOOST_ASIO_NODISCARD BOOST_ASIO_CONSTEXPR typename enable_if<
- call_traits<T, void(Property)>::overload == static_value,
- typename call_traits<T, void(Property)>::result_type
+ call_traits<impl, T, void(Property)>::overload == static_value,
+ typename call_traits<impl, T, void(Property)>::result_type
>::type
operator()(
BOOST_ASIO_MOVE_ARG(T),
BOOST_ASIO_MOVE_ARG(Property)) const
BOOST_ASIO_NOEXCEPT_IF((
- call_traits<T, void(Property)>::is_noexcept))
+ call_traits<impl, T, void(Property)>::is_noexcept))
{
return static_query<
typename decay<T>::type,
template <typename T, typename Property>
BOOST_ASIO_NODISCARD BOOST_ASIO_CONSTEXPR typename enable_if<
- call_traits<T, void(Property)>::overload == call_member,
- typename call_traits<T, void(Property)>::result_type
+ call_traits<impl, T, void(Property)>::overload == call_member,
+ typename call_traits<impl, T, void(Property)>::result_type
>::type
operator()(
BOOST_ASIO_MOVE_ARG(T) t,
BOOST_ASIO_MOVE_ARG(Property) p) const
BOOST_ASIO_NOEXCEPT_IF((
- call_traits<T, void(Property)>::is_noexcept))
+ call_traits<impl, T, void(Property)>::is_noexcept))
{
return BOOST_ASIO_MOVE_CAST(T)(t).query(BOOST_ASIO_MOVE_CAST(Property)(p));
}
template <typename T, typename Property>
BOOST_ASIO_NODISCARD BOOST_ASIO_CONSTEXPR typename enable_if<
- call_traits<T, void(Property)>::overload == call_free,
- typename call_traits<T, void(Property)>::result_type
+ call_traits<impl, T, void(Property)>::overload == call_free,
+ typename call_traits<impl, T, void(Property)>::result_type
>::type
operator()(
BOOST_ASIO_MOVE_ARG(T) t,
BOOST_ASIO_MOVE_ARG(Property) p) const
BOOST_ASIO_NOEXCEPT_IF((
- call_traits<T, void(Property)>::is_noexcept))
+ call_traits<impl, T, void(Property)>::is_noexcept))
{
return query(BOOST_ASIO_MOVE_CAST(T)(t), BOOST_ASIO_MOVE_CAST(Property)(p));
}
template <typename T>
const T static_instance<T>::instance = {};
-} // namespace asio_query_fn
+} // namespace boost_asio_query_fn
namespace boost {
namespace asio {
namespace {
-static BOOST_ASIO_CONSTEXPR const asio_query_fn::impl&
- query = asio_query_fn::static_instance<>::instance;
+static BOOST_ASIO_CONSTEXPR const boost_asio_query_fn::impl&
+ query = boost_asio_query_fn::static_instance<>::instance;
} // namespace
+typedef boost_asio_query_fn::impl query_t;
+
template <typename T, typename Property>
struct can_query :
integral_constant<bool,
- asio_query_fn::call_traits<T, void(Property)>::overload !=
- asio_query_fn::ill_formed>
+ boost_asio_query_fn::call_traits<query_t, T, void(Property)>::overload !=
+ boost_asio_query_fn::ill_formed>
{
};
template <typename T, typename Property>
struct is_nothrow_query :
integral_constant<bool,
- asio_query_fn::call_traits<T, void(Property)>::is_noexcept>
+ boost_asio_query_fn::call_traits<query_t, T, void(Property)>::is_noexcept>
{
};
template <typename T, typename Property>
struct query_result
{
- typedef typename asio_query_fn::call_traits<
- T, void(Property)>::result_type type;
+ typedef typename boost_asio_query_fn::call_traits<
+ query_t, T, void(Property)>::result_type type;
};
} // namespace asio