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

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.

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


PrevUpHomeNext