Boost logo

Boost Users :

Subject: Re: [Boost-users] Fwd: Describing "traits" of a class's members
From: Chris Stankevitz (chrisstankevitz_at_[hidden])
Date: 2013-03-02 03:24:20


On Wed, Feb 27, 2013 at 5:13 PM, Steven Watanabe <watanabesj_at_[hidden]> wrote:
>> Can you modify the attached program so that the object
>> TCPositionTraits holds all the traits for the TCPosition object. Not
>> just the traits for the "double" parameters, as is currently the case.
>> Notably missing from TCPositionTraits is a reference to
>> TCPosition::mSteps.
>
> That's actually pretty easy:

> typedef boost::variant<
> TSItemImpl<double>,
> TSItemImpl<unsigned> > TSItem;
>
> then use boost::apply_visitor for all
> operations on TSItems.

Steven,

Thank you for your help with this. I have reworked my code to use
boost::variant and am happy with it(*):

https://github.com/chrisstankevitz/trait

(*) I am working right now to remove the hard-coded references to
TCTraitsDouble and TCTraitsUnsigned within Traitses.h and instead make
them user-definable via variadic template arguments. I have a
question outstanding at comp.lang.c++.moderated which will hopefully
give me some direction in that effort.

Thank you again for your help and time diving in and understanding
what I am attempting to do!

Chris


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