blob: 59b103264ffcb7c84bdd9b4d3497b7e26c17fb14 [file] [log] [blame]
Brian Silverman4a2409e2018-08-04 23:24:02 -07001[/
2Copyright 2018 Glen Joseph Fernandes
3<glenjofe -at- gmail.com>
4
5Distributed under the Boost Software License,
6Version 1.0. (See accompanying file LICENSE_1_0.txt
7or copy at http://www.boost.org/LICENSE_1_0.txt).
8]
9
10[section:detected detected]
11
12 template<template<class...> class Op, class... Args>
13 using detected_t = __below;
14
15__alias `Op<Args...>` if it is a valid template-id, otherwise
16`boost::nonesuch`.
17
18__std_paper [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4502.pdf N4502]
19
20__compat Requires C++11 variadic templates and C++11 template aliases.
21
22__header `#include <boost/type_traits/detected.hpp>`
23
24__examples
25
26Suppose you wish to determine whether a type has a `size()` const-member function, then given the meta-functions:
27
28 template <class T>
29 using size_member_tester = decltype(std::declval<const T&>().size());
30
31 template <class T>
32 using size_member_t = boost::detected_t<size_member_tester, T >;
33
34
35Then the type `size_member_t<T>` is an alias for `size_member_tester<T>` if the operation is valid, and an alias for
36`boost::nonesuch` otherwise.
37
38See also: __is_detected, __is_detected_convertible, __is_detected_exact.
39
40[endsect]