@@ -77,30 +77,28 @@ class Vector : public std::array<T, N>
77
77
constexpr Vector ()
78
78
{ this ->fill (0 ); }
79
79
80
+ template <typename U>
81
+ requires std::convertible_to<U, T>
82
+ constexpr explicit Vector (U v)
83
+ { this ->fill (modm::round_smart<T, U>(v)); }
84
+
85
+ template <typename U>
86
+ constexpr Vector (const U (&arr)[N])
87
+ { std::transform (std::begin (arr), std::end (arr), this ->begin (), [] (U v) { return modm::round_smart<T, U>(v); }); }
88
+
80
89
/* *
81
90
* @brief Multi purpose constructor.
82
91
*
83
- * @param args scalars, Vectors and Arrays in your desired order
92
+ * @param args Scalar type(s), modm::Vector(s) or std::array(s) in any order
84
93
*/
85
94
template <class ... Args>
86
95
constexpr Vector (Args... args)
87
96
{
88
- // Is perfect forwarding required here?
97
+ // Not sure if perfect forwarding is required here ! ?
89
98
// assign<0>(std::forward<Args>(args)...);
90
99
assign<0 >(args...);
91
100
}
92
101
93
- template <typename U>
94
- requires std::convertible_to<U, T>
95
- constexpr explicit Vector (U v)
96
- { this ->fill (modm::round_smart<T, U>(v)); }
97
-
98
- template <typename U>
99
- constexpr Vector (const U (&arr)[N])
100
- {
101
- std::transform (std::begin (arr), std::end (arr), this ->begin (), [] (U v) { return modm::round_smart<T, U>(v); });
102
- }
103
-
104
102
template <typename U>
105
103
[[deprecated(" Use constructor instead!" )]]
106
104
Vector<U, N> convert() const
@@ -157,7 +155,7 @@ class Vector : public std::array<T, N>
157
155
{
158
156
Vector<U, N> res;
159
157
160
- // no clue why, but RVO / Loop unrolling is not applied for this ...
158
+ // no clue why, but RVO / Loop unrolling does not apply here ...
161
159
// std::transform(this->begin(), this->end(), other.begin(), res.begin(), Func{});
162
160
163
161
// ... but this optimizes perfectly.
@@ -183,7 +181,7 @@ class Vector : public std::array<T, N>
183
181
{
184
182
Vector<U, N> res;
185
183
186
- // no clue why, but RVO / Loop unrolling is not applied for this ...
184
+ // no clue why, but RVO / Loop unrolling does not apply here ...
187
185
// std::transform(this->begin(), this->end(), res.begin(), Func{});
188
186
189
187
// ... but this optimizes perfectly.
@@ -209,7 +207,7 @@ class Vector : public std::array<T, N>
209
207
{
210
208
Vector<U, N> res;
211
209
212
- // no clue why, but RVO / Loop unrolling is not applied for this ...
210
+ // no clue why, but RVO / Loop unrolling does not apply here ...
213
211
// std::transform(this->begin(), this->end(), res.begin(), Func{});
214
212
215
213
// ... but this optimizes perfectly.
@@ -430,7 +428,7 @@ class Vector : public std::array<T, N>
430
428
constexpr float getAngleTo (const Vector& other) const requires (N == 2 )
431
429
{ return (other - *this ).getAngle (); }
432
430
433
- // TODO implement as operator+=(Angle phi), operator-=(Angle phi) instead ??
431
+ // TODO implement as operator+=(Angle phi), operator-=(Angle phi) ??
434
432
constexpr Vector& rotate (float phi) requires (N == 2 )
435
433
{
436
434
const float c = std::cos (phi);
0 commit comments