I have an incredibly exciting library that can translate points: it should work with any point types
template
auto translate_point(T &p, int x
With SFINAE, I would do something like this:
template
auto translate_point(T &p, int x, int y) -> decltype(p[0], void())
{
p[0] += x;
p[1] += y;
}
template::value>
auto translate_point(T &p, int x, int y) -> decltype(p.x, p.y, void())
{
p.x += x;
p.y += y;
}
By doing this, when T = (class with StupidPoint
as base class), the second overload will be called.
But it is easier with a simple overload, as pointed out by m.s.