Fix to alternate copy return value.

This commit is contained in:
John Wellbelove 2019-11-21 12:29:20 +00:00
parent c69ca9e41d
commit 487064b864
2 changed files with 27 additions and 7 deletions

View File

@ -73,8 +73,9 @@ namespace ETLSTD
copy(TIterator1 sb, TIterator1 se, TIterator2 db)
{
typedef typename ETLSTD::iterator_traits<TIterator1>::value_type value_t;
typedef typename ETLSTD::iterator_traits<TIterator1>::difference_type difference_t;
return TIterator2(memcpy(db, sb, sizeof(value_t) * (se - sb)));
return TIterator2(memcpy(db, sb, sizeof(value_t) * (se - sb))) + (se - sb);
}
// Other iterator

View File

@ -166,8 +166,15 @@ namespace
int data1[10];
int data2[10];
std::copy(std::begin(dataA), std::end(dataA), std::begin(data1));
etlstd::copy(std::begin(dataA), std::end(dataA), std::begin(data2));
int* pstl = std::copy(std::begin(dataA), std::end(dataA), std::begin(data1));
int* petl = etlstd::copy(std::begin(dataA), std::end(dataA), std::begin(data2));
using difference_type_t = std::iterator_traits<int*>::difference_type;
difference_type_t dstl = std::distance(data1, pstl);
difference_type_t detl = std::distance(data2, petl);
CHECK_EQUAL(dstl, detl);
bool isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2));
CHECK(isEqual);
@ -179,8 +186,15 @@ namespace
Data data1[10];
Data data2[10];
std::copy(std::begin(dataD), std::end(dataD), std::begin(data1));
etlstd::copy(std::begin(dataD), std::end(dataD), std::begin(data2));
Data* pstl = std::copy(std::begin(dataD), std::end(dataD), std::begin(data1));
Data* petl = etlstd::copy(std::begin(dataD), std::end(dataD), std::begin(data2));
using difference_type_t = std::iterator_traits<Data*>::difference_type;
difference_type_t dstl = std::distance(data1, pstl);
difference_type_t detl = std::distance(data2, petl);
CHECK_EQUAL(dstl, detl);
bool isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2));
CHECK(isEqual);
@ -192,8 +206,13 @@ namespace
List data1(dataL.size());
List data2(dataL.size());
std::copy(std::begin(dataA), std::end(dataA), std::begin(data1));
etlstd::copy(std::begin(dataA), std::end(dataA), std::begin(data2));
List::iterator pstl = std::copy(std::begin(dataA), std::end(dataA), std::begin(data1));
List::iterator petl = etlstd::copy(std::begin(dataA), std::end(dataA), std::begin(data2));
using difference_type_t = List::difference_type;
difference_type_t dstl = std::distance(data1.begin(), pstl);
difference_type_t detl = std::distance(data2.begin(), petl);
bool isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2));
CHECK(isEqual);