mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 00:32:57 -04:00
dtoolbase: add std::initializer_list constructors for pvector, epvector, pdeque, plist, pset, pmultiset
Closes #520
This commit is contained in:
parent
b1018d52ee
commit
7c6e677a23
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include <Eigen/StdVector>
|
#include <Eigen/StdVector>
|
||||||
|
|
||||||
|
#include <initializer_list>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unfortunately, on Windows, std::vector can't be used for classes with
|
* Unfortunately, on Windows, std::vector can't be used for classes with
|
||||||
* explicitly alignment requirements, due to a minor mistake in the template
|
* 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, 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(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(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
|
#else // HAVE_EIGEN
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "pallocator.h"
|
#include "pallocator.h"
|
||||||
#include "register_type.h"
|
#include "register_type.h"
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
#include <initializer_list>
|
||||||
|
|
||||||
#if !defined(USE_STL_ALLOCATOR) || defined(CPPPARSER)
|
#if !defined(USE_STL_ALLOCATOR) || defined(CPPPARSER)
|
||||||
// If we're not using custom allocators, just use the standard class
|
// 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(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, 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(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
|
#endif // USE_STL_ALLOCATOR
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "pallocator.h"
|
#include "pallocator.h"
|
||||||
#include "register_type.h"
|
#include "register_type.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <initializer_list>
|
||||||
|
|
||||||
#if !defined(USE_STL_ALLOCATOR) || defined(CPPPARSER)
|
#if !defined(USE_STL_ALLOCATOR) || defined(CPPPARSER)
|
||||||
// If we're not using custom allocators, just use the standard class
|
// 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(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, 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(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::iterator iterator;
|
||||||
typedef typename base_class::const_iterator const_iterator;
|
typedef typename base_class::const_iterator const_iterator;
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include <hash_set>
|
#include <hash_set>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <initializer_list>
|
||||||
|
|
||||||
#if !defined(USE_STL_ALLOCATOR) || defined(CPPPARSER)
|
#if !defined(USE_STL_ALLOCATOR) || defined(CPPPARSER)
|
||||||
// If we're not using custom allocators, just use the standard class
|
// If we're not using custom allocators, just use the standard class
|
||||||
// definition.
|
// definition.
|
||||||
@ -52,6 +54,7 @@ public:
|
|||||||
typedef std::set<Key, Compare, allocator> base_class;
|
typedef std::set<Key, Compare, allocator> base_class;
|
||||||
pset(TypeHandle type_handle = pset_type_handle) : base_class(Compare(), allocator(type_handle)) { }
|
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(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
|
#ifdef USE_TAU
|
||||||
std::pair<typename base_class::iterator, bool>
|
std::pair<typename base_class::iterator, bool>
|
||||||
@ -110,6 +113,7 @@ public:
|
|||||||
typedef pallocator_single<Key> allocator;
|
typedef pallocator_single<Key> allocator;
|
||||||
pmultiset(TypeHandle type_handle = pset_type_handle) : std::multiset<Key, Compare, allocator>(Compare(), allocator(type_handle)) { }
|
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(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
|
#ifdef HAVE_STL_HASH
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#define PVECTOR_H
|
#define PVECTOR_H
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <initializer_list>
|
||||||
|
|
||||||
#include "dtoolbase.h"
|
#include "dtoolbase.h"
|
||||||
#include "pallocator.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, 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)) { }
|
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(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> ©) {
|
pvector<Type> &operator =(const pvector<Type> ©) {
|
||||||
base_class::operator =(copy);
|
base_class::operator =(copy);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user