On Wed, Oct 6, 2010 at 12:56 PM, alfC
Hi,
Excuse my simple minded questions. Sometimes by asking this question (often with negative answer) I understand more on the design of the Boost libraries.
Besides possible redundancy, why is that the fusion containers, for example fusion::vector, doesn't have a template member function to extract elements?
fusion::vector
stuff(1.2, 3, "hola"); stuff.at<2>(); //returns "hola", just like at_c<2>(stuff); Wouldn't it be more consistent with std::vector v, v[2] or v.at(2);
No, because things like std::vector is an implementation class, hence
it can be done in any way they want, however fusion does not have that
luxury, for example, boost::array is defined as a fusion container, so
you can do something like this:
template<typename T>
void printSecondElement( const T &t )
{
std::cout << *next(begin(t));
}
Now, you can do something like this with it:
fusion::vector