3 #include <iolink/IOLinkAPI.h>
7 #include <initializer_list>
22 using Iterator = ValueType*;
23 using ConstIterator =
const ValueType*;
48 VectorX(std::initializer_list<ValueType> init);
60 for (
size_t i = 0; i < m_size; ++i)
62 m_data[i] =
static_cast<ValueType
>(other[i]);
77 inline size_t size()
const {
return m_size; }
82 inline ValueType
at(
size_t index)
const {
return m_data[index]; }
87 inline void setAt(
size_t index, ValueType value) { m_data[index] = value; }
89 inline ValueType& operator[](
size_t index) {
return m_data[index]; }
90 inline ValueType operator[](
size_t index)
const {
return m_data[index]; }
92 inline Iterator begin() noexcept {
return m_data; }
93 inline ConstIterator begin() const noexcept {
return m_data; }
94 inline Iterator end() noexcept {
return static_cast<Iterator
>(m_data + m_size); }
95 inline ConstIterator end() const noexcept {
return static_cast<ConstIterator
>(m_data + m_size); }
97 bool operator==(
const VectorX& other)
const;
98 bool operator!=(
const VectorX& other)
const;
119 std::string toString()
const;
133 VectorX& operator*=(ValueType value);
134 VectorX& operator/=(ValueType value);
136 inline VectorX operator*(ValueType s)
const {
return VectorX(*
this) *= s; }
137 inline VectorX operator/(ValueType s)
const {
return VectorX(*
this) /= s; }
139 friend inline VectorX operator*(ValueType s,
VectorX v) {
return v *= s; }
163 bool operator<(
const VectorX& other)
const;
164 bool operator<=(
const VectorX& other)
const;
165 bool operator>(
const VectorX& other)
const;
166 bool operator>=(
const VectorX& other)
const;
178 std::array<ValueType, 4> m_array;
181 template <
typename T>
183 operator<<(std::ostream& os,
const VectorX<T>& v)
193 extern template class IOLINK_API_IMPORT VectorX<uint8_t>;
194 extern template class IOLINK_API_IMPORT VectorX<int8_t>;
195 extern template class IOLINK_API_IMPORT VectorX<uint16_t>;
196 extern template class IOLINK_API_IMPORT VectorX<int16_t>;
197 extern template class IOLINK_API_IMPORT VectorX<uint32_t>;
198 extern template class IOLINK_API_IMPORT VectorX<int32_t>;
199 extern template class IOLINK_API_IMPORT VectorX<uint64_t>;
200 extern template class IOLINK_API_IMPORT VectorX<int64_t>;
201 extern template class IOLINK_API_IMPORT VectorX<float>;
202 extern template class IOLINK_API_IMPORT VectorX<double>;