mirror of
https://github.com/ETLCPP/etl.git
synced 2026-11-09 14:49:53 +08:00
Merge remote-tracking branch 'origin/hotfix/vector-insert-bug' into development
This commit is contained in:
commit
2bcf9c2039
@ -744,8 +744,8 @@ namespace etl
|
||||
etl::uninitialized_copy_n(p_end - construct_old_n, construct_old_n, p_construct_old);
|
||||
ETL_ADD_DEBUG_COUNT(construct_old_n)
|
||||
|
||||
// Copy old.
|
||||
etl::copy_n(p_buffer + insert_begin, copy_old_n, p_buffer + insert_end);
|
||||
// Copy old.
|
||||
std::copy_backward(p_buffer + insert_begin, p_buffer + insert_begin + copy_old_n, p_buffer + insert_end + copy_old_n);
|
||||
|
||||
// Construct new.
|
||||
etl::uninitialized_fill_n(p_end, construct_new_n, value);
|
||||
@ -801,15 +801,15 @@ namespace etl
|
||||
etl::uninitialized_copy_n(p_end - construct_old_n, construct_old_n, p_construct_old);
|
||||
ETL_ADD_DEBUG_COUNT(construct_old_n)
|
||||
|
||||
// Copy old.
|
||||
etl::copy_n(p_buffer + insert_begin, copy_old_n, p_buffer + insert_end);
|
||||
// Copy old.
|
||||
std::copy_backward(p_buffer + insert_begin, p_buffer + insert_begin + copy_old_n, p_buffer + insert_end + copy_old_n);
|
||||
|
||||
// Construct new.
|
||||
etl::uninitialized_copy_n(first + copy_new_n, construct_new_n, p_end);
|
||||
ETL_ADD_DEBUG_COUNT(construct_new_n)
|
||||
|
||||
// Copy new.
|
||||
etl::copy_n(first, copy_new_n, p_buffer + insert_begin);
|
||||
// Copy new.
|
||||
etl::copy_n(first, copy_new_n, p_buffer + insert_begin);
|
||||
|
||||
p_end += count;
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ SOFTWARE.
|
||||
|
||||
#define ETL_VERSION_MAJOR 14
|
||||
#define ETL_VERSION_MINOR 8
|
||||
#define ETL_VERSION_PATCH 0
|
||||
#define ETL_VERSION_PATCH 1
|
||||
|
||||
#define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) ETL_STRINGIFY(ETL_VERSION_MINOR) ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION_W ETL_WIDE_STRING(ETL_CONCAT(ETL_CONCAT(ETL_VERSION_MAJOR, ETL_VERSION_MINOR), ETL_VERSION_PATCH))
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
===============================================================================
|
||||
14.8.1
|
||||
Fixed bug for certain inserts in etl::vector
|
||||
|
||||
===============================================================================
|
||||
14.8.0
|
||||
Added etl::callback_service
|
||||
|
||||
12
test/data.h
12
test/data.h
@ -53,6 +53,10 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~TestDataDC()
|
||||
{
|
||||
}
|
||||
|
||||
bool operator < (const TestDataDC& other) const
|
||||
{
|
||||
return value < other.value;
|
||||
@ -109,6 +113,10 @@ public:
|
||||
index(index_)
|
||||
{}
|
||||
|
||||
virtual ~TestDataNDC()
|
||||
{
|
||||
}
|
||||
|
||||
bool operator < (const TestDataNDC& other) const
|
||||
{
|
||||
return value < other.value;
|
||||
@ -174,6 +182,10 @@ public:
|
||||
other.valid = false;
|
||||
}
|
||||
|
||||
virtual ~TestDataM()
|
||||
{
|
||||
}
|
||||
|
||||
TestDataM& operator =(TestDataM&& other)
|
||||
{
|
||||
value = other.value;
|
||||
|
||||
@ -1036,5 +1036,70 @@ namespace
|
||||
|
||||
CHECK(!is_equal);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_insert_bug)
|
||||
{
|
||||
struct S
|
||||
{
|
||||
virtual ~S()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
S(int i): i(i){}
|
||||
|
||||
int i;
|
||||
};
|
||||
|
||||
const S raw[6] = { 1, 2, 3, 4, 5, 6 };
|
||||
|
||||
etl::vector<S, 10> dest(etl::begin(raw), etl::end(raw));
|
||||
etl::vector<S, 10> src((size_t) 2, S(8));
|
||||
|
||||
dest.insert(dest.begin(), src.begin(), src.end());
|
||||
|
||||
CHECK(dest.size() == 8);
|
||||
CHECK_EQUAL(src[0].i, dest[0].i);
|
||||
CHECK_EQUAL(src[1].i, dest[1].i);
|
||||
CHECK_EQUAL(raw[0].i, dest[2].i);
|
||||
CHECK_EQUAL(raw[1].i, dest[3].i);
|
||||
CHECK_EQUAL(raw[2].i, dest[4].i);
|
||||
CHECK_EQUAL(raw[3].i, dest[5].i);
|
||||
CHECK_EQUAL(raw[4].i, dest[6].i);
|
||||
CHECK_EQUAL(raw[5].i, dest[7].i);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_insert_n_bug)
|
||||
{
|
||||
struct S
|
||||
{
|
||||
virtual ~S()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
S(int i): i(i){}
|
||||
|
||||
int i;
|
||||
};
|
||||
|
||||
const S raw[6] = { 1, 2, 3, 4, 5, 6 };
|
||||
|
||||
etl::vector<S, 10> dest(etl::begin(raw), etl::end(raw));
|
||||
|
||||
dest.insert(dest.begin(), 2, S(8));
|
||||
|
||||
CHECK(dest.size() == 8);
|
||||
CHECK_EQUAL(8, dest[0].i);
|
||||
CHECK_EQUAL(8, dest[1].i);
|
||||
CHECK_EQUAL(raw[0].i, dest[2].i);
|
||||
CHECK_EQUAL(raw[1].i, dest[3].i);
|
||||
CHECK_EQUAL(raw[2].i, dest[4].i);
|
||||
CHECK_EQUAL(raw[3].i, dest[5].i);
|
||||
CHECK_EQUAL(raw[4].i, dest[6].i);
|
||||
CHECK_EQUAL(raw[5].i, dest[7].i);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user