xref: /freebsd-src/contrib/llvm-project/libcxx/include/__concepts/constructible.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
1349cc55cSDimitry Andric //===----------------------------------------------------------------------===//
2349cc55cSDimitry Andric //
3349cc55cSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4349cc55cSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5349cc55cSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6349cc55cSDimitry Andric //
7349cc55cSDimitry Andric //===----------------------------------------------------------------------===//
8349cc55cSDimitry Andric 
9349cc55cSDimitry Andric #ifndef _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H
10349cc55cSDimitry Andric #define _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H
11349cc55cSDimitry Andric 
12349cc55cSDimitry Andric #include <__concepts/convertible_to.h>
13349cc55cSDimitry Andric #include <__concepts/destructible.h>
14349cc55cSDimitry Andric #include <__config>
15*bdd1243dSDimitry Andric #include <__type_traits/is_constructible.h>
16349cc55cSDimitry Andric 
17349cc55cSDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18349cc55cSDimitry Andric #  pragma GCC system_header
19349cc55cSDimitry Andric #endif
20349cc55cSDimitry Andric 
21349cc55cSDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
22349cc55cSDimitry Andric 
2381ad6265SDimitry Andric #if _LIBCPP_STD_VER > 17
24349cc55cSDimitry Andric 
25349cc55cSDimitry Andric // [concept.constructible]
26349cc55cSDimitry Andric template<class _Tp, class... _Args>
27349cc55cSDimitry Andric concept constructible_from =
28349cc55cSDimitry Andric     destructible<_Tp> && is_constructible_v<_Tp, _Args...>;
29349cc55cSDimitry Andric 
30349cc55cSDimitry Andric // [concept.default.init]
31349cc55cSDimitry Andric 
32349cc55cSDimitry Andric template<class _Tp>
33349cc55cSDimitry Andric concept __default_initializable = requires { ::new _Tp; };
34349cc55cSDimitry Andric 
35349cc55cSDimitry Andric template<class _Tp>
36349cc55cSDimitry Andric concept default_initializable = constructible_from<_Tp> &&
37349cc55cSDimitry Andric     requires { _Tp{}; } && __default_initializable<_Tp>;
38349cc55cSDimitry Andric 
39349cc55cSDimitry Andric // [concept.moveconstructible]
40349cc55cSDimitry Andric template<class _Tp>
41349cc55cSDimitry Andric concept move_constructible =
42349cc55cSDimitry Andric   constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>;
43349cc55cSDimitry Andric 
44349cc55cSDimitry Andric // [concept.copyconstructible]
45349cc55cSDimitry Andric template<class _Tp>
46349cc55cSDimitry Andric concept copy_constructible =
47349cc55cSDimitry Andric   move_constructible<_Tp> &&
48349cc55cSDimitry Andric   constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp> &&
49349cc55cSDimitry Andric   constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp> &&
50349cc55cSDimitry Andric   constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>;
51349cc55cSDimitry Andric 
5281ad6265SDimitry Andric #endif // _LIBCPP_STD_VER > 17
53349cc55cSDimitry Andric 
54349cc55cSDimitry Andric _LIBCPP_END_NAMESPACE_STD
55349cc55cSDimitry Andric 
56349cc55cSDimitry Andric #endif // _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H
57