Subject: Re: [boost] [generic programming] header file for general "default" operations for C++ classes
From: Walt Karas (wkaras_at_[hidden])
Date: 2016-05-05 12:03:42
Gavin Lambert <gavinl <at> compacsort.com> writes:
> On 5/05/2016 07:45, Walt Karas wrote:
> > Yes, but there is not full overlap of the capabilities. Fusion doesn't seem
> > to provide a way to define a class with access control, base classes, and
> > member functions as a sequence. I'm assuming BOOST_FUSION_DEFINE_STRUCT has
> > no runtime overhead, although I could not find and explicit statement to
> > that effect.
> If you put all the members that should participate in the comparison
> into the fusion sequence, you can then wrap this sequence in another
> class with base classes and other methods.
> Depending on requirements, the fusion sequence could either be another
> base class, or it could be a member of the wrapper class with the
> wrapper class defining delegating operators for the comparisons.
Good point. However, I don't see that BOOST_FUSION_DEFINE_STRUCT (or any
other Fusion facility) can create a class with base classes that are also in
the sequence along with the data members. Also, under the approach you
describe, all data members would have to have the same access (private,
protected or public).
To clarify, what I propose (as well as the approach using fusion) is more
general than just comparison operators. Please see the example function
pad_bytes() in tst.cpp.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk