Skip to content

Commit 2c10664

Browse files
authored
[libc++][NFC] Merge add_{const, cv, volatile}.h into a single header (#115610)
There isn't much benefit in having granular headers for only a few simple lines of code.
1 parent ac30a0f commit 2c10664

File tree

10 files changed

+26
-82
lines changed

10 files changed

+26
-82
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,12 +738,10 @@ set(files
738738
__tuple/tuple_like_no_subrange.h
739739
__tuple/tuple_size.h
740740
__tuple/tuple_types.h
741-
__type_traits/add_const.h
742-
__type_traits/add_cv.h
741+
__type_traits/add_cv_quals.h
743742
__type_traits/add_lvalue_reference.h
744743
__type_traits/add_pointer.h
745744
__type_traits/add_rvalue_reference.h
746-
__type_traits/add_volatile.h
747745
__type_traits/aligned_storage.h
748746
__type_traits/aligned_union.h
749747
__type_traits/alignment_of.h

libcxx/include/__type_traits/add_const.h

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

libcxx/include/__type_traits/add_cv.h renamed to libcxx/include/__type_traits/add_cv_quals.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@
1717

1818
_LIBCPP_BEGIN_NAMESPACE_STD
1919

20+
template <class _Tp>
21+
struct _LIBCPP_TEMPLATE_VIS add_const {
22+
typedef _LIBCPP_NODEBUG const _Tp type;
23+
};
24+
25+
#if _LIBCPP_STD_VER >= 14
26+
template <class _Tp>
27+
using add_const_t = typename add_const<_Tp>::type;
28+
#endif
29+
2030
template <class _Tp>
2131
struct _LIBCPP_TEMPLATE_VIS add_cv {
2232
typedef _LIBCPP_NODEBUG const volatile _Tp type;
@@ -27,6 +37,16 @@ template <class _Tp>
2737
using add_cv_t = typename add_cv<_Tp>::type;
2838
#endif
2939

40+
template <class _Tp>
41+
struct _LIBCPP_TEMPLATE_VIS add_volatile {
42+
typedef _LIBCPP_NODEBUG volatile _Tp type;
43+
};
44+
45+
#if _LIBCPP_STD_VER >= 14
46+
template <class _Tp>
47+
using add_volatile_t = typename add_volatile<_Tp>::type;
48+
#endif
49+
3050
_LIBCPP_END_NAMESPACE_STD
3151

3252
#endif // _LIBCPP___TYPE_TRAITS_ADD_CV_H

libcxx/include/__type_traits/add_volatile.h

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

libcxx/include/__type_traits/is_trivially_assignable.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H
1111

1212
#include <__config>
13-
#include <__type_traits/add_const.h>
1413
#include <__type_traits/add_lvalue_reference.h>
1514
#include <__type_traits/add_rvalue_reference.h>
1615
#include <__type_traits/integral_constant.h>

libcxx/include/__utility/as_const.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
#define _LIBCPP___UTILITY_AS_CONST_H
1111

1212
#include <__config>
13-
#include <__type_traits/add_const.h>
14-
#include <__utility/forward.h>
15-
#include <__utility/move.h>
1613

1714
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1815
# pragma GCC system_header
@@ -22,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2219

2320
#if _LIBCPP_STD_VER >= 17
2421
template <class _Tp>
25-
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept {
22+
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& as_const(_Tp& __t) noexcept {
2623
return __t;
2724
}
2825

libcxx/include/any

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ namespace std {
8585
#include <__memory/allocator_destructor.h>
8686
#include <__memory/allocator_traits.h>
8787
#include <__memory/unique_ptr.h>
88-
#include <__type_traits/add_const.h>
88+
#include <__type_traits/add_cv_quals.h>
8989
#include <__type_traits/add_pointer.h>
9090
#include <__type_traits/aligned_storage.h>
9191
#include <__type_traits/conditional.h>

libcxx/include/module.modulemap

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,10 @@ module std_core [system] {
6363
}
6464

6565
module type_traits {
66-
module add_const { header "__type_traits/add_const.h" }
67-
module add_cv { header "__type_traits/add_cv.h" }
66+
module add_cv_quals { header "__type_traits/add_cv_quals.h" }
6867
module add_lvalue_reference { header "__type_traits/add_lvalue_reference.h" }
6968
module add_pointer { header "__type_traits/add_pointer.h" }
7069
module add_rvalue_reference { header "__type_traits/add_rvalue_reference.h" }
71-
module add_volatile { header "__type_traits/add_volatile.h" }
7270
module aligned_storage { header "__type_traits/aligned_storage.h" }
7371
module aligned_union { header "__type_traits/aligned_union.h" }
7472
module alignment_of { header "__type_traits/alignment_of.h" }

libcxx/include/type_traits

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,12 +425,10 @@ namespace std
425425
*/
426426

427427
#include <__config>
428-
#include <__type_traits/add_const.h>
429-
#include <__type_traits/add_cv.h>
428+
#include <__type_traits/add_cv_quals.h>
430429
#include <__type_traits/add_lvalue_reference.h>
431430
#include <__type_traits/add_pointer.h>
432431
#include <__type_traits/add_rvalue_reference.h>
433-
#include <__type_traits/add_volatile.h>
434432
#include <__type_traits/aligned_storage.h>
435433
#include <__type_traits/aligned_union.h>
436434
#include <__type_traits/alignment_of.h>

libcxx/include/variant

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,8 @@ namespace std {
226226
#include <__memory/construct_at.h>
227227
#include <__tuple/find_index.h>
228228
#include <__tuple/sfinae_helpers.h>
229-
#include <__type_traits/add_const.h>
230-
#include <__type_traits/add_cv.h>
229+
#include <__type_traits/add_cv_quals.h>
231230
#include <__type_traits/add_pointer.h>
232-
#include <__type_traits/add_volatile.h>
233231
#include <__type_traits/common_type.h>
234232
#include <__type_traits/conditional.h>
235233
#include <__type_traits/conjunction.h>

0 commit comments

Comments
 (0)