Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

detected

template<template<class...> class Op, class... Args>
using detected_t = see-below;

Aliases: Op<Args...> if it is a valid template-id, otherwise boost::nonesuch.

C++ Standard Paper: N4502

Compiler Compatibility: Requires C++11 variadic templates and C++11 template aliases.

Header: #include <boost/type_traits/detected.hpp>

Examples:

Suppose you wish to determine whether a type has a size() const-member function, then given the meta-functions:

template <class T>
using size_member_tester = decltype(std::declval<const T&>().size());

template <class T>
using size_member_t = boost::detected_t<size_member_tester, T >;

Then the type size_member_t<T> is an alias for size_member_tester<T> if the operation is valid, and an alias for boost::nonesuch otherwise.

See also: is_detected, is_detected_convertible, is_detected_exact.


PrevUpHomeNext