Stratax 0.4.0rc1
Loading...
Searching...
No Matches
Compound.hpp
Go to the documentation of this file.
1
4#pragma once
5
7
8#include <cstddef>
9#include <type_traits>
10#include <vector>
11
12namespace stratax::core::compound_detail {
13
33template<bool Stage, Array A, typename Evaluate>
34A& write_results(A& lhs, Evaluate evaluate)
35{
36 const auto count = lhs.size();
37 if constexpr (Stage)
38 {
39 std::vector<typename A::value_type> results;
40 results.reserve(count);
41 for (std::size_t i = 0; i < count; ++i)
42 {
43 results.push_back(static_cast<typename A::value_type>(evaluate(i)));
44 }
45 for (std::size_t i = 0; i < count; ++i)
46 {
47 lhs[i] = results[i];
48 }
49 }
50 else
51 {
52 for (std::size_t i = 0; i < count; ++i)
53 {
54 lhs[i] = static_cast<typename A::value_type>(evaluate(i));
55 }
56 }
57 return lhs;
58}
59
61template<typename A>
62inline constexpr bool owns_storage = is_array<std::remove_cvref_t<A>>::value;
63
64} // namespace stratax::core::compound_detail
constexpr bool owns_storage
True for a Stratax container with unique owning element storage.
Definition Compound.hpp:62
A & write_results(A &lhs, Evaluate evaluate)
Writes computed values, staging them when storage may overlap.
Definition Compound.hpp:34
Dtype and array interface concepts.
Trait identifying supported Stratax owning array specializations.
Definition Concepts.hpp:106