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. Advertisements

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:
    985
    Stylus Studio
    Aug 3, 2004
  2. Chris Theis
    Replies:
    2
    Views:
    631
    Chris Theis
    Jul 24, 2003
  3. Casey Hawthorne
    Replies:
    4
    Views:
    1,311
    Jarek Zgoda
    Aug 4, 2006
  4. Reporter
    Replies:
    3
    Views:
    664
    Mike Schilling
    May 12, 2007
  5. Replies:
    1
    Views:
    2,279
    Gianni Mariani
    Jun 8, 2007
  6. Peng Yu
    Replies:
    3
    Views:
    984
    Thomas J. Gritzan
    Oct 26, 2008
  7. nguillot
    Replies:
    5
    Views:
    812
  8. Replies:
    1
    Views:
    366
Loading...