Skip to content

Commit 8b74333

Browse files
committed
Cleanup for C++20 testing on a Mac M1
This patch supplies additional cleanups that were independently developed testing C++20 on an M1 mac. After rebasing onto the changes already landed in `master`, the main effect is to adopt an additional library feature macro, in the style of existing feature macros, rather than rely on inline tests for the C++ language version. Also added platform support for the Arm 9 CPU, and fixed up a typo or two.
1 parent d200f0f commit 8b74333

File tree

5 files changed

+93
-62
lines changed

5 files changed

+93
-62
lines changed

Diff for: groups/bsl/bsl+bslhdrs/bsl_functional.h

+9-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ BSLS_IDENT("$Id: $")
2727
namespace bsl {
2828

2929
// Import selected symbols into bsl namespace
30-
using std::binary_negate;
3130
using std::divides;
3231
using std::greater;
3332
using std::greater_equal;
@@ -40,13 +39,10 @@ namespace bsl {
4039
using std::modulus;
4140
using std::multiplies;
4241
using std::negate;
43-
using std::not1;
44-
using std::not2;
4542
using std::not_equal_to;
4643
using std::plus;
47-
using std::unary_negate;
4844

49-
#if ! defined BSLS_LIBRARYFEATURES_HAS_CPP17_DEPRECATED_REMOVED
45+
#if !defined(BSLS_LIBRARYFEATURES_HAS_CPP17_DEPRECATED_REMOVED)
5046
// These names are removed by C++17
5147
using std::binary_function;
5248
using std::bind1st;
@@ -69,6 +65,14 @@ namespace bsl {
6965
using std::unary_function;
7066
#endif
7167

68+
#if !defined(BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED)
69+
// These names are removed by C++20
70+
using std::binary_negate;
71+
using std::not1;
72+
using std::not2;
73+
using std::unary_negate;
74+
#endif
75+
7276
#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
7377
namespace placeholders = std::placeholders;
7478

Diff for: groups/bsl/bsl+bslhdrs/bsl_memory.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ namespace bsl {
3131
// using std::allocator;
3232
//..
3333

34-
using std::get_temporary_buffer;
35-
using std::raw_storage_iterator;
36-
using std::return_temporary_buffer;
3734
using std::uninitialized_copy;
3835
using std::uninitialized_fill;
3936
using std::uninitialized_fill_n;
@@ -82,6 +79,12 @@ namespace bsl {
8279
using std::undeclare_reachable;
8380
#endif // BSLS_LIBRARYFEATURES_HAS_CPP11_GARBAGE_COLLECTION_API
8481

82+
#ifndef BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED
83+
using std::get_temporary_buffer;
84+
using std::raw_storage_iterator;
85+
using std::return_temporary_buffer;
86+
#endif
87+
8588
#ifndef BDE_OMIT_INTERNAL_DEPRECATED
8689
// Import additional names expected by existing code, but not mandated by
8790
// the standard header. This may get tricky if some standard library

Diff for: groups/bsl/bsl+bslhdrs/bsl_type_traits.h

+53-52
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ using std::is_object;
113113
using std::is_scalar;
114114
using std::is_compound;
115115

116+
116117
// 20.10.4.3, type properties:
117118
using std::is_trivial;
118119
using std::is_standard_layout;
119-
using std::is_pod;
120-
using std::is_literal_type;
120+
using std::is_pod; // deprecated by C++20
121121
using std::is_abstract;
122122
using std::is_signed;
123123
using std::is_unsigned;
@@ -172,19 +172,22 @@ using std::aligned_union;
172172
#endif
173173
using std::common_type;
174174
using std::underlying_type;
175+
176+
#if !defined(BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED)
177+
// These names are removed by C++20
178+
using std::is_literal_type;
175179
using std::result_of;
180+
#endif
176181

177182
#ifdef BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES
178183
template <std::size_t LEN, std::size_t ALIGN>
179-
using aligned_storage_t =
180-
typename std::aligned_storage<LEN, ALIGN>::type;
184+
using aligned_storage_t = typename std::aligned_storage<LEN, ALIGN>::type;
181185
// 'aligned_storage_t' is an alias to the return type of the
182186
// 'std::aligned_storage' meta-function.
183187

184188
#ifdef BSLS_COMPILERFEATURES_SUPPORT_VARIADIC_TEMPLATES
185189
template <std::size_t LEN, class... TYPES>
186-
using aligned_union_t =
187-
typename std::aligned_union<LEN, TYPES...>::type;
190+
using aligned_union_t = typename std::aligned_union<LEN, TYPES...>::type;
188191
// 'aligned_union_t' is an alias to the return type of the
189192
// 'std::aligned_union' meta-function.
190193

@@ -205,22 +208,24 @@ using make_unsigned_t = typename std::make_unsigned<TYPE>::type;
205208
// 'std::make_unsigned' meta-function.
206209

207210
template <class TYPE>
208-
using remove_all_extents_t =
209-
typename std::remove_all_extents<TYPE>::type;
211+
using remove_all_extents_t = typename std::remove_all_extents<TYPE>::type;
210212
// 'remove_all_extents_t' is an alias to the return type of the
211213
// 'std::remove_all_extents' meta-function.
212214

213-
template <class TYPE>
214-
using result_of_t = typename std::result_of<TYPE>::type;
215-
// ' result_of_t' is an alias to the return type of the
216-
// 'std::result_of' meta-function.
217-
218215
template <class TYPE>
219216
using underlying_type_t = typename std::underlying_type<TYPE>::type;
220217
// 'underlying_type_t' is an alias to the return type of the
221218
// 'std::underlying_type' meta-function.
222219
#endif
223220

221+
#if !defined(BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED)
222+
// These names are removed by C++20
223+
template <class TYPE>
224+
using result_of_t = typename std::result_of<TYPE>::type;
225+
// ' result_of_t' is an alias to the return type of the
226+
// 'std::result_of' meta-function.
227+
# endif
228+
224229
#ifdef BSLS_LIBRARYFEATURES_HAS_CPP14_BASELINE_LIBRARY
225230
using std::is_null_pointer;
226231
using std::is_final;
@@ -287,50 +292,24 @@ template <class TYPE>
287292
BSLS_KEYWORD_INLINE_VARIABLE
288293
constexpr bool is_standard_layout_v = std::is_standard_layout<TYPE>::value;
289294

290-
// ----------------------------------------------------------------------------
291-
292-
#if defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION >= 110000 && \
295+
# if defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION >= 110000 && \
293296
BSLS_COMPILERFEATURES_CPLUSPLUS >= 202002L
294-
#pragma GCC diagnostic push
295-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
296-
#endif
297+
# pragma GCC diagnostic push
298+
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
299+
# endif
297300

298301
template <class TYPE>
299-
#if BSLS_COMPILERFEATURES_CPLUSPLUS >= 202002L
302+
# if BSLS_COMPILERFEATURES_CPLUSPLUS >= 202002L
300303
BSLA_DEPRECATED // Warn of using 'bsl::is_pod_v' even though we suppress
301304
// warnings of using 'std::is_pod' in this implementation.
302-
#endif // C++20
305+
# endif // C++20
303306
BSLS_KEYWORD_INLINE_VARIABLE
304307
constexpr bool is_pod_v = std::is_pod<TYPE>::value;
305308

306-
#if defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION >= 110000 && \
309+
# if defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION >= 110000 && \
307310
BSLS_COMPILERFEATURES_CPLUSPLUS >= 202002L
308-
#pragma GCC diagnostic pop
309-
#endif
310-
311-
// ----------------------------------------------------------------------------
312-
313-
#if defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION >= 110000 && \
314-
BSLS_COMPILERFEATURES_CPLUSPLUS >= 201703L
315-
#pragma GCC diagnostic push
316-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
317-
#endif
318-
319-
#if BSLS_COMPILERFEATURES_CPLUSPLUS < 202002L
320-
template <class TYPE>
321-
BSLA_DEPRECATED // Warn of using 'bsl::is_literal_type' even though we
322-
// suppress warnings of using 'std::is_pod' in this
323-
// implementation.
324-
BSLS_KEYWORD_INLINE_VARIABLE
325-
constexpr bool is_literal_type_v = std::is_literal_type<TYPE>::value;
326-
#else
327-
// Removed in C++20
328-
#endif // Introduced in C++17 already deprecated; removed in C++20.
329-
330-
#if defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION >= 110000 && \
331-
BSLS_COMPILERFEATURES_CPLUSPLUS >= 201703L
332-
#pragma GCC diagnostic pop
333-
#endif
311+
# pragma GCC diagnostic pop
312+
# endif
334313

335314
// ----------------------------------------------------------------------------
336315

@@ -470,7 +449,7 @@ template <class TYPE1, class TYPE2>
470449
BSLS_KEYWORD_INLINE_VARIABLE
471450
constexpr bool is_base_of_v = std::is_base_of<TYPE1, TYPE2>::value;
472451

473-
#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
452+
# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
474453
template <class ...Bools>
475454
BSLS_KEYWORD_INLINE_VARIABLE
476455
constexpr bool conjunction_v = std::conjunction<Bools...>::value;
@@ -529,8 +508,30 @@ template <class TYPE1, class TYPE2>
529508
BSLS_KEYWORD_INLINE_VARIABLE
530509
constexpr std::size_t is_nothrow_swappable_with_v =
531510
std::is_nothrow_swappable_with<TYPE1, TYPE2>::value;
532-
#endif
533-
#endif
511+
# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
512+
513+
# if(!defined BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED)
514+
// These names are removed by C++20
515+
# if defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION >= 110000
516+
# pragma GCC diagnostic push
517+
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
518+
# endif
519+
520+
template <class TYPE>
521+
BSLA_DEPRECATED // Warn of using 'bsl::is_literal_type' even though we
522+
// suppress warnings of using 'std::is_pod' in this
523+
// implementation.
524+
BSLS_KEYWORD_INLINE_VARIABLE
525+
constexpr bool is_literal_type_v = std::is_literal_type<TYPE>::value;
526+
527+
# if defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION >= 110000
528+
# pragma GCC diagnostic pop
529+
# endif
530+
# endif // BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED
531+
532+
#endif // BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES
533+
534+
// ----------------------------------------------------------------------------
534535

535536
#if 0
536537
// These traits are provided by BDE, and have additional members for
@@ -642,7 +643,7 @@ using std::void_t;
642643
#endif
643644

644645
// ----------------------------------------------------------------------------
645-
// Copyright 2019 Bloomberg Finance L.P.
646+
// Copyright 2022 Bloomberg Finance L.P.
646647
//
647648
// Licensed under the Apache License, Version 2.0 (the "License");
648649
// you may not use this file except in compliance with the License.

Diff for: groups/bsl/bsls/bsls_libraryfeatures.h

+20-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ BSLS_IDENT("$Id: $")
4343
// BSLS_LIBRARYFEATURES_HAS_CPP17_PMR: <memory_resource>
4444
// BSLS_LIBRARYFEATURES_HAS_CPP17_TIMESPEC_GET: <ctime>
4545
// BSLS_LIBRARYFEATURES_HAS_CPP17_ALIGNED_ALLOC: <cstdlib>
46+
// BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED: more legacy removed
4647
// BSLS_LIBRARYFEATURES_STDCPP_GNU: implementation is GNU libstdc++
4748
// BSLS_LIBRARYFEATURES_STDCPP_IBM: implementation is IBM
4849
// BSLS_LIBRARYFEATURES_STDCPP_INTELLISENSE: Intellisense is running
@@ -376,7 +377,7 @@ BSLS_IDENT("$Id: $")
376377
// deprecated in C++14 and will be removed in C++17.
377378
//
378379
///'BSLS_LIBRARYFEATURES_HAS_CPP14_BASELINE_LIBRARY'
379-
///----------------------------------------------------
380+
///-------------------------------------------------
380381
// The 'BSLS_LIBRARYFEATURES_HAS_CPP14_BASELINE_LIBRARY' macro is used to
381382
// identify whether the current platform's standard library supports a baseline
382383
// set of C++14 library features (which are defined below). This is especially
@@ -445,7 +446,7 @@ BSLS_IDENT("$Id: $")
445446
//: o MSVC 2015
446447
//
447448
///'BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY'
448-
///----------------------------------------------------
449+
///-------------------------------------------------
449450
// This macro is used to identify whether the current platform's standard
450451
// library supports a baseline set of C++17 library features (which are defined
451452
// below). This is especially important in BSL when importing standard library
@@ -659,6 +660,17 @@ BSLS_IDENT("$Id: $")
659660
// '__cplusplus >= 201703L', standard library implementations often provide
660661
// configuration flags to expose the deprecated library features.
661662
//
663+
///'BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED'
664+
///---------------------------------------------------
665+
// The 'BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED' macro is defined for
666+
// libraries that do not export names removed in C++20, such as
667+
// 'std::get_temporary_buffer' and `std::result_of`.
668+
// 'BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED' is generally the
669+
// negation of 'BSLS_LIBRARYFEATURES_HAS_CPP98_AUTO_PTR'. Although the removal
670+
// of deprecated C++20 types is conceptually equivalent to '__cplusplus >=
671+
// 201703L', standard library implementations often provide configuration flags
672+
// to expose the deprecated library features.
673+
//
662674
///'BSLS_LIBRARYFEATURES_HAS_CPP11_PROGRAM_TERMINATION'
663675
///----------------------------------------------------
664676
// The 'BSLS_LIBRARYFEATURES_HAS_CPP11_PROGRAM_TERMINATION' macro is defined if
@@ -1083,6 +1095,12 @@ BSLS_IDENT("$Id: $")
10831095
// keep deprecated functions available.
10841096
#endif
10851097

1098+
#if BSLS_COMPILERFEATURES_CPLUSPLUS >= 202002L
1099+
#define BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED 1
1100+
// Set when C++20 is detected. Adjusted below for implementations that
1101+
// keep deprecated functions available.
1102+
#endif
1103+
10861104
// ============================================================================
10871105
// PLATFORM SPECIFIC FEATURE DETECTION
10881106
// ----------------------------------------------------------------------------

Diff for: groups/bsl/bsls/bsls_platform.h

+5
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ struct Platform {
921921
struct CpuArmv6 : CpuArm {};
922922
struct CpuArmv7 : CpuArm {};
923923
struct CpuArmv8 : CpuArm {};
924+
struct CpuArmv9 : CpuArm {};
924925

925926
// PLATFORM TRAITS
926927

@@ -997,6 +998,10 @@ struct Platform {
997998
#if defined(BSLS_PLATFORM_CPU_ARM_V8)
998999
typedef CpuArmv8 Cpu;
9991000
#endif
1001+
#if defined(BSLS_PLATFORM_CPU_ARM_V9)
1002+
typedef CpuArmv9 Cpu;
1003+
#endif
1004+
10001005
};
10011006

10021007
} // close package namespace

0 commit comments

Comments
 (0)