Skip to content

Commit be39977

Browse files
ZERICO2005mateoconlechuga
authored andcommitted
Expanded <type_traits> and <concepts>
1 parent 41ff391 commit be39977

File tree

8 files changed

+702
-52
lines changed

8 files changed

+702
-52
lines changed

src/libcxx/header_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <exception>
2727
#include <initializer_list>
2828
#include <limits>
29+
#include <memory>
2930
#include <new>
3031
#include <numbers>
3132
#include <type_traits>

src/libcxx/include/__config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,12 @@
77
#define _EZCXX_INLINE [[__gnu__::__visibility__("hidden"), __gnu__::__always_inline__]] inline
88
#define _EZCXX_NODISCARD [[nodiscard]]
99
#define _EZCXX_NODISCARD_EXT [[nodiscard]]
10+
#define _EZCXX_HIDDEN __attribute__((__visibility__("hidden")))
11+
#define _EZCXX_INTERNAL_LINKAGE __attribute__((internal_linkage))
12+
#define _EZCXX_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__))
13+
#define _EZCXX_HIDE_FROM_ABI _EZCXX_HIDDEN _EZCXX_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
14+
#define _EZCXX_NODEBUG __attribute__((__nodebug__))
15+
#define _EZCXX_TEMPLATE_VIS __attribute__ ((__type_visibility__("default")))
16+
#define _EZCXX_LIFETIMEBOUND [[_Clang::__lifetimebound__]]
1017

1118
#endif // _EZCXX_CONFIG

src/libcxx/include/concepts

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
// -*- C++ -*-
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
29
#ifndef _EZCXX_CONCEPTS
310
#define _EZCXX_CONCEPTS
411

@@ -11,22 +18,38 @@ namespace std {
1118
template<class _Tp, class _Up>
1219
concept same_as = is_same<_Tp, _Up>::value && is_same<_Up, _Tp>::value;
1320

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-
1921
template <class _Dp, class _Bp>
2022
concept derived_from =
2123
is_base_of_v<_Bp, _Dp> &&
2224
is_convertible_v<const volatile _Dp*, const volatile _Bp*>;
2325

24-
template<class _Tp>
25-
concept destructible = is_nothrow_destructible_v<_Tp>;
26+
template<class _From, class _To>
27+
concept convertible_to =
28+
is_convertible_v<_From, _To> &&
29+
requires { static_cast<_To>(std::declval<_From>()); };
2630

27-
template<class _Tp, class... _Args>
28-
concept constructible_from =
29-
destructible<_Tp> && is_constructible_v<_Tp, _Args...>;
31+
template <class _Tp, class _Up>
32+
concept common_reference_with =
33+
same_as<common_reference_t<_Tp, _Up>, common_reference_t<_Up, _Tp>> &&
34+
convertible_to<_Tp, common_reference_t<_Tp, _Up>> && convertible_to<_Up, common_reference_t<_Tp, _Up>>;
35+
36+
template <class _Tp, class _Up>
37+
concept common_with =
38+
same_as<common_type_t<_Tp, _Up>, common_type_t<_Up, _Tp>> &&
39+
requires {
40+
static_cast<common_type_t<_Tp, _Up>>(std::declval<_Tp>());
41+
static_cast<common_type_t<_Tp, _Up>>(std::declval<_Up>());
42+
} &&
43+
common_reference_with<
44+
add_lvalue_reference_t<const _Tp>,
45+
add_lvalue_reference_t<const _Up>> &&
46+
common_reference_with<
47+
add_lvalue_reference_t<common_type_t<_Tp, _Up>>,
48+
common_reference_t<
49+
add_lvalue_reference_t<const _Tp>,
50+
add_lvalue_reference_t<const _Up>
51+
>
52+
>;
3053

3154
template<class _Tp>
3255
concept integral = is_integral_v<_Tp>;
@@ -40,9 +63,19 @@ concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>;
4063
template<class _Tp>
4164
concept floating_point = is_floating_point_v<_Tp>;
4265

66+
template<class _Tp>
67+
concept destructible = is_nothrow_destructible_v<_Tp>;
68+
69+
template<class _Tp, class... _Args>
70+
concept constructible_from =
71+
destructible<_Tp> && is_constructible_v<_Tp, _Args...>;
72+
73+
template <class _Tp>
74+
concept default_initializable = constructible_from<_Tp> && requires { _Tp{}; ::new _Tp; };
75+
4376
template<class _Tp>
4477
concept move_constructible =
45-
constructible_from<_Tp, _Tp> && std::convertible_to<_Tp, _Tp>;
78+
constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>;
4679

4780
template<class _Tp>
4881
concept copy_constructible =

src/libcxx/include/memory

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// -*- C++ -*-
2+
#ifndef _EZCXX_MEMORY
3+
#define _EZCXX_MEMORY
4+
5+
#pragma clang system_header
6+
7+
namespace std {
8+
9+
template <class _Tp>
10+
inline _Tp* addressof(_Tp& __x) noexcept {
11+
return __builtin_addressof(__x);
12+
}
13+
14+
template <class _Tp>
15+
_Tp* addressof(const _Tp&&) noexcept = delete;
16+
17+
} // namespace std
18+
19+
#endif // _EZCXX_MEMORY

0 commit comments

Comments
 (0)