Boost logo

Boost Users :

From: cheesy4poofs (cheesy4poofs_at_[hidden])
Date: 2006-02-03 12:57:07


Hello,

I've been trying for days to get a simple serialization example to work in
our main project. I finally started taking snippets of code from the
regular project into a sample project to post the code here. However, all
the code in my sample project always compiles and runs. It's practically
identical to our main project.

At this point, I'm pretty sure I've stumbled unto a bug in the compiler. I
even found a web page that seems to have the same problem I have:

http://aspn.activestate.com/ASPN/Mail/Message/boost/2768351

Here's a small sample of the problem:

struct Node
{
        unsigned int handle;

        template <typename Archive>
        void save(Archive& ar, const unsigned int version) const
        {
                ar << handle;
        }

        template <typename Archive>
        void load(Archive& ar, const unsigned int version)
        {
                ar >> handle;
        }
        BOOST_SERIALIZATION_SPLIT_MEMBER()
}

In a nutshell, I have a std::map<unsigned int, Node> that I'm trying to
serialize. The code to save compiles fine. But the load() method fails on
compile with the STATIC_ASSERTION_FAILURE. If I comment out the ar >>
handle;, it compiles fine. If I then uncomment ar >> handle; (after a good
compile), it STILL COMPILES FINE. If I do a clean/rebuild of the project,
it then fails with the STATIC_ASSERTION_FAILURE!

I went into the iserializer.hpp:577 header of boost and found the offending
line:

    // if this assertion trips. It means we're trying to load a
    // const object with a compiler that doesn't have correct
    // funtion template ordering. On other compilers, this is
    // handled below.
    BOOST_STATIC_ASSERT(! boost::is_const<T>::value);

Based on the comment above, it seems MSVC 7.1 is having problems with
correct function template ordering? On a whim, I commented out the
BOOST_STATIC_ASSERT and now I see this compile error:

..\API\inc\boost\archive\basic_text_iprimitive.hpp(80) : error C2679: binary
'>>' : no operator found which takes a right-hand operand of type 'const
unsigned int' (or there is no acceptable conversion)
        ..\API\inc\boost\archive\text_iarchive.hpp(45) : see reference to
function template instantiation 'void
boost::archive::basic_text_iprimitive<IStream>::load<T>(T &)' being compiled
        with
        [
            IStream=std::istream,
            T=const unsigned int
        ]

My question is - how can I solve this so I can use serialization? The link
above seems to indicate boost 1.32 works for Microsoft Visual Studio 7.1.
Are there any other possible solutions that don't involve rolling back to an
earlier boost version?

Thanks for any help,
Scott


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