aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/std/version
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2021-10-19 11:06:56 +0100
committerJonathan Wakely <jwakely@redhat.com>2021-10-19 15:01:16 +0100
commit82b2e4f8cf5a01c6724fe3f465a77ee03cfcaae2 (patch)
treeebc6317967464146890f1a47aae196445dd0bb31 /libstdc++-v3/include/std/version
parent6920d5a1a2834e9c62d441b8f4c6186b01107d13 (diff)
downloadgcc-82b2e4f8cf5a01c6724fe3f465a77ee03cfcaae2.zip
gcc-82b2e4f8cf5a01c6724fe3f465a77ee03cfcaae2.tar.gz
gcc-82b2e4f8cf5a01c6724fe3f465a77ee03cfcaae2.tar.bz2
libstdc++: Implement monadic operations for std::optional (P0798R8)
Another new addition to the C++23 working draft. The new member functions of std::optional are only defined for C++23, but the new members of _Optional_payload_base are defined for C++20 so that they can be used in non-propagating-cache in <ranges>. The _Optional_payload_base::_M_construct member can also be used in non-propagating-cache now, because it's constexpr since r12-4389. There will be an LWG issue about the feature test macro, suggesting that we should just bump the value of __cpp_lib_optional instead. I haven't done that here, but it can be changed once consensus is reached on the change. libstdc++-v3/ChangeLog: * include/std/optional (_Optional_payload_base::_Storage): Add constructor taking a callable function to invoke. (_Optional_payload_base::_M_apply): New function. (__cpp_lib_monadic_optional): Define for C++23. (optional::and_then, optional::transform, optional::or_else): Define for C++23. * include/std/ranges (__detail::__cached): Remove. (__detail::__non_propagating_cache): Remove use of __cached for contained value. Use _Optional_payload_base::_M_construct and _Optional_payload_base::_M_apply to set the contained value. * include/std/version (__cpp_lib_monadic_optional): Define. * testsuite/20_util/optional/monadic/and_then.cc: New test. * testsuite/20_util/optional/monadic/or_else.cc: New test. * testsuite/20_util/optional/monadic/or_else_neg.cc: New test. * testsuite/20_util/optional/monadic/transform.cc: New test. * testsuite/20_util/optional/monadic/version.cc: New test.
Diffstat (limited to 'libstdc++-v3/include/std/version')
-rw-r--r--libstdc++-v3/include/std/version3
1 files changed, 3 insertions, 0 deletions
diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
index 2b11830..0a7b28a 100644
--- a/libstdc++-v3/include/std/version
+++ b/libstdc++-v3/include/std/version
@@ -292,6 +292,9 @@
#define __cpp_lib_adaptor_iterator_pair_constructor 202106L
#define __cpp_lib_invoke_r 202106L
#define __cpp_lib_is_scoped_enum 202011L
+#if __cpp_lib_concepts
+# define __cpp_lib_monadic_optional 202110L
+#endif
#define __cpp_lib_move_only_function 202110L
#define __cpp_lib_string_contains 202011L
#if _GLIBCXX_USE_CXX11_ABI // Only supported with cxx11-abi