M
mm298309
To the anonymous editor of Template(programming) on wikipedia
Please see the article's talk page, http://en.wikipedia.org/wiki/Talk:Template_(programming).
To keep this on topic:
template <typename L, typename R>
typename promote<L, R>::type max(const L &left, const R &right)
{
return (left > right) ? left : right;
}
is a nice idea, but it has unexpected results with something like:
int j = max(-1, 0u); // implementation-defined behaviour
Of course, it's still better than:
const int& j = std::max(1,1);
int i = j; // UB
Please see the article's talk page, http://en.wikipedia.org/wiki/Talk:Template_(programming).
To keep this on topic:
template <typename L, typename R>
typename promote<L, R>::type max(const L &left, const R &right)
{
return (left > right) ? left : right;
}
is a nice idea, but it has unexpected results with something like:
int j = max(-1, 0u); // implementation-defined behaviour
Of course, it's still better than:
const int& j = std::max(1,1);
int i = j; // UB