]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | [/ |
2 | Copyright 2015 John Maddock. | |
3 | Distributed under the Boost Software License, Version 1.0. | |
4 | (See accompanying file LICENSE_1_0.txt or copy at | |
5 | http://www.boost.org/LICENSE_1_0.txt). | |
6 | ] | |
7 | ||
8 | [section:is_constructible is_constructible] | |
9 | ||
10 | template <class T, class... Args> | |
11 | struct is_constructible : public __tof {}; | |
12 | ||
13 | __inherit If `T` can be constructed from `Args`, | |
14 | then inherits from __true_type, otherwise inherits from __false_type. Type `T` | |
15 | must be a complete type. | |
16 | ||
17 | Formally the trait answers the question, is the expression: | |
18 | ||
19 | T t(std::declval<Args>()...); | |
20 | ||
21 | valid? | |
22 | ||
23 | There are a number of important special cases for this trait: | |
24 | ||
25 | is_constructible<T>::value | |
26 | ||
27 | Indicates whether `T` is default constructible, while: | |
28 | ||
29 | is_constructible<T, const T&>::value | |
30 | ||
31 | Indicates whether `T` is copy-constructible, and: | |
32 | ||
33 | is_constructible<T, T>::value | |
34 | ||
35 | Indicates whether `T` is move-constructible. | |
36 | ||
37 | ||
38 | __compat This trait requires the C++11 features `decltype` variadic templates and SFINAE-expression support for full support. | |
39 | While there is some fallback code for cases where this is not the case, the trait should really be considered broken in that case. | |
40 | ||
41 | __header ` #include <boost/type_traits/is_copy_constructible.hpp>` or ` #include <boost/type_traits.hpp>` | |
42 | ||
43 | [endsect] | |
44 |