To the anonymous editor of Template(programming) on wikipedia

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top