Turi Create  4.0
set.hpp
1 /* Copyright © 2017 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5  */
6 #ifndef TURI_SERIALIZE_SET_HPP
7 #define TURI_SERIALIZE_SET_HPP
8 
9 #include <set>
10 #include <core/storage/serialization/iarchive.hpp>
11 #include <core/storage/serialization/oarchive.hpp>
12 #include <core/storage/serialization/iterator.hpp>
13 
14 namespace turi {
15 namespace archive_detail {
16  /** serializes a set */
17  template <typename OutArcType, typename T>
18  struct serialize_impl<OutArcType, std::set<T>, false > {
19  static void exec(OutArcType& oarc, const std::set<T>& vec){
20  serialize_iterator(oarc,
21  vec.begin(), vec.end(), vec.size());
22  }
23  };
24 
25  /** deserializes a set */
26  template <typename InArcType, typename T>
27  struct deserialize_impl<InArcType, std::set<T>, false > {
28  static void exec(InArcType& iarc, std::set<T>& vec){
29  vec.clear();
30  deserialize_iterator<InArcType, T>(iarc,
31  std::inserter(vec,vec.end()));
32  }
33  };
34 
35 } // archive_detail
36 } // turicreate
37 
38 #endif
STL namespace.
void serialize_iterator(OutArcType &oarc, RandomAccessIterator begin, RandomAccessIterator end)
Serializes the contents between the iterators begin and end.
Definition: iterator.hpp:36