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>
15bdd1243dSDimitry 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 
23*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 20
24349cc55cSDimitry Andric 
25349cc55cSDimitry Andric // [concept.constructible]
26349cc55cSDimitry Andric template <class _Tp, class... _Args>
27*06c3fb27SDimitry Andric concept constructible_from = destructible<_Tp> && is_constructible_v<_Tp, _Args...>;
28349cc55cSDimitry Andric 
29349cc55cSDimitry Andric // [concept.default.init]
30349cc55cSDimitry Andric 
31349cc55cSDimitry Andric template <class _Tp>
32349cc55cSDimitry Andric concept __default_initializable = requires { ::new _Tp; };
33349cc55cSDimitry Andric 
34349cc55cSDimitry Andric template <class _Tp>
35*06c3fb27SDimitry Andric concept default_initializable = constructible_from<_Tp> && requires { _Tp{}; } && __default_initializable<_Tp>;
36349cc55cSDimitry Andric 
37349cc55cSDimitry Andric // [concept.moveconstructible]
38349cc55cSDimitry Andric template <class _Tp>
39*06c3fb27SDimitry Andric concept move_constructible = constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>;
40349cc55cSDimitry Andric 
41349cc55cSDimitry Andric // [concept.copyconstructible]
42*06c3fb27SDimitry Andric // clang-format off
43349cc55cSDimitry Andric template <class _Tp>
44349cc55cSDimitry Andric concept copy_constructible =
45349cc55cSDimitry Andric     move_constructible<_Tp> &&
46349cc55cSDimitry Andric     constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp> &&
47349cc55cSDimitry Andric     constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp> &&
48349cc55cSDimitry Andric     constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>;
49*06c3fb27SDimitry Andric // clang-format on
50349cc55cSDimitry Andric 
51*06c3fb27SDimitry Andric #endif // _LIBCPP_STD_VER >= 20
52349cc55cSDimitry Andric 
53349cc55cSDimitry Andric _LIBCPP_END_NAMESPACE_STD
54349cc55cSDimitry Andric 
55349cc55cSDimitry Andric #endif // _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H
56