Skip to content
Snippets Groups Projects
  1. Mar 20, 2023
  2. Jan 16, 2023
  3. Dec 16, 2022
    • Jonathan Wakely's avatar
      libstdc++: Add monadic operations to std::expected for C++23 (P2505R5) · 8d9e2776
      Jonathan Wakely authored
      This was approved for C++23 last month in Kona.
      
      libstdc++-v3/ChangeLog:
      
      	* include/std/expected (expected): Add monadic operations.
      	(expected<void, E>): Likewise.
      	* include/std/version (__cpp_lib_expected): Bump value.
      	* testsuite/20_util/expected/synopsis.cc: Adjust expected macro
      	value.
      	* testsuite/20_util/expected/version.cc: Likewise.
      	* testsuite/20_util/expected/illformed_neg.cc: Prune additional
      	errors from ill-formed monadic operations.
      	* testsuite/20_util/expected/observers.cc: Check error_or.
      	* testsuite/20_util/expected/monadic.cc: New test.
      8d9e2776
    • Jonathan Wakely's avatar
      libstdc++: Fixes for std::expected · 59822c39
      Jonathan Wakely authored
      This fixes some bugs in the swap functions for std::expected.
      
      It also disables the noexcept-specifiers for equality operators, because
      those are problematic when querying whether a std::expected is equality
      comparable. The operator==(const expected<T,E>&, const U&) function is
      not constrained, so is viable for comparing expected<T,E> with
      expected<void,G>, but then we get an error from the noexcept-specifier.
      
      libstdc++-v3/ChangeLog:
      
      	* include/std/expected (expected::_M_swap_val_unex): Guard the
      	correct object.
      	(expected::swap): Move is_swappable
      	requirement from static_assert to constraint.
      	(swap): Likewise.
      	(operator==): Remove noexcept-specifier.
      	* testsuite/20_util/expected/swap.cc: Check swapping of
      	types without non-throwing move constructor. Check constraints
      	on swap.
      	* testsuite/20_util/expected/unexpected.cc: Check constraints on
      	swap.
      	* testsuite/20_util/expected/equality.cc: New test.
      59822c39
  4. Nov 02, 2022
    • Jonathan Wakely's avatar
      libstdc++: Remove unnecessary variant member in std::expected · f4874691
      Jonathan Wakely authored
      Hui Xie pointed out that we don't need a dummy member in the union,
      because all constructors always initialize either _M_val or _M_unex.
      
      We still need the _M_void member of the expected<void, E>
      specialization, because the constructor has to initialize something when
      not using the _M_unex member.
      
      libstdc++-v3/ChangeLog:
      
      	* include/std/expected (expected::_M_invalid): Remove.
      f4874691
  5. Aug 04, 2022
    • Jonathan Wakely's avatar
      libstdc++: Rename data members of std::unexpected and std::bad_expected_access · 07c7ee4d
      Jonathan Wakely authored
      The P2549R1 paper was accepted for C++23. I already implemented it for
      our <expected>, but I didn't rename the private daata members, only the
      public member functions. This renames the data members for consistency
      with the working draft.
      
      libstdc++-v3/ChangeLog:
      
      	* include/std/expected (unexpected::_M_val): Rename to _M_unex.
      	(bad_expected_access::_M_val): Likewise.
      07c7ee4d
  6. Apr 08, 2022
  7. Mar 27, 2022
    • Jonathan Wakely's avatar
      libstdc++: Define std::expected for C++23 (P0323R12) · b78e0ce2
      Jonathan Wakely authored
      Because this adds a new class template called std::unexpected, we have
      to stop declaring the std::unexpected() function (which was deprecated
      in C++11 and removed in C++17).
      
      libstdc++-v3/ChangeLog:
      
      	* doc/doxygen/user.cfg.in: Add new header.
      	* include/Makefile.am: Likewise.
      	* include/Makefile.in: Regenerate.
      	* include/precompiled/stdc++.h: Add new header.
      	* include/std/version (__cpp_lib_expected): Define.
      	* libsupc++/exception [__cplusplus > 202002] (unexpected)
      	(unexpected_handler, set_unexpected): Do not declare for C++23.
      	* include/std/expected: New file.
      	* testsuite/20_util/expected/assign.cc: New test.
      	* testsuite/20_util/expected/cons.cc: New test.
      	* testsuite/20_util/expected/illformed_neg.cc: New test.
      	* testsuite/20_util/expected/observers.cc: New test.
      	* testsuite/20_util/expected/requirements.cc: New test.
      	* testsuite/20_util/expected/swap.cc: New test.
      	* testsuite/20_util/expected/synopsis.cc: New test.
      	* testsuite/20_util/expected/unexpected.cc: New test.
      	* testsuite/20_util/expected/version.cc: New test.
      b78e0ce2
Loading