xref: /llvm-project/libcxx/include/__concepts/constructible.h (revision 5aa03b648b827128d439f705cd7d57d59673741d)
158915667SArthur O'Dwyer //===----------------------------------------------------------------------===//
258915667SArthur O'Dwyer //
358915667SArthur O'Dwyer // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
458915667SArthur O'Dwyer // See https://llvm.org/LICENSE.txt for license information.
558915667SArthur O'Dwyer // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
658915667SArthur O'Dwyer //
758915667SArthur O'Dwyer //===----------------------------------------------------------------------===//
858915667SArthur O'Dwyer 
958915667SArthur O'Dwyer #ifndef _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H
1058915667SArthur O'Dwyer #define _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H
1158915667SArthur O'Dwyer 
1258915667SArthur O'Dwyer #include <__concepts/convertible_to.h>
1358915667SArthur O'Dwyer #include <__concepts/destructible.h>
1458915667SArthur O'Dwyer #include <__config>
1566ba7c32SNikolas Klauser #include <__type_traits/is_constructible.h>
1658915667SArthur O'Dwyer 
1758915667SArthur O'Dwyer #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1858915667SArthur O'Dwyer #  pragma GCC system_header
1958915667SArthur O'Dwyer #endif
2058915667SArthur O'Dwyer 
2158915667SArthur O'Dwyer _LIBCPP_BEGIN_NAMESPACE_STD
2258915667SArthur O'Dwyer 
234f15267dSNikolas Klauser #if _LIBCPP_STD_VER >= 20
2458915667SArthur O'Dwyer 
2558915667SArthur O'Dwyer // [concept.constructible]
2658915667SArthur O'Dwyer template <class _Tp, class... _Args>
27*5aa03b64SLouis Dionne concept constructible_from = destructible<_Tp> && is_constructible_v<_Tp, _Args...>;
2858915667SArthur O'Dwyer 
2958915667SArthur O'Dwyer // [concept.default.init]
3058915667SArthur O'Dwyer 
3158915667SArthur O'Dwyer template <class _Tp>
3258915667SArthur O'Dwyer concept __default_initializable = requires { ::new _Tp; };
3358915667SArthur O'Dwyer 
3458915667SArthur O'Dwyer template <class _Tp>
35*5aa03b64SLouis Dionne concept default_initializable = constructible_from<_Tp> && requires { _Tp{}; } && __default_initializable<_Tp>;
3658915667SArthur O'Dwyer 
3758915667SArthur O'Dwyer // [concept.moveconstructible]
3858915667SArthur O'Dwyer template <class _Tp>
39*5aa03b64SLouis Dionne concept move_constructible = constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>;
4058915667SArthur O'Dwyer 
4158915667SArthur O'Dwyer // [concept.copyconstructible]
42*5aa03b64SLouis Dionne // clang-format off
4358915667SArthur O'Dwyer template <class _Tp>
4458915667SArthur O'Dwyer concept copy_constructible =
4558915667SArthur O'Dwyer     move_constructible<_Tp> &&
4658915667SArthur O'Dwyer     constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp> &&
4758915667SArthur O'Dwyer     constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp> &&
4858915667SArthur O'Dwyer     constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>;
49*5aa03b64SLouis Dionne // clang-format on
5058915667SArthur O'Dwyer 
514f15267dSNikolas Klauser #endif // _LIBCPP_STD_VER >= 20
5258915667SArthur O'Dwyer 
5358915667SArthur O'Dwyer _LIBCPP_END_NAMESPACE_STD
5458915667SArthur O'Dwyer 
5558915667SArthur O'Dwyer #endif // _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H
56