[libc++] Make optional::iterator experimental (#173470)
We haven't yet decided what we want the `optional::iterator` type to be in the end, so let's make it experimental for now so that we don't commit to an ABI yet.
This commit is contained in:
parent
6f5c214928
commit
89c8a253d7
14 changed files with 48 additions and 15 deletions
|
|
@ -51,7 +51,8 @@ Implemented Papers
|
|||
(`Github <https://llvm.org/PR105381>`__)
|
||||
- P2835R7: Expose ``std::atomic_ref``'s object address (`Github <https://llvm.org/PR118377>`__)
|
||||
- P2944R3: Comparisons for ``reference_wrapper`` (`Github <https://llvm.org/PR105424>`__)
|
||||
- P3168R2: Give ``std::optional`` Range Support (`Github <https://llvm.org/PR105430>`__)
|
||||
- P3168R2: Give ``std::optional`` Range Support
|
||||
(guarded by ``-fexperimental-library``, `Github <https://llvm.org/PR105430>`__)
|
||||
- P3567R2: ``flat_meow`` Fixes (`Github <https://llvm.org/PR162022>`__)
|
||||
- P3836R2: Make ``optional<T&>`` trivially copyable (`Github <https://llvm.org/PR171275>`__)
|
||||
- P1789R3: Library Support for Expansion Statements (`Github <https://llvm.org/PR167184>`__)
|
||||
|
|
|
|||
|
|
@ -33,5 +33,6 @@
|
|||
#define _LIBCPP_HAS_EXPERIMENTAL_TZDB _LIBCPP_HAS_EXPERIMENTAL_LIBRARY
|
||||
#define _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM _LIBCPP_HAS_EXPERIMENTAL_LIBRARY
|
||||
#define _LIBCPP_HAS_EXPERIMENTAL_HARDENING_OBSERVE_SEMANTIC _LIBCPP_HAS_EXPERIMENTAL_LIBRARY
|
||||
#define _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR _LIBCPP_HAS_EXPERIMENTAL_LIBRARY
|
||||
|
||||
#endif // _LIBCPP___CONFIGURATION_EXPERIMENTAL_H
|
||||
|
|
|
|||
|
|
@ -709,7 +709,7 @@ inline constexpr bool __is_constructible_for_optional_initializer_list_v<_Tp&, _
|
|||
template <class _Tp, class = void>
|
||||
struct __optional_iterator {};
|
||||
|
||||
# if _LIBCPP_STD_VER >= 26
|
||||
# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR
|
||||
|
||||
template <class _Tp>
|
||||
struct __optional_iterator<_Tp, enable_if_t<is_object_v<_Tp>>> {
|
||||
|
|
@ -796,7 +796,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
# endif // _LIBCPP_STD_VER >= 26
|
||||
# endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR
|
||||
|
||||
template <class _Tp>
|
||||
class _LIBCPP_DECLSPEC_EMPTY_BASES optional
|
||||
|
|
|
|||
|
|
@ -598,7 +598,9 @@ __cpp_lib_void_t 201411L <type_traits>
|
|||
# define __cpp_lib_not_fn 202306L
|
||||
# undef __cpp_lib_optional
|
||||
# define __cpp_lib_optional 202506L
|
||||
# define __cpp_lib_optional_range_support 202406L
|
||||
# if _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR
|
||||
# define __cpp_lib_optional_range_support 202406L
|
||||
# endif
|
||||
# undef __cpp_lib_out_ptr
|
||||
# define __cpp_lib_out_ptr 202311L
|
||||
// # define __cpp_lib_philox_engine 202406L
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@
|
|||
|
||||
#include <version>
|
||||
|
||||
#if !_LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR
|
||||
# error "-fexperimental-library should enable optional::iterator"
|
||||
#endif
|
||||
|
||||
#if !_LIBCPP_HAS_EXPERIMENTAL_PSTL
|
||||
# error "-fexperimental-library should enable the PSTL"
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ void test() {
|
|||
|
||||
opt.has_value(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
|
||||
#if TEST_STD_VER >= 26
|
||||
#if TEST_STD_VER >= 26 && _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR
|
||||
opt.begin(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
cOpt.begin(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
opt.end(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
|
|
@ -92,8 +92,10 @@ void test() {
|
|||
|
||||
optRef.has_value(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
|
||||
# if _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR
|
||||
optRef.begin(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
optRef.end(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
# endif
|
||||
|
||||
*optRef; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
*cOptRef; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
|
|
|
|||
|
|
@ -146,11 +146,17 @@
|
|||
# error "__cpp_lib_optional should have the value 202506L in c++26"
|
||||
# endif
|
||||
|
||||
# ifndef __cpp_lib_optional_range_support
|
||||
# error "__cpp_lib_optional_range_support should be defined in c++26"
|
||||
# endif
|
||||
# if __cpp_lib_optional_range_support != 202406L
|
||||
# error "__cpp_lib_optional_range_support should have the value 202406L in c++26"
|
||||
# if !defined(_LIBCPP_VERSION) || _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR
|
||||
# ifndef __cpp_lib_optional_range_support
|
||||
# error "__cpp_lib_optional_range_support should be defined in c++26"
|
||||
# endif
|
||||
# if __cpp_lib_optional_range_support != 202406L
|
||||
# error "__cpp_lib_optional_range_support should have the value 202406L in c++26"
|
||||
# endif
|
||||
# else
|
||||
# ifdef __cpp_lib_optional_range_support
|
||||
# error "__cpp_lib_optional_range_support should not be defined when the requirement '!defined(_LIBCPP_VERSION) || _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR' is not met!"
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif // TEST_STD_VER > 23
|
||||
|
|
|
|||
|
|
@ -7489,11 +7489,17 @@
|
|||
# error "__cpp_lib_optional should have the value 202506L in c++26"
|
||||
# endif
|
||||
|
||||
# ifndef __cpp_lib_optional_range_support
|
||||
# error "__cpp_lib_optional_range_support should be defined in c++26"
|
||||
# endif
|
||||
# if __cpp_lib_optional_range_support != 202406L
|
||||
# error "__cpp_lib_optional_range_support should have the value 202406L in c++26"
|
||||
# if !defined(_LIBCPP_VERSION) || _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR
|
||||
# ifndef __cpp_lib_optional_range_support
|
||||
# error "__cpp_lib_optional_range_support should be defined in c++26"
|
||||
# endif
|
||||
# if __cpp_lib_optional_range_support != 202406L
|
||||
# error "__cpp_lib_optional_range_support should have the value 202406L in c++26"
|
||||
# endif
|
||||
# else
|
||||
# ifdef __cpp_lib_optional_range_support
|
||||
# error "__cpp_lib_optional_range_support should not be defined when the requirement '!defined(_LIBCPP_VERSION) || _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR' is not met!"
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef __cpp_lib_out_ptr
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
// REQUIRES: std-at-least-c++26
|
||||
|
||||
// UNSUPPORTED: libcpp-has-no-experimental-optional-iterator
|
||||
|
||||
// <optional>
|
||||
|
||||
// constexpr iterator optional::begin() noexcept;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
// REQUIRES: std-at-least-c++26
|
||||
|
||||
// UNSUPPORTED: libcpp-has-no-experimental-optional-iterator
|
||||
|
||||
// <optional>
|
||||
|
||||
// template <class T> class optional<T&>::iterator;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
// REQUIRES: std-at-least-c++26
|
||||
|
||||
// UNSUPPORTED: libcpp-has-no-experimental-optional-iterator
|
||||
|
||||
// <optional>
|
||||
|
||||
// constexpr iterator optional::end() noexcept;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
// REQUIRES: std-at-least-c++26
|
||||
|
||||
// UNSUPPORTED: libcpp-has-no-experimental-optional-iterator
|
||||
|
||||
// <optional>
|
||||
|
||||
// template <class T> class optional::iterator;
|
||||
|
|
|
|||
|
|
@ -1026,6 +1026,8 @@ feature_test_macros = [
|
|||
"name": "__cpp_lib_optional_range_support",
|
||||
"values": {"c++26": 202406}, # P3168R2 Give std::optional Range Support
|
||||
"headers": ["optional"],
|
||||
"test_suite_guard": "!defined(_LIBCPP_VERSION) || _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR",
|
||||
"libcxx_guard": "_LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR",
|
||||
},
|
||||
{
|
||||
"name": "__cpp_lib_out_ptr",
|
||||
|
|
|
|||
|
|
@ -362,6 +362,7 @@ DEFAULT_PARAMETERS = [
|
|||
if experimental
|
||||
else [
|
||||
AddFeature("libcpp-has-no-incomplete-pstl"),
|
||||
AddFeature("libcpp-has-no-experimental-optional-iterator"),
|
||||
AddFeature("libcpp-has-no-experimental-tzdb"),
|
||||
AddFeature("libcpp-has-no-experimental-syncstream"),
|
||||
AddFeature("libcpp-has-no-experimental-hardening-observe-semantic"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue