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 <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>