I am writing a class in which I am overloading operator[] and I want one function to have vector as input and the second one to have vector of vectors as input, but when I call it like
obj[{ 0 }]
then I got ambigious call error. The functions are declared like
const Tensor operator[](const std::vector<std::vector<uint32_t>>& ranges) const;
const float operator[](const std::vector<uint32_t>& index) const;
Is there any way to handle that ambiguity?
>Solution :
The compiler has no way of knowing by seeing the argument {0} which one to choose among the two equally ranked overloads.
One way to resolve the ambiguity is to explicitly tell the compiler as shown below:
obj[std::vector<uint32_t>{0}]; //calls #2
obj[std::vector<std::vector<uint32_t>>{0}]; //calls #1