2#include <ossia/network/value/value.hpp>
8template <
typename TernaryFun>
9struct apply_ternary_fun_visitor
11 template <
typename T,
typename U,
typename V>
16#if !defined(FAST_COMPILES)
17 template <
typename U,
typename V>
20 return std::move(val);
22 template <
typename U,
typename V>
27 template <
typename U,
typename V>
30 return std::move(val);
32 template <
typename U,
typename V>
41 return TernaryFun::compute(val,
min,
max);
45 return TernaryFun::compute(val,
min,
max);
49 return (
char)TernaryFun::compute((int32_t)val, (int32_t)
min, (int32_t)
max);
53 return (
bool)TernaryFun::compute((int32_t)val, (int32_t)
min, (int32_t)
max);
56 template <std::
size_t N>
58 std::array<float, N> val,
const std::array<float, N>&
min,
59 const std::array<float, N>&
max)
61 for(std::size_t i = 0; i < N; i++)
63 val[i] = TernaryFun::compute(val[i],
min[i],
max[i]);
68 template <std::
size_t N>
71 for(std::size_t i = 0; i < N; i++)
73 val[i] = TernaryFun::compute(val[i],
min,
max);
81 const std::vector<ossia::value>& incoming,
const std::vector<ossia::value>&
min,
82 const std::vector<ossia::value>&
max)
84 std::vector<ossia::value> val;
85 const auto N = incoming.size();
86 const auto nmin =
min.size();
87 const auto nmax =
max.size();
88 if(N == nmin && N == nmax)
91 for(std::size_t i = 0; i < N; i++)
93 val.push_back(ossia::apply(*
this, incoming[i].v,
min[i].v,
max[i].v));
100 std::vector<ossia::value>&& val,
const std::vector<ossia::value>&
min,
101 const std::vector<ossia::value>&
max)
103 const auto N = val.size();
104 const auto nmin =
min.size();
105 const auto nmax =
max.size();
106 if(N == nmin && N == nmax)
108 for(std::size_t i = 0; i < N; i++)
110 val[i] = ossia::apply(*
this, std::move(val)[i].v,
min[i].v,
max[i].v);
120 std::vector<ossia::value> val;
121 const auto N = incoming.size();
123 for(std::size_t i = 0; i < N; i++)
125 val.push_back(ossia::apply(*
this, incoming[i].v,
min.v,
max.v));
133 const auto N = val.size();
134 for(std::size_t i = 0; i < N; i++)
136 val[i] = ossia::apply(*
this, std::move(val)[i].v,
min.v,
max.v);
144 return ossia::apply(*
this, val.v,
min.v,
max.v);
150 return ossia::apply(*
this, std::move(val.v),
min.v,
max.v);
155template <
typename BinaryFun>
156struct apply_binary_fun_visitor
158 template <
typename T,
typename U>
164#if !defined(FAST_COMPILES)
165 template <
typename U>
168 return std::move(val);
170 template <
typename U>
175 template <
typename U>
178 return std::move(val);
180 template <
typename U>
189 return int32_t{BinaryFun::compute(val,
min)};
193 return float{BinaryFun::compute(val,
min)};
197 return (
char)BinaryFun::compute((int32_t)val, (int32_t)
min);
201 return (
bool)BinaryFun::compute((int32_t)val, (int32_t)
min);
204 template <std::
size_t N>
205 ossia::value operator()(std::array<float, N> val,
const std::array<float, N>&
min)
207 for(std::size_t i = 0; i < N; i++)
209 val[i] = BinaryFun::compute(val[i],
min[i]);
214 template <std::
size_t N>
217 for(std::size_t i = 0; i < N; i++)
219 val[i] = BinaryFun::compute(val[i],
min);
227 const std::vector<ossia::value>& incoming,
const std::vector<ossia::value>&
min)
229 std::vector<ossia::value> val;
230 const auto N = incoming.size();
231 const auto nmin =
min.size();
235 for(std::size_t i = 0; i < N; i++)
237 val.push_back(ossia::apply(*
this, incoming[i].v,
min[i].v));
244 operator()(std::vector<ossia::value>&& val,
const std::vector<ossia::value>&
min)
246 const auto N = val.size();
247 const auto nmin =
min.size();
250 for(std::size_t i = 0; i < N; i++)
252 val[i] = ossia::apply(*
this, std::move(val)[i].v,
min[i].v);
259 operator()(
const std::vector<ossia::value>& incoming,
const ossia::value&
min)
261 std::vector<ossia::value> val;
262 const auto N = incoming.size();
264 for(std::size_t i = 0; i < N; i++)
266 val.push_back(ossia::apply(*
this, incoming[i].v,
min.v));
273 const auto N = val.size();
274 for(std::size_t i = 0; i < N; i++)
276 val[i] = ossia::apply(*
this, std::move(val)[i].v,
min.v);
283 return ossia::apply(*
this, val.v,
min.v);
288 return ossia::apply(*
this, std::move(val.v),
min.v);
The value class.
Definition value.hpp:173
OSSIA_INLINE constexpr auto min(const T a, const U b) noexcept -> typename std::conditional<(sizeof(T) > sizeof(U)), T, U >::type
min function tailored for values
Definition math.hpp:125
OSSIA_INLINE constexpr auto max(const T a, const U b) noexcept -> typename std::conditional<(sizeof(T) > sizeof(U)), T, U >::type
max function tailored for values
Definition math.hpp:96