I'm using boost::fusion.
Lets say I have something like the following:
make_vector(1, make_vector('b', 3, make_vector(4, 5.5), "six"), 7, 8)
I want to produce an function f such that
f(make_vector(1, make_vector('b', 3, make_vector(4, 5.5), "six"), 7, 8))
-> [1, 'b', 3, 4, 5.5, "six", 7, 8]
i.e. a flattened version of the sequence.
I don't mind if this is a view of the original sequence or an actual vector.
I don't mind a solution in C++0x if it can compile on GCC 4.5.1.
Note:
Whilst I'd prefer not to restrict the data elements, if it helps, feel free to require that the "data" elements all derive from a common base class.
i.e.
class DataBase {}
template <class T>
class Data : public DataBase
{
public:
Data(const T& x) : m_x(x)
T m_x;
}
template <class T>
T make_data(const T& x) { return Data<T>(x); }
Then
make_vector(
make_data(1),
make_vector(
make_data('b'),
make_data(3),
make_vector(
make_data(4),
make_data(5.5)
),
make_data("six")
),
make_data(7),
make_data(8)
)
I figure then you can work out what the data elements are by using "is_base_of".