MPL: Arguments to transform metafunction

Hi All, I have a doubt regarding the arguments to the mpl::transform metafunction. In the MPL book (page 42), the mpl::transform is presented as follows: template <class Sequence1, class Sequence2, class BinaryOperation> struct transform; Here mpl::transform takes 2 sequences and a binary operation and it results in a sequence. But in a later portion of the book (page 124), while discussing about sequence building algorithms, the following is presented: typedef mpl::vector_c<int, 1, 2, 3> v123; typedef mpl::plus<_1, mpl::int_<5> > add5; typedef mpl::transform<v123, add5>::type v678; Here mpl::transform takes 1 sequence and a unary operation and it results in a sequence. How does mpl::transform supports such different arguments? Rgds, anna

AMDG Missing Rainbow wrote:
Here mpl::transform takes 2 sequences and a binary operation and it results in a sequence.
<snip>
Here mpl::transform takes 1 sequence and a unary operation and it results in a sequence. How does mpl::transform supports such different arguments?
mpl::transform is "overloaded" to handle either 1 or 2 sequences. The actual definition is something like: template<class Sequence1, class Sequence2OrUnaryOperation, class BinaryOperation = na> struct transform : transform2<Sequence1, Sequence2OrUnaryOperation, BinaryOperation> {}; template<class Sequence1, class UnaryOperation> struct transform<Sequence, UnaryOperation> : transform1<Sequence1, UnaryOperation> {}; In Christ, Steven Watanabe
participants (2)
-
Missing Rainbow
-
Steven Watanabe