Boost logo

Boost Users :

From: Bill Lear (rael_at_[hidden])
Date: 2007-09-19 22:12:19


I have a standard serialize method, working under various flavors
of gcc and the Intel C++ compilers:

struct ElementEnum {
    enum Origin { Standard, Base, Custom };
};

class Foo {
...
    ElementEnum::Origin origin : 4;

    template<...>
    void serialize(...) {
        ar & BOOST_SERIALIZATION_NVP(origin);
    }
};

However, under the PathScale EKO compiler (pathCC), I get an error:

"error: invalid initialization of reference of type Origin& from expression
of type const unsigned char:4."

Apparently make_nvp takes as its second argument a non-const reference.
It appears that non-const references are illegal under this compiler,
and, who knows, perhaps the latest C++ standard??

I was able to create a test case that caused this same error.
However, the test case also failed under gcc and the Intel compiler,
so the test case (appended below after my sig) is not narrow enough,
apparently.

If I rewrite the serialization method to not use the
BOOST_SERIALIZATION_NVP macro at all, the code works.

Any help on working around this (aside from tearing out
BOOST_SERIALIAZATION_NVP() calls altogether) would be appreciated.

Bill

// test case to provoke the same error that I got compiling
// serialization code under PathScale EKO compiler.
#include <iostream>
using namespace std;

template <class T>
void print(T& t) {
   cout << "t is now: " << t << endl;
}

struct Foo {
    int itsie : 4;
};

int main() {
    Foo f;

    print(f.itsie);
}


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