Program Listing for File commaInitializer.hpp#
↰ Return to documentation for file (librapid/include/librapid/array/commaInitializer.hpp)
#ifndef LIBRAPID_ARRAY_COMMA_INITIALIZER_HPP
#define LIBRAPID_ARRAY_COMMA_INITIALIZER_HPP
namespace librapid::detail {
template<typename ArrT>
class CommaInitializer {
public:
using Scalar = typename typetraits::TypeInfo<ArrT>::Scalar;
CommaInitializer() = delete;
template<typename T>
explicit LIBRAPID_ALWAYS_INLINE CommaInitializer(ArrT &dst, const T &val) : m_array(dst) {
next(static_cast<Scalar>(val));
}
template<typename T>
LIBRAPID_ALWAYS_INLINE CommaInitializer &operator,(const T &val) {
next(static_cast<Scalar>(val));
return *this;
}
private:
LIBRAPID_ALWAYS_INLINE void next(const Scalar &other) {
m_array.storage()[m_index] = other;
++m_index;
}
ArrT &m_array;
int64_t m_index = 0;
};
} // namespace librapid::detail
#endif // LIBRAPID_ARRAY_COMMA_INITIALIZER_HPP