Problems with using `sizeof` in `requires` clause

This should compile, but it doesn’t

template <typename... U>
constexpr auto adder(U... u) ->  bool
    requires(sizeof...(U) == 3)
{
    return true;
}



bool f()
{
   return adder<int>(2,34,45);
}

I talked with engineering who agree that is a compiler issue and we’ve added TPR#33322 to track.

The work around would be to change:

return adder<int>(2,34,45);

to

return adder<int,int,int>(2,34,45);

Thanks for the report,
Mat

Thanks a for a quick reply. I’ll use the work-around for now.

Hi j.badwaik,

We should have TPR #33322 fixed in our 23.5 release.

% nvc++ --c++20 vpreq.cc -V23.3
"vpreq.cc", line 13: error: no instance of function template "f" matches the argument list
            argument types are: (int, unsigned int, double)
    f<int>(1, 2u, 3.0); // error
    ^

"vpreq.cc", line 14: error: no instance of function template "g" matches the argument list
            argument types are: (int, unsigned int, double)
    g<int>(4, 5u, 6.0); // error
    ^

2 errors detected in the compilation of "vpreq.cc".
% nvc++ --c++20 vpreq.cc -V23.5
%

Thanks again for the report,
Mat

Thank you! :-)