Here is the simple example:
#include <type_traits>
#include <ranges>
#include <vector>
struct MyClass
{
void f( int ) {}
void f( char ) {}
template <std::ranges::input_range Rng>
requires requires ( MyClass cls, const std::ranges::range_value_t<Rng>& val )
{
{ cls.f( val ) };
}
void f( Rng&& rng ) {}
};
int main()
{
MyClass cls;
cls.f( 10 );
cls.f( 'a' );
cls.f( std::vector<int>{ 10, 15 } );
}
According to Godbolt this example compiles successfully on MSVC and GCC, but fails to compile on Clang. What does the standard say about such require-expressions?
Update: we might simplify the example so that there is no circularity in methods calls (Godbolt):
#include <type_traits>
#include <ranges>
#include <vector>
struct MyClass
{
void g( int ) {}
void g( char ) {}
template <std::ranges::input_range Rng>
requires requires ( MyClass cls, const std::ranges::range_value_t<Rng>& val )
{
{ cls.g( val ) };
}
void f( Rng&& rng ) {}
};
int main()
{
MyClass cls;
cls.g( 10 );
cls.g( 'a' );
cls.f( std::vector<int>{ 10, 15 } );
}
The compilers act the same way as for the original example.