Yes, it is probably a weird question, but I tried a lot, and I started to think that maybe is impossible to overload this template function properly:
#include <iterator>
class Foo
{
private:
const int arr[5] = {10, 20, 30, 40, 50};
public:
const int* begin() const { return arr; }
friend auto std::begin<>(const Foo &f) -> decltype(f.begin());
}
It always throw the same error (in GCC 12.2.0):
main.cxx:10:13: error: template-id ‘begin<>’ for ‘const int* std::begin<>(const Foo&)’ does not match any template declaration
I just wanna know if is possible do things like this. Thanks.
Off topic, but if you’re injecting std into friends, they won’t be friends long.