9 #ifndef IMPKERNEL_CONVERTIBLE_VECTOR_H
10 #define IMPKERNEL_CONVERTIBLE_VECTOR_H
11 #include <IMP/kernel_config.h>
16 #include <cereal/access.hpp>
19 #if defined(_MSC_VER) && _MSC_VER == 1500
20 # include <type_traits>
21 # include <boost/type_traits.hpp>
22 # include <boost/utility.hpp>
25 #if IMP_COMPILER_HAS_DEBUG_VECTOR &&IMP_HAS_CHECKS >= IMP_INTERNAL
26 #include <debug/vector>
32 #ifdef IMP_KERNEL_CUDA_LIB
33 # include <IMP/internal/UnifiedAllocator.h>
34 # define IMP_VECTOR_ALLOCATOR internal::UnifiedAllocator
36 # define IMP_VECTOR_ALLOCATOR std::allocator
39 IMPKERNEL_BEGIN_NAMESPACE
49 template <
class T,
class Allocator = std::allocator<T>>
51 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
52 #if IMP_COMPILER_HAS_DEBUG_VECTOR &&IMP_HAS_CHECKS >= IMP_INTERNAL
54 public __gnu_debug::vector<T, Allocator>
57 public std::vector<T, Allocator>
61 #if IMP_COMPILER_HAS_DEBUG_VECTOR &&IMP_HAS_CHECKS >= IMP_INTERNAL
62 typedef __gnu_debug::vector<T, Allocator> V;
64 typedef std::vector<T, Allocator> V;
67 friend class cereal::access;
69 template<
class Archive>
void save(Archive &ar)
const {
70 size_t sz = V::size();
78 template<
class Archive>
void load(Archive &ar) {
90 explicit Vector(
unsigned int sz,
const T &t = T()) : V(sz, t) {}
91 #if defined(_MSC_VER) && _MSC_VER == 1500
94 typename boost::disable_if<std::is_integral<It>::value>::type *t=0) {
95 for (It it = b; it != e; ++it) {
100 explicit Vector(
const std::vector<VO> &o) {
102 for (std::vector<VO>::const_iterator it = o.begin();
103 it != o.end(); ++it) {
112 explicit Vector(
const std::vector<VO> &o)
113 : V(o.begin(), o.end()) {}
121 V::insert(V::end(), o.begin(), o.end());
124 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
125 void show(std::ostream &out = std::cout)
const {
127 for (
unsigned int i = 0; i < V::size(); ++i) {
128 if (i > 0) out <<
", ";
138 std::ostringstream oss;
142 std::size_t __hash__()
const {
143 return boost::hash_range(V::begin(), V::end());
148 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
149 template <
class T,
class Allocator>
154 template <
class T,
class Allocator>
155 inline Vector<T, Allocator> operator+(Vector<T, Allocator> ret,
156 const Vector<T, Allocator> &o) {
157 ret.insert(ret.end(), o.begin(), o.end());
163 #if IMP_COMPILER_HAS_DEBUG_VECTOR &&IMP_HAS_CHECKS >= IMP_INTERNAL
164 template <
class T,
class Allocator>
165 inline std::size_t hash_value(
const __gnu_debug::vector<T, Allocator> &t) {
166 return boost::hash_range(t.begin(), t.end());
170 IMPKERNEL_END_NAMESPACE
173 template <
class Archive,
class T,
class Allocator>
174 struct specialize<Archive, IMP::Vector<T, Allocator>,
175 cereal::specialization::member_load_save> {};
Helper functions for implementing hashes.
Helper class to aid in output of IMP classes to streams.
A more IMP-like version of the std::vector.
Base class for a simple primitive-like type.
std::ostream & show(Hierarchy h, std::ostream &out=std::cout)
Print the hierarchy using a given decorator to display each node.
Base class for a simple primitive-like type.
Helper class to aid in output of IMP classes to streams.