Inconsistency between std::minmax and boost::minmax

So, C++11 has been approved, and in the new standard library, there is: template <typename T> std::pair<const T&, const T&> minmax ( const T& a, const T& b ) but in Boost, we've got: template <typename T> tuple< T const&, T const& > minmax(T const& a, T const& b) { I can easily change boost minmax to return a pair instead of a 2-element tuple, but that's an interface change, and might break existing code. On the other hand, giving them the same interface will make it easier for people to move to C++11's library functions. Any opinions? ideas? -- Marshall P.S. boost::minmax_element, on the other hand, already returns a pair, not a two-element tuple. I'm pretty sure it doesn't satisfy the C++ complexity requirements, but that's easily fixed.

On Fri, Feb 24, 2012 at 1:52 PM, Marshall Clow <mclow.lists@gmail.com>wrote:
So, C++11 has been approved, and in the new standard library, there is:
template <typename T> std::pair<const T&, const T&> minmax ( const T& a, const T& b )
but in Boost, we've got: template <typename T> tuple< T const&, T const& > minmax(T const& a, T const& b) {
I can easily change boost minmax to return a pair instead of a 2-element tuple, but that's an interface change, and might break existing code.
On the other hand, giving them the same interface will make it easier for people to move to C++11's library functions.
Any opinions? ideas?
I could be wrong about this, but wouldn't that be problematic for C++03 std::pair, which (typically) barfs when instantiated with reference types? - Jeff

On Feb 24, 2012, at 2:00 PM, Jeffrey Lee Hellrung, Jr. wrote:
On Fri, Feb 24, 2012 at 1:52 PM, Marshall Clow <mclow.lists@gmail.com>wrote:
So, C++11 has been approved, and in the new standard library, there is:
template <typename T> std::pair<const T&, const T&> minmax ( const T& a, const T& b )
but in Boost, we've got: template <typename T> tuple< T const&, T const& > minmax(T const& a, T const& b) {
I can easily change boost minmax to return a pair instead of a 2-element tuple, but that's an interface change, and might break existing code.
On the other hand, giving them the same interface will make it easier for people to move to C++11's library functions.
Any opinions? ideas?
I could be wrong about this, but wouldn't that be problematic for C++03 std::pair, which (typically) barfs when instantiated with reference types?
Unfortunately, all I can find is
late after the review, as I finally scrounged to add the library for a release, Eric Niebler noted the bad behavior of std::pair for minmax and suggested to use Boost.tuple instead.
Does anyone have a link to this discussion? -- Marshall Marshall Clow Idio Software <mailto:mclow.lists@gmail.com> A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait). -- Yu Suzuki

On 2/24/2012 4:58 PM, Marshall Clow wrote:
On Feb 24, 2012, at 2:00 PM, Jeffrey Lee Hellrung, Jr. wrote:
On Fri, Feb 24, 2012 at 1:52 PM, Marshall Clow <mclow.lists@gmail.com>wrote:
So, C++11 has been approved, and in the new standard library, there is:
template <typename T> std::pair<const T&, const T&> minmax ( const T& a, const T& b )
but in Boost, we've got: template <typename T> tuple< T const&, T const& > minmax(T const& a, T const& b) {
I can easily change boost minmax to return a pair instead of a 2-element tuple, but that's an interface change, and might break existing code.
On the other hand, giving them the same interface will make it easier for people to move to C++11's library functions.
Any opinions? ideas?
I could be wrong about this, but wouldn't that be problematic for C++03 std::pair, which (typically) barfs when instantiated with reference types?
Unfortunately, all I can find is
late after the review, as I finally scrounged to add the library for a release, Eric Niebler noted the bad behavior of std::pair for minmax and suggested to use Boost.tuple instead.
Does anyone have a link to this discussion?
Not offhand, but I can tell you that my objection was precisely because C++03 std::pair cannot hold references. -- Eric Niebler BoostPro Computing http://www.boostpro.com
participants (3)
-
Eric Niebler
-
Jeffrey Lee Hellrung, Jr.
-
Marshall Clow