Boost logo

Boost Users :

Subject: [Boost-users] [Tuple] augment_tuple, patch, or whatever... maybe MPL?
From: Hossein Haeri (powerprogman_at_[hidden])
Date: 2010-11-23 07:05:19


Dear all,

Is there any function in Boost.Tuple which works like this for n-tuples for any given n?

template<typename T1, typename T2, typename T3>
tuples::tuple<T1, T2, T3> augment_tuple(tuples::tuple<T1, T2> tup, T3 t3)
{
  return tuples::make_tuple(tup.get<0>(), tup.get<1>(), t3);
}

(Obviously, here n == 2.) The purpose of this augment_tuple (or, patch, or whatever) is to take an n-tuple and a new element and patch the new element to the end of the n-tuple in order to get a (n + 1)-tuple. Repetitive code which can produce enough overloads for a large enough n is of course trivial. I'm wondering whether MPL has a utility which can automated this though?

TIA,
--Hossein


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net