15 #ifndef ALLIUM_LA_VECTOR_TRAIT_HPP
16 #define ALLIUM_LA_VECTOR_TRAIT_HPP
18 #include <allium/util/crtp.hpp>
19 #include <allium/util/numeric.hpp>
29 template <
typename Derived,
typename N>
34 using Real = real_part_t<Number>;
36 template <
typename Other>
37 Derived& operator-= (
const Other& other) {
38 derived(
this) += (-1.0 * other);
42 Derived& operator/= (Number divisor) {
43 derived(
this) *= (Number(1.0) / divisor);
47 template <
typename Other>
48 Derived operator+ (
const Other& rhs)
const {
49 Derived result(derived(
this));
54 template <
typename Other>
55 Derived operator- (
const Other& rhs)
const {
56 Derived result(derived(
this));
61 Derived operator* (Number factor)
const {
62 Derived result(derived(
this));
67 Derived operator/ (Number divisor)
const {
68 Derived result(derived(
this));
74 template <
typename T,
typename R =
void>
75 using enable_if_vector
82 enable_if_vector<T, T>
83 operator* (
typename T::Number factor,
const T& rhs) {
Generates common vector operations automatically.
Definition: vector_trait.hpp:31
Trait that implements the self helper routine for the curiously recurring template pattern.
Definition: crtp.hpp:36