Boost logo

Boost :

From: Richard Crossley (rdc_at_[hidden])
Date: 2005-02-10 01:57:27


Why use bind here at all?

How about just...

template<class Archive>
struct save_visitor : boost::static_visitor<>{
save_visitor(Archive& ar)
        : m_ar(&ar)
{
}
template<class T>
void operator()(T const & value) const
{
        (*m_ar) << BOOST_SERIALIZATION_NVP(value);
}
private:
        Archive* m_ar;
};

template<class Archive,BOOST_VARIANT_ENUM_PARAMS(typename T)>
void save(Archive & ar,boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>
const & v,unsigned int version)
{
        int which = v.which();
      ar << BOOST_SERIALIZATION_NVP(which);
      apply_visitor(variant::save_visitor(ar),v);
}

Regards,

Richard.

> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]] On Behalf Of Robert Ramey
> Sent: 10 February 2005 05:27
> To: boost_at_[hidden]
> Subject: [boost] Re: Release 1.33 [serialization]
> [variant]-non-intrusiveversion
>
> So, to summarize,
>
> On my machine the results for test_variant are:
>
> fail borland 5.51
> fail borland 5.64
> fail msvc 6
> fail VC 8.0
>
> pass VC 7.1
> pass gcc 3.3
>
> I'm sure these are issues with other libraries and older
> compilers rather than the serialization of variant itself.
> See if you can convince the respective authors to help you on this.
>
> Robert Ramey
>
>
> Here is the message for msvc:
>
> test_variant.cpp
> Linking to lib file: libboost_serialization-vc6-mt-gd-1_32.lib
> C:\BoostMainCVS\boost/serialization/variant.hpp(118) : error
> C2780: 'class boost::_bi::bind_t<R,class
> boost::_mfi::dm<R,T>,class boost::_bi::list1<class
> boost::_bi::value<R> > > __cdecl boost::bind(R T::*,A1)' :
> expects 2 arguments - 3 provided
> C:\BoostMainCVS\boost/bind.hpp(1501) : see
> declaration of 'bind'


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk