|
1 | | -// -*- C++ -*- |
2 | | -#ifndef _EZCXX_CONCEPTS |
3 | | -#define _EZCXX_CONCEPTS |
4 | | - |
5 | | -#include <type_traits> |
6 | | - |
7 | | -#pragma clang system_header |
8 | | - |
9 | | -namespace std { |
10 | | - |
11 | | -template <class _Tp, class _Up> |
12 | | -concept same_as = is_same<_Tp, _Up>::value && is_same<_Up, _Tp>::value; |
13 | | - |
14 | | -// arithmetic: |
15 | | - |
16 | | -template <class _Tp> |
17 | | -concept integral = is_integral_v<_Tp>; |
18 | | - |
19 | | -template <class _Tp> |
20 | | -concept signed_integral = integral<_Tp> && is_signed_v<_Tp>; |
21 | | - |
22 | | -template <class _Tp> |
23 | | -concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>; |
24 | | - |
25 | | -template <class _Tp> |
26 | | -concept floating_point = is_floating_point_v<_Tp>; |
27 | | - |
28 | | -} // namespace std |
29 | | - |
30 | | -#endif // _EZCXX_CONCEPTS |
| 1 | +// -*- C++ -*- |
| 2 | +#ifndef _EZCXX_CONCEPTS |
| 3 | +#define _EZCXX_CONCEPTS |
| 4 | + |
| 5 | +#include <type_traits> |
| 6 | + |
| 7 | +#pragma clang system_header |
| 8 | + |
| 9 | +namespace std { |
| 10 | + |
| 11 | +template<class _Tp, class _Up> |
| 12 | +concept same_as = is_same<_Tp, _Up>::value && is_same<_Up, _Tp>::value; |
| 13 | + |
| 14 | +template<class _From, class _To> |
| 15 | +concept convertible_to = |
| 16 | + is_convertible_v<_From, _To> && |
| 17 | + requires { static_cast<_To>(std::declval<_From>()); }; |
| 18 | + |
| 19 | +template <class _Dp, class _Bp> |
| 20 | +concept derived_from = |
| 21 | + is_base_of_v<_Bp, _Dp> && |
| 22 | + is_convertible_v<const volatile _Dp*, const volatile _Bp*>; |
| 23 | + |
| 24 | +template<class _Tp> |
| 25 | +concept destructible = is_nothrow_destructible_v<_Tp>; |
| 26 | + |
| 27 | +template<class _Tp, class... _Args> |
| 28 | +concept constructible_from = |
| 29 | + destructible<_Tp> && is_constructible_v<_Tp, _Args...>; |
| 30 | + |
| 31 | +template<class _Tp> |
| 32 | +concept integral = is_integral_v<_Tp>; |
| 33 | + |
| 34 | +template<class _Tp> |
| 35 | +concept signed_integral = integral<_Tp> && is_signed_v<_Tp>; |
| 36 | + |
| 37 | +template<class _Tp> |
| 38 | +concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>; |
| 39 | + |
| 40 | +template<class _Tp> |
| 41 | +concept floating_point = is_floating_point_v<_Tp>; |
| 42 | + |
| 43 | +template<class _Tp> |
| 44 | +concept move_constructible = |
| 45 | + constructible_from<_Tp, _Tp> && std::convertible_to<_Tp, _Tp>; |
| 46 | + |
| 47 | +template<class _Tp> |
| 48 | +concept copy_constructible = |
| 49 | + move_constructible<_Tp> && |
| 50 | + constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp> && |
| 51 | + constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp> && |
| 52 | + constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>; |
| 53 | + |
| 54 | +} // namespace std |
| 55 | + |
| 56 | +#endif // _EZCXX_CONCEPTS |
0 commit comments