https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99433
Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ppalka at gcc dot gnu.org Ever confirmed|0 |1 Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2021-03-17 --- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> --- I think the underlying problem here is excessive instantiation due to usage of deduced return types, which leads to hard errors during overload resolution. If I give the lambda in your testcase a concrete return type decltype(nucl + ' '), and apply the following change to <ranges> (giving concrete return types to a couple of lambdas therein) then we accept the testcase. diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index 1be74beb860..9fd647c144f 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -803,7 +803,11 @@ namespace views // otherwise capture by value. auto __closure = [...__args(__maybe_refwrap(std::forward<_Args>(__args)))] - <typename _Range> (_Range&& __r) { + <typename _Range> (_Range&& __r) + -> decltype(_Callable{}(std::forward<_Range>(__r), + (static_cast<unwrap_reference_t + <remove_const_t<decltype(__args)>>> + (__args))...)) { // This static_cast has two purposes: it forwards a // reference_wrapper<T> capture as a T&, and otherwise // forwards the captured argument as an rvalue. @@ -1655,6 +1659,7 @@ namespace views { inline constexpr __adaptor::_RangeAdaptor transform = [] <viewable_range _Range, typename _Fp> (_Range&& __r, _Fp&& __f) + -> decltype(transform_view{std::forward<_Range>(__r), std::forward<_Fp>(__f)}) { return transform_view{std::forward<_Range>(__r), std::forward<_Fp>(__f)}; }; For maximum SFINAE friendliness, all the range adaptors objects should probably be changed to avoid using deduced return types, in a manner similar to the above. While we're at it, we should make them conditionally noexcept.