[fusion] is there an adapter for C-arrays?

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? Thanks, _____________________ Vicente Juan Botet Escribá

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. Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net http://www.facebook.com/djowel Meet me at BoostCon http://www.boostcon.com/home http://www.facebook.com/boostcon

----- Original Message ----- From: "Joel de Guzman" <joel@boost-consulting.com> To: <boost@lists.boost.org> Sent: Sunday, February 07, 2010 1:20 AM Subject: Re: [boost] [fusion] is there an adapter for C-arrays?
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 don't know if I'm taking the good way. I need to apply a function to all the elements of a compound C++ type satisfying a given type constraint. For example, if I have struct Type { void f(); }; struct D1 : Type {}; struct D2 : Type {}; struct S1 { D1 d1; int i; }; struct S2 : Type { char c; S1 s1; D2 d2; }; S2 a[3]; I would like to apply f() to all the instances inheritig from Type, that is { a[0], a[1], a[2], a[0].s1.d1, a[1].s1.d1, a[2].s1.d1,a[0].d2, a[1].d2, a[2].d2} I think that I will need to see every type as a sequence, then make a flat view of the tree, restrict with a filter_view and last apply the function on the resulting sequence. Is there a simple way to implement this flat view? Or even better, is it already available? Best, Vicente

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/fusio... https://svn.boost.org/trac/boost/browser/sandbox/SOC/2009/fusion/boost/fusio...
[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_/t... https://svn.boost.org/trac/boost/browser/trunk/boost/fusion/algorithm/iterat... Unfortunately the code is pretty much broken at the moment. https://svn.boost.org/trac/boost/ticket/3858 -Christopher

On 2/7/2010 9:19 AM, Christopher Schmidt wrote:
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/fusio... https://svn.boost.org/trac/boost/browser/sandbox/SOC/2009/fusion/boost/fusio...
Cool! Can you backport that for non-C++0x compilers? Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net http://www.facebook.com/djowel Meet me at BoostCon http://www.boostcon.com/home http://www.facebook.com/boostcon

----- Original Message ----- From: "Christopher Schmidt" <mr.chr.schmidt@online.de> To: <boost@lists.boost.org> 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/fusio... https://svn.boost.org/trac/boost/browser/sandbox/SOC/2009/fusion/boost/fusio...
[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_/t... https://svn.boost.org/trac/boost/browser/trunk/boost/fusion/algorithm/iterat...
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. Do you know if it is planned to document the tree extension soon? Is there any post about this subject? 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. Thanks again, Vicente

vicente.botet schrieb:
----- Original Message ----- From: "Christopher Schmidt" <mr.chr.schmidt@online.de> To: <boost@lists.boost.org> 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/fusio... https://svn.boost.org/trac/boost/browser/sandbox/SOC/2009/fusion/boost/fusio...
[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_/t... https://svn.boost.org/trac/boost/browser/trunk/boost/fusion/algorithm/iterat...
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

----- Original Message ----- From: "Christopher Schmidt" <mr.chr.schmidt@online.de> To: <boost@lists.boost.org> Sent: Sunday, February 07, 2010 8:45 PM Subject: Re: [boost] [fusion] is there an adapter for C-arrays?
vicente.botet schrieb:
----- Original Message ----- From: "Christopher Schmidt" <mr.chr.schmidt@online.de> To: <boost@lists.boost.org> 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/fusio... https://svn.boost.org/trac/boost/browser/sandbox/SOC/2009/fusion/boost/fusio...
[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_/t... https://svn.boost.org/trac/boost/browser/trunk/boost/fusion/algorithm/iterat...
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
Hi, I've the impression you have introduced a interface break as before the array directory was for boost_array, and now is for POD arrays? I would prefer a hierarchycal directory fusion/adapted/boost/array.hpp fusion/adapted/boost/mpl.hpp fusion/adapted/boost/tuple.hpp fusion/adapted/boost/detail/array fusion/adapted/boost/detail/mpl fusion/adapted/boost/detail/tuple fusion/adapted/builtin/array.hpp fusion/adapted/builtin/struct.hpp fusion/adapted/builtin/detail/array fusion/adapted/builtin/detail/struct fusion/adapted/std/pair.hpp fusion/adapted/std/detail/pair The old files can be made deprecated includig the new ones. Now all the files are at the array level (detail directory has desapeared), so can be directly include by the user, thus my previous remark is still valid. Update C:\cygwin\home\Vicente\boost\trunk\boost\fusion\adapted\array\detail C:\cygwin\home\Vicente\boost\trunk\boost\fusion\adapted\array\array_iterator.hpp C:\cygwin\home\Vicente\boost\trunk\boost\fusion\adapted\array\size_impl.hpp C:\cygwin\home\Vicente\boost\trunk\boost\fusion\adapted\array\tag_of.hpp C:\cygwin\home\Vicente\boost\trunk\boost\fusion\adapted\array\value_at_impl.hpp C:\cygwin\home\Vicente\boost\trunk\boost\fusion\adapted\array\value_of_impl.hpp C:\cygwin\home\Vicente\boost\trunk\boost\fusion\adapted\array\category_of_impl.hpp C:\cygwin\home\Vicente\boost\trunk\boost\fusion\adapted\array\is_sequence_impl.hpp C:\cygwin\home\Vicente\boost\trunk\boost\fusion\adapted\array\at_impl.hpp C:\cygwin\home\Vicente\boost\trunk\boost\fusion\adapted\array\begin_impl.hpp C:\cygwin\home\Vicente\boost\trunk\boost\fusion\adapted\array\deref_impl.hpp C:\cygwin\home\Vicente\boost\trunk\boost\fusion\adapted\array\is_view_impl.hpp C:\cygwin\home\Vicente\boost\trunk\boost\fusion\adapted\array\end_impl.hpp At revision: 59579 Best, Vicente

vicente.botet schrieb:
----- Original Message ----- From: "Christopher Schmidt" <mr.chr.schmidt@online.de> To: <boost@lists.boost.org> Sent: Sunday, February 07, 2010 8:45 PM Subject: Re: [boost] [fusion] is there an adapter for C-arrays?
vicente.botet schrieb:
----- Original Message ----- From: "Christopher Schmidt" <mr.chr.schmidt@online.de> To: <boost@lists.boost.org> 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/fusio... https://svn.boost.org/trac/boost/browser/sandbox/SOC/2009/fusion/boost/fusio...
[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_/t... https://svn.boost.org/trac/boost/browser/trunk/boost/fusion/algorithm/iterat...
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
Hi,
I've the impression you have introduced a interface break as before the array directory was for boost_array, and now is for POD arrays?
I moved the functionality for boost::array to boost_array.hpp . boost_array.hpp is included by array.hpp though. https://svn.boost.org/trac/boost/browser/trunk/boost/fusion/adapted/array.hp... By the way, I did not document my changes. I would like to wait for an approval by Dan or Joel before introducing this new feature.
I would prefer a hierarchycal directory
fusion/adapted/boost/array.hpp fusion/adapted/boost/mpl.hpp fusion/adapted/boost/tuple.hpp fusion/adapted/boost/detail/array fusion/adapted/boost/detail/mpl fusion/adapted/boost/detail/tuple fusion/adapted/builtin/array.hpp fusion/adapted/builtin/struct.hpp fusion/adapted/builtin/detail/array fusion/adapted/builtin/detail/struct fusion/adapted/std/pair.hpp fusion/adapted/std/detail/pair
The old files can be made deprecated includig the new ones.
I used file prefixes in the c++0x port (array.hpp, boost_array.hpp, std_array.hpp) to distinguish between specific types and/or namespaces.
From a plain technical point of view this is a more convenient as the detail implementation of certain types may be shared across namespaces.
https://svn.boost.org/trac/boost/browser/sandbox/SOC/2009/fusion/boost/fusio... -Christopher

----- Original Message ----- From: "Christopher Schmidt" <mr.chr.schmidt@online.de> To: <boost@lists.boost.org> Sent: Sunday, February 07, 2010 10:02 PM Subject: Re: [boost] [fusion] is there an adapter for C-arrays?
vicente.botet schrieb:
Hi,
I've the impression you have introduced a interface break as before the array directory was for boost_array, and now is for POD arrays?
I moved the functionality for boost::array to boost_array.hpp . boost_array.hpp is included by array.hpp though.
https://svn.boost.org/trac/boost/browser/trunk/boost/fusion/adapted/array.hp...
Do you mean that the files in 1.42, boost\fusion\adapted\array\* where not public,and that only the files at the adaptee level where public?
I used file prefixes in the c++0x port (array.hpp, boost_array.hpp, std_array.hpp) to distinguish between specific types and/or namespaces.
From a plain technical point of view this is a more convenient as the detail implementation of certain types may be shared across namespaces.
https://svn.boost.org/trac/boost/browser/sandbox/SOC/2009/fusion/boost/fusio...
Yes, this is more coherent than the current file naming, BTW mpl.hpp doesn't follows the rule. Vicente

On 2/8/2010 5:02 AM, Christopher Schmidt wrote:
I've the impression you have introduced a interface break as before the array directory was for boost_array, and now is for POD arrays?
I moved the functionality for boost::array to boost_array.hpp . boost_array.hpp is included by array.hpp though.
https://svn.boost.org/trac/boost/browser/trunk/boost/fusion/adapted/array.hp...
By the way, I did not document my changes. I would like to wait for an approval by Dan or Joel before introducing this new feature.
FWIW, I'm for the change as long as it is documented in a prominent place. The change is consistent with boost_tuple and std_pair. Slightly off-topic: Christopher, while I got your attention, if you have some cycles to spare, I'd also like to request some feature additions that need to be done but I've not gotten to do it: fusion-adapt-struct for templates (e.g. std::pair<...>). This is one of the most often requested feature. Of course, this applies to adapt-assoc-struct too and the new adapt-class. These critters come to be one of the most used features of fusion. Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net http://www.facebook.com/djowel Meet me at BoostCon http://www.boostcon.com/home http://www.facebook.com/boostcon

On 2/8/2010 6:45 AM, Christopher Schmidt wrote:
Check the (undocumented) code in the ext_-directories.
https://svn.boost.org/trac/boost/browser/trunk/boost/fusion/container/ext_/t... https://svn.boost.org/trac/boost/browser/trunk/boost/fusion/algorithm/iterat...
Unfortunately the code is pretty much broken at the moment.
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. <snip>
Here's the deal: the code needs a complete rewrite. The original idea was to make it vastly simpler to adapt a segmented data structure to Fusion and greatly lower the burden Fusion algorithms place on compilers. The problem is that -- for decent compile times -- it requires a separate segmented version of every Fusion algorithm, which I never got around to. Also, the segmented view is forward, and had I done it right, it would be bidirectional. Then the Fusion code base shifted and broke the extension. In all my days of writing code, 2 coding problems stand out as particularly difficult: reference tracking of xpressive::basic_regex, and Fusion's segmented extension. To rewrite Fusion's segmented extension, I'll need several weeks of free time, which I just haven't had. I've always meant to get back to it, and still hope to. -- Eric Niebler BoostPro Computing http://www.boostpro.com
participants (4)
-
Christopher Schmidt
-
Eric Niebler
-
Joel de Guzman
-
vicente.botet