diff --git a/groups/bdl/bdlb/bdlb_nullablevalue.h b/groups/bdl/bdlb/bdlb_nullablevalue.h index 0c2c373306..b360054a64 100644 --- a/groups/bdl/bdlb/bdlb_nullablevalue.h +++ b/groups/bdl/bdlb/bdlb_nullablevalue.h @@ -675,7 +675,7 @@ bool operator==(const bsl::optional& lhs, } #endif ; -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template bool operator==(const NullableValue& lhs, const std::optional& rhs) @@ -694,7 +694,7 @@ bool operator==(const std::optional& lhs, } #endif ; -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES /// Return `true` if the specified `lhs` and `rhs` nullable objects do not /// have the same value, and `false` otherwise. Two nullable objects do not @@ -729,7 +729,7 @@ bool operator!=(const NullableValue& lhs, } #endif ; -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template bool operator!=(const std::optional& lhs, const NullableValue& rhs) @@ -748,7 +748,7 @@ bool operator!=(const NullableValue& lhs, } #endif ; -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES /// Return `true` if the specified `lhs` and `rhs` objects do not have the /// same value, and `false` otherwise. A nullable object and a value of @@ -830,7 +830,7 @@ bool operator<(const NullableValue& lhs, } #endif ; -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template bool operator<(const std::optional& lhs, const NullableValue& rhs) @@ -849,7 +849,7 @@ bool operator<(const NullableValue& lhs, } #endif ; -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES /// Return `true` if the specified `lhs` nullable object is ordered before /// the specified `rhs`, and `false` otherwise. `lhs` is ordered before @@ -909,7 +909,7 @@ bool operator>(const NullableValue& lhs, } #endif ; -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template bool operator>(const std::optional& lhs, const NullableValue& rhs) @@ -928,7 +928,7 @@ bool operator>(const NullableValue& lhs, } #endif ; -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES /// Return `true` if the specified `lhs` nullable object is ordered after /// the specified `rhs`, and `false` otherwise. `lhs` is ordered after @@ -987,7 +987,7 @@ bool operator<=(const NullableValue& lhs, } #endif ; -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template bool operator<=(const std::optional& lhs, const NullableValue& rhs) @@ -1006,7 +1006,7 @@ bool operator<=(const NullableValue& lhs, } #endif ; -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES /// Return `true` if the specified `lhs` nullable object is ordered before /// the specified `rhs` or `lhs` and `rhs` have the same value, and `false` @@ -1065,7 +1065,7 @@ bool operator>=(const NullableValue& lhs, } #endif ; -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template bool operator>=(const std::optional& lhs, const NullableValue& rhs) @@ -1084,7 +1084,7 @@ bool operator>=(const NullableValue& lhs, } #endif ; -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES /// Return `true` if the specified `lhs` nullable object is ordered after /// the specified `rhs` or `lhs` and `rhs` have the same value, and `false` @@ -1864,7 +1864,7 @@ bool bdlb::operator==(const bsl::optional& lhs, return lhs == static_cast&>(rhs); } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template inline bool bdlb::operator==(const NullableValue& lhs, @@ -1890,7 +1890,7 @@ bool bdlb::operator==(const std::optional& lhs, { return lhs == static_cast&>(rhs); } -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES template inline @@ -1932,7 +1932,7 @@ bool bdlb::operator!=(const NullableValue& lhs, return static_cast&>(lhs) != rhs; } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template inline bool bdlb::operator!=(const std::optional& lhs, @@ -1958,7 +1958,7 @@ bool bdlb::operator!=(const NullableValue& lhs, { return static_cast&>(lhs) != rhs; } -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES template inline @@ -2044,7 +2044,7 @@ bool bdlb::operator<(const NullableValue& lhs, return static_cast&>(lhs) < rhs; } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template inline bool bdlb::operator<(const std::optional& lhs, @@ -2070,7 +2070,7 @@ bool bdlb::operator<(const NullableValue& lhs, { return static_cast&>(lhs) < rhs; } -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES template inline @@ -2134,7 +2134,7 @@ bool bdlb::operator>(const NullableValue& lhs, return static_cast&>(lhs) > rhs; } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template inline bool bdlb::operator>(const std::optional& lhs, @@ -2160,7 +2160,7 @@ bool bdlb::operator>(const NullableValue& lhs, { return static_cast&>(lhs) > rhs; } -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES template inline @@ -2226,7 +2226,7 @@ bool bdlb::operator<=(const NullableValue& lhs, return static_cast&>(lhs) <= rhs; } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template inline bool bdlb::operator<=(const std::optional& lhs, @@ -2252,7 +2252,7 @@ bool bdlb::operator<=(const NullableValue& lhs, { return static_cast&>(lhs) <= rhs; } -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES template inline @@ -2319,7 +2319,7 @@ bool bdlb::operator>=(const NullableValue& lhs, return static_cast&>(lhs) >= rhs; } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template inline bool bdlb::operator>=(const std::optional& lhs, @@ -2345,7 +2345,7 @@ bool bdlb::operator>=(const NullableValue& lhs, { return static_cast&>(lhs) >= rhs; } -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES template inline diff --git a/groups/bdl/bdlb/bdlb_nullablevalue.t.cpp b/groups/bdl/bdlb/bdlb_nullablevalue.t.cpp index 3a17b96aef..3ecd0a2ee3 100644 --- a/groups/bdl/bdlb/bdlb_nullablevalue.t.cpp +++ b/groups/bdl/bdlb/bdlb_nullablevalue.t.cpp @@ -58,11 +58,11 @@ # include #endif -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES # include # include # include -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES using namespace BloombergLP; using namespace bsl; @@ -622,10 +622,10 @@ void testRelationalOperations(const INIT_TYPE& lesserVal, typedef bsl::optional< FIRST_TYPE> FIRST_BO_TYPE; typedef bsl::optional SECOND_BO_TYPE; -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES typedef std::optional< FIRST_TYPE> FIRST_SO_TYPE; typedef std::optional SECOND_SO_TYPE; -#endif +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES testRelationalOperationsNonNull(lesserVal, greaterVal); @@ -648,7 +648,7 @@ void testRelationalOperations(const INIT_TYPE& lesserVal, testRelationalOperationsBothNull(); testRelationalOperationsBothNull(); -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES testRelationalOperationsNonNull(lesserVal, greaterVal); testRelationalOperationsNonNull(lesserVal, @@ -659,10 +659,11 @@ void testRelationalOperations(const INIT_TYPE& lesserVal, testRelationalOperationsBothNull(); testRelationalOperationsBothNull(); -#endif +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES #if defined BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON && \ - defined BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS + defined BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS && \ + defined BSLSTL_OPTIONAL_USES_STD_ALIASES ASSERTV(( bsl::three_way_comparable_with == @@ -6789,7 +6790,8 @@ struct Foo { template void Foo::foo() { -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS +#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS) && \ + defined(BSLSTL_OPTIONAL_USES_STD_ALIASES) // Even more weirdly, the issue goes away if `NullableValue` is // instantiated with `t_TYPE` instead of a fixed type. bdlb::NullableValue nv = 1; @@ -7802,7 +7804,7 @@ int main(int argc, char *argv[]) << "TEST `operator<<` FOR `std::optional` AND `std::variant`" << endl << "========================================================" << endl; -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES bsl::ostringstream oss; @@ -7871,7 +7873,7 @@ int main(int argc, char *argv[]) #else if (verbose) cout << "SKIP: Not Available: " "`std::optional`, `std::variant`" << endl; -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES } break; case 32: { // -------------------------------------------------------------------- diff --git a/groups/bdl/bdlb/bdlb_nullablevalue_cpp03.h b/groups/bdl/bdlb/bdlb_nullablevalue_cpp03.h index a6883a1c93..5484261fec 100644 --- a/groups/bdl/bdlb/bdlb_nullablevalue_cpp03.h +++ b/groups/bdl/bdlb/bdlb_nullablevalue_cpp03.h @@ -21,7 +21,7 @@ // regions of C++11 code, then this header contains no code and is not // '#include'd in the original header. // -// Generated on Wed Sep 4 19:02:35 2024 +// Generated on Tue Jan 21 17:01:55 2025 // Command line: sim_cpp11_features.pl bdlb_nullablevalue.h #ifdef COMPILING_BDLB_NULLABLEVALUE_H @@ -603,7 +603,7 @@ bool operator==(const bsl::optional& lhs, } #endif ; -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template bool operator==(const NullableValue& lhs, const std::optional& rhs) @@ -622,7 +622,7 @@ bool operator==(const std::optional& lhs, } #endif ; -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES /// Return `true` if the specified `lhs` and `rhs` nullable objects do not /// have the same value, and `false` otherwise. Two nullable objects do not @@ -657,7 +657,7 @@ bool operator!=(const NullableValue& lhs, } #endif ; -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template bool operator!=(const std::optional& lhs, const NullableValue& rhs) @@ -676,7 +676,7 @@ bool operator!=(const NullableValue& lhs, } #endif ; -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES /// Return `true` if the specified `lhs` and `rhs` objects do not have the /// same value, and `false` otherwise. A nullable object and a value of @@ -758,7 +758,7 @@ bool operator<(const NullableValue& lhs, } #endif ; -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template bool operator<(const std::optional& lhs, const NullableValue& rhs) @@ -777,7 +777,7 @@ bool operator<(const NullableValue& lhs, } #endif ; -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES /// Return `true` if the specified `lhs` nullable object is ordered before /// the specified `rhs`, and `false` otherwise. `lhs` is ordered before @@ -837,7 +837,7 @@ bool operator>(const NullableValue& lhs, } #endif ; -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template bool operator>(const std::optional& lhs, const NullableValue& rhs) @@ -856,7 +856,7 @@ bool operator>(const NullableValue& lhs, } #endif ; -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES /// Return `true` if the specified `lhs` nullable object is ordered after /// the specified `rhs`, and `false` otherwise. `lhs` is ordered after @@ -915,7 +915,7 @@ bool operator<=(const NullableValue& lhs, } #endif ; -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template bool operator<=(const std::optional& lhs, const NullableValue& rhs) @@ -934,7 +934,7 @@ bool operator<=(const NullableValue& lhs, } #endif ; -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES /// Return `true` if the specified `lhs` nullable object is ordered before /// the specified `rhs` or `lhs` and `rhs` have the same value, and `false` @@ -993,7 +993,7 @@ bool operator>=(const NullableValue& lhs, } #endif ; -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template bool operator>=(const std::optional& lhs, const NullableValue& rhs) @@ -1012,7 +1012,7 @@ bool operator>=(const NullableValue& lhs, } #endif ; -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES /// Return `true` if the specified `lhs` nullable object is ordered after /// the specified `rhs` or `lhs` and `rhs` have the same value, and `false` @@ -1900,7 +1900,7 @@ bool bdlb::operator==(const bsl::optional& lhs, return lhs == static_cast&>(rhs); } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template inline bool bdlb::operator==(const NullableValue& lhs, @@ -1926,7 +1926,7 @@ bool bdlb::operator==(const std::optional& lhs, { return lhs == static_cast&>(rhs); } -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES template inline @@ -1968,7 +1968,7 @@ bool bdlb::operator!=(const NullableValue& lhs, return static_cast&>(lhs) != rhs; } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template inline bool bdlb::operator!=(const std::optional& lhs, @@ -1994,7 +1994,7 @@ bool bdlb::operator!=(const NullableValue& lhs, { return static_cast&>(lhs) != rhs; } -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES template inline @@ -2080,7 +2080,7 @@ bool bdlb::operator<(const NullableValue& lhs, return static_cast&>(lhs) < rhs; } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template inline bool bdlb::operator<(const std::optional& lhs, @@ -2106,7 +2106,7 @@ bool bdlb::operator<(const NullableValue& lhs, { return static_cast&>(lhs) < rhs; } -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES template inline @@ -2170,7 +2170,7 @@ bool bdlb::operator>(const NullableValue& lhs, return static_cast&>(lhs) > rhs; } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template inline bool bdlb::operator>(const std::optional& lhs, @@ -2196,7 +2196,7 @@ bool bdlb::operator>(const NullableValue& lhs, { return static_cast&>(lhs) > rhs; } -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES template inline @@ -2262,7 +2262,7 @@ bool bdlb::operator<=(const NullableValue& lhs, return static_cast&>(lhs) <= rhs; } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template inline bool bdlb::operator<=(const std::optional& lhs, @@ -2288,7 +2288,7 @@ bool bdlb::operator<=(const NullableValue& lhs, { return static_cast&>(lhs) <= rhs; } -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES template inline @@ -2355,7 +2355,7 @@ bool bdlb::operator>=(const NullableValue& lhs, return static_cast&>(lhs) >= rhs; } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template inline bool bdlb::operator>=(const std::optional& lhs, @@ -2381,7 +2381,7 @@ bool bdlb::operator>=(const NullableValue& lhs, { return static_cast&>(lhs) >= rhs; } -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES template inline diff --git a/groups/bdl/bdlb/bdlb_numericparseutil.t.cpp b/groups/bdl/bdlb/bdlb_numericparseutil.t.cpp index f9aadb7f67..678368ffb3 100644 --- a/groups/bdl/bdlb/bdlb_numericparseutil.t.cpp +++ b/groups/bdl/bdlb/bdlb_numericparseutil.t.cpp @@ -3143,7 +3143,7 @@ namespace FromCharsAssumptions { const bool k_OVER = true; const bool k_UNDER = false; -void verifyLwg3081(const std::string_view& toParse, +void verifyLwg3081(const bsl::string_view& toParse, bool isOverflow, bsl::chars_format fmt) { diff --git a/groups/bdl/bdljsn/bdljsn_json.h b/groups/bdl/bdljsn/bdljsn_json.h index fe70844383..66cc789e90 100644 --- a/groups/bdl/bdljsn/bdljsn_json.h +++ b/groups/bdl/bdljsn/bdljsn_json.h @@ -2309,8 +2309,7 @@ class Json_Initializer { /// containing the specified `sv`. Json_Initializer(const bsl::string_view& sv); // IMPLICIT -#if defined(BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY) \ -&& !defined(BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY) +#if defined(BSLSTL_STRING_VIEW_AND_STD_STRING_VIEW_COEXIST) /// Create a `Json_Initializer` object containing a `bsl::string_view` /// containing the specified `sv`. Json_Initializer(const std::string_view& sv); // IMPLICIT @@ -2371,8 +2370,7 @@ class Json_MemberInitializer { Json_MemberInitializer(const bsl::string_view& sv, const Json_Initializer& ji); -#if defined(BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY) \ -&& !defined(BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY) +#if defined(BSLSTL_STRING_VIEW_AND_STD_STRING_VIEW_COEXIST) // Create a `Json_MemberInitializer` object a key whose value is equal to // the specified `sv` and whose value is equal to the specified `ji`. Json_MemberInitializer(const std::string_view& sv, @@ -5064,8 +5062,7 @@ Json_Initializer::Json_Initializer(const bsl::string_view& sv) { } -#if defined(BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY) \ -&& !defined(BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY) +#if defined(BSLSTL_STRING_VIEW_AND_STD_STRING_VIEW_COEXIST) inline Json_Initializer::Json_Initializer(const std::string_view& sv) : d_storage(bsl::string_view(sv.data(), sv.size())) @@ -5149,8 +5146,7 @@ Json_MemberInitializer::Json_MemberInitializer(const bsl::string_view& sv, { } -#if defined(BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY) \ -&& !defined(BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY) +#if defined(BSLSTL_STRING_VIEW_AND_STD_STRING_VIEW_COEXIST) inline Json_MemberInitializer::Json_MemberInitializer(const std::string_view& sv, const Json_Initializer& ji) diff --git a/groups/bsl/bslim/bslim_bslstandardheadertest.t.cpp b/groups/bsl/bslim/bslim_bslstandardheadertest.t.cpp index 4288872e4b..d3c3e7000c 100644 --- a/groups/bsl/bslim/bslim_bslstandardheadertest.t.cpp +++ b/groups/bsl/bslim/bslim_bslstandardheadertest.t.cpp @@ -143,6 +143,7 @@ #include // C++20 header #include #include +#include #include #include #include // C++20 header @@ -242,6 +243,8 @@ using namespace BloombergLP; // defined in `bslstl`. // //----------------------------------------------------------------------------- +// [40] BSLS_LIBRARYFEATURES_FORCE_ABI_CPP* +// [39] HARDWARE_INTERFERENCE // [38] CONCERN: `copy_n` function is usable from `bsl`. // [37] C++20 `bsl_type_traits.h` ADDITIONS // [36] C++20 `std::ranges` interop with `bsl::array` @@ -952,6 +955,87 @@ int main(int argc, char *argv[]) printf("TEST " __FILE__ " CASE %d\n", test); switch (test) { case 0: // Zero is always the leading case. + case 40: { + // -------------------------------------------------------------------- + // TESTING: BSLS_LIBRARYFEATURES_FORCE_ABI_CPP* + // + // Concerns: + // 1 That the when the force ABI flag is set, the expected + // `bsl` types are, and are not, type aliases to the platform + // standard library + // + // Plan: + // + // Testing + // + // -------------------------------------------------------------------- + + if (verbose) printf("\n'BSLS_LIBRARYFEATURES_FORCE_ABI_CPP*'" + "\n=====================================\n"); + + // +--------------------+------------------------------------+ + // | Feature | Minimum Language Version For Alias | + // +====================+====================================+ + // | span | C++20 | + // +--------------------+------------------------------------+ + // | string_view | C++20 [1] | + // +--------------------+------------------------------------+ + // | array | C++17 [1] | + // +--------------------+------------------------------------+ + // | optional | C++17 | + // +--------------------+------------------------------------+ + // | uncaught_exception | C++17 | + // +--------------------+------------------------------------+ + // + // See `bsls_libraryfeatures` documentation for more details. + + bool spanIsAlias = false; + bool stringViewIsAlias = false; + bool arrayIsAlias = false; + bool optionalInherits = false; + bool uncaughtExceptionIsAlias = false; + +#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY) + spanIsAlias = bsl::is_same, std::span >::value; +#endif +#if defined(BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY) + stringViewIsAlias = + bsl::is_same::value; + arrayIsAlias = + bsl::is_same, std::array >::value; + optionalInherits = + bsl::is_base_of, bsl::optional >::value; + uncaughtExceptionIsAlias = (&bsl::uncaught_exceptions == + &std::uncaught_exceptions); +#endif + if (veryVerbose) { + P(spanIsAlias); + P(stringViewIsAlias); + P(arrayIsAlias); + P(optionalInherits); + P(uncaughtExceptionIsAlias); + } + +#if defined(BSLS_LIBRARYFEATURES_FORCE_ABI_CPP11) + ASSERT(!spanIsAlias); + ASSERT(!stringViewIsAlias); + ASSERT(!arrayIsAlias); + ASSERT(!optionalInherits); + ASSERT(!uncaughtExceptionIsAlias); +#elif defined(BSLS_LIBRARYFEATURES_FORCE_ABI_CPP17) + ASSERT(!spanIsAlias); + ASSERT(!stringViewIsAlias); + ASSERT(arrayIsAlias); + ASSERT(optionalInherits); + ASSERT(uncaughtExceptionIsAlias); +#elif defined(BSLS_LIBRARYFEATURES_FORCE_ABI_CPP20) + ASSERT(spanIsAlias); + ASSERT(stringViewIsAlias); + ASSERT(arrayIsAlias); + ASSERT(optionalInherits); + ASSERT(uncaughtExceptionIsAlias); +#endif + } break; case 39: { // -------------------------------------------------------------------- // HARDWARE_INTERFERENCE @@ -1259,7 +1343,7 @@ int main(int argc, char *argv[]) const bool res_v = bsl::is_pointer_interconvertible_base_of_v < Bar, Baz>; -#if defined(BSLS_PLATFORM_CMP_MSVC) && BSLS_PLATFORM_CMP_VERSION <= 1937 +#if defined(BSLS_PLATFORM_CMP_MSVC) && BSLS_PLATFORM_CMP_VERSION <= 1942 // Known Windows bug. Hopefully fixed in future release. const bool expected = false; @@ -3756,7 +3840,7 @@ int main(int argc, char *argv[]) ASSERT(bsl::dynamic_extent == size_t(-1)); -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY +#ifdef BSLSTL_SPAN_IS_ALIASED ASSERT((bsl::is_same_v, bsl::span >)); ASSERT((bsl::is_same_v, bsl::span >)); ASSERT((bsl::is_same_v; -#if defined(BSLS_PLATFORM_CMP_MSVC) && BSLS_PLATFORM_CMP_VERSION <= 1937 +#if defined(BSLS_PLATFORM_CMP_MSVC) && BSLS_PLATFORM_CMP_VERSION <= 1942 // Known Windows bug. Hopefully fixed in future release. const bool expected = false; diff --git a/groups/bsl/bslstl/bslstl_array.h b/groups/bsl/bslstl/bslstl_array.h index 8727ea80c8..263c8e21c2 100644 --- a/groups/bsl/bslstl/bslstl_array.h +++ b/groups/bsl/bslstl/bslstl_array.h @@ -200,8 +200,9 @@ BSLS_IDENT("$Id: $") #include #endif // BDE_DONT_ALLOW_TRANSITIVE_INCLUDES -#ifndef BDE_DISABLE_CPP17_ABI -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#if defined (BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY) && \ + !(defined(BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED) && \ + (BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED < 17)) #include // 'std::array' #include // 'std::get' @@ -212,9 +213,7 @@ using std::get; } // close namespace bsl #define BSLSTL_ARRAY_IS_ALIASED -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY -#endif // BDE_DISABLE_CPP17_ABI - +#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY && not disabled #ifndef BSLSTL_ARRAY_IS_ALIASED diff --git a/groups/bsl/bslstl/bslstl_badoptionalaccess.h b/groups/bsl/bslstl/bslstl_badoptionalaccess.h index 4b3d2dc6f6..6698402ef5 100644 --- a/groups/bsl/bslstl/bslstl_badoptionalaccess.h +++ b/groups/bsl/bslstl/bslstl_badoptionalaccess.h @@ -31,12 +31,18 @@ BSLS_IDENT("$Id: $") #ifdef BDE_BUILD_TARGET_EXC -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY -#include // for 'std::bad_optional_access' -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#if defined(BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY) && \ + !(defined(BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED) && \ + (BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED < 17)) + #define BSLSTL_BAD_OPTIONAL_ACCESS_IS_ALIASED 1 +#endif // Has C++17 and not disabled + +#ifdef BSLSTL_BAD_OPTIONAL_ACCESS_IS_ALIASED + #include // for 'std::bad_optional_access' +#endif // BSLSTL_BAD_OPTIONAL_ACCESS_IS_ALIASED namespace bsl { -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_BAD_OPTIONAL_ACCESS_IS_ALIASED typedef std::bad_optional_access bad_optional_access; #else // ========================= @@ -84,11 +90,12 @@ const char *bad_optional_access::what() const BSLS_EXCEPTION_VIRTUAL_NOTHROW { return "bad_optional_access"; } -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // else - BSLSTL_BAD_OPTIONAL_ACCESS_IS_ALIASED } // close namespace bsl #endif // BDE_BUILD_TARGET_EXC + #endif // ---------------------------------------------------------------------------- diff --git a/groups/bsl/bslstl/bslstl_badoptionalaccess.t.cpp b/groups/bsl/bslstl/bslstl_badoptionalaccess.t.cpp index 24e2f69589..b6fc925e75 100644 --- a/groups/bsl/bslstl/bslstl_badoptionalaccess.t.cpp +++ b/groups/bsl/bslstl/bslstl_badoptionalaccess.t.cpp @@ -94,26 +94,14 @@ void aSsErT(bool condition, const char *message, int line) #define ASSERT_OPT_PASS(EXPR) BSLS_ASSERTTEST_ASSERT_OPT_PASS(EXPR) #define ASSERT_OPT_FAIL(EXPR) BSLS_ASSERTTEST_ASSERT_OPT_FAIL(EXPR) -//============================================================================= -// GLOBAL FUNCTIONS FOR TESTING -//----------------------------------------------------------------------------- - -//============================================================================= -// USAGE EXAMPLE -//----------------------------------------------------------------------------- - //============================================================================= // MAIN PROGRAM //----------------------------------------------------------------------------- int main(int argc, char *argv[]) { - int test = argc > 1 ? atoi(argv[1]) : 0; bool verbose = argc > 2; -// bool veryVerbose = argc > 3; -// bool veryVeryVerbose = argc > 4; -// bool veryVeryVeryVerbose = argc > 5; printf("TEST " __FILE__ " CASE %d\n", test); @@ -139,11 +127,11 @@ int main(int argc, char *argv[]) if (verbose) printf("\n'bsl::bad_optional_access' TYPEDEF" "\n==================================\n"); -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_BAD_OPTIONAL_ACCESS_IS_ALIASED ASSERT((bsl::is_same::value)); -#endif //BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_BAD_OPTIONAL_ACCESS_IS_ALIASED } break; case 3: { // -------------------------------------------------------------------- @@ -170,12 +158,13 @@ int main(int argc, char *argv[]) // -------------------------------------------------------------------- if (verbose) printf("\nDEFAULT CONSTRUCTION AND `what` METHOD" "\n======================================\n"); -#ifndef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY + +#ifndef BSLSTL_BAD_OPTIONAL_ACCESS_IS_ALIASED // string returned by `what()` method is implementation specific so we // can only check our own implementation const bsl::bad_optional_access b; ASSERT(0 == strcmp("bad_optional_access", b.what())); -#endif // #ifndef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // #ifndef BSLSTL_BAD_OPTIONAL_ACCESS_IS_ALIASED } break; case 2: { @@ -211,7 +200,7 @@ int main(int argc, char *argv[]) // }; // } // namespace std // ``` -#ifndef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifndef BSLSTL_BAD_OPTIONAL_ACCESS_IS_ALIASED // While noexcept specification is a standard requirement, at least one // library implementation does not apply the noexcept specification // correctly. @@ -221,7 +210,7 @@ int main(int argc, char *argv[]) bsl::bad_optional_access b; ASSERT(BSLS_KEYWORD_NOEXCEPT_AVAILABLE == BSLS_KEYWORD_NOEXCEPT_OPERATOR(b.what())); -#endif +#endif // #ifndef BSLSTL_BAD_OPTIONAL_ACCESS_IS_ALIASED } break; case 1: { // -------------------------------------------------------------------- @@ -241,16 +230,18 @@ int main(int argc, char *argv[]) if (verbose) printf("\nBREATHING TEST" "\n==============\n"); + bsl::bad_optional_access b; + const std::exception *ptr = &b; ASSERT(0 != b.what()); ASSERT(0 != ptr->what()); } break; -#endif //BDE_BUILD_TARGET_EXC +#endif // BDE_BUILD_TARGET_EXC default: { - fprintf(stderr, "WARNING: CASE `%d' NOT FOUND.\n", test); - testStatus = -1; + fprintf(stderr, "WARNING: CASE `%d' NOT FOUND.\n", test); + testStatus = -1; } } diff --git a/groups/bsl/bslstl/bslstl_badvariantaccess.h b/groups/bsl/bslstl/bslstl_badvariantaccess.h index 763f22b112..8f4f89c362 100644 --- a/groups/bsl/bslstl/bslstl_badvariantaccess.h +++ b/groups/bsl/bslstl/bslstl_badvariantaccess.h @@ -28,12 +28,19 @@ BSLS_IDENT("$Id: $") #ifdef BDE_BUILD_TARGET_EXC -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY -#include // for 'std::bad_variant_access' -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#if defined(BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY) && \ + !(defined(BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED) && \ + (BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED < 17)) + #define BSLSTL_BAD_VARIANT_ACCESS_IS_ALIASED 1 +#endif // Has C++17 and not disabled + + +#ifdef BSLSTL_BAD_VARIANT_ACCESS_IS_ALIASED + #include // for 'std::bad_variant_access' +#endif // BSLSTL_BAD_VARIANT_ACCESS_IS_ALIASED namespace bsl { -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_BAD_VARIANT_ACCESS_IS_ALIASED using std::bad_variant_access; #else // ======================== @@ -81,7 +88,7 @@ const char *bad_variant_access::what() const BSLS_EXCEPTION_VIRTUAL_NOTHROW { return "bad_variant_access"; } -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_BAD_VARIANT_ACCESS_IS_ALIASED } // close namespace bsl diff --git a/groups/bsl/bslstl/bslstl_badvariantaccess.t.cpp b/groups/bsl/bslstl/bslstl_badvariantaccess.t.cpp index 2c08c811d4..908d7f1441 100644 --- a/groups/bsl/bslstl/bslstl_badvariantaccess.t.cpp +++ b/groups/bsl/bslstl/bslstl_badvariantaccess.t.cpp @@ -95,14 +95,6 @@ void aSsErT(bool condition, const char *message, int line) #define ASSERT_OPT_PASS(EXPR) BSLS_ASSERTTEST_ASSERT_OPT_PASS(EXPR) #define ASSERT_OPT_FAIL(EXPR) BSLS_ASSERTTEST_ASSERT_OPT_FAIL(EXPR) -//============================================================================= -// GLOBAL FUNCTIONS FOR TESTING -//----------------------------------------------------------------------------- - -//============================================================================= -// USAGE EXAMPLE -//----------------------------------------------------------------------------- - //============================================================================= // MAIN PROGRAM //----------------------------------------------------------------------------- @@ -111,9 +103,6 @@ int main(int argc, char *argv[]) { int test = argc > 1 ? atoi(argv[1]) : 0; bool verbose = argc > 2; - // bool veryVerbose = argc > 3; - // bool veryVeryVerbose = argc > 4; - // bool veryVeryVeryVerbose = argc > 5; printf("TEST " __FILE__ " CASE %d\n", test); @@ -141,11 +130,11 @@ int main(int argc, char *argv[]) printf("\n'bsl::bad_variant_access' TYPEDEF" "\n=================================\n"); -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_BAD_VARIANT_ACCESS_IS_ALIASED BSLMF_ASSERT((bsl::is_same::value)); -#endif //BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_BAD_VARIANT_ACCESS_IS_ALIASED } break; case 3: { // -------------------------------------------------------------------- @@ -170,12 +159,13 @@ int main(int argc, char *argv[]) if (verbose) printf("\nDEFAULT CONSTRUCTION AND `what` METHOD" "\n======================================\n"); -#ifndef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY + +#ifndef BSLSTL_BAD_VARIANT_ACCESS_IS_ALIASED // string returned by `what()` method is implementation specific so we // can only check our own implementation const bsl::bad_variant_access b; ASSERT(0 == strcmp("bad_variant_access", b.what())); -#endif // #ifndef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // #ifndef BSLSTL_BAD_VARIANT_ACCESS_IS_ALIASED } break; case 2: { @@ -213,7 +203,7 @@ int main(int argc, char *argv[]) // }; // } // namespace std // ``` -#ifndef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifndef BSLSTL_BAD_VARIANT_ACCESS_IS_ALIASED // While noexcept specification is a standard requirement, at least one // library implementation does not apply the noexcept specification // correctly. @@ -223,7 +213,7 @@ int main(int argc, char *argv[]) bsl::bad_variant_access b; ASSERT(BSLS_KEYWORD_NOEXCEPT_AVAILABLE == BSLS_KEYWORD_NOEXCEPT_OPERATOR(b.what())); -#endif +#endif // #ifndef BSLSTL_BAD_VARIANT_ACCESS_IS_ALIASED } break; case 1: { // -------------------------------------------------------------------- @@ -250,7 +240,7 @@ int main(int argc, char *argv[]) ASSERT(0 != b.what()); ASSERT(0 != ptr->what()); } break; -#endif //BDE_BUILD_TARGET_EXC +#endif // BDE_BUILD_TARGET_EXC default: { fprintf(stderr, "WARNING: CASE `%d' NOT FOUND.\n", test); testStatus = -1; diff --git a/groups/bsl/bslstl/bslstl_exception.cpp b/groups/bsl/bslstl/bslstl_exception.cpp index 9faacb9ee4..281670204a 100644 --- a/groups/bsl/bslstl/bslstl_exception.cpp +++ b/groups/bsl/bslstl/bslstl_exception.cpp @@ -7,7 +7,7 @@ BSLS_IDENT("$Id$ $CSID$") #include #include -#ifndef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifndef BSLSTL_EXCEPTION_UNCAUGHT_EXCEPTIONS_IS_ALIAS // Clang, libstdc++, and MSVC have the implementation of 'uncaught_exceptions' // in their dylib. We can just call it. Otherwise, we simulate it from the @@ -42,7 +42,7 @@ int uncaught_exceptions() throw() } } // close namespace bsl -#endif // UNCAUGHT_EXCEPTIONS_EMULATED +#endif // BSLSTL_EXCEPTION_UNCAUGHT_EXCEPTIONS_IS_ALIAS #endif diff --git a/groups/bsl/bslstl/bslstl_exception.h b/groups/bsl/bslstl/bslstl_exception.h index fd17036d7c..ecb511e980 100644 --- a/groups/bsl/bslstl/bslstl_exception.h +++ b/groups/bsl/bslstl/bslstl_exception.h @@ -54,16 +54,22 @@ BSLS_IDENT("$Id: $") #include namespace bsl { -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#if defined (BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY) && \ + !(defined(BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED) && \ + (BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED < 17)) + + #define BSLSTL_EXCEPTION_UNCAUGHT_EXCEPTIONS_IS_ALIAS using std::uncaught_exceptions; -#else +#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY && not disabled + +#ifndef BSLSTL_EXCEPTION_UNCAUGHT_EXCEPTIONS_IS_ALIAS /// Return the number of exceptions that have been thrown or rethrown in /// the current thread that have not been caught. If the C++17 baseline /// library is not available, this function may return 1 even if more /// than 1 uncaught exception exists, but if guaranteed to return 0 if /// there are no uncaught exceptions. int uncaught_exceptions() throw(); -#endif +#endif // ndef BSLSTL_EXCEPTION_UNCAUGHT_EXCEPTIONS_IS_ALIAS } // close namespace bsl #endif diff --git a/groups/bsl/bslstl/bslstl_iomanip.h b/groups/bsl/bslstl/bslstl_iomanip.h index fe6d6ed5cd..eaab23f041 100644 --- a/groups/bsl/bslstl/bslstl_iomanip.h +++ b/groups/bsl/bslstl/bslstl_iomanip.h @@ -340,7 +340,7 @@ quoted(bsl::basic_string& value, t_CHAR_TYPE escape = t_CHAR_TYPE('\\')); -#ifndef BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY +#ifndef BSLSTL_STRING_VIEW_IS_ALIASED template BloombergLP::bslstl::IoManip_QuotedStringViewFormatter @@ -352,7 +352,7 @@ quoted(const bsl::basic_string_view& value, // Return an object, containing quoted version of the specified 'value' // obtained using the optionally specified 'delim' and 'escape' characters, // and that can be inserted to output stream. -#endif // BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY +#endif // not BSLSTL_STRING_VIEW_IS_ALIASED #endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY } // close namespace bsl @@ -529,7 +529,7 @@ bsl::quoted(bsl::basic_string& value, escape); } -#ifndef BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY +#ifndef BSLSTL_STRING_VIEW_IS_ALIASED template BloombergLP::bslstl::IoManip_QuotedStringViewFormatter @@ -546,7 +546,7 @@ bsl::quoted(const bsl::basic_string_view& value, delim, escape); } -#endif // BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY +#endif // not BSLSTL_STRING_VIEW_IS_ALIASED #endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY #endif diff --git a/groups/bsl/bslstl/bslstl_optional.h b/groups/bsl/bslstl/bslstl_optional.h index ff3c7c78e8..07ccf46c6a 100644 --- a/groups/bsl/bslstl/bslstl_optional.h +++ b/groups/bsl/bslstl/bslstl_optional.h @@ -163,6 +163,25 @@ BSLS_IDENT("$Id: $") // Section: BSLSTL_OPTIONAL_* Macros // ============================================================================ +#if defined (BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY) && \ + !(defined(BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED) && \ + (BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED < 17)) + +/// The following macro `BSLSTL_OPTIONAL_USES_STD_ALIASES` controls whether +/// platform standard library is used as a basis for `bsl` types in the +/// following ways: +/// - `bsl::nullopt` is an alias to `std::nullopt` +/// +/// - `bsl::optional` inherits from `std::optional`, i.e., +/// `std::optional` is used for types that are *not* allocator-aware. +/// +/// This macro does *not* control whether there are conversions and comparisons +/// between `std::optional` and `bsl::optional`, that is conditioned only on +/// whether `std::optional` is available (i.e., +/// `BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY` is defined). + #define BSLSTL_OPTIONAL_USES_STD_ALIASES +#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY & not disabled + # ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY // This macro is defined as 'std::is_constructible::value' in C++11 and @@ -226,7 +245,7 @@ BSLS_IDENT("$Id: $") TYPE, \ bsl::optional::type>) -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES #define BSLSTL_OPTIONAL_CONVERTS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) \ BSLSTL_OPTIONAL_CONVERTS_FROM( \ TYPE, \ @@ -236,13 +255,13 @@ BSLS_IDENT("$Id: $") BSLSTL_OPTIONAL_ASSIGNS_FROM( \ TYPE, \ std::optional::type>) -# else // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# else // BSLSTL_OPTIONAL_USES_STD_ALIASES // The value of these macros is chosen to not affect the constraints these // macros appears in. #define BSLSTL_OPTIONAL_CONVERTS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) false #define BSLSTL_OPTIONAL_ASSIGNS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) false -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY else +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES else // Macros to define common constraints that enable a constructor or assignment // operator. @@ -415,12 +434,12 @@ struct Optional_NulloptConstructToken { namespace bsl { -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES using nullopt_t = std::nullopt_t; using std::nullopt; -# else // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# else // BSLSTL_OPTIONAL_USES_STD_ALIASES // ================ // struct nullopt_t @@ -454,7 +473,7 @@ nullopt_t nullopt(BloombergLP::bslstl::Optional_NulloptConstructToken{}); extern const nullopt_t nullopt; # endif -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES template class optional; @@ -867,7 +886,7 @@ class Optional_Base { BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCT_PROPAGATES_ALLOCATOR(t_TYPE, t_ANY_TYPE)); -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES /// Create a disengaged `Optional_Base` object if the specified /// `original` object is disengaged, and an `Optional_Base` object with /// the value of `original.value()` converted to `t_TYPE` otherwise. @@ -883,7 +902,7 @@ class Optional_Base { template Optional_Base(BloombergLP::bslstl::Optional_MoveConstructFromStdOptional, std::optional&& original); -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES #if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES /// Create an `Optional_Base` object having the value of the (template @@ -964,7 +983,7 @@ class Optional_Base { BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional, BSLMF_MOVABLEREF_DEDUCE(Optional_Base) original); -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES /// If the specified `original` contains a value, create an /// `Optional_Base` object whose contained value is initialized from /// `*original`, converted to `t_TYPE`. Otherwise, create a disengaged @@ -987,7 +1006,7 @@ class Optional_Base { allocator_type allocator, BloombergLP::bslstl::Optional_MoveConstructFromStdOptional, std::optional&& original); -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES #if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES /// Create an `Optional_Base` object whose contained value is @@ -1271,7 +1290,7 @@ class Optional_Base { // class Optional_Base // ================================== -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES /// Specialization of `Optional_Base` for `value_type` that is not /// allocator-aware when `std::optional` is available. template @@ -1431,7 +1450,7 @@ class Optional_Base : public std::optional { BloombergLP::bslmf::IsBitwiseCopyable, BloombergLP::bslmf::IsBitwiseCopyable::value); }; -# else // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# else // BSLSTL_OPTIONAL_USES_STD_ALIASES // ============================================================================ // Section: Definition of Pre-C++17 Allocator-Unaware 'Optional_Base' @@ -1790,7 +1809,7 @@ class Optional_Base { } #endif // BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT else }; -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY else +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES else } // close package namespace } // close enterprise namespace @@ -1934,7 +1953,7 @@ class optional : public BloombergLP::bslstl::Optional_Base { t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)); -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template optional( const std::optional& original, @@ -1983,7 +2002,7 @@ class optional : public BloombergLP::bslstl::Optional_Base { BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_STD_OPTIONAL(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)); -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES #if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES /// Create an `optional` object having the value of the (template @@ -2116,7 +2135,7 @@ class optional : public BloombergLP::bslstl::Optional_Base { t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)); -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES /// Create a disengaged `optional` object if the specified `original` /// object is disengaged, and an `optional` object with the value of /// `original.value()` converted to `t_TYPE` otherwise. Use the @@ -2171,7 +2190,7 @@ class optional : public BloombergLP::bslstl::Optional_Base { BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_STD_OPTIONAL(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)); -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES #if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES /// Create an `optional` object having the value of the (template @@ -2284,7 +2303,7 @@ class optional : public BloombergLP::bslstl::Optional_Base { operator=(BloombergLP::bslmf::MovableRef rhs); #endif // RVALUES else -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES /// Disengage this object if the specified `rhs` object is disengaged, /// and assign to this object the value of `rhs.value()` (of /// `t_ANY_TYPE`) converted to `t_TYPE` otherwise. Return a reference @@ -2304,7 +2323,7 @@ class optional : public BloombergLP::bslstl::Optional_Base { template BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_STD_OPTIONAL(t_TYPE, t_ANY_TYPE)& operator=(std::optional&& rhs); -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES }; } // close namespace bsl @@ -2726,7 +2745,7 @@ constexpr compare_three_way_result_t operator<=>( const std::optional& rhs); #endif -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES /// Efficiently exchange the values of the specified `lhs` and `rhs` /// objects. This method provides the no-throw exception-safety guarantee /// if the template parameter `t_TYPE` provides that guarantee and the @@ -2816,7 +2835,7 @@ bool operator>=(const bsl::optional& lhs, template bool operator>=(const std::optional& lhs, const bsl::optional& rhs); -#endif +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES /// Return an `optional` object containing a `t_TYPE` object created by /// invoking a `bsl::optional` allocator-extended `in_place_t` constructor @@ -3157,7 +3176,7 @@ Optional_Base::Optional_Base( } } -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template template inline @@ -3181,7 +3200,7 @@ Optional_Base::Optional_Base( emplace(std::move(original.value())); } } -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES #if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES template @@ -3299,7 +3318,7 @@ Optional_Base::Optional_Base( } } -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template template inline @@ -3329,7 +3348,7 @@ Optional_Base::Optional_Base( emplace(std::move(original.value())); } } -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES #if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES template @@ -3789,7 +3808,7 @@ Optional_Base::operator bool() const // class Optional_Base // ================================== -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES // PROTECTED CREATORS template inline @@ -4006,7 +4025,7 @@ const t_TYPE& Optional_Base::dereferenceRaw() const } # endif // BDE_OMIT_INTERNAL_DEPRECATED -# else // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# else // BSLSTL_OPTIONAL_USES_STD_ALIASES // ============================================================================ // Section: Pre-C++17 Allocator-Unaware 'Optional_Base' Method Definitions @@ -4557,7 +4576,7 @@ Optional_Base::operator bool() const BSLS_KEYWORD_NOEXCEPT return has_value(); } #endif // BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // else BSLSTL_OPTIONAL_USES_STD_ALIASES } // close package namespace } // close enterprise namespace @@ -4671,7 +4690,7 @@ optional::optional( { } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template template optional::optional( @@ -4717,7 +4736,7 @@ optional::optional( std::move(original)) { } -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES #if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES template @@ -4874,7 +4893,7 @@ optional::optional( { } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template template optional::optional( @@ -4937,7 +4956,7 @@ optional::optional( std::move(original)) { } -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES #if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES template @@ -5064,7 +5083,7 @@ optional::operator=(BloombergLP::bslmf::MovableRef rhs) } #endif // RVALUES else -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template template BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_STD_OPTIONAL(t_TYPE, const t_ANY_TYPE&)& @@ -5090,7 +5109,7 @@ optional::operator=(std::optional&& rhs) } return *this; } -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES // ============================================================================ // Section: Free Function Definitions @@ -5523,7 +5542,7 @@ constexpr compare_three_way_result_t operator<=>( #endif // BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON && // BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template inline typename bsl::enable_if::value, @@ -5683,7 +5702,7 @@ bool operator>=(const std::optional& lhs, } return lhs.has_value() && *lhs >= *rhs; } -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES template BSLS_KEYWORD_CONSTEXPR bsl::optional::type> diff --git a/groups/bsl/bslstl/bslstl_optional.t.cpp b/groups/bsl/bslstl/bslstl_optional.t.cpp index 3d1ab7fbde..e2094c7530 100644 --- a/groups/bsl/bslstl/bslstl_optional.t.cpp +++ b/groups/bsl/bslstl/bslstl_optional.t.cpp @@ -8475,7 +8475,7 @@ void TestDriver::testCase15() P( bslmf::IsBitwiseMoveable::value); T_ P_(bslmf::IsBitwiseCopyable::value); P( bslmf::IsBitwiseCopyable::value); -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES T_ P_(bslmf::IsBitwiseMoveable_v>); P( bslmf::IsBitwiseCopyable_v>); T_ P( std::is_trivially_copyable_v>); @@ -8495,7 +8495,7 @@ void TestDriver::testCase15() >::value); BSLMF_ASSERT(!bslma::UsesBslmaAllocator >::value); -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES BSLMF_ASSERT(!bslmf::IsBitwiseCopyable_v< std::optional>>); #endif @@ -8515,7 +8515,7 @@ void TestDriver::testCase15() (void) bslmf::IsTriviallyCopyableCheck::value; } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES if (bslmf::IsBitwiseCopyable_v == bslmf::IsBitwiseCopyable_v>) { ASSERTV(valueTypeName, usesAllocatorObj, @@ -9866,12 +9866,12 @@ void TestDriver::testCase10b() testCase10b_imp >(); testCase10b_imp >(); -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES testCase10b_imp >(); testCase10b_imp >(); testCase10b_imp >(); testCase10b_imp >(); -#endif //BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif //BSLSTL_OPTIONAL_USES_STD_ALIASES } /// Perform the 10b test between optionals of UDTs @@ -9883,12 +9883,12 @@ void testCase10b_udts_imp() TestDriver::template testCase10b_imp >(); -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES TestDriver::template testCase10b_imp >(); TestDriver::template testCase10b_imp >(); -#endif //BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif //BSLSTL_OPTIONAL_USES_STD_ALIASES } /// Perform the 10b test between optionals of UDTs. Note that, unlike the @@ -10100,7 +10100,7 @@ void testCase9() testCase9_imp, bsl::optional >(); -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES // swap between bsl::optional and std::optional works only for non-AA // types @@ -10235,7 +10235,7 @@ void TestDriver::testCase7b_imp() TEST_EXT_COPY_FROM_ENGAGED_OPT(MoveUtil::move(csource)); #endif // BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES { typedef std::optional SRC_OPT_TYPE; typedef bslalg::ConstructorProxy SourceWithAllocator; @@ -10257,7 +10257,7 @@ void TestDriver::testCase7b_imp() // should trigger a copy constructor TEST_EXT_COPY_FROM_ENGAGED_OPT(MoveUtil::move(csource)); } -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES } } @@ -10375,7 +10375,7 @@ void TestDriver::testCase7a_imp() TEST_COPY_FROM_ENGAGED_OPT(MoveUtil::move(csource)); #endif // BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES { typedef std::optional SRC_OPT_TYPE; typedef bslalg::ConstructorProxy SourceWithAllocator; @@ -10398,7 +10398,7 @@ void TestDriver::testCase7a_imp() // should trigger a copy constructor TEST_COPY_FROM_ENGAGED_OPT(MoveUtil::move(csource)); } -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES } } template @@ -10420,7 +10420,7 @@ void TestDriver::testCase7a_imp_constmovebug() source.emplace(3); TEST_MOVE_FROM_ENGAGED_OPT(source, PROPAGATE_ON_MOVE); } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES { typedef std::optional SRC_OPT_TYPE; typedef bslalg::ConstructorProxy SourceWithAllocator; @@ -10430,11 +10430,11 @@ void TestDriver::testCase7a_imp_constmovebug() source.emplace(3); TEST_MOVE_FROM_ENGAGED_OPT(source, false); } -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES } } -#if BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES #if (BSLS_LIBRARYFEATURES_STDCPP_GNU && \ (!defined(_GLIBCXX_RELEASE) || \ @@ -10447,7 +10447,7 @@ void TestDriver::testCase7a_imp_constmovebug() #define STD_OPTIONAL_CONST_MOVE_BUG 1 #endif -#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES template void TestDriver::testCase7a() @@ -10861,7 +10861,7 @@ void testCase6() testCase6_imp_a, bsl::optional >(); -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES testCase6_imp_a, bsl::optional >(); testCase6_imp_a, std::optional >(); @@ -10877,7 +10877,7 @@ void testCase6() testCase6_imp_a, bsl::optional >(); testCase6_imp_a, std::optional >(); -#endif //BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#endif //BSLSTL_OPTIONAL_USES_STD_ALIASES } if (veryVerbose) printf("\tComparison with a non `optional` .\n"); @@ -13618,7 +13618,7 @@ int main(int argc, char **argv) if (verbose) printf("TEST bsl::optional>\n" "===========================================\n"); -#if defined(BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY) && \ +#if defined(BSLSTL_OPTIONAL_USES_STD_ALIASES) && \ !defined(BSLS_PLATFORM_CMP_CLANG) typedef bsl::optional> Obj; diff --git a/groups/bsl/bslstl/bslstl_optional_cpp03.h b/groups/bsl/bslstl/bslstl_optional_cpp03.h index 5d5844d90e..3e835df20c 100644 --- a/groups/bsl/bslstl/bslstl_optional_cpp03.h +++ b/groups/bsl/bslstl/bslstl_optional_cpp03.h @@ -21,7 +21,7 @@ // regions of C++11 code, then this header contains no code and is not // '#include'd in the original header. // -// Generated on Tue Jan 7 15:20:53 2025 +// Generated on Tue Jan 21 17:01:29 2025 // Command line: sim_cpp11_features.pl bslstl_optional.h #ifdef COMPILING_BSLSTL_OPTIONAL_H @@ -30,6 +30,25 @@ // Section: BSLSTL_OPTIONAL_* Macros // ============================================================================ +#if defined (BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY) && \ + !(defined(BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED) && \ + (BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED < 17)) + +/// The following macro `BSLSTL_OPTIONAL_USES_STD_ALIASES` controls whether +/// platform standard library is used as a basis for `bsl` types in the +/// following ways: +/// - `bsl::nullopt` is an alias to `std::nullopt` +/// +/// - `bsl::optional` inherits from `std::optional`, i.e., +/// `std::optional` is used for types that are *not* allocator-aware. +/// +/// This macro does *not* control whether there are conversions and comparisons +/// between `std::optional` and `bsl::optional`, that is conditioned only on +/// whether `std::optional` is available (i.e., +/// `BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY` is defined). + #define BSLSTL_OPTIONAL_USES_STD_ALIASES +#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY & not disabled + # ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY // This macro is defined as 'std::is_constructible::value' in C++11 and @@ -93,7 +112,7 @@ TYPE, \ bsl::optional::type>) -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES #define BSLSTL_OPTIONAL_CONVERTS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) \ BSLSTL_OPTIONAL_CONVERTS_FROM( \ TYPE, \ @@ -103,13 +122,13 @@ BSLSTL_OPTIONAL_ASSIGNS_FROM( \ TYPE, \ std::optional::type>) -# else // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# else // BSLSTL_OPTIONAL_USES_STD_ALIASES // The value of these macros is chosen to not affect the constraints these // macros appears in. #define BSLSTL_OPTIONAL_CONVERTS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) false #define BSLSTL_OPTIONAL_ASSIGNS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) false -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY else +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES else // Macros to define common constraints that enable a constructor or assignment // operator. @@ -282,12 +301,12 @@ struct Optional_NulloptConstructToken { namespace bsl { -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES using nullopt_t = std::nullopt_t; using std::nullopt; -# else // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# else // BSLSTL_OPTIONAL_USES_STD_ALIASES // ================ // struct nullopt_t @@ -321,7 +340,7 @@ nullopt_t nullopt(BloombergLP::bslstl::Optional_NulloptConstructToken{}); extern const nullopt_t nullopt; # endif -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES template class optional; @@ -1074,7 +1093,7 @@ class Optional_Base { BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCT_PROPAGATES_ALLOCATOR(t_TYPE, t_ANY_TYPE)); -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES /// Create a disengaged `Optional_Base` object if the specified /// `original` object is disengaged, and an `Optional_Base` object with /// the value of `original.value()` converted to `t_TYPE` otherwise. @@ -1090,7 +1109,7 @@ class Optional_Base { template Optional_Base(BloombergLP::bslstl::Optional_MoveConstructFromStdOptional, std::optional&& original); -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES #if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES // {{{ BEGIN GENERATED CODE @@ -1498,7 +1517,7 @@ class Optional_Base { BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional, BSLMF_MOVABLEREF_DEDUCE(Optional_Base) original); -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES /// If the specified `original` contains a value, create an /// `Optional_Base` object whose contained value is initialized from /// `*original`, converted to `t_TYPE`. Otherwise, create a disengaged @@ -1521,7 +1540,7 @@ class Optional_Base { allocator_type allocator, BloombergLP::bslstl::Optional_MoveConstructFromStdOptional, std::optional&& original); -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES #if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES // {{{ BEGIN GENERATED CODE @@ -2470,7 +2489,7 @@ class Optional_Base { // class Optional_Base // ================================== -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES /// Specialization of `Optional_Base` for `value_type` that is not /// allocator-aware when `std::optional` is available. template @@ -2630,7 +2649,7 @@ class Optional_Base : public std::optional { BloombergLP::bslmf::IsBitwiseCopyable, BloombergLP::bslmf::IsBitwiseCopyable::value); }; -# else // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# else // BSLSTL_OPTIONAL_USES_STD_ALIASES // ============================================================================ // Section: Definition of Pre-C++17 Allocator-Unaware 'Optional_Base' @@ -3996,7 +4015,7 @@ class Optional_Base { } #endif // BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT else }; -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY else +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES else } // close package namespace } // close enterprise namespace @@ -4140,7 +4159,7 @@ class optional : public BloombergLP::bslstl::Optional_Base { t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)); -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template optional( const std::optional& original, @@ -4189,7 +4208,7 @@ class optional : public BloombergLP::bslstl::Optional_Base { BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_STD_OPTIONAL(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)); -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES #if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES // {{{ BEGIN GENERATED CODE @@ -4650,7 +4669,7 @@ class optional : public BloombergLP::bslstl::Optional_Base { t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)); -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES /// Create a disengaged `optional` object if the specified `original` /// object is disengaged, and an `optional` object with the value of /// `original.value()` converted to `t_TYPE` otherwise. Use the @@ -4705,7 +4724,7 @@ class optional : public BloombergLP::bslstl::Optional_Base { BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_STD_OPTIONAL(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)); -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES #if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES // {{{ BEGIN GENERATED CODE @@ -5191,7 +5210,7 @@ class optional : public BloombergLP::bslstl::Optional_Base { operator=(BloombergLP::bslmf::MovableRef rhs); #endif // RVALUES else -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES /// Disengage this object if the specified `rhs` object is disengaged, /// and assign to this object the value of `rhs.value()` (of /// `t_ANY_TYPE`) converted to `t_TYPE` otherwise. Return a reference @@ -5211,7 +5230,7 @@ class optional : public BloombergLP::bslstl::Optional_Base { template BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_STD_OPTIONAL(t_TYPE, t_ANY_TYPE)& operator=(std::optional&& rhs); -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES }; } // close namespace bsl @@ -5633,7 +5652,7 @@ constexpr compare_three_way_result_t operator<=>( const std::optional& rhs); #endif -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES /// Efficiently exchange the values of the specified `lhs` and `rhs` /// objects. This method provides the no-throw exception-safety guarantee /// if the template parameter `t_TYPE` provides that guarantee and the @@ -5723,7 +5742,7 @@ bool operator>=(const bsl::optional& lhs, template bool operator>=(const std::optional& lhs, const bsl::optional& rhs); -#endif +#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES /// Return an `optional` object containing a `t_TYPE` object created by /// invoking a `bsl::optional` allocator-extended `in_place_t` constructor @@ -7459,7 +7478,7 @@ Optional_Base::Optional_Base( } } -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template template inline @@ -7483,7 +7502,7 @@ Optional_Base::Optional_Base( emplace(std::move(original.value())); } } -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES #if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES // {{{ BEGIN GENERATED CODE @@ -8158,7 +8177,7 @@ Optional_Base::Optional_Base( } } -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template template inline @@ -8188,7 +8207,7 @@ Optional_Base::Optional_Base( emplace(std::move(original.value())); } } -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES #if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES // {{{ BEGIN GENERATED CODE @@ -9827,7 +9846,7 @@ Optional_Base::operator bool() const // class Optional_Base // ================================== -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES // PROTECTED CREATORS template inline @@ -10044,7 +10063,7 @@ const t_TYPE& Optional_Base::dereferenceRaw() const } # endif // BDE_OMIT_INTERNAL_DEPRECATED -# else // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# else // BSLSTL_OPTIONAL_USES_STD_ALIASES // ============================================================================ // Section: Pre-C++17 Allocator-Unaware 'Optional_Base' Method Definitions @@ -12220,7 +12239,7 @@ Optional_Base::operator bool() const BSLS_KEYWORD_NOEXCEPT return has_value(); } #endif // BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // else BSLSTL_OPTIONAL_USES_STD_ALIASES } // close package namespace } // close enterprise namespace @@ -12334,7 +12353,7 @@ optional::optional( { } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template template optional::optional( @@ -12380,7 +12399,7 @@ optional::optional( std::move(original)) { } -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES #if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES // {{{ BEGIN GENERATED CODE @@ -13049,7 +13068,7 @@ optional::optional( { } -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template template optional::optional( @@ -13112,7 +13131,7 @@ optional::optional( std::move(original)) { } -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES #if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES // {{{ BEGIN GENERATED CODE @@ -13892,7 +13911,7 @@ optional::operator=(BloombergLP::bslmf::MovableRef rhs) } #endif // RVALUES else -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template template BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_STD_OPTIONAL(t_TYPE, const t_ANY_TYPE&)& @@ -13918,7 +13937,7 @@ optional::operator=(std::optional&& rhs) } return *this; } -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES // ============================================================================ // Section: Free Function Definitions @@ -14351,7 +14370,7 @@ constexpr compare_three_way_result_t operator<=>( #endif // BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON && // BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES template inline typename bsl::enable_if::value, @@ -14511,7 +14530,7 @@ bool operator>=(const std::optional& lhs, } return lhs.has_value() && *lhs >= *rhs; } -# endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY +# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES template BSLS_KEYWORD_CONSTEXPR bsl::optional::type> diff --git a/groups/bsl/bslstl/bslstl_span.h b/groups/bsl/bslstl/bslstl_span.h index 9b99e56281..e81f2207c0 100644 --- a/groups/bsl/bslstl/bslstl_span.h +++ b/groups/bsl/bslstl/bslstl_span.h @@ -144,7 +144,9 @@ BSLS_IDENT("$Id: $") #include #include -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY +#if defined (BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY) && \ + !(defined(BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED) && \ + (BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED < 20)) #include namespace bsl { using std::dynamic_extent; @@ -152,8 +154,10 @@ namespace bsl { using std::as_bytes; using std::as_writable_bytes; } -#else +#define BSLSTL_SPAN_IS_ALIASED +#endif // BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY & not disabled +#ifndef BSLSTL_SPAN_IS_ALIASED #include #include #include @@ -284,7 +288,7 @@ struct Span_Utility bsl::nullptr_t>::type > > : public bsl::true_type {}; -#endif +#endif // BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY }; @@ -361,7 +365,7 @@ class span { Span_Utility::IsArrayConvertible< const t_OTHER_TYPE, element_type>::value, void *>::type = NULL) BSLS_KEYWORD_NOEXCEPT; -#endif +#endif // BSLSTL_ARRAY_IS_ALIASED #ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY /// Construct a span from the specified std::array `arr`. This @@ -385,7 +389,7 @@ class span { Span_Utility::IsArrayConvertible< const t_OTHER_TYPE, element_type>::value, void *>::type = NULL) BSLS_KEYWORD_NOEXCEPT; -#endif +#endif // BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY /// Construct a span from the specified span `other`. This constructor /// participates in overload resolution only if `t_OTHER_TYPE(*)[]` is @@ -636,7 +640,7 @@ class span { Span_Utility::IsArrayConvertible< const t_OTHER_TYPE, element_type>::value, void *>::type = NULL) BSLS_KEYWORD_NOEXCEPT; -#endif +#endif // BSLSTL_ARRAY_IS_ALIASED #ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY /// Construct a span from the specified std::array `arr`. This @@ -659,7 +663,7 @@ class span { Span_Utility::IsArrayConvertible< const t_OTHER_TYPE, element_type>::value, void *>::type = NULL) BSLS_KEYWORD_NOEXCEPT; -#endif +#endif // BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY #ifndef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY /// Construct a span from the specified bsl::vector `v`. This @@ -711,7 +715,7 @@ class span { Span_Utility::IsArrayConvertible< const CHAR_TYPE, element_type>::value, void *>::type = NULL) BSLS_KEYWORD_NOEXCEPT; -#endif +#endif // no BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY #ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY template @@ -735,7 +739,7 @@ class span { , d_size(bsl::size(c)) { } -#endif +#endif // BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY /// Construct a span from the specified span `other`. This constructor /// participates in overload resolution only if `t_OTHER_TYPE(*)[]` is @@ -889,7 +893,7 @@ span(bsl::array &) -> span; /// `span`. template span(const bsl::array &) -> span; -#endif +#endif // not BSLSTL_ARRAY_IS_ALIASED /// Deduce the template parameters `TYPE` and `SIZE` from the corresponding /// template parameters of the `std::array` supplied to the constructor of @@ -912,7 +916,7 @@ span(bsl::vector &) -> span; /// parameter of the `bsl::vector` supplied to the constructor of `span`. template span(const bsl::vector &) -> span; -#endif +#endif // BSLS_COMPILERFEATURES_SUPPORT_CTAD // FREE FUNCTIONS #ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY @@ -941,7 +945,7 @@ template BSLS_KEYWORD_CONSTEXPR_CPP14 span as_writable_bytes(span s) BSLS_KEYWORD_NOEXCEPT; -#endif +#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY /// Exchange the value of the specified `a` object with the value of the /// specified `b` object. @@ -1022,7 +1026,7 @@ bsl::span::span(const bsl::array& arr, : d_data_p(arr.data()) { } -#endif +#endif // not BSLSTL_ARRAY_IS_ALIASED #ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY template @@ -1046,7 +1050,7 @@ bsl::span::span(const std::array& arr, : d_data_p(arr.data()) { } -#endif +#endif // BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY template template @@ -1277,7 +1281,7 @@ bsl::span::span( , d_size(SIZE) { } -#endif +#endif // not BSLSTL_ARRAY_IS_ALIASED #ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY template @@ -1306,7 +1310,7 @@ bsl::span::span( , d_size(SIZE) { } -#endif +#endif // BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY #ifndef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY template @@ -1368,7 +1372,7 @@ inline bsl::span::span( , d_size(sv.size()) { } -#endif +#endif // no BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY template template @@ -1623,7 +1627,7 @@ bsl::as_writable_bytes(bsl::span s) } // BDE_VERIFY pragma: pop -#endif +#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY template BSLS_KEYWORD_CONSTEXPR_CPP14 inline @@ -1634,8 +1638,9 @@ bsl::swap(bsl::span& a, bsl::span& b) a.swap(b); } -#endif // BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY -#endif // INCLUDED_BSLSTL_SPAN +#endif // BSLSTL_SPAN_IS_ALIASED + +#endif // ---------------------------------------------------------------------------- // Copyright 2022 Bloomberg Finance L.P. diff --git a/groups/bsl/bslstl/bslstl_span.t.cpp b/groups/bsl/bslstl/bslstl_span.t.cpp index d746bb2f8e..3ef22a7ce1 100644 --- a/groups/bsl/bslstl/bslstl_span.t.cpp +++ b/groups/bsl/bslstl/bslstl_span.t.cpp @@ -123,22 +123,21 @@ void aSsErT(bool condition, const char *message, int line) // only if we're not using `std::span`, because all three implementations of // std::span add `noexcept` to `front`, `back`, `first`, `last`, and `subspan`, // as well as the `(pointer, pointer)` and `(pointer, size)` constructors. -#ifndef BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY +#ifndef BSLSTL_SPAN_IS_ALIASED #define NOEXCEPT_TEST_ONLY_BSL_SPAN 1 #endif #ifdef BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT -#define ASSERT_NOEXCEPT(...) BSLS_ASSERT( noexcept(__VA_ARGS__)) -#define ASSERT_NOT_NOEXCEPT(...) BSLS_ASSERT(!noexcept(__VA_ARGS__)) +#define ASSERT_NOEXCEPT(...) ASSERT( noexcept(__VA_ARGS__)) +#define ASSERT_NOT_NOEXCEPT(...) ASSERT(!noexcept(__VA_ARGS__)) #else -#define ASSERT_NOEXCEPT(...) BSLS_ASSERT(true) -#define ASSERT_NOT_NOEXCEPT(...) BSLS_ASSERT(true) +#define ASSERT_NOEXCEPT(...) +#define ASSERT_NOT_NOEXCEPT(...) #endif // We want to test `span::at` only if we're using our own implementation or we // have a C++26 compliant standard library. -// are using our own implementation. -#if !defined(BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY) || \ +#if !defined(BSLSTL_SPAN_IS_ALIASED) || \ defined(BSLS_LIBRARYFEATURES_HAS_CPP26_BASELINE_LIBRARY) #define TEST_BSL_SPAN_AT 1 #endif diff --git a/groups/bsl/bslstl/bslstl_stringview.cpp b/groups/bsl/bslstl/bslstl_stringview.cpp index 1d1d86a4ce..211a5ff6cd 100644 --- a/groups/bsl/bslstl/bslstl_stringview.cpp +++ b/groups/bsl/bslstl/bslstl_stringview.cpp @@ -7,7 +7,9 @@ BSLS_IDENT("$Id$ $CSID$") #include #include -#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY) +#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY) && \ + (!defined(BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED) || \ + (BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED >= 20)) #if !defined(BSLSTL_STRING_VIEW_IS_ALIASED) #error Must be aliased for C++20 and later. #endif diff --git a/groups/bsl/bslstl/bslstl_stringview.h b/groups/bsl/bslstl/bslstl_stringview.h index a4677f6a1a..35599a11bf 100644 --- a/groups/bsl/bslstl/bslstl_stringview.h +++ b/groups/bsl/bslstl/bslstl_stringview.h @@ -222,18 +222,27 @@ BSLS_IDENT("$Id: $") # include #endif // BDE_DONT_ALLOW_TRANSITIVE_INCLUDES -#if defined(BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY) \ -&& !defined(BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY) -#define BSLSTL_STRING_VIEW_AND_STD_STRING_VIEW_COEXIST +#if defined(BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY) \ +&& (!defined(BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY) || \ + (defined(BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED) && \ + (BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED < 20))) + /// `bsl` and `std::string_view`s coexist when we have at least C++17 + /// standard library available, but C++20 library is not available, or it + /// is disabled due to ABI compatibility reasons. +# define BSLSTL_STRING_VIEW_AND_STD_STRING_VIEW_COEXIST #endif -// 'BDE_DISABLE_CPP17_ABI' is intended for CI builds only, to allow simulation -// of Sun/AIX builds on Linux hosts. It is an error to define this symbol in -// Bloomberg production builds. -#ifndef BDE_DISABLE_CPP17_ABI -# ifdef BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY +#if defined (BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY) && \ + !(defined(BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED) && \ + (BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED < 20)) -# include + /// `BSLSTL_STRING_VIEW_IS_ALIASED` is defined when `bsl::string_view` and + /// its accompanying symbols are aliases to their `std` equivalents. Note + /// that `std::string` may coexist with `bsl::string_view` that is *not* an + /// alias of it; see `BSLSTL_STRING_VIEW_AND_STD_STRING_VIEW_COEXIST`. +# define BSLSTL_STRING_VIEW_IS_ALIASED + +# include namespace bsl { @@ -241,9 +250,9 @@ using std::basic_string_view; using std::string_view; using std::wstring_view; -# if defined(BSLS_COMPILERFEATURES_SUPPORT_UTF8_CHAR_TYPE) +# if defined(BSLS_COMPILERFEATURES_SUPPORT_UTF8_CHAR_TYPE) using std::u8string_view; -# endif +# endif using std::u16string_view; using std::u32string_view; @@ -258,9 +267,7 @@ using std::operator>; using std::operator>=; } -# define BSLSTL_STRING_VIEW_IS_ALIASED -# endif // BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY -#endif // BDE_DISABLE_CPP17_ABI +#endif // BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY & not disabled #ifndef BSLSTL_STRING_VIEW_IS_ALIASED @@ -2826,8 +2833,6 @@ void bslh::hashAppend( } // close enterprise namespace #endif // BSLSTL_STRING_VIEW_IS_ALIASED -#undef BSLSTL_STRING_VIEW_AND_STD_STRING_VIEW_COEXIST - #endif // ---------------------------------------------------------------------------- diff --git a/groups/bsl/bslstl/bslstl_stringview.t.cpp b/groups/bsl/bslstl/bslstl_stringview.t.cpp index 3ba2a4ee1b..7bec08a264 100644 --- a/groups/bsl/bslstl/bslstl_stringview.t.cpp +++ b/groups/bsl/bslstl/bslstl_stringview.t.cpp @@ -749,7 +749,7 @@ typename bsl::basic_string_view::size_type findLastNotOf( // HELPER CLASSES FOR TESTING ITERATOR INTERFACES // ---------------------------------------------------------------------------- -#ifndef BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY +#ifndef BSLSTL_STRING_VIEW_IS_ALIASED // ================== // class TestIterator @@ -1403,11 +1403,16 @@ void TestDriver::testCase22() const ObjC::value_type *STRING = TestDriver::s_testString; const ObjC::value_type *NULL_PTR = 0; - ASSERT_SAFE_PASS(operator ""_sv(STRING, 0)); - ASSERT_SAFE_PASS(operator ""_sv(STRING, 5)); + // afeher: for some reason the using directive above does not work + ASSERT_SAFE_PASS( + bsl::string_view_literals::operator ""_sv(STRING, 0)); + ASSERT_SAFE_PASS( + bsl::string_view_literals::operator ""_sv(STRING, 5)); - ASSERT_SAFE_PASS(operator ""_sv(NULL_PTR, 0)); - ASSERT_SAFE_FAIL(operator ""_sv(NULL_PTR, 5)); + ASSERT_SAFE_PASS( + bsl::string_view_literals::operator ""_sv(NULL_PTR, 0)); + ASSERT_SAFE_FAIL( + bsl::string_view_literals::operator ""_sv(NULL_PTR, 5)); } #endif } @@ -1490,11 +1495,16 @@ void TestDriver::testCase22() TestDriver::s_testString; const ObjW::value_type *NULL_PTR = 0; - ASSERT_SAFE_PASS(operator ""_sv(STRING, 0)); - ASSERT_SAFE_PASS(operator ""_sv(STRING, 5)); + // afeher: for some reason the using directive above does not work + ASSERT_SAFE_PASS( + bsl::string_view_literals::operator ""_sv(STRING, 0)); + ASSERT_SAFE_PASS( + bsl::string_view_literals::operator ""_sv(STRING, 5)); - ASSERT_SAFE_PASS(operator ""_sv(NULL_PTR, 0)); - ASSERT_SAFE_FAIL(operator ""_sv(NULL_PTR, 5)); + ASSERT_SAFE_PASS( + bsl::string_view_literals::operator ""_sv(NULL_PTR, 0)); + ASSERT_SAFE_FAIL( + bsl::string_view_literals::operator ""_sv(NULL_PTR, 5)); } #endif } @@ -1570,7 +1580,7 @@ void TestDriver::testCase21() { #define STRING_VIEW_HAS_CONTAINS #endif -#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY) +#if defined(BSLSTL_STRING_VIEW_IS_ALIASED) ASSERT(( bsl::is_same >::value)); #elif defined(BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY) @@ -6968,7 +6978,7 @@ void TestDriver::testCase2() if (verbose) printf("Validate `TestIterator` and `TestSentinel`.\n"); { -#ifdef BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY +#ifdef BSLSTL_STRING_VIEW_IS_ALIASED ASSERT((true ==std::is_same::value));