|
Boost : |
From: Edward Diener (eldiener_at_[hidden])
Date: 2021-03-24 13:38:33
On 3/24/2021 4:41 AM, Daniela Engert via Boost wrote:
> Am 23.03.2021 um 21:13 schrieb Edward Diener via Boost:
>> I apologize for this non-Boost related post, but I ran into what I
>> thought was a C++17 bug in clang ( also in vc++14.2 C++17 )...
>
> In a template of form
>
> template<class T, bool (*)(T)> whatever
>
> up until C++14, the function argument type in the non-type template
> parameter was never looked at in the deduction of type T because NTTPs
> weren't deemed dependent on placeholder types in their function
> arguments. Beginning with C++17, they are. Therefore you may get
> conflicting type deduction because the second, additional deduction path
> from the function argument type in the NTTP will never deduce a
> top-level cv-qualified T in case of non-reference-like arguments. But
> the first, formerly only deduction path, may. And therein lies the
> conflict in your example where T = const char in the first path and T =
> char is in the second.
>
> Well, at least this is my understanding of P0172.
I appreciate your explanation, and the following is not directed at you
personally:
What is there to deduce ? If I specify whatever<char const,nullptr> then
T is 'char const'. It's right there in my instantiation. Making it
impossible in this simple situation to specify the T type when it is a
top-level const type can not be C++ in any logical sense. I also do not
even begin to understand why 'bool (*)(char const)' becomes 'bool
(*)(char)' in any logical world. Clearly a char const is not the same as
a char. Who in their right minds would make up a rule that says they are
the same, whether in a function declaration or not ? They clearly are
not, unless you are out to destroy the notion that top-level consts in
function declarations mean anything.
Honestly if this is now C++, something seriously has gone wrong AFAICS.
No doubt I am missing something basic, but this is truly "Alice in
Wonderland" stuff to me. OK, I have had my rant. In what I was working
on I will just specify that T as a top-level const is disallowed. My
design can get by on that, rather than come up with some tortured code
that allows T as a top-level const in the sort of signature above which
works in both C++14 and C++17 on up.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk