Ruby STL container setting slices fixes
Setting an STL container wrapper slice better matches the way Ruby arrays work. The behaviour is now the same as Ruby arrays. The only exception is the default value used when expanding a container cannot be nil as this is not a valid type/value for C++ container elements.
This commit is contained in:
parent
cd33aba427
commit
bb2523a003
4 changed files with 68 additions and 22 deletions
|
|
@ -41,7 +41,7 @@
|
|||
getslice(const std::array<T, N>* self, Difference i, Difference j) {
|
||||
using Sequence = std::array<T, N>;
|
||||
typename Sequence::size_type size = self->size();
|
||||
typename Sequence::size_type ii = (i == size && j == size) ? i : swig::check_index(i, size);
|
||||
typename Sequence::size_type ii = swig::check_index(i, size, (i == size && j == size));
|
||||
typename Sequence::size_type jj = swig::slice_index(j, size);
|
||||
|
||||
if (ii == 0 && jj == size) {
|
||||
|
|
@ -61,7 +61,6 @@
|
|||
typename Sequence::size_type ii = swig::check_index(i, size, true);
|
||||
typename Sequence::size_type jj = swig::slice_index(j, size);
|
||||
|
||||
std::cout << "setslice " << v[0] << " " << v[1] << std::endl;
|
||||
if (ii == 0 && jj == size) {
|
||||
std::copy(v.begin(), v.end(), self->begin());
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue