C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Make typename optional when used with a name dependent on a constrained template

From: Christoph Meyer <christoph.meyer.2006_at_[hidden]>
Date: Wed, 22 Feb 2023 09:36:37 +0100

On Tuesday, 21 February 2023 23:30:09 MET Thiago Macieira via Std-Proposals
wrote:
> On Tuesday, 21 February 2023 13:27:57 PST Christoph Meyer via Std-Proposals
> wrote:
>> ```c++
>> template <has_inner_type T>
>> void foo(T value)
>> {
>> T::inner innerValue;
>> // do something with value and innerValue
>> }
>> ```
>
> Would it also apply to types that are not checked by the concept constraint?
>
> template <has_inner_type T>
> void foo(T value)
> {
> T::outer innerValue;
> // do something with value and innerValue
> }
>
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel DCAI Cloud Engineering

No, it would only apply to types which are explicitly backed up by a typename requirement; all other dependent names would be treated as values by default, as it is the case now.
Also note that the use of the `typename` keyword in this context would be *optional*, not *prohibited*. If you want to mark a name as a typename to make things more clear, you still have the freedom to do so, but forcing the programmer just seems redundant.

Sincerely,
Christoph Meyer

Received on 2023-02-22 08:36:51