dtoolbase: add std::initializer_list constructors for pvector, epvector, pdeque, plist, pset, pmultiset

Closes #520
This commit is contained in:
Brian Lach 2019-01-10 01:29:24 +01:00 committed by rdb
parent b1018d52ee
commit 7c6e677a23
5 changed files with 13 additions and 1 deletions

View File

@ -20,6 +20,8 @@
#include <Eigen/StdVector>
#include <initializer_list>
/**
* Unfortunately, on Windows, std::vector can't be used for classes with
* explicitly alignment requirements, due to a minor mistake in the template
@ -46,6 +48,7 @@ public:
epvector(size_type n, TypeHandle type_handle = pvector_type_handle) : base_class(n, Type(), allocator()) { }
epvector(size_type n, const Type &value, TypeHandle type_handle = pvector_type_handle) : base_class(n, value, allocator()) { }
epvector(const Type *begin, const Type *end, TypeHandle type_handle = pvector_type_handle) : base_class(begin, end, allocator()) { }
epvector(std::initializer_list<Type> init, TypeHandle type_handle = pvector_type_handle) : base_class(std::move(init), allocator()) { }
};
#else // HAVE_EIGEN

View File

@ -18,7 +18,7 @@
#include "pallocator.h"
#include "register_type.h"
#include <deque>
#include <initializer_list>
#if !defined(USE_STL_ALLOCATOR) || defined(CPPPARSER)
// If we're not using custom allocators, just use the standard class
@ -40,6 +40,7 @@ public:
pdeque(TypeHandle type_handle = pdeque_type_handle) : std::deque<Type, pallocator_array<Type> >(allocator(type_handle)) { }
pdeque(size_type n, TypeHandle type_handle = pdeque_type_handle) : std::deque<Type, pallocator_array<Type> >(n, Type(), allocator(type_handle)) { }
pdeque(size_type n, const Type &value, TypeHandle type_handle = pdeque_type_handle) : std::deque<Type, pallocator_array<Type> >(n, value, allocator(type_handle)) { }
pdeque(std::initializer_list<Type> init, TypeHandle type_handle = pdeque_type_handle) : std::deque<Type, pallocator_array<Type> >(std::move(init), allocator(type_handle)) { }
};
#endif // USE_STL_ALLOCATOR

View File

@ -18,6 +18,7 @@
#include "pallocator.h"
#include "register_type.h"
#include <list>
#include <initializer_list>
#if !defined(USE_STL_ALLOCATOR) || defined(CPPPARSER)
// If we're not using custom allocators, just use the standard class
@ -40,6 +41,7 @@ public:
plist(TypeHandle type_handle = plist_type_handle) : base_class(allocator(type_handle)) { }
plist(size_type n, TypeHandle type_handle = plist_type_handle) : base_class(n, Type(), allocator(type_handle)) { }
plist(size_type n, const Type &value, TypeHandle type_handle = plist_type_handle) : base_class(n, value, allocator(type_handle)) { }
plist(std::initializer_list<Type> init, TypeHandle type_handle = plist_type_handle) : base_class(std::move(init), allocator(type_handle)) { }
typedef typename base_class::iterator iterator;
typedef typename base_class::const_iterator const_iterator;

View File

@ -24,6 +24,8 @@
#include <hash_set>
#endif
#include <initializer_list>
#if !defined(USE_STL_ALLOCATOR) || defined(CPPPARSER)
// If we're not using custom allocators, just use the standard class
// definition.
@ -52,6 +54,7 @@ public:
typedef std::set<Key, Compare, allocator> base_class;
pset(TypeHandle type_handle = pset_type_handle) : base_class(Compare(), allocator(type_handle)) { }
pset(const Compare &comp, TypeHandle type_handle = pset_type_handle) : base_class(comp, type_handle) { }
pset(std::initializer_list<Key> init, TypeHandle type_handle = pset_type_handle) : base_class(std::move(init), allocator(type_handle)) { }
#ifdef USE_TAU
std::pair<typename base_class::iterator, bool>
@ -110,6 +113,7 @@ public:
typedef pallocator_single<Key> allocator;
pmultiset(TypeHandle type_handle = pset_type_handle) : std::multiset<Key, Compare, allocator>(Compare(), allocator(type_handle)) { }
pmultiset(const Compare &comp, TypeHandle type_handle = pset_type_handle) : std::multiset<Key, Compare, allocator>(comp, type_handle) { }
pmultiset(std::initializer_list<Key> init, TypeHandle type_handle = pset_type_handle) : std::multiset<Key, Compare, allocator>(std::move(init), allocator(type_handle)) { }
};
#ifdef HAVE_STL_HASH

View File

@ -15,6 +15,7 @@
#define PVECTOR_H
#include <vector>
#include <initializer_list>
#include "dtoolbase.h"
#include "pallocator.h"
@ -51,6 +52,7 @@ public:
explicit pvector(size_type n, TypeHandle type_handle = pvector_type_handle) : base_class(n, Type(), allocator(type_handle)) { }
explicit pvector(size_type n, const Type &value, TypeHandle type_handle = pvector_type_handle) : base_class(n, value, allocator(type_handle)) { }
pvector(const Type *begin, const Type *end, TypeHandle type_handle = pvector_type_handle) : base_class(begin, end, allocator(type_handle)) { }
pvector(std::initializer_list<Type> init, TypeHandle type_handle = pvector_type_handle) : base_class(std::move(init), allocator(type_handle)) { }
pvector<Type> &operator =(const pvector<Type> &copy) {
base_class::operator =(copy);