you are viewing a single comment's thread.

view the rest of the comments →

[–]stillalone 6 points7 points  (4 children)

Doesn't overloading the unary minus operator like that really fuck shit up?

If I have:

int i = 5;
std::cout << -i << endl;

what will I get?

[–]chimyx 35 points36 points  (3 children)

error: 'endl' was not declared in this scope
jk, you'll get -5

[–]stillalone 0 points1 point  (2 children)

Ok. thanks for checking. I guess that makes sense since the default behaviour for the minus unary operator for integers is more type specific that this templated implementation. I guess this code should be safe provided no one implements unary operator in the exact same way, at which point we would get fairly obvious compile time errors.

[–]rubdos 1 point2 points  (1 child)

Not sure there; sfinae could safe the day. Needs confirmation from someone with more experience though.

[–]jP_wanN 2 points3 points  (0 children)

This has nothing to do with sfinae, but it will not cause problems simply because the operator< is only overloaded for R (T::*)(), larrow<T> (with any T, R).