On 04/02/2020 03:07, Patrick Palka wrote:
This patch implements [range.adaptors].  It also includes the changes from P3280
and P3278 and P3323, without which many standard examples won't work.

I see that with this <https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;a=commit;h=cba9ef069e58eac00f30489d3ef21390caee6e45> "libstdc++: Implement C++20 range adaptors", compiling <ranges> with recent Clang trunk (which appears to mostly implement C++20 concepts now) in -std=c++2a mode fails as below (besides also failing due to some "missing" typenames, where Clang apparently doesn't yet implement P0634R3). And I'm not sure which of Clang vs. GCC is right here.

The failure is

gcc/trunk/inst/include/c++/10.0.1/ranges:1512:47: error: ambiguous deduction 
for template arguments of '_RangeAdaptor'
    inline constexpr __adaptor::_RangeAdaptor filter
                                              ^
gcc/trunk/inst/include/c++/10.0.1/ranges:1073:2: note: candidate function [with 
_Callable = std::ranges::views::(lambda at 
gcc/trunk/inst/include/c++/10.0.1/ranges:1513:9)]
        _RangeAdaptor(const _Callable& = {})
        ^
gcc/trunk/inst/include/c++/10.0.1/ranges:1078:2: note: candidate function [with 
_Callable = std::ranges::views::(lambda at 
gcc/trunk/inst/include/c++/10.0.1/ranges:1513:9)]
        _RangeAdaptor(_Callable __callable)
        ^

and a stripped-down reproducer is

template<typename T> struct S {
  S(T const &) requires true;
  S(T) requires false;
};
S s = 0;

(Clang accepts this when the last line is replaced with

S<int> s = 0;

and thus no class template argument deduction needs to be done.)

I think what is relevant here is [over.match.class.deduct]/1 in the current spec, which specifies a helper set of hypothetical function templates based on a class' constructors for class template argument deduction. It details the function templates' template parameters, function parameters, and return types, but does not mention requires-clauses. From my superficial understanding of concepts and class template argument deduction it would thus look like the constructors' requires-clauses should indeed not be taken into account here?

Reply via email to