Boost logo

Boost :

From: Joel de Guzman (joel_at_[hidden])
Date: 2006-05-07 20:58:26


David Abrahams wrote:
> Tobias Schwinger <tschwinger_at_[hidden]> writes:
>
>> David Abrahams wrote:
>>> Tobias Schwinger <tschwinger_at_[hidden]> writes:
>>>
>>>
>>>> For those about to reply "don't use is_sequence" please answer this
>>>> question first:
>>>>
>>>> How to traverse a tree where the nodes are sequences and the leafes
>>>> are mpl::intS without it?
>>>
>>> Just reformulate the tree so that nodes are all wrapped in something
>>> you can recognize reliably:
>>>
>>> tree<
>>> list<
>>> tree<vector<int, long> >
>>> , tree<vector<long,int> >
>>> >
>>> >
>>>
>> Pretty nice for hard-wired input -- impractical in my case, though.
>> Why not make is_sequence work reliably?
>
> Because it's impossible. It's always going to look for some features
> of the type being tested that can be present even if the type is not,
> in fact, a sequence.

I don't see why it is impossible. MPL sequences can always
specialize is_sequence<T>. is_sequence *can* work reliably
100% of the time:

     template <class S>
     struct is_sequence : mpl::false_ {}; // default

     // your specializations here

Regards,

-- 
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