Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-10-23 08:48:19


"Joel de Guzman" <joel_at_[hidden]> writes:

> How about:
>
> template <class I>
> inline typename mpl::deref<I>::type
> operator*(I)
> {
> typedef typename mpl::deref<I>::type result;
> return result();
> }
>
> Then:
>
> typedef mpl::list<int, char, std::string> tlist;
>
> mpl::begin<tlist>::type i1;
> int i = *i1;
>
> mpl::next<i1>::type i2;
> char c = *i2;
>
> mpl::next<i2>::type i3;
> std::string s = *i3;
>
> This is how it's done in Fusion.

Aren't you a little worried about introducing such a general overload
for operator*, even though mpl::deref does tend to limit it through
SFINAE a bit?

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk