3#include "collection.hpp"
4#include "collection_adapter.hpp"
5#include "type_traits.hpp"
18 template <
typename TElement>
19 struct CollectionAdapter<TElement, std::vector<TElement>> {
20 Collection<TElement> operator()(
const std::vector<TElement>& input) {
24 Collection<TElement> operator()(std::vector<TElement>&& input) {
34 template <
typename TElement,
typename TContainer>
35 struct CollectionAdapter<
38 !std::is_same_v<TElement, traits::value_type_of_t<TContainer>> &&
39 traits::is_iterable_v<TContainer> &&
40 std::is_constructible_v<
42 traits::value_type_of_t<TContainer>>
44 Collection<TElement> operator()(
const TContainer& input) {
45 std::vector<TElement> elements(std::begin(input), std::end(input));
49 Collection<TElement> operator()(TContainer&& input) {
50 std::vector<TElement> elements;
54 elements.reserve(
static_cast<size_t>(std::distance(std::begin(input), std::end(input)))
56 for (
auto& element : input) {
57 elements.emplace_back(std::move(element));
67 template <
typename TElement,
size_t NumInstances>
68 struct CollectionAdapter<TElement, std::array<TElement, NumInstances>> {
69 Collection<TElement> operator()(
const std::array<TElement, NumInstances>& array) {
73 Collection<TElement> operator()(std::array<TElement, NumInstances>&& array) {
74 std::vector<TElement> elements(
75 std::make_move_iterator(array.begin()),
76 std::make_move_iterator(array.end())
85 template <
typename TElement,
size_t NumInstances>
86 struct CollectionAdapter<TElement, TElement[NumInstances]> {
87 Collection<TElement> operator()(
const TElement (&array)[NumInstances]) {
91 Collection<TElement> operator()(TElement (&&array)[NumInstances]) {
92 std::vector<TElement> elements(
93 std::make_move_iterator(array),
94 std::make_move_iterator(array + NumInstances)
104 template <
typename TElement>
105 struct CollectionAdapter<TElement, TElement> {
106 Collection<TElement> operator()(
const TElement& one_and_only) {
110 Collection<TElement> operator()(TElement&& one_and_only) {
119 template <
typename TElement,
typename TInput>
120 struct CollectionAdapter<
123 !std::is_same_v<TElement, TInput> &&
124 !traits::is_iterable_v<TInput> &&
125 std::is_constructible_v<TElement, TInput>
127 Collection<TElement> operator()(
const TInput& input) {
131 Collection<TElement> operator()(TInput&& input) {
static Collection< TElement > take_ownership(std::vector< TElement > &&data)
Takes ownership of a temporary std::vector, moving it into the collection.
Definition collection.hpp:183
static Collection< TElement > borrow(const T *data, size_t num_instances)
Borrows binary compatible data into the collection.
Definition collection.hpp:149
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:20