std::experimental::ranges::Constructible - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::experimental::ranges::Constructible

From cppreference.com
< cpp‎ | experimental‎ | ranges

Defined in header `<experimental/ranges/concepts>` |  |
template < class T, class... Args > concept bool __ConstructibleObject = /* exposition only */ ranges::Destructible<T>() && requires(Args&&... args) { T{ std::forward<Args>(args)... }; new T{ std::forward<Args>(args)... }; }; template < class T, class... Args > concept bool __BindableReference = /* exposition only */ std::is_reference<T>::value && requires(Args&&... args) { T( std::forward<Args>(args)... ); }; template < class T, class... Args > concept bool Constructible() { return __ConstructibleObject<T, Args...> || __BindableReference<T, Args...>; } |  | (ranges TS)

The concept Constructible<T, Args..>() is used to constrain a type to be either an object type constructible from a set of types, or a reference type that can be bound to those arguments.

### [edit] Notes

As of the current working draft, Constructible<int&, char&>() is satisfied because the cast in __BindableReference is a reinterpret_cast.

Unlike std::is_constructible, `Constructible` requires a new-expression to be valid and also uses list-initialization, where narrowing conversions are not allowed, initializer-list constructors are preferentially called, and aggregate initialization can be performed. For example:

- Constructible<int, double>() is not satisfied, even though ConvertibleTo<double, int>() is satisfied and std::is_constructible<int, double>::value is true.
- Given struct A { int a; };, Constructible<A, int>() is satisfied, even though std::is_constructible<A, int>::value is false.

### [edit] See also

is_constructibleis_trivially_constructibleis_nothrow_constructible (C++11)(C++11)(C++11) | checks if a type has a constructor for specific arguments (class template) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/experimental/ranges/concepts/Constructible&oldid=89358"