From: Joel de Guzman (joel_at_[hidden])
Date: 2003-10-23 06:06:52
David B. Held <dheld_at_[hidden]> wrote:
> "David B. Held" <dheld_at_[hidden]> wrote in message
> It occurs to me that what is needed is a run-time analog of
> at<>, which has the same signature as get<> for tuples.
> Then I wouldn't need to convert to a tuple (though tuples do
> have a nice interface). How hard would that be?
template <int N, class S>
inline typename mpl::at_c<S, N>::type
typedef typename mpl::at_c<S, N>::type result;
However, be reminded that mpl::at has O(N) complexity.
The function could potentially generate lots of instantiations.
Well, the old tuples get<N> implementation is known to be
compile-time innefficient already.
template <class I>
inline typename mpl::deref<I>::type
typedef typename mpl::deref<I>::type result;
typedef mpl::list<int, char, std::string> tlist;
int i = *i1;
char c = *i2;
std::string s = *i3;
This is how it's done in Fusion.
-- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk