https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122396
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Tomasz Kaminski <[email protected]>: https://gcc.gnu.org/g:d554b8a704bae6c3470fbf44a95559fc26bc75d1 commit r16-5186-gd554b8a704bae6c3470fbf44a95559fc26bc75d1 Author: Tomasz KamiÅski <[email protected]> Date: Thu Nov 6 15:22:12 2025 +0100 libstdc++: optional<T&> for function and unbounded array should not be range [PR122396] This implements proposed resolution for LWG4308 [1]. For T denoting either function type or unbounded array, the optional<T&> no longer exposes iterator, and viable begin/end members. The conditionally provided iterator type, it is now defined in __optional_ref_base base class. Furthermore, range support for optional<T&> is now also guarded by __cpp_lib_optional_range_support. [1] https://cplusplus.github.io/LWG/issue4308 PR libstdc++/122396 libstdc++-v3/ChangeLog: * include/std/optional (__optional_ref_base): Define. (std::optional<_Tp&>): Inherit from __optional_ref_base<_Tp>. (optional<_Tp&>::iterator): Move to base class. (optional<_Tp&>::begin, optional<_Tp&>::end): Use deduced return type and constrain accordingly. * testsuite/20_util/optional/range.cc: Add test for optional<T&>. Reviewed-by: Jonathan Wakely <[email protected]> Signed-off-by: Tomasz KamiÅski <[email protected]>
