|
Boost Users : |
Subject: Re: [Boost-users] Fusion: Structs containing an array
From: TONGARI (tongari95_at_[hidden])
Date: 2011-02-02 12:11:20
2011/2/1 Gunther Laure <gunther.laure_at_[hidden]>
> Hi!
>
> I am trying to use boost fusion to build [de]serializer for simple types
> (int ...) and structs.
> I had success until I tried structures holding arrays.
>
> Example:
> struct EntryTable
> {
> unsigned int count;
> unsigned int data[4];
> };
>
> BOOST_FUSION_ADAPT_STRUCT(
> EntryTable,
> (unsigned int, count)
> (unsigned int, data[4])
> )
[...]
> fusion::vector<unsigned int, unsigned int[4]> f2 = t; // doesnt work (not
> even compile)
[...]
> What am I doing wrong? Is there a simple way to simple wrap an array using
> fusion?
>
It's infeasible to use C-array here since there's no assignment for such.
Use Boost.Array instead.
Sample code
---------------------
typedef boost::array<unsigned int, 4> array_t;
struct EntryTable
{
unsigned int count;
boost::array<unsigned int, 4> data;
};
BOOST_FUSION_ADAPT_STRUCT(
EntryTable,
(unsigned int, count)
(array_t, data)
)
...
EntryTable t;
fusion::vector<unsigned int, array_t> f2 = t; // now it should work
HTH
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