[fusion] how to get the tuple of min values of 2 tuples whatever their length?

I have two tuples:
typedef boost::tuple

On 7/17/2013 7:17 AM, Frédéric Bron wrote:
Have you tried the binary version of fusion::transform described at: http://www.boost.org/doc/libs/1_54_0/libs/fusion/doc/html/fusion/algorithm/t... You'll need a polymorphic function object wrapping std::min(unless fusion has an adapter), something like(untested): struct PolyMin { template<typename T> struct result { typedef typename boost::remove_const< typename boost::remove_reference<T>::type>::type type; }; template<typename T> T operator()(const T& lhs, const T& rhs) const { return (std::min)(lhs, rhs); } }; Jeff

On 07/17/2013 01:17 PM, Frédéric Bron wrote:
Others have already pointed you to fusion::transform. There is a complete example of this in the documentation, albeit it does pairwise subtraction instead of min: http://www.boost.org/fusion/doc/html/fusion/functional/adapters/fused_functi...

Thank you all!
It works now with the code below.
What was the most difficult was to find the headers to include.
Frédéric
#include <iostream>
#include <string>
#include

I'm curious, wouldn't fusion's binary transform algorithm work for you? c = boost::fusion::transform(a, b, min());
Much simpler indeed! Thanks. Below is the full code.
The part with struct result is a bit strange to me!
I do not understand what Self(T, T) means.
Frédéric
#include <iostream>
#include <string>
#include

The part with struct result is a bit strange to me! I do not understand what Self(T, T) means.
See [1] and [2]. Regards, Nate [1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1454.html [2] http://www.boost.org/doc/libs/1_54_0/libs/utility/utility.htm#result_of
participants (5)
-
Bjorn Reese
-
Frédéric Bron
-
Jeff Flinn
-
Nathan Ridge
-
TONGARI J