Boost logo

Boost Users :

Subject: Re: [Boost-users] how to compare fusion adapted structures
From: Christopher Schmidt (mr.chr.schmidt_at_[hidden])
Date: 2010-05-06 10:04:52


Olaf Peter schrieb:
> Hi,
>
> in my project I do have a lot of fusion adapted structures (due to use
> for/with spirit).

Just a note aside: starting with release 1.43 you are able to define
fusion sequences in situ. If you just need public attributes in your
structs, without helper functions, you can probably save some typing. See

http://www.boost.org/doc/libs/1_43_0/libs/fusion/doc/html/fusion/adapted/define_struct.html

for more information.

> Now I want to compare them. How to reuse the informations? In the
> example attached, I show the (imo) complicated way using
> fusion::vector_tie. I would like reuse the BOOST_FUSION_ADAPT_STRUCT
> macro since it generates tag_of<>, struct_member<>, struct_member_name<>
> , struct_size<> etc.

fusion::equal_to or fusion::operator== (defined in
<boost/fusion/sequence/comparison/equal_to.hpp>) should work fine.

> At
> http://www.boost.org/doc/libs/1_42_0/libs/fusion/doc/html/fusion/extension/ext_full.html
> there is the full blown feature shown how to adapt the structure for a
> fusion iterator. What do I really need for simple comparing? Is it the
> way to use? Even simpler one?
[snip]

Adapting a class-type includes generation of the necessary boilerplate
for iteration. In fact, there should not be any difference between one
of the provided random access sequences (such as fusion::vector) and an
adapted sequence.

-Christopher


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