Date: Tue, 08 Apr 2025 19:08:19 +0300
Is the term «templated function» derived from the term «templated entity»? If so then in the definition of the term «templated function» there should be present the term «templated entity» instead of the words «a function that is templated». For example,
something like «templated function is a function templated entity». English is not my native language and maybe the words «function templated entity» is not correct enough but I think in any case the term «templated entity» should be used in the definition of the term «templated function».
Consider another example from the C++23 Standard. In the paragraph #4 of the section «7.5.5.2 Closure types» there is the following example
[Example 2 :
struct C {
template C(T); };
void func(int i) { int x = [=](this auto&&) { return i; }(); // OK
int y = [=](this C) { return i; }(); // error
int z = [](this C) { return 42; }(); // OK
}
— end example]
But there is no explanation what this object parameter «this C» means in the lambda expressions and neither reference is provided to make it clear. So if somebody will start to read the section he will be very confused.
With best regards
(Vlad from Moscow)
You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com
>Среда, 2 апреля 2025, 21:24 +03:00 от Brian Bi <bbi5291_at_[hidden]>:
>
>
>On Wed, Apr 2, 2025 at 2:12PM Vladimir Grigoriev via Std-Discussion < std-discussion_at_[hidden] > wrote:
>>In my opinion you are wrong. It is indeed a defect in the standard description that only confuses readers. At least there can be used the term templated function call operator instead of the function call operator.
>
>The text in its current form succinctly conveys two things. First, if a requires-clause is permitted for the function call operator or operator template of the lambda, then that requires-clause is obtained from the requires-clause of the lambda-declarator. Second, if a requires-clause is not permitted on the function call operator (because it's not templated), but one is provided on the lambda-declarator anyway, then the program is ill-formed (because we import the requires-clause from the lambda-declarator into a context where it shall not appear). It avoids any redundant description.
>
>We should not attempt to redundantly restate here the rules for where requires-clauses can appear.
>
>>
>>By the way in the C++20 Standard there is even no definition of the term templated function. If I am not mistaken it appears only in the C++23 but nevertheless is not clear:
>>
>>«A templated function is a function template or a function that is templated.»
>>
>>What does «a function that is templated» mean?!
>
>See https://eel.is/c++draft/temp.pre#8
>
>>
>>The text of the Standard shall be rewritten. As is it is very and very bad and takes too much time to understand what is written in the Standard.
>
>The standard is not a tutorial. It's written by people who do not wish for it to be difficult to understand; but making it easy to understand is not the most important objective.
>
>>
>>With best regards
>>(Vlad from Moscow)
>>
>>
>>
>>
>>You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com
>>
>>
>>>Среда, 2 апреля 2025, 19:29 +03:00 от Andrew Schepler < aschepler_at_[hidden] >:
>>>
>>>On Wed, Apr 2, 2025 at 10:45AM Vladimir Grigoriev via Std-Discussion < std-discussion_at_[hidden] > wrote:
>>>>It just means that the provided quote in the C++ Standard and other similar quotes are incorrect. There must be included somehow the term «templated entities» to make the quotes clear what they are saying about. In my opinion it is a serious defect of the Standard because in other place of the Standard there is written:
>>>>
>>>>4 The optional requires-clause in an init-declarator or member-declarator shall be present only if the declarator declares a templated function.
>>>
>>>I don't think this is a Standard defect. A non-templated lambda with requires-clause is syntactically valid. The call operator of its closure type has that same requires-clause. But that call operator is semantically invalid because of that very rule you quoted ([dcl.decl.general] p4). So the program is ill-formed. The existing Standard wording is sufficient.
>>>
>>>There are plenty of other semantic requirements which must be checked for a closure type or its members, where the lambda expression itself wouldn't violate the wording of the same rule.
>>>
>>>-- Andrew Schepler
>>>
>>>>
>>>>The provided by me quote should be looked like for example:
>>>>
>>>>«...The trailing requires-clause of a templated entity that is either the function call operator or operator template is the requires-clause of the lambda-declarator, if any.»
>>>>
>>>>With best regards
>>>>(Vlad from Moscow)
>>>>
>>>>
>>>>You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com
>>>>
>>>>
>>>>>Среда, 2 апреля 2025, 1:02 +03:00 от Christof Meerwald < cmeerw_at_[hidden] >:
>>>>>
>>>>>On Wed, Apr 02, 2025 at 12:33:51AM +0300, Vladimir Grigoriev via Std-Discussion wrote:
>>>>>>
>>>>>> In the paragraph #3 of the section «7.5.5.1 Closure types» of the C++20 Standard there is written
>>>>>>
>>>>>> «...The trailing requires-clause of the function call operator or operator template is the requires-clause of the lambda-declarator, if any.»
>>>>>>
>>>>>> So can a non-generic lambda have a trailing requires clause? And if the text of the quote is correct why is not there an example of such a lambda?
>>>>>Sure, it just needs to be templated, e.g.
>>>>>
>>>>> template<bool B>
>>>>> void f()
>>>>> {
>>>>> [] () requires B { } ();
>>>>> }
>>>>>
>>>>>
>>>>>There isn't an example for every feature in the standard as the
>>>>>standard is not a tutorial. Anything surprising or non-obvious should
>>>>>be highlighted by having an example in the standard.
>>>>>
>>>>>
>>>>>Christof
>>>>>
>>>>>--
>>>>>https://cmeerw.org sip:cmeerw at cmeerw.org
>>>>>mailto: cmeerw at cmeerw.org xmpp:cmeerw at cmeerw.org
>>>> --
>>>>Std-Discussion mailing list
>>>>Std-Discussion_at_[hidden]cpp.org
>>>>https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>> --
>>Std-Discussion mailing list
>>Std-Discussion_at_[hidden]
>>https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>
>--
>Brian Bi
>
>
>
something like «templated function is a function templated entity». English is not my native language and maybe the words «function templated entity» is not correct enough but I think in any case the term «templated entity» should be used in the definition of the term «templated function».
Consider another example from the C++23 Standard. In the paragraph #4 of the section «7.5.5.2 Closure types» there is the following example
[Example 2 :
struct C {
template C(T); };
void func(int i) { int x = [=](this auto&&) { return i; }(); // OK
int y = [=](this C) { return i; }(); // error
int z = [](this C) { return 42; }(); // OK
}
— end example]
But there is no explanation what this object parameter «this C» means in the lambda expressions and neither reference is provided to make it clear. So if somebody will start to read the section he will be very confused.
With best regards
(Vlad from Moscow)
You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com
>Среда, 2 апреля 2025, 21:24 +03:00 от Brian Bi <bbi5291_at_[hidden]>:
>
>
>On Wed, Apr 2, 2025 at 2:12PM Vladimir Grigoriev via Std-Discussion < std-discussion_at_[hidden] > wrote:
>>In my opinion you are wrong. It is indeed a defect in the standard description that only confuses readers. At least there can be used the term templated function call operator instead of the function call operator.
>
>The text in its current form succinctly conveys two things. First, if a requires-clause is permitted for the function call operator or operator template of the lambda, then that requires-clause is obtained from the requires-clause of the lambda-declarator. Second, if a requires-clause is not permitted on the function call operator (because it's not templated), but one is provided on the lambda-declarator anyway, then the program is ill-formed (because we import the requires-clause from the lambda-declarator into a context where it shall not appear). It avoids any redundant description.
>
>We should not attempt to redundantly restate here the rules for where requires-clauses can appear.
>
>>
>>By the way in the C++20 Standard there is even no definition of the term templated function. If I am not mistaken it appears only in the C++23 but nevertheless is not clear:
>>
>>«A templated function is a function template or a function that is templated.»
>>
>>What does «a function that is templated» mean?!
>
>See https://eel.is/c++draft/temp.pre#8
>
>>
>>The text of the Standard shall be rewritten. As is it is very and very bad and takes too much time to understand what is written in the Standard.
>
>The standard is not a tutorial. It's written by people who do not wish for it to be difficult to understand; but making it easy to understand is not the most important objective.
>
>>
>>With best regards
>>(Vlad from Moscow)
>>
>>
>>
>>
>>You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com
>>
>>
>>>Среда, 2 апреля 2025, 19:29 +03:00 от Andrew Schepler < aschepler_at_[hidden] >:
>>>
>>>On Wed, Apr 2, 2025 at 10:45AM Vladimir Grigoriev via Std-Discussion < std-discussion_at_[hidden] > wrote:
>>>>It just means that the provided quote in the C++ Standard and other similar quotes are incorrect. There must be included somehow the term «templated entities» to make the quotes clear what they are saying about. In my opinion it is a serious defect of the Standard because in other place of the Standard there is written:
>>>>
>>>>4 The optional requires-clause in an init-declarator or member-declarator shall be present only if the declarator declares a templated function.
>>>
>>>I don't think this is a Standard defect. A non-templated lambda with requires-clause is syntactically valid. The call operator of its closure type has that same requires-clause. But that call operator is semantically invalid because of that very rule you quoted ([dcl.decl.general] p4). So the program is ill-formed. The existing Standard wording is sufficient.
>>>
>>>There are plenty of other semantic requirements which must be checked for a closure type or its members, where the lambda expression itself wouldn't violate the wording of the same rule.
>>>
>>>-- Andrew Schepler
>>>
>>>>
>>>>The provided by me quote should be looked like for example:
>>>>
>>>>«...The trailing requires-clause of a templated entity that is either the function call operator or operator template is the requires-clause of the lambda-declarator, if any.»
>>>>
>>>>With best regards
>>>>(Vlad from Moscow)
>>>>
>>>>
>>>>You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com
>>>>
>>>>
>>>>>Среда, 2 апреля 2025, 1:02 +03:00 от Christof Meerwald < cmeerw_at_[hidden] >:
>>>>>
>>>>>On Wed, Apr 02, 2025 at 12:33:51AM +0300, Vladimir Grigoriev via Std-Discussion wrote:
>>>>>>
>>>>>> In the paragraph #3 of the section «7.5.5.1 Closure types» of the C++20 Standard there is written
>>>>>>
>>>>>> «...The trailing requires-clause of the function call operator or operator template is the requires-clause of the lambda-declarator, if any.»
>>>>>>
>>>>>> So can a non-generic lambda have a trailing requires clause? And if the text of the quote is correct why is not there an example of such a lambda?
>>>>>Sure, it just needs to be templated, e.g.
>>>>>
>>>>> template<bool B>
>>>>> void f()
>>>>> {
>>>>> [] () requires B { } ();
>>>>> }
>>>>>
>>>>>
>>>>>There isn't an example for every feature in the standard as the
>>>>>standard is not a tutorial. Anything surprising or non-obvious should
>>>>>be highlighted by having an example in the standard.
>>>>>
>>>>>
>>>>>Christof
>>>>>
>>>>>--
>>>>>https://cmeerw.org sip:cmeerw at cmeerw.org
>>>>>mailto: cmeerw at cmeerw.org xmpp:cmeerw at cmeerw.org
>>>> --
>>>>Std-Discussion mailing list
>>>>Std-Discussion_at_[hidden]cpp.org
>>>>https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>> --
>>Std-Discussion mailing list
>>Std-Discussion_at_[hidden]
>>https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>
>--
>Brian Bi
>
>
>
Received on 2025-04-08 16:08:46