Skip to content

Commit 17ce48f

Browse files
authored
[libc++] Remove __is_replaceable emulation (llvm#167355)
The Trivial Relocation feature has been removed from the C++26 working draft. Based on discussions in Kona, it is unlikely that the "replaceable" type concept will come back in the C++29 time frame. Since we don't have a use for the type trait in the library at the moment, remove the code associated to it. If we end up needing something like it in the future, we can always add it back.
1 parent f2a4287 commit 17ce48f

File tree

18 files changed

+3
-470
lines changed

18 files changed

+3
-470
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,6 @@ set(files
859859
__type_traits/is_reference.h
860860
__type_traits/is_reference_wrapper.h
861861
__type_traits/is_referenceable.h
862-
__type_traits/is_replaceable.h
863862
__type_traits/is_same.h
864863
__type_traits/is_scalar.h
865864
__type_traits/is_signed.h

libcxx/include/__exception/exception_ptr.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
7575

7676
public:
7777
// exception_ptr is basically a COW string so it is trivially relocatable.
78-
// It is also replaceable because assignment has normal value semantics.
7978
using __trivially_relocatable _LIBCPP_NODEBUG = exception_ptr;
80-
using __replaceable _LIBCPP_NODEBUG = exception_ptr;
8179

8280
_LIBCPP_HIDE_FROM_ABI exception_ptr() _NOEXCEPT : __ptr_() {}
8381
_LIBCPP_HIDE_FROM_ABI exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {}

libcxx/include/__expected/expected.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include <__type_traits/is_nothrow_assignable.h>
3131
#include <__type_traits/is_nothrow_constructible.h>
3232
#include <__type_traits/is_reference.h>
33-
#include <__type_traits/is_replaceable.h>
3433
#include <__type_traits/is_same.h>
3534
#include <__type_traits/is_swappable.h>
3635
#include <__type_traits/is_trivially_constructible.h>
@@ -472,8 +471,6 @@ class expected : private __expected_base<_Tp, _Err> {
472471
__conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value && __libcpp_is_trivially_relocatable<_Err>::value,
473472
expected,
474473
void>;
475-
using __replaceable _LIBCPP_NODEBUG =
476-
__conditional_t<__is_replaceable_v<_Tp> && __is_replaceable_v<_Err>, expected, void>;
477474

478475
template <class _Up>
479476
using rebind = expected<_Up, error_type>;

libcxx/include/__locale

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale&);
5757
class _LIBCPP_EXPORTED_FROM_ABI locale {
5858
public:
5959
// locale is essentially a shared_ptr that doesn't support weak_ptrs and never got a move constructor,
60-
// so it is trivially relocatable. Like shared_ptr, it is also replaceable.
60+
// so it is trivially relocatable.
6161
using __trivially_relocatable _LIBCPP_NODEBUG = locale;
62-
using __replaceable _LIBCPP_NODEBUG = locale;
6362

6463
// types:
6564
class _LIBCPP_EXPORTED_FROM_ABI facet;

libcxx/include/__memory/shared_ptr.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,8 @@ class _LIBCPP_SHARED_PTR_TRIVIAL_ABI shared_ptr {
317317
#endif
318318

319319
// A shared_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require
320-
// any bookkeeping, so it's always trivially relocatable. It is also replaceable because assignment just rebinds the
321-
// shared_ptr to manage a different object.
320+
// any bookkeeping, so it's always trivially relocatable.
322321
using __trivially_relocatable _LIBCPP_NODEBUG = shared_ptr;
323-
using __replaceable _LIBCPP_NODEBUG = shared_ptr;
324322

325323
private:
326324
element_type* __ptr_;
@@ -1186,9 +1184,8 @@ class _LIBCPP_SHARED_PTR_TRIVIAL_ABI weak_ptr {
11861184
#endif
11871185

11881186
// A weak_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require
1189-
// any bookkeeping, so it's always trivially relocatable. It's also replaceable for the same reason.
1187+
// any bookkeeping, so it's always trivially relocatable.
11901188
using __trivially_relocatable _LIBCPP_NODEBUG = weak_ptr;
1191-
using __replaceable _LIBCPP_NODEBUG = weak_ptr;
11921189

11931190
private:
11941191
element_type* __ptr_;

libcxx/include/__memory/unique_ptr.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include <__type_traits/is_function.h>
4040
#include <__type_traits/is_pointer.h>
4141
#include <__type_traits/is_reference.h>
42-
#include <__type_traits/is_replaceable.h>
4342
#include <__type_traits/is_same.h>
4443
#include <__type_traits/is_swappable.h>
4544
#include <__type_traits/is_trivially_relocatable.h>
@@ -145,8 +144,6 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr {
145144
__libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value,
146145
unique_ptr,
147146
void>;
148-
using __replaceable _LIBCPP_NODEBUG =
149-
__conditional_t<__is_replaceable_v<pointer> && __is_replaceable_v<deleter_type>, unique_ptr, void>;
150147

151148
private:
152149
_LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_);
@@ -413,8 +410,6 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr<_Tp[], _Dp> {
413410
__libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value,
414411
unique_ptr,
415412
void>;
416-
using __replaceable _LIBCPP_NODEBUG =
417-
__conditional_t<__is_replaceable_v<pointer> && __is_replaceable_v<deleter_type>, unique_ptr, void>;
418413

419414
private:
420415
template <class _Up, class _OtherDeleter>

libcxx/include/__split_buffer

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include <__type_traits/integral_constant.h>
3131
#include <__type_traits/is_nothrow_assignable.h>
3232
#include <__type_traits/is_nothrow_constructible.h>
33-
#include <__type_traits/is_replaceable.h>
3433
#include <__type_traits/is_swappable.h>
3534
#include <__type_traits/is_trivially_destructible.h>
3635
#include <__type_traits/is_trivially_relocatable.h>
@@ -484,10 +483,6 @@ public:
484483
__libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,
485484
__split_buffer,
486485
void>;
487-
using __replaceable _LIBCPP_NODEBUG =
488-
__conditional_t<__is_replaceable_v<pointer> && __container_allocator_is_replaceable<__alloc_traits>::value,
489-
__split_buffer,
490-
void>;
491486

492487
__split_buffer(const __split_buffer&) = delete;
493488
__split_buffer& operator=(const __split_buffer&) = delete;

libcxx/include/__type_traits/is_replaceable.h

Lines changed: 0 additions & 61 deletions
This file was deleted.

libcxx/include/__utility/pair.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
#include <__type_traits/is_implicitly_default_constructible.h>
3232
#include <__type_traits/is_nothrow_assignable.h>
3333
#include <__type_traits/is_nothrow_constructible.h>
34-
#include <__type_traits/is_replaceable.h>
35-
#include <__type_traits/is_same.h>
3634
#include <__type_traits/is_swappable.h>
3735
#include <__type_traits/is_trivially_relocatable.h>
3836
#include <__type_traits/nat.h>
@@ -102,7 +100,6 @@ struct pair
102100
__conditional_t<__libcpp_is_trivially_relocatable<_T1>::value && __libcpp_is_trivially_relocatable<_T2>::value,
103101
pair,
104102
void>;
105-
using __replaceable _LIBCPP_NODEBUG = __conditional_t<__is_replaceable_v<_T1> && __is_replaceable_v<_T2>, pair, void>;
106103

107104
_LIBCPP_HIDE_FROM_ABI pair(pair const&) = default;
108105
_LIBCPP_HIDE_FROM_ABI pair(pair&&) = default;

libcxx/include/__vector/vector.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
#include <__type_traits/is_nothrow_assignable.h>
5555
#include <__type_traits/is_nothrow_constructible.h>
5656
#include <__type_traits/is_pointer.h>
57-
#include <__type_traits/is_replaceable.h>
5857
#include <__type_traits/is_same.h>
5958
#include <__type_traits/is_trivially_relocatable.h>
6059
#include <__type_traits/type_identity.h>
@@ -123,10 +122,6 @@ class vector {
123122
__libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,
124123
vector,
125124
void>;
126-
using __replaceable _LIBCPP_NODEBUG =
127-
__conditional_t<__is_replaceable_v<pointer> && __container_allocator_is_replaceable<__alloc_traits>::value,
128-
vector,
129-
void>;
130125

131126
static_assert(__check_valid_allocator<allocator_type>::value, "");
132127
static_assert(is_same<typename allocator_type::value_type, value_type>::value,

0 commit comments

Comments
 (0)