Question: Does the boost serialization library support serialization of std::unique\_ptr?
I tried to compile the code below, but if I include the 
**boost::archive::text\_oarchive oa(ofs); oa << g;** line, 

the compiler (btw gcc4.7 with -std=c++11 flag) throws an error 

**/usr/include/boost/serialization/access.hpp:118:9: error: ‘class std::unique\_ptr’ has no member named ‘serialize’** 

```
#include <iostream>
#include <memory>
#include <fstream>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
class MyDegrees
{
public:
  void setDeg(int d){deg = d;}
  int getDeg()const {return deg;}
private:
  friend class boost::serialization::access;
    template<class Archive>
    void serialize(Archive & ar, const unsigned int version)
    { ar & deg; }
  int deg;
};
class gps_position
{
private:
    friend class boost::serialization::access;
    template<class Archive>
    void serialize(Archive & ar, const unsigned int version)
    { ar & degrees; }
    std::unique_ptr<MyDegrees> degrees;
public:
    gps_position(): degrees(std::unique_ptr<MyDegrees>(new MyDegrees)){};
    void setDeg(int d){degrees->setDeg(d);}
    int getDeg() const {return degrees->getDeg();}
};
int main()
{
    std::ofstream ofs("filename");
    gps_position g;
    g.setDeg(45);
    std::cout<<g.getDeg()<<std::endl;
    {// compiler error, fine if commented out
        boost::archive::text_oarchive oa(ofs); oa << g;
    }
  return 0;
}

```

Answer: 
recent versions of boost serialization provide support for all std smart pointer types.
No, there is no out of the box adaption. You will need to provide a non-intrusive adapter yourself. See the [tutorial here](http://www.boost.org/libs/serialization/) to get an idea how to do that.