C++ Logo

STD-DISCUSSION

Advanced search

Subject: Fwd: Requires expressions: local parameters
From: Vladimir Grigoriev (vlad.moscow_at_[hidden])
Date: 2019-08-09 07:12:59


That is the following function definition

template <typename T> requires requires ( T ) { typename T::value_type; }
void f( const T & )
{
// ...
}

is semantically equivalent to

template <typename T> requires requires ( typename T::value_type  ) {  }
void f( const T & )
{
// ...
}
I know that the requirement-body may not be empty. However semantically these requires expressions are equivalent.

So in my opinion in any case the description of requires expressions should be appended (be more complete) relative to using such declarations as typename T::value_type in an requires expression. Even maybe such constructions as shown above (with an empty requirement-body) should be allowed..

With best regards,
Vlad from Moscow

You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com

-------- Пересылаемое сообщение --------
От кого: Vladimir Grigoriev <vlad.moscow_at_[hidden]>
Кому: std-discussion <std-discussion_at_[hidden]>
Дата: Четверг, 8 августа 2019, 12:09 +03:00
Тема: Requires expressions: local parameters

From the description of  the requires expressions (C++20) it is not clear what is a valid local declaration and whether they are estimated the same way as the type-requirement.

Fro example it is impossible to say based on the description of the requires expressions in the C++ Standard whether this local parameter declaration is valid

template <typename T>
requires requires ( typename T::value_type x ) { /* ... */ }
struct A {};

Will the decl-specifier typename T::value_type  be considered as a type-requirement and evaluated to true or false?

So in my opinion the description is incomplete. It should describe such a case.

With best regards.
Vlad from Moscow

You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com
----------------------------------------------------------------------



STD-DISCUSSION list run by herb.sutter at gmail.com

Older Archives on Google Groups