Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] compile-time detection of whether serialization is implemented for a class
From: Robert Ramey (ramey_at_[hidden])
Date: 2012-02-16 20:28:30


Nelson, Erik - 2 wrote:
> Robert Ramey wrote:
>>
>> I would look into something like:
>>
>> #include <boost/serialization/level.hpp>
>>
>> my_type x;
>>
>> if(boost::serialization::implementation_level<my_type>,
>> boost::serialization::level_type::not_serializable){
>> ...
>> }
>>
>> or some variation of there of such as:
>>
>> #include <boost/serialization/level.hpp>
>>
>> namespace boost {
>> namespace serialization {
>>
>> template<class T>
>> struct is_serializable {
>> typedef typename
>> boost::mpl::greater_than<
>> boost::serialization::implementation_level<my_type>,
>> boost::serialization::level_type::not_serializable
>> >::type
>> type;
>> };
>>
>
>
> I played around with that a little, but it looks like for that to
> work I'd need to do something like
>
> BOOST_CLASS_IMPLEMENTATION(my_class,
> boost::serialization::not_serializable)
>
> for each type that was not serializable... am I missing something?
> In my experiment it seems like
>
> boost::serialization::implementation_level<A>::type::value
>
> resolves to object_class_info unless I use the
> BOOST_CLASS_IMPLEMENTATION. That's akin to manually marking the
> types, which I'd like to avoid if possible.

OK - looks like you've got me there. I was hoping
that there was a cheap trick - but I guess not.

Robert Ramey


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