@@ -417,6 +417,20 @@ struct EmptyPythonVisitor
417417 void visit (classT &) const {}
418418};
419419
420+ namespace internal {
421+ template <typename vector_type, bool T_picklable = false >
422+ struct def_pickle_std_vector {
423+ static void run (bp::class_<vector_type> &) {}
424+ };
425+
426+ template <typename vector_type>
427+ struct def_pickle_std_vector <vector_type, true > {
428+ static void run (bp::class_<vector_type> &cl) {
429+ cl.def_pickle (PickleVector<vector_type>());
430+ }
431+ };
432+ } // namespace internal
433+
420434// /
421435// / \brief Expose an std::vector from a type given as template argument.
422436// / \tparam vector_type std::vector type to expose
@@ -426,7 +440,7 @@ struct EmptyPythonVisitor
426440// / conversion from a Python list to a std::vector<T,Allocator>
427441// /
428442template <class vector_type , bool NoProxy = false ,
429- bool EnableFromPythonListConverter = true >
443+ bool EnableFromPythonListConverter = true , bool pickable = true >
430444struct StdVectorPythonVisitor {
431445 typedef typename vector_type::value_type value_type;
432446 typedef StdContainerFromPythonList<vector_type, NoProxy>
@@ -469,8 +483,9 @@ struct StdVectorPythonVisitor {
469483 " Copy constructor" ))
470484
471485 .def (vector_indexing)
472- .def (add_std_visitor)
473- .def_pickle (PickleVector<vector_type>());
486+ .def (add_std_visitor);
487+
488+ internal::def_pickle_std_vector<vector_type, pickable>::run (cl);
474489 }
475490 if (EnableFromPythonListConverter) {
476491 // Register conversion
0 commit comments