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 a snapshot of the master branch, built from commit 01b856e70e.
PrevUpHomeNext

is_constructible

template <class T, class... Args>
struct is_constructible : public true_type-or-false_type {};

Inherits: If T can be constructed from Args, then inherits from true_type, otherwise inherits from false_type. Type T must be a complete type.

Formally the trait answers the question, is the expression:

T t(std::declval<Args>()...);

valid?

There are a number of important special cases for this trait:

is_constructible<T>::value

Indicates whether T is default constructible, while:

is_constructible<T, const T&>::value

Indicates whether T is copy-constructible, and:

is_constructible<T, T>::value

Indicates whether T is move-constructible.

Compiler Compatibility: This trait requires the C++11 features decltype variadic templates and SFINAE-expression support for full support. While there is some fallback code for cases where this is not the case, the trait should really be considered broken in that case. The header will define the macro BOOST_TT_IS_CONSTRUCTIBLE_CONFORMING when the full implementation is available.

Header: #include <boost/type_traits/is_constructible.hpp> or #include <boost/type_traits.hpp>


PrevUpHomeNext