[Boost-bugs] [Boost C++ Libraries] #9780: Error in boost_typetraits std::min example?

Subject: [Boost-bugs] [Boost C++ Libraries] #9780: Error in boost_typetraits std::min example?
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-03-16 01:28:41


#9780: Error in boost_typetraits std::min example?
--------------------------+------------------------------
 Reporter: evan.teran@… | Type: Bugs
   Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.55.0
 Severity: Cosmetic | Keywords:
--------------------------+------------------------------
 In the documentation for boost_typetraits, an example is given on how to
 improve std::min. However, at least at first glance it looks like there is
 a typo. The example reads:


 {{{
 template <class T, class U>
 typename common_type<T, U>::type min(T t, T u)
 {
    return t < u ? t : u;
 }
 }}}

 Notice that type `T` is being used for the argument `u`. If I understand
 the example better, the point is that the return type of `min` will be the
 correct type. But I would expect the `u` parameter to still have the type
 `U` **not** `T`.

 As it is, I believe that this code will cast the second parameter to type
 `T` when it is passed to the function.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9780>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC