I'm trying to overload binary operator+ for nested template class with clang and got the error invalid operands to binary expression. Note: candidate template ignored: couldn't infer template argument T. Something like:
template<typename T>
class Container
{
struct Iterator {
template<typename U>
friend typename Container<U>::Iterator operator+(size_t, typename Container<U>::Iterator const&);
};
};
template<typename U>
typename Container<U>::Iterator
operator+(size_t, typename Container<U>::Iterator const&)
{
return Container<U>::Iterator{};
}
Is there way to overload binary operators for nested template class using clang compiler?
C++17 can be used.
::is an undeduced context. It's not possible to deduceU.