|
Boost : |
Subject: Re: [boost] [fusion] is there an adapter for C-arrays?
From: Christopher Schmidt (mr.chr.schmidt_at_[hidden])
Date: 2010-02-07 14:45:17
vicente.botet schrieb:
> ----- Original Message -----
> From: "Christopher Schmidt" <mr.chr.schmidt_at_[hidden]>
> To: <boost_at_[hidden]>
> Sent: Sunday, February 07, 2010 2:19 AM
> Subject: Re: [boost] [fusion] is there an adapter for C-arrays?
>> vicente.botet schrieb:
>>>> On 2/7/2010 3:34 AM, vicente.botet wrote:
>>>>> Hi,
>>>>>
>>>>> I need to visit the members of a C++ type using Fusion sequences. For structures I plan
>>>>> to use BOOST_FUSION_ADAPT_STRUCT. I need also to visit also c-arrays (with static
>>>>> size). I see that there is already an adapter for boost::array. Is there an adapter for
>>>>> C-arrays?
>>>>
>>>> Sorry, no. Would you want to contribute one? It's easy if you
>>>> take a look at the boost::array adapter.
>>>
>>> Hi,
>>>
>>> Well if doesn't exists I will need to see how to do it :) I will inform you when I reach to get something.
>>
>> I just added an implementation for adapting plain arrays to the c++0x
>> branch of fusion. You can find the code here:
>>
>> https://svn.boost.org/trac/boost/browser/sandbox/SOC/2009/fusion/boost/fusion/adapted/array.hpp
>> https://svn.boost.org/trac/boost/browser/sandbox/SOC/2009/fusion/boost/fusion/adapted/detail/po_array
>>
>>>
>> [snip]
>>>
>>> Is there a simple way to implement this flat view? Or even better, is it already available?
>>
>> It is. Check the (undocumented) code in the ext_-directories.
>>
>> https://svn.boost.org/trac/boost/browser/trunk/boost/fusion/container/ext_/tree.hpp
>> https://svn.boost.org/trac/boost/browser/trunk/boost/fusion/algorithm/iteration/ext_/for_each_s.hpp
>>
>> Unfortunately the code is pretty much broken at the moment.
>>
>> https://svn.boost.org/trac/boost/ticket/3858
>>
>> -Christopher
>
> Hi,
>
> thanks for all these pointers. I was starting to implement it,when DING, your post appeared. I'm sure I would made a lot of errors before reaching to run the test.
I ported my code to the trunk. Update to the HEAD and include
<boost/fusion/adapted/array.hpp> in your code.
> Do you know if it is planned to document the tree extension soon? Is there any post about this subject?
The segmented extension is pretty much proto specific in its current
form. From my limited point of view, it still needs some work in order
to be a useful component aside of Spirit/Proto-alike use-cases.
Unfortunately Eric Niebler, the original author, has not continued
development on this extension. For more information, see the old posts
in the archives.
http://lists.boost.org/Archives/boost/2006/09/110708.php
As the code is broken, undocumented and may change in the future, I
suggest you to connect your fusion sequences recursively via
fusion::fold and fusion::join.
> Just a remark most of the .hpp files on po_array are not self contained as the structure po_array_tag is not declared in th file.
the *.hpp-files in the detail folder are not meant to be included by the
user. po_array_tag is defined in /detail/tag_of.hpp, which is always
included by array.hpp before any other /detail/*_impl.hpp-header.
-Christopher
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk