mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
vector_ext
This commit is contained in:
parent
bb21758cb6
commit
cfb38b2737
@ -50,10 +50,9 @@ SOFTWARE.
|
||||
#include "exception.h"
|
||||
#include "debug_count.h"
|
||||
#include "private/vector_base.h"
|
||||
|
||||
#include "algorithm.h"
|
||||
#include "iterator.h"
|
||||
#include "functional.h"
|
||||
#include "static_assert.h"
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#include <initializer_list>
|
||||
@ -1131,6 +1130,8 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
ETL_STATIC_ASSERT((MAX_SIZE_ > 0U), "Zero capacity etl::vector is not valid");
|
||||
|
||||
static const size_t MAX_SIZE = MAX_SIZE_;
|
||||
|
||||
//*************************************************************************
|
||||
@ -1296,20 +1297,20 @@ namespace etl
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// A vector implementation that uses a fixed size buffer.
|
||||
/// A vector implementation that uses a fixed size external buffer.
|
||||
/// The buffer is supplied on construction.
|
||||
///\tparam T The element type.
|
||||
///\ingroup vector
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
class vector<T, 0> : public etl::ivector<T>
|
||||
class vector_ext : public etl::ivector<T>
|
||||
{
|
||||
public:
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor.
|
||||
//*************************************************************************
|
||||
vector(void* buffer, size_t max_size)
|
||||
vector_ext(void* buffer, size_t max_size)
|
||||
: etl::ivector<T>(reinterpret_cast<T*>(buffer), max_size)
|
||||
{
|
||||
this->initialise();
|
||||
@ -1317,9 +1318,9 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, with size.
|
||||
///\param initial_size The initial size of the vector.
|
||||
///\param initial_size The initial size of the vector_ext.
|
||||
//*************************************************************************
|
||||
explicit vector(size_t initial_size, void* buffer, size_t max_size)
|
||||
explicit vector_ext(size_t initial_size, void* buffer, size_t max_size)
|
||||
: etl::ivector<T>(reinterpret_cast<T*>(buffer), max_size)
|
||||
{
|
||||
this->initialise();
|
||||
@ -1328,10 +1329,10 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from initial size and value.
|
||||
///\param initial_size The initial size of the vector.
|
||||
///\param value The value to fill the vector with.
|
||||
///\param initial_size The initial size of the vector_ext.
|
||||
///\param value The value to fill the vector_ext with.
|
||||
//*************************************************************************
|
||||
vector(size_t initial_size, typename etl::ivector<T>::parameter_t value, void* buffer, size_t max_size)
|
||||
vector_ext(size_t initial_size, typename etl::ivector<T>::parameter_t value, void* buffer, size_t max_size)
|
||||
: etl::ivector<T>(reinterpret_cast<T*>(buffer), max_size)
|
||||
{
|
||||
this->initialise();
|
||||
@ -1345,7 +1346,7 @@ namespace etl
|
||||
///\param last The iterator to the last element + 1.
|
||||
//*************************************************************************
|
||||
template <typename TIterator>
|
||||
vector(TIterator first, TIterator last, void* buffer, size_t max_size)
|
||||
vector_ext(TIterator first, TIterator last, void* buffer, size_t max_size)
|
||||
: etl::ivector<T>(reinterpret_cast<T*>(buffer), max_size)
|
||||
{
|
||||
this->assign(first, last);
|
||||
@ -1355,7 +1356,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Constructor, from an initializer_list.
|
||||
//*************************************************************************
|
||||
vector(std::initializer_list<T> init, void* buffer, size_t max_size)
|
||||
vector_ext(std::initializer_list<T> init, void* buffer, size_t max_size)
|
||||
: etl::ivector<T>(reinterpret_cast<T*>(buffer), max_size)
|
||||
{
|
||||
this->assign(init.begin(), init.end());
|
||||
@ -1365,7 +1366,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Copy constructor.
|
||||
//*************************************************************************
|
||||
vector(const vector& other, void* buffer, size_t max_size)
|
||||
vector_ext(const vector_ext& other, void* buffer, size_t max_size)
|
||||
: etl::ivector<T>(reinterpret_cast<T*>(buffer), max_size)
|
||||
{
|
||||
this->assign(other.begin(), other.end());
|
||||
@ -1374,7 +1375,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
vector& operator = (const vector& rhs)
|
||||
vector_ext& operator = (const vector_ext& rhs)
|
||||
{
|
||||
if (&rhs != this)
|
||||
{
|
||||
@ -1388,7 +1389,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Move constructor.
|
||||
//*************************************************************************
|
||||
vector(vector&& other, void* buffer, size_t max_size)
|
||||
vector_ext(vector_ext&& other, void* buffer, size_t max_size)
|
||||
: etl::ivector<T>(reinterpret_cast<T*>(buffer), max_size)
|
||||
{
|
||||
if (this != &other)
|
||||
@ -1409,7 +1410,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Move assignment operator.
|
||||
//*************************************************************************
|
||||
vector& operator = (vector&& rhs)
|
||||
vector_ext& operator = (vector_ext&& rhs)
|
||||
{
|
||||
if (&rhs != this)
|
||||
{
|
||||
@ -1432,7 +1433,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
//*************************************************************************
|
||||
~vector()
|
||||
~vector_ext()
|
||||
{
|
||||
this->clear();
|
||||
}
|
||||
@ -1464,6 +1465,8 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
ETL_STATIC_ASSERT((MAX_SIZE_ > 0U), "Zero capacity etl::vector is not valid");
|
||||
|
||||
static const size_t MAX_SIZE = MAX_SIZE_;
|
||||
|
||||
//*************************************************************************
|
||||
@ -1594,14 +1597,14 @@ namespace etl
|
||||
///\ingroup vector
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
class vector<T*, 0> : public etl::ivector<T*>
|
||||
class vector_ext<T*> : public etl::ivector<T*>
|
||||
{
|
||||
public:
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor.
|
||||
//*************************************************************************
|
||||
vector(void* buffer, size_t max_size)
|
||||
vector_ext(void* buffer, size_t max_size)
|
||||
: etl::ivector<T*>(reinterpret_cast<T**>(buffer), max_size)
|
||||
{
|
||||
this->initialise();
|
||||
@ -1609,9 +1612,9 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, with size.
|
||||
///\param initial_size The initial size of the vector.
|
||||
///\param initial_size The initial size of the vector_ext.
|
||||
//*************************************************************************
|
||||
vector(size_t initial_size, void* buffer, size_t max_size)
|
||||
vector_ext(size_t initial_size, void* buffer, size_t max_size)
|
||||
: etl::ivector<T*>(reinterpret_cast<T**>(buffer), max_size)
|
||||
{
|
||||
this->initialise();
|
||||
@ -1620,10 +1623,10 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from initial size and value.
|
||||
///\param initial_size The initial size of the vector.
|
||||
///\param value The value to fill the vector with.
|
||||
///\param initial_size The initial size of the vector_ext.
|
||||
///\param value The value to fill the vector_ext with.
|
||||
//*************************************************************************
|
||||
vector(size_t initial_size, typename etl::ivector<T*>::parameter_t value, void* buffer, size_t max_size)
|
||||
vector_ext(size_t initial_size, typename etl::ivector<T*>::parameter_t value, void* buffer, size_t max_size)
|
||||
: etl::ivector<T*>(reinterpret_cast<T**>(buffer), max_size)
|
||||
{
|
||||
this->initialise();
|
||||
@ -1637,7 +1640,7 @@ namespace etl
|
||||
///\param last The iterator to the last element + 1.
|
||||
//*************************************************************************
|
||||
template <typename TIterator>
|
||||
vector(TIterator first, TIterator last, void* buffer, size_t max_size)
|
||||
vector_ext(TIterator first, TIterator last, void* buffer, size_t max_size)
|
||||
: etl::ivector<T*>(reinterpret_cast<T**>(buffer), max_size)
|
||||
{
|
||||
this->assign(first, last);
|
||||
@ -1647,7 +1650,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Constructor, from an initializer_list.
|
||||
//*************************************************************************
|
||||
vector(std::initializer_list<T*> init, void* buffer, size_t max_size)
|
||||
vector_ext(std::initializer_list<T*> init, void* buffer, size_t max_size)
|
||||
: etl::ivector<T*>(reinterpret_cast<T**>(buffer), max_size)
|
||||
{
|
||||
this->assign(init.begin(), init.end());
|
||||
@ -1657,7 +1660,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Copy constructor.
|
||||
//*************************************************************************
|
||||
vector(const vector& other, void* buffer, size_t max_size)
|
||||
vector_ext(const vector_ext& other, void* buffer, size_t max_size)
|
||||
: etl::ivector<T*>(reinterpret_cast<T**>(buffer), max_size)
|
||||
{
|
||||
(void)etl::ivector<T*>::operator = (other);
|
||||
@ -1666,7 +1669,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
vector& operator = (const vector& rhs)
|
||||
vector_ext& operator = (const vector_ext& rhs)
|
||||
{
|
||||
(void)etl::ivector<T*>::operator = (rhs);
|
||||
|
||||
@ -1677,7 +1680,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Move constructor.
|
||||
//*************************************************************************
|
||||
vector(vector&& other, void* buffer, size_t max_size)
|
||||
vector_ext(vector_ext&& other, void* buffer, size_t max_size)
|
||||
: etl::ivector<T*>(reinterpret_cast<T**>(buffer), max_size)
|
||||
{
|
||||
(void)etl::ivector<T*>::operator = (etl::move(other));
|
||||
@ -1686,7 +1689,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Move assignment operator.
|
||||
//*************************************************************************
|
||||
vector& operator = (vector&& rhs)
|
||||
vector_ext& operator = (vector_ext&& rhs)
|
||||
{
|
||||
(void)etl::ivector<T*>::operator = (etl::move(rhs));
|
||||
|
||||
@ -1697,7 +1700,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
//*************************************************************************
|
||||
~vector()
|
||||
~vector_ext()
|
||||
{
|
||||
this->clear();
|
||||
}
|
||||
|
||||
@ -37,9 +37,9 @@ SOFTWARE.
|
||||
/// Definitions of the ETL version
|
||||
///\ingroup utilities
|
||||
|
||||
#define ETL_VERSION_MAJOR 18
|
||||
#define ETL_VERSION_MINOR 20
|
||||
#define ETL_VERSION_PATCH 2
|
||||
#define ETL_VERSION_MAJOR 19
|
||||
#define ETL_VERSION_MINOR 0
|
||||
#define ETL_VERSION_PATCH 0
|
||||
#define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION_U16 ETL_STRINGIFY(ETL_VERSION_MAJOR) u"." ETL_STRINGIFY(ETL_VERSION_MINOR) u"." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Embedded Template Library",
|
||||
"version": "18.20.2",
|
||||
"version": "19.0.0",
|
||||
"author s": {
|
||||
"name": "John Wellbelove",
|
||||
"email": "john.wellbelove@etlcpp.com"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name=Embedded Template Library
|
||||
version=18.20.2
|
||||
version=19.0.0
|
||||
author= John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
license=MIT
|
||||
|
||||
@ -1,3 +1,16 @@
|
||||
===============================================================================
|
||||
19.0.0
|
||||
Containers with external buffers or pools are now separate classes instead of specialisations.
|
||||
|
||||
etl::circular_buffer<T, 0> => etl::circular_buffer_ext<T>
|
||||
etl::forward_list<T, 0> => etl::forward_list_ext<T>
|
||||
etl::list<T, 0> => etl::list_ext<T>
|
||||
etl::string<0> => etl::string_ext
|
||||
etl::wstring<0> => etl::wstring_ext
|
||||
etl::u16string<0> => etl::u16string_ext
|
||||
etl::u32string<0> => etl::u32string_ext
|
||||
etl::vector<T, 0> => etl::vector_ext<T>
|
||||
|
||||
===============================================================================
|
||||
18.20.2
|
||||
Fixed etl::to_string for floating point numbers between 0 & -1.0
|
||||
|
||||
@ -47,9 +47,9 @@ namespace
|
||||
|
||||
SUITE(test_vector)
|
||||
{
|
||||
typedef etl::vector<int, 0> Data;
|
||||
typedef etl::ivector<int> IData;
|
||||
typedef std::vector<int> Compare_Data;
|
||||
typedef etl::vector_ext<int> Data;
|
||||
typedef etl::ivector<int> IData;
|
||||
typedef std::vector<int> Compare_Data;
|
||||
|
||||
Compare_Data initial_data;
|
||||
Compare_Data less_data;
|
||||
@ -1077,8 +1077,8 @@ namespace
|
||||
|
||||
const S raw[6] = { 1, 2, 3, 4, 5, 6 };
|
||||
|
||||
etl::vector<S, 0> dest(etl::begin(raw), etl::end(raw), sbuffer1, SIZE);
|
||||
etl::vector<S, 0> src((size_t) 2, S(8), sbuffer2, SIZE);
|
||||
etl::vector_ext<S> dest(etl::begin(raw), etl::end(raw), sbuffer1, SIZE);
|
||||
etl::vector_ext<S> src((size_t) 2, S(8), sbuffer2, SIZE);
|
||||
|
||||
dest.insert(dest.begin(), src.begin(), src.end());
|
||||
|
||||
@ -1112,7 +1112,7 @@ namespace
|
||||
|
||||
const S raw[6] = { 1, 2, 3, 4, 5, 6 };
|
||||
|
||||
etl::vector<S, 0> dest(etl::begin(raw), etl::end(raw), sbuffer1, SIZE);
|
||||
etl::vector_ext<S> dest(etl::begin(raw), etl::end(raw), sbuffer1, SIZE);
|
||||
|
||||
dest.insert(dest.begin(), 2, S(8));
|
||||
|
||||
|
||||
@ -47,12 +47,12 @@ namespace
|
||||
|
||||
SUITE(test_vector_pointer)
|
||||
{
|
||||
typedef etl::vector<int*, 0> Data;
|
||||
typedef etl::vector<const int*, 0> CData;
|
||||
typedef etl::ivector<int*> IData;
|
||||
typedef etl::ivector<const int*> CIData;
|
||||
typedef std::vector<int*> Compare_Data;
|
||||
typedef std::vector<const int*> CCompare_Data;
|
||||
typedef etl::vector_ext<int*> Data;
|
||||
typedef etl::vector_ext<const int*> CData;
|
||||
typedef etl::ivector<int*> IData;
|
||||
typedef etl::ivector<const int*> CIData;
|
||||
typedef std::vector<int*> Compare_Data;
|
||||
typedef std::vector<const int*> CCompare_Data;
|
||||
|
||||
Compare_Data initial_data;
|
||||
Compare_Data less_data;
|
||||
@ -1819,7 +1819,7 @@ namespace
|
||||
TEST_FIXTURE(SetupFixture, test_const_ivector_of_pointer_to_pointer)
|
||||
{
|
||||
int i1 = 1;
|
||||
etl::vector<int*, 0> consttest(buffer1, SIZE);
|
||||
etl::vector_ext<int*> consttest(buffer1, SIZE);
|
||||
consttest.push_back(&i1);
|
||||
const etl::ivector<int*>& ct = consttest;
|
||||
|
||||
@ -1833,7 +1833,7 @@ namespace
|
||||
TEST_FIXTURE(SetupFixture, test_const_ivector_of_pointer_to_const_pointer)
|
||||
{
|
||||
int i1 = 1;
|
||||
etl::vector<const int*, 0> consttest(buffer1, SIZE);
|
||||
etl::vector_ext<const int*> consttest(buffer1, SIZE);
|
||||
consttest.push_back(&i1);
|
||||
const etl::ivector<const int*>& ct = consttest;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user