Subject: [Boost-bugs] [Boost C++ Libraries] #10488: Compilation of serializing shared_ptr<const Object> fails
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-09-10 12:53:39
#10488: Compilation of serializing shared_ptr<const Object> fails
-------------------------------------------------+-------------------------
Reporter: visa.jokelainen@⦠| Owner: ramey
Type: Bugs | Status: new
Milestone: To Be Determined | Component:
Version: Boost 1.56.0 | serialization
Keywords: shared_ptr serialization const | Severity: Regression
compilation |
-------------------------------------------------+-------------------------
Compilation of code that includes serialization of shared_ptr<const
Object> fails with Boost 1.56.0 with error:
{{{
/usr/include/boost/smart_ptr/shared_ptr.hpp:323:25: note: no known
conversion for argument 1 from âconst boost::shared_ptr<const TestClass>â
to âconst boost::shared_ptr<void>&â
}}}
This works with Boost 1.55.0 and earlier versions.
Tested on Arch Linux with clang 3.4.2 and g++ 4.9.1.
Here's a little test to replicate the problem:
{{{
#include <fstream>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/make_shared.hpp>
class TestClass
{
public:
TestClass(int i) : _i(i) {}
private:
friend class boost::serialization::access;
TestClass() {}
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & _i;
}
int _i;
};
typedef boost::shared_ptr<TestClass> ClassPtr;
typedef boost::shared_ptr<const TestClass> ConstClassPtr;
int main(int argc, char* argv[])
{
ClassPtr ptr = boost::make_shared<TestClass>(13);
ConstClassPtr cPtr = boost::make_shared<const TestClass>(42);
{
std::ifstream ifs("test");
boost::archive::text_iarchive ia(ifs);
ia >> ptr; // This works
ia >> cPtr; // This doesn't
}
return 0;
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/10488> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC