Skip to content
Snippets Groups Projects
Commit 6211cf54 authored by Wilson Jallet's avatar Wilson Jallet :clapper:
Browse files

[std-array] array_indexing_suite: get_slice returns std::vector<T>

parent d0f7674a
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,7 @@ class array_indexing_suite ...@@ -32,6 +32,7 @@ class array_indexing_suite
typedef typename Container::size_type index_type; typedef typename Container::size_type index_type;
typedef typename Container::size_type size_type; typedef typename Container::size_type size_type;
typedef typename Container::difference_type difference_type; typedef typename Container::difference_type difference_type;
static constexpr std::size_t Size = std::tuple_size<Container>{};
template <class Class> template <class Class>
static void extension_def(Class &) {} static void extension_def(Class &) {}
...@@ -67,10 +68,12 @@ class array_indexing_suite ...@@ -67,10 +68,12 @@ class array_indexing_suite
static bp::object get_slice(Container &container, index_type from, static bp::object get_slice(Container &container, index_type from,
index_type to) { index_type to) {
if (from > to) return bp::object(Container()); if (from > to) return bp::object(std::array<data_type, 0>());
size_t size = to - from + 1; // will be >= 0
Container out; std::vector<data_type> out;
std::copy(container.begin() + from, container.begin() + to, out.begin()); for (size_t i = 0; i < size; i++) {
out.push_back(container[i]);
}
return bp::object(std::move(out)); return bp::object(std::move(out));
} }
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment