In the following code clang complains that there exist no conversion operator:
class A{
public:
operator int () const {return i;}
A(int i_): i(i_) {}
template<class B>
friend auto operator * (const B& l, A&& r)
-> decltype(l * int(std::move(r))){
return l * int(std::move(r));
}
int i;
};
This happens with all clang versions 6-9, see https://godbolt.org/z/ELuRHp. The error message is as follows:
<source>:11:19: error: cannot convert 'typename std::remove_reference<A &>::type' (aka 'A') to
'int' without a conversion operator
-> decltype(l * int(std::move(r))){
^~~~~~~~~~~~~~~~
The same code compiles with gcc 7-9 just fine, so I'm wondering if this is a bug in clang or maybe the code is not correct.
Edit: A shorter version of the same error, which was provided by @daniel-langr, can be found here https://godbolt.org/z/Krnh27.
The original code example is a simplified version of a class in our code base, hence the unnecessary decltype.