1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H
10 #define _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H
11 
12 #include <__concepts/convertible_to.h>
13 #include <__concepts/destructible.h>
14 #include <__config>
15 #include <__type_traits/is_constructible.h>
16 
17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18 #  pragma GCC system_header
19 #endif
20 
21 _LIBCPP_BEGIN_NAMESPACE_STD
22 
23 #if _LIBCPP_STD_VER > 17
24 
25 // [concept.constructible]
26 template<class _Tp, class... _Args>
27 concept constructible_from =
28     destructible<_Tp> && is_constructible_v<_Tp, _Args...>;
29 
30 // [concept.default.init]
31 
32 template<class _Tp>
33 concept __default_initializable = requires { ::new _Tp; };
34 
35 template<class _Tp>
36 concept default_initializable = constructible_from<_Tp> &&
37     requires { _Tp{}; } && __default_initializable<_Tp>;
38 
39 // [concept.moveconstructible]
40 template<class _Tp>
41 concept move_constructible =
42   constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>;
43 
44 // [concept.copyconstructible]
45 template<class _Tp>
46 concept copy_constructible =
47   move_constructible<_Tp> &&
48   constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp> &&
49   constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp> &&
50   constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>;
51 
52 #endif // _LIBCPP_STD_VER > 17
53 
54 _LIBCPP_END_NAMESPACE_STD
55 
56 #endif // _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H
57