Lets consider the following code (compiles successfully with clang++ 7.0.0, compiler arguments are -std=c++17 -Wall -Wextra -Werror -pedantic-errors):
#include <iostream>
struct Foo
{
template <typename Type = void>
operator int()
{
return 42;
}
};
int main()
{
const auto i = Foo{}.operator int();
std::cout << i << std::endl;
}
Is it possible to call such templated user-defined conversion operator with explicitly provided template arguments? The naive approach doesn't compile:
const auto i = Foo{}.operator int<bool>();