Hi,

In the following code I show how a boost::variant that has a boost::blank cannot be serialized, and a proposed fix. I argue that this should work out of the box. This is with Boost 1.42.0.

Am I doing something wrong here, or is serialization of boost::blank somewhere already?

Thanks

#include <boost/variant/variant.hpp>
#include <boost/serialization/variant.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <sstream>

#ifdef FIX
// suggested fix: non-intrusive serialize() for boost::blank
namespace boost { namespace serialization
{
    template<class Archive>
    void serialize(Archive &, boost::blank &, const unsigned int)
    {
        // Nothing to do here
    }
} }
#endif

int main()
{
    boost::variant<int, double> v1 = 666;
    boost::variant<boost::blank, int, double> v2 = 666;

    std::ostringstream os;
    boost::archive::text_oarchive oa(os);
   
    // works!
    oa << v1;
   
    // compile error about boost::blank not having a serialize method
    // #define FIX to compile
    oa << v2;

    return 0;
}