56 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H10#define _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H11 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_header19#endif20 21_LIBCPP_BEGIN_NAMESPACE_STD22 23#if _LIBCPP_STD_VER >= 2024 25// [concept.constructible]26template <class _Tp, class... _Args>27concept constructible_from = destructible<_Tp> && is_constructible_v<_Tp, _Args...>;28 29// [concept.default.init]30 31template <class _Tp>32concept __default_initializable = requires { ::new _Tp; };33 34template <class _Tp>35concept default_initializable = constructible_from<_Tp> && requires { _Tp{}; } && __default_initializable<_Tp>;36 37// [concept.moveconstructible]38template <class _Tp>39concept move_constructible = constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>;40 41// [concept.copyconstructible]42// clang-format off43template <class _Tp>44concept copy_constructible =45 move_constructible<_Tp> &&46 constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp> &&47 constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp> &&48 constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>;49// clang-format on50 51#endif // _LIBCPP_STD_VER >= 2052 53_LIBCPP_END_NAMESPACE_STD54 55#endif // _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H56