Skip to content

Commit

Permalink
Cleanup for C++20 testing on a Mac M1
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AlisdairM committed Jul 6, 2022
1 parent a3b45e6 commit 3cf86f4
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 62 deletions.
14 changes: 9 additions & 5 deletions groups/bsl/bsl+bslhdrs/bsl_functional.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ BSLS_IDENT("$Id: $")
namespace bsl {

// Import selected symbols into bsl namespace
using std::binary_negate;
using std::divides;
using std::greater;
using std::greater_equal;
Expand All @@ -40,13 +39,10 @@ namespace bsl {
using std::modulus;
using std::multiplies;
using std::negate;
using std::not1;
using std::not2;
using std::not_equal_to;
using std::plus;
using std::unary_negate;

#if ! defined BSLS_LIBRARYFEATURES_HAS_CPP17_DEPRECATED_REMOVED
#if !defined(BSLS_LIBRARYFEATURES_HAS_CPP17_DEPRECATED_REMOVED)
// These names are removed by C++17
using std::binary_function;
using std::bind1st;
Expand All @@ -69,6 +65,14 @@ namespace bsl {
using std::unary_function;
#endif

#if !defined(BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED)
// These names are removed by C++20
using std::binary_negate;
using std::not1;
using std::not2;
using std::unary_negate;
#endif

#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
namespace placeholders = std::placeholders;

Expand Down
9 changes: 6 additions & 3 deletions groups/bsl/bsl+bslhdrs/bsl_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ namespace bsl {
// using std::allocator;
//..

using std::get_temporary_buffer;
using std::raw_storage_iterator;
using std::return_temporary_buffer;
using std::uninitialized_copy;
using std::uninitialized_fill;
using std::uninitialized_fill_n;
Expand Down Expand Up @@ -82,6 +79,12 @@ namespace bsl {
using std::undeclare_reachable;
#endif // BSLS_LIBRARYFEATURES_HAS_CPP11_GARBAGE_COLLECTION_API

#ifndef BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED
using std::get_temporary_buffer;
using std::raw_storage_iterator;
using std::return_temporary_buffer;
#endif

#ifndef BDE_OMIT_INTERNAL_DEPRECATED
// Import additional names expected by existing code, but not mandated by
// the standard header. This may get tricky if some standard library
Expand Down
105 changes: 53 additions & 52 deletions groups/bsl/bsl+bslhdrs/bsl_type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ using std::is_object;
using std::is_scalar;
using std::is_compound;


// 20.10.4.3, type properties:
using std::is_trivial;
using std::is_standard_layout;
using std::is_pod;
using std::is_literal_type;
using std::is_pod; // deprecated by C++20
using std::is_abstract;
using std::is_signed;
using std::is_unsigned;
Expand Down Expand Up @@ -172,19 +172,22 @@ using std::aligned_union;
#endif
using std::common_type;
using std::underlying_type;

#if !defined(BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED)
// These names are removed by C++20
using std::is_literal_type;
using std::result_of;
#endif

#ifdef BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES
template <std::size_t LEN, std::size_t ALIGN>
using aligned_storage_t =
typename std::aligned_storage<LEN, ALIGN>::type;
using aligned_storage_t = typename std::aligned_storage<LEN, ALIGN>::type;
// 'aligned_storage_t' is an alias to the return type of the
// 'std::aligned_storage' meta-function.

#ifdef BSLS_COMPILERFEATURES_SUPPORT_VARIADIC_TEMPLATES
template <std::size_t LEN, class... TYPES>
using aligned_union_t =
typename std::aligned_union<LEN, TYPES...>::type;
using aligned_union_t = typename std::aligned_union<LEN, TYPES...>::type;
// 'aligned_union_t' is an alias to the return type of the
// 'std::aligned_union' meta-function.

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

template <class TYPE>
using remove_all_extents_t =
typename std::remove_all_extents<TYPE>::type;
using remove_all_extents_t = typename std::remove_all_extents<TYPE>::type;
// 'remove_all_extents_t' is an alias to the return type of the
// 'std::remove_all_extents' meta-function.

template <class TYPE>
using result_of_t = typename std::result_of<TYPE>::type;
// ' result_of_t' is an alias to the return type of the
// 'std::result_of' meta-function.

template <class TYPE>
using underlying_type_t = typename std::underlying_type<TYPE>::type;
// 'underlying_type_t' is an alias to the return type of the
// 'std::underlying_type' meta-function.
#endif

#if !defined(BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED)
// These names are removed by C++20
template <class TYPE>
using result_of_t = typename std::result_of<TYPE>::type;
// ' result_of_t' is an alias to the return type of the
// 'std::result_of' meta-function.
# endif

#ifdef BSLS_LIBRARYFEATURES_HAS_CPP14_BASELINE_LIBRARY
using std::is_null_pointer;
using std::is_final;
Expand Down Expand Up @@ -287,50 +292,24 @@ template <class TYPE>
BSLS_KEYWORD_INLINE_VARIABLE
constexpr bool is_standard_layout_v = std::is_standard_layout<TYPE>::value;

// ----------------------------------------------------------------------------

#if defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION >= 110000 && \
# if defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION >= 110000 && \
BSLS_COMPILERFEATURES_CPLUSPLUS >= 202002L
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
# endif

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

#if defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION >= 110000 && \
# if defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION >= 110000 && \
BSLS_COMPILERFEATURES_CPLUSPLUS >= 202002L
#pragma GCC diagnostic pop
#endif

// ----------------------------------------------------------------------------

#if defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION >= 110000 && \
BSLS_COMPILERFEATURES_CPLUSPLUS >= 201703L
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif

#if BSLS_COMPILERFEATURES_CPLUSPLUS < 202002L
template <class TYPE>
BSLA_DEPRECATED // Warn of using 'bsl::is_literal_type' even though we
// suppress warnings of using 'std::is_pod' in this
// implementation.
BSLS_KEYWORD_INLINE_VARIABLE
constexpr bool is_literal_type_v = std::is_literal_type<TYPE>::value;
#else
// Removed in C++20
#endif // Introduced in C++17 already deprecated; removed in C++20.

#if defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION >= 110000 && \
BSLS_COMPILERFEATURES_CPLUSPLUS >= 201703L
#pragma GCC diagnostic pop
#endif
# pragma GCC diagnostic pop
# endif

// ----------------------------------------------------------------------------

Expand Down Expand Up @@ -470,7 +449,7 @@ template <class TYPE1, class TYPE2>
BSLS_KEYWORD_INLINE_VARIABLE
constexpr bool is_base_of_v = std::is_base_of<TYPE1, TYPE2>::value;

#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
template <class ...Bools>
BSLS_KEYWORD_INLINE_VARIABLE
constexpr bool conjunction_v = std::conjunction<Bools...>::value;
Expand Down Expand Up @@ -529,8 +508,30 @@ template <class TYPE1, class TYPE2>
BSLS_KEYWORD_INLINE_VARIABLE
constexpr std::size_t is_nothrow_swappable_with_v =
std::is_nothrow_swappable_with<TYPE1, TYPE2>::value;
#endif
#endif
# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY

# if(!defined BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED)
// These names are removed by C++20
# if defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION >= 110000
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
# endif

template <class TYPE>
BSLA_DEPRECATED // Warn of using 'bsl::is_literal_type' even though we
// suppress warnings of using 'std::is_pod' in this
// implementation.
BSLS_KEYWORD_INLINE_VARIABLE
constexpr bool is_literal_type_v = std::is_literal_type<TYPE>::value;

# if defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION >= 110000
# pragma GCC diagnostic pop
# endif
# endif // BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED

#endif // BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES

// ----------------------------------------------------------------------------

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

// ----------------------------------------------------------------------------
// Copyright 2019 Bloomberg Finance L.P.
// Copyright 2022 Bloomberg Finance L.P.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
22 changes: 20 additions & 2 deletions groups/bsl/bsls/bsls_libraryfeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ BSLS_IDENT("$Id: $")
// BSLS_LIBRARYFEATURES_HAS_CPP17_PMR: <memory_resource>
// BSLS_LIBRARYFEATURES_HAS_CPP17_TIMESPEC_GET: <ctime>
// BSLS_LIBRARYFEATURES_HAS_CPP17_ALIGNED_ALLOC: <cstdlib>
// BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED: more legacy removed
// BSLS_LIBRARYFEATURES_STDCPP_GNU: implementation is GNU libstdc++
// BSLS_LIBRARYFEATURES_STDCPP_IBM: implementation is IBM
// BSLS_LIBRARYFEATURES_STDCPP_INTELLISENSE: Intellisense is running
Expand Down Expand Up @@ -376,7 +377,7 @@ BSLS_IDENT("$Id: $")
// deprecated in C++14 and will be removed in C++17.
//
///'BSLS_LIBRARYFEATURES_HAS_CPP14_BASELINE_LIBRARY'
///----------------------------------------------------
///-------------------------------------------------
// The 'BSLS_LIBRARYFEATURES_HAS_CPP14_BASELINE_LIBRARY' macro is used to
// identify whether the current platform's standard library supports a baseline
// set of C++14 library features (which are defined below). This is especially
Expand Down Expand Up @@ -445,7 +446,7 @@ BSLS_IDENT("$Id: $")
//: o MSVC 2015
//
///'BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY'
///----------------------------------------------------
///-------------------------------------------------
// This macro is used to identify whether the current platform's standard
// library supports a baseline set of C++17 library features (which are defined
// below). This is especially important in BSL when importing standard library
Expand Down Expand Up @@ -659,6 +660,17 @@ BSLS_IDENT("$Id: $")
// '__cplusplus >= 201703L', standard library implementations often provide
// configuration flags to expose the deprecated library features.
//
///'BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED'
///---------------------------------------------------
// The 'BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED' macro is defined for
// libraries that do not export names removed in C++20, such as
// 'std::get_temporary_buffer' and `std::result_of`.
// 'BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED' is generally the
// negation of 'BSLS_LIBRARYFEATURES_HAS_CPP98_AUTO_PTR'. Although the removal
// of deprecated C++20 types is conceptually equivalent to '__cplusplus >=
// 201703L', standard library implementations often provide configuration flags
// to expose the deprecated library features.
//
///'BSLS_LIBRARYFEATURES_HAS_CPP11_PROGRAM_TERMINATION'
///----------------------------------------------------
// The 'BSLS_LIBRARYFEATURES_HAS_CPP11_PROGRAM_TERMINATION' macro is defined if
Expand Down Expand Up @@ -1083,6 +1095,12 @@ BSLS_IDENT("$Id: $")
// keep deprecated functions available.
#endif

#if BSLS_COMPILERFEATURES_CPLUSPLUS >= 202002L
#define BSLS_LIBRARYFEATURES_HAS_CPP20_DEPRECATED_REMOVED 1
// Set when C++20 is detected. Adjusted below for implementations that
// keep deprecated functions available.
#endif

// ============================================================================
// PLATFORM SPECIFIC FEATURE DETECTION
// ----------------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions groups/bsl/bsls/bsls_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ struct Platform {
struct CpuArmv6 : CpuArm {};
struct CpuArmv7 : CpuArm {};
struct CpuArmv8 : CpuArm {};
struct CpuArmv9 : CpuArm {};

// PLATFORM TRAITS

Expand Down Expand Up @@ -997,6 +998,10 @@ struct Platform {
#if defined(BSLS_PLATFORM_CPU_ARM_V8)
typedef CpuArmv8 Cpu;
#endif
#if defined(BSLS_PLATFORM_CPU_ARM_V9)
typedef CpuArmv9 Cpu;
#endif

};

} // close package namespace
Expand Down

0 comments on commit 3cf86f4

Please sign in to comment.