version 2.2.1

std::initializer_list supports for vector and dequeue
This commit is contained in:
2020-08-14 18:00:28 +03:00
parent e76a07a3f3
commit 31f0d88157
6 changed files with 21 additions and 1 deletions

View File

@@ -3,7 +3,7 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake
project(pip)
set(_PIP_MAJOR 2)
set(_PIP_MINOR 2)
set(_PIP_REVISION 0)
set(_PIP_REVISION 1)
set(_PIP_SUFFIX _alpha)
set(_PIP_COMPANY SHS)
set(_PIP_DOMAIN org.SHS)

View File

@@ -49,6 +49,9 @@ PIVector<char> vec(4u, 'p');
piForeachC (char i, vec)
cout << i << ", ";
// p, p, p, p,
piCout << PIVector<int>({1, 2, 3});
// 1, 2, 3
//! [PIVector::PIVector]
//! [PIVector::at_c]
PIVector<int> vec;

View File

@@ -32,6 +32,10 @@
* \brief Contructs vector with size "size" filled elements "value"
* \details Example: \snippet picontainers.cpp PIVector::PIVector
* \fn PIVector::PIVector(std::initializer_list list);
* \brief Contructs vector from C++11 initializer list
* \details Example: \snippet picontainers.cpp PIVector::PIVector
* \fn const T & PIVector::at(size_t index) const;
* \brief Read-only access to element by index "index"
* \details Example: \snippet picontainers.cpp PIVector::at_c

View File

@@ -42,6 +42,7 @@
#else
# include <malloc.h>
#endif
#include <initializer_list>
#include <string.h>
#include <new>
#ifndef PIP_MEMALIGN_BYTES

View File

@@ -39,6 +39,11 @@ public:
alloc(other.pid_size, true);
newT(pid_data + pid_start, other.pid_data + other.pid_start, pid_size);
}
inline PIDeque(std::initializer_list<T> init_list): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
alloc(init_list.size(), true);
newT(pid_data, init_list.begin(), init_list.size());
}
inline PIDeque(const T * data, size_t size): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
alloc(size, true);
@@ -49,6 +54,7 @@ public:
resize(pid_size, f);
}
inline PIDeque(PIDeque<T> && other): pid_data(other.pid_data), pid_size(other.pid_size), pid_rsize(other.pid_rsize), pid_start(other.pid_start) {
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
other._reset();
}
inline virtual ~PIDeque() {

View File

@@ -44,11 +44,17 @@ public:
alloc(other.piv_size);
newT(piv_data, other.piv_data, piv_size);
}
inline PIVector(std::initializer_list<T> init_list): piv_data(0), piv_size(0), piv_rsize(0) {
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
alloc(init_list.size());
newT(piv_data, init_list.begin(), init_list.size());
}
inline PIVector(size_t piv_size, const T & f = T()): piv_data(0), piv_size(0), piv_rsize(0) {
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
resize(piv_size, f);
}
inline PIVector(PIVector<T> && other): piv_data(other.piv_data), piv_size(other.piv_size), piv_rsize(other.piv_rsize) {
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
other._reset();
}
inline virtual ~PIVector() {