To the anonymous editor of Template(programming) on wikipedia

Discussion in 'C++' started by mm298309@spamcorptastic.com, Jan 23, 2009.

  1. Guest

    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
    , Jan 23, 2009
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stylus Studio
    Replies:
    0
    Views:
    655
    Stylus Studio
    Aug 3, 2004
  2. T.J.
    Replies:
    7
    Views:
    10,485
    Andy Dingley
    Apr 18, 2005
  3. Casey Hawthorne
    Replies:
    4
    Views:
    998
    Jarek Zgoda
    Aug 4, 2006
  4. Reporter
    Replies:
    3
    Views:
    470
    Mike Schilling
    May 12, 2007
  5. Replies:
    1
    Views:
    220
Loading...

Share This Page