[serialization] Question about pointers and casting

Dear Boost Experts --
I'm using g++ 4.2.1, OS X 10.6.1, boost 1.40, although I have also
seen this on linux. In attempting to
understand how boost::serialization works, I've stumbled across the
following curiosity. The following
program compiles and runs fine (I've eliminated diagnostic output
which verifies the serialization.)
#include <iostream>
#include <fstream>
#include

Ben wrote:
{ std::ifstream ifs(fname); boost::archive::binary_iarchive ar(ifs); ar >> static_cast(a2p); }
You're trying to write to an rvalue. Note that
int *ip = 0;
static_cast

Ahhh - so try ar >> static_cast(a2p); Robert Ramey troy d. straszheim wrote:
Ben wrote:
{ std::ifstream ifs(fname); boost::archive::binary_iarchive ar(ifs); ar >> static_cast(a2p); }
You're trying to write to an rvalue. Note that
int *ip = 0; static_cast
(ip) = 0; // lvalue required as // left operand of assignment doesn't compile either...
-t
participants (3)
-
Ben
-
Robert Ramey
-
troy d. straszheim