Boost logo

Boost :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2003-04-09 05:04:26

"Eric Friedman" <ebf_at_[hidden]> wrote in message
> Gennadiy Rozental wrote:
> [snip]
> > 2. Does not add support for const types and document how const variant
> could
> > be implemented in specific case. User willing to use variant in generic
> > solution will need to select 'variant'/'variant const' himself.
> I'm not sure what this documentation would look like. Perhaps you could
> detail a particular case where you see potential difficulty for the user
> we could work from there.
> Thanks,
> Eric

template<typename T1,typename T2>
struct my_struct
    boost::variant<T1,T2> m_value;

Here if user want to add support for const T1 and T2 he will need to do
something like:

template<typename T1,typename T2>
struct my_struct
    typedef boost::mpl::if_<boost::is_const<T1>::value,boost::variant<T1,T2>
const,boost::variant<T1,T2> >::type value_type;

    value_type m_value;

In all other cases one should be able to use variant<> const form of
expression to achieve const variant. These both points worth documenting


Boost list run by bdawes at, gregod at, cpdaniel at, john at