Boost logo

Boost Users :

Subject: Re: [Boost-users] [fusion][mpl][array] making boost array a conforming mpl sequence (through fusion)
From: Stjepan Rajko (stjepan.rajko_at_[hidden])
Date: 2009-02-12 12:12:25


Joel,

On Tue, Feb 10, 2009 at 8:10 PM, Joel de Guzman
<joel_at_[hidden]> wrote:
> Stjepan Rajko wrote:
>>
>> Hi,
>>
>> I tried to make boost::array a conforming MPL sequence by including:
>>
>> #include <boost/fusion/adapted/array.hpp> // makes array a conforming
>> fusion sequence
>> #include <boost/fusion/mpl.hpp> // makes fusion sequences conforming
>> MPL sequences
>>
>> but,
>>
>> typedef boost::array<int, 1> array;
>> assert(boost::mpl::is_sequence<array>::type::value); // fails
>>
>> Am I misinterpreting the fusion documentation in expecting that this
>> should work? Is there another way of making boost::array an mpl
>> sequence?
>
> I think the basic problem is that is_sequence is not really part
> of the requirements for an MPL sequence. You don't have to be a
> conforming MPL sequences. I am not sure how to best approach this.
> Perhaps the MPL authors have a better idea?
>

I was able to get the fusion-adapted boost::array to be a conforming
mpl sequence by adding:

namespace boost { namespace mpl {

template<typename T, std::size_t N>
struct tag<boost::array<T,N> >
{
    typedef boost::fusion::fusion_sequence_tag type;
};

template<typename T, std::size_t N>
struct sequence_tag<boost::array<T,N> >
{
    typedef boost::fusion::fusion_sequence_tag type;
};

}}

Best,

Stjepan


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net