21 #ifndef otb_VariadicConcatenateFunctor_h
22 #define otb_VariadicConcatenateFunctor_h
24 #include "itkVariableLengthVector.h"
36 namespace variadic_concatenate_details
42 static_assert(std::is_scalar<T>::value,
43 "variadic_concatenate_details::NumberOfElements<T> only works for T and itk::VariableLengthVector<T> where T is a scalar type.");
50 static_assert(std::is_scalar<T>::value,
51 "variadic_concatenate_details::NumberOfElements<T> only works for T and itk::VariableLengthVector<T> where T is a scalar type.");
55 template <
typename... T>
59 return std::accumulate(sizes.begin(), sizes.end(), 0);
62 template <
typename Out,
typename T>
63 size_t fillVector(itk::VariableLengthVector<Out>& out,
size_t idx,
const T& t)
65 assert(idx < out.GetSize());
66 out[idx] =
static_cast<Out
>(t);
70 template <
typename Out,
typename T>
71 size_t fillVector(itk::VariableLengthVector<Out>& out,
size_t idx,
const itk::VariableLengthVector<T>& t)
73 assert(idx + t.GetSize() <= out.GetSize());
74 for (
auto it = 0UL; it < t.GetSize(); ++it)
75 out[idx + it] =
static_cast<Out
>(t[it]);
76 return idx + t.GetSize();
79 template <
typename Out,
typename Current,
typename... T>
80 size_t fillVector(itk::VariableLengthVector<Out>& out,
size_t idx,
const Current& current,
const T&... t)
97 template <
typename TOut,
typename... TIns>
103 itk::VariableLengthVector<TOut> out(numberOfElements);
112 constexpr
size_t OutputSize(
const std::array<
size_t,
sizeof...(TIns)> inputsNbBands)
const
114 return std::accumulate(inputsNbBands.begin(), inputsNbBands.end(), 0);