|
Boost Users : |
Subject: Re: [Boost-users] [fusion] making an inner struct boost fusion compatible?
From: Oswin Krause (Oswin.Krause_at_[hidden])
Date: 2012-09-24 05:04:25
Hi,
so after a weekend of thinking about this issue, i am still not much
nearer to an solution.
Everything begins with that i want to automatically adapt a structure
to the needs of my library.
which is:
1. it is fusion compatible such that it's elements form a fusion
seqeunce(easy)
2. there exist a container type storing the structure such, that for
every element of structure a container exists (also easy).
3. These containers now shall also be a fusion sequence (aparently
hard).
Th idea is, that one an algorithm can decide to only work on a small
fraction of the heterogenous data having a nice memory layout at the
same time.
This is my approach which failed:
//slightly simplified example
struct SomeStruct{
int a;
float b;
};
//specialisation for my interface. Will be a macro.
template<>
struct SequenceType<SomeStruct>{//sequence type of the structure i want
to create
struct type: boost::fusion::sequence_facade<
type,
boost::fusion::random_access_traversal_tag
> {
//create fusion sequence interface
BOOST_FUSION_DEFINE_STRUCT_MEMBERS_IMPL(type,
(std::vector<int>,a)(std::vector<float>b))
//sequence interface
typedef SomeStruct value_type;
struct reference{...};//reference to an element
struct const_reference{...};
typedef ProxyIterator<type, value_type, reference > iterator;
typedef ProxyIterator<const type, value_type, const_reference >
const_iterator;
iterator begin(){...}//naming collision :(
const_iterator begin()const{...}//naming collision :(
iterator end(){...}//naming collision :(
const_iterator end()const{...}//naming collision :(
};
....
};
so what would be a good solution for my problem?
On 2012-09-21 09:52, Nathan Ridge wrote:
>> thanks for the reply.
>> Is it possible to just copy and rename the macro, or does it depend
>> on
>> newer features of fusion? I need to be compatible with boost 1.45 so
>> i
>> can't use it directly (also i need to add a few more functions to
>> the
>> structure later on)
>
> BOOST_FUSION_DEFINE_STRUCT_INLINE is implemented using the
> sequence_facade
> and iterator_facade extension mechanisms, which were present in Boost
> 1.45
> [1] [2]. So, it should be straightforward to back-port the macro to
> 1.45.
>
> Regards,
> Nate
>
> [1]
>
> http://www.boost.org/doc/libs/1_45_0/libs/fusion/doc/html/fusion/extension/sequence_facade.html
> [2]
>
> http://www.boost.org/doc/libs/1_45_0/libs/fusion/doc/html/fusion/extension/iterator_facade.html
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
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