diff --git a/ref_app/src/math/extended_complex/extended_complex.h b/ref_app/src/math/extended_complex/extended_complex.h index 1cc71fe4c..c965a4065 100644 --- a/ref_app/src/math/extended_complex/extended_complex.h +++ b/ref_app/src/math/extended_complex/extended_complex.h @@ -156,23 +156,25 @@ class complex { public: - typedef T value_type; + using value_type = T; EXTENDED_COMPLEX_CONSTEXPR complex(const value_type& my_x = value_type(), const value_type& my_y = value_type()) : my_re(my_x), my_im(my_y) { } - EXTENDED_COMPLEX_CONSTEXPR complex(const complex& other) : my_re(other.real()), - my_im(other.imag()) { } + EXTENDED_COMPLEX_CONSTEXPR complex(const complex& other) : my_re(other.my_re), + my_im(other.my_im) { } - EXTENDED_COMPLEX_CONSTEXPR complex(complex&& other) noexcept : my_re(std::move(static_cast(other.my_re))), - my_im(std::move(static_cast(other.my_im))) { } + EXTENDED_COMPLEX_CONSTEXPR complex(complex&& other) noexcept + : my_re(std::move(static_cast(other.my_re))), + my_im(std::move(static_cast(other.my_im))) { } template - EXTENDED_COMPLEX_CONSTEXPR complex(const complex& my_z) : my_re(static_cast(my_z.real())), - my_im(static_cast(my_z.imag())) { } + EXTENDED_COMPLEX_CONSTEXPR complex(const complex& my_z) + : my_re(static_cast(my_z.my_re)), + my_im(static_cast(my_z.my_im)) { } - EXTENDED_COMPLEX_CONSTEXPR complex& operator=(const complex& other) + EXTENDED_COMPLEX_CONSTEXPR auto operator=(const complex& other) -> complex& { if(this != &other) { @@ -183,7 +185,7 @@ return *this; } - EXTENDED_COMPLEX_CONSTEXPR complex& operator=(complex&& other) noexcept + EXTENDED_COMPLEX_CONSTEXPR auto operator=(complex&& other) noexcept -> complex& { my_re = std::move(static_cast(other.my_re)); my_im = std::move(static_cast(other.my_im)); @@ -192,7 +194,7 @@ } template - EXTENDED_COMPLEX_CONSTEXPR complex& operator=(const complex& other) + EXTENDED_COMPLEX_CONSTEXPR auto operator=(const complex& other) -> complex& { my_re = static_cast(other.my_re); my_im = static_cast(other.my_im); @@ -200,10 +202,18 @@ return *this; } - EXTENDED_COMPLEX_CONSTEXPR complex& operator=(const value_type& other_x) + EXTENDED_COMPLEX_CONSTEXPR auto operator=(const value_type& other_x) -> complex& { my_re = other_x; - my_im = static_cast(static_cast(UINT8_C(0))); + imag(static_cast(static_cast(UINT8_C(0)))); + + return *this; + } + + EXTENDED_COMPLEX_CONSTEXPR auto operator=(value_type&& other_x) noexcept -> complex& + { + my_re = std::move(other_x); + imag(static_cast(static_cast(UINT8_C(0)))); return *this; } @@ -214,6 +224,9 @@ EXTENDED_COMPLEX_CONSTEXPR auto real(const value_type& my_x) -> void { my_re = my_x; } EXTENDED_COMPLEX_CONSTEXPR auto imag(const value_type& my_y) -> void { my_im = my_y; } + EXTENDED_COMPLEX_CONSTEXPR auto real(value_type&& my_x) noexcept -> void { my_re = std::move(my_x); } + EXTENDED_COMPLEX_CONSTEXPR auto imag(value_type&& my_y) noexcept -> void { my_im = std::move(my_y); } + EXTENDED_COMPLEX_CONSTEXPR auto operator+=(const value_type& my_x) -> complex& { my_re += my_x; @@ -258,8 +271,8 @@ { if(this == &my_z) { - my_re = static_cast(static_cast(UINT8_C(0))); - my_im = static_cast(static_cast(UINT8_C(0))); + real(static_cast(static_cast(UINT8_C(0)))); + imag(static_cast(static_cast(UINT8_C(0)))); } else { @@ -273,17 +286,17 @@ template EXTENDED_COMPLEX_CONSTEXPR auto operator*=(const complex& my_z) -> complex& { - const value_type tmp_re(my_re); + const value_type tmp_re { my_re }; if(this == &my_z) { - my_re = (tmp_re * tmp_re) - (my_im * my_im); - my_im = (tmp_re * my_im) * 2U; + real((tmp_re * tmp_re) - (my_im * my_im)); + imag((tmp_re * my_im) * 2U); } else { - my_re = (tmp_re * my_z.my_re) - (my_im * my_z.my_im); - my_im = (tmp_re * my_z.my_im) + (my_im * my_z.my_re); + real((tmp_re * my_z.my_re) - (my_im * my_z.my_im)); + imag((tmp_re * my_z.my_im) + (my_im * my_z.my_re)); } return *this; @@ -294,32 +307,32 @@ { if(this == &my_z) { - my_re = static_cast(static_cast(UINT8_C(1))); - my_im = static_cast(static_cast(UINT8_C(0))); + real(static_cast(static_cast(UINT8_C(1)))); + imag(static_cast(static_cast(UINT8_C(0)))); } else { - if(fabs(my_z.real()) < fabs(my_z.imag())) + if(fabs(my_z.my_re) < fabs(my_z.my_im)) { - const value_type my_c_over_d = my_z.real() / my_z.imag(); + const value_type my_c_over_d { my_z.my_re / my_z.my_im }; - const value_type my_denominator = (my_z.real() * my_c_over_d) + my_z.imag(); + const value_type my_denominator { (my_z.my_re * my_c_over_d) + my_z.my_im }; - const value_type my_tmp_re(my_re); + const value_type my_tmp_re { my_re }; - my_re = ((my_tmp_re * my_c_over_d) + my_im) / my_denominator; - my_im = ((my_im * my_c_over_d) - my_tmp_re) / my_denominator; + real(((my_tmp_re * my_c_over_d) + my_im) / my_denominator); + imag(((my_im * my_c_over_d) - my_tmp_re) / my_denominator); } else { - const value_type my_d_over_c = my_z.imag() / my_z.real(); + const value_type my_d_over_c { my_z.my_im / my_z.my_re }; - const value_type my_denominator = (my_z.imag() * my_d_over_c) + my_z.real(); + const value_type my_denominator { (my_z.my_im * my_d_over_c) + my_z.my_re }; - const value_type my_tmp_re(my_re); + const value_type my_tmp_re { my_re }; - my_re = (( my_im * my_d_over_c) + my_tmp_re) / my_denominator; - my_im = ((-my_tmp_re * my_d_over_c) + my_im) / my_denominator; + real((( my_im * my_d_over_c) + my_tmp_re) / my_denominator); + imag(((-my_tmp_re * my_d_over_c) + my_im) / my_denominator); } } @@ -394,8 +407,8 @@ return *this; } - EXTENDED_COMPLEX_CONSTEXPR value_type real() const { return my_re; } - EXTENDED_COMPLEX_CONSTEXPR value_type imag() const { return my_im; } + EXTENDED_COMPLEX_CONSTEXPR auto real() const -> value_type { return my_re; } + EXTENDED_COMPLEX_CONSTEXPR auto imag() const -> value_type { return my_im; } EXTENDED_COMPLEX_CONSTEXPR auto real(const value_type& my_x) -> void { my_re = my_x; } EXTENDED_COMPLEX_CONSTEXPR auto imag(const value_type& my_y) -> void { my_im = my_y; } @@ -459,7 +472,7 @@ template EXTENDED_COMPLEX_CONSTEXPR auto operator*=(const complex& my_z) -> complex& { - const value_type tmp_re(my_re); + const value_type tmp_re { my_re }; if(this == &my_z) { @@ -489,22 +502,22 @@ if(fabs(my_z.real()) < fabs(my_z.imag())) { - const value_type my_c_over_d = my_z.real() / my_z.imag(); + const value_type my_c_over_d { my_z.real() / my_z.imag() }; - const value_type my_denominator = (my_z.real() * my_c_over_d) + my_z.imag(); + const value_type my_denominator { (my_z.real() * my_c_over_d) + my_z.imag() }; - const value_type my_tmp_re(my_re); + const value_type my_tmp_re { my_re }; real(((my_tmp_re * my_c_over_d) + my_im) / my_denominator); imag(((my_im * my_c_over_d) - my_tmp_re) / my_denominator); } else { - const value_type my_d_over_c = my_z.imag() / my_z.real(); + const value_type my_d_over_c { my_z.imag() / my_z.real() }; - const value_type my_denominator = (my_z.imag() * my_d_over_c) + my_z.real(); + const value_type my_denominator { (my_z.imag() * my_d_over_c) + my_z.real() }; - const value_type my_tmp_re(my_re); + const value_type my_tmp_re { my_re }; real((( my_im * my_d_over_c) + my_tmp_re) / my_denominator); imag(((-my_tmp_re * my_d_over_c) + my_im) / my_denominator); diff --git a/ref_app/src/util/STL/array b/ref_app/src/util/STL/array index bd6aa9aff..78c53c879 100644 --- a/ref_app/src/util/STL/array +++ b/ref_app/src/util/STL/array @@ -41,8 +41,8 @@ static STL_LOCAL_CONSTEXPR size_type static_size = N; - STL_LOCAL_CONSTEXPR_ALGORITHMS iterator begin() { return elems; } - STL_LOCAL_CONSTEXPR_ALGORITHMS iterator end () { return elems + N; } + STL_LOCAL_CONSTEXPR iterator begin() { return elems; } + STL_LOCAL_CONSTEXPR iterator end () { return elems + N; } STL_LOCAL_CONSTEXPR const_iterator begin() const { return elems; } STL_LOCAL_CONSTEXPR const_iterator end () const { return elems + N; } @@ -50,8 +50,8 @@ STL_LOCAL_CONSTEXPR const_iterator cbegin() const { return elems; } STL_LOCAL_CONSTEXPR const_iterator cend () const { return elems + N; } - STL_LOCAL_CONSTEXPR_ALGORITHMS reverse_iterator rbegin() { return reverse_iterator(elems + N); } - STL_LOCAL_CONSTEXPR_ALGORITHMS reverse_iterator rend () { return reverse_iterator(elems); } + STL_LOCAL_CONSTEXPR reverse_iterator rbegin() { return reverse_iterator(elems + N); } + STL_LOCAL_CONSTEXPR reverse_iterator rend () { return reverse_iterator(elems); } STL_LOCAL_CONSTEXPR const_reverse_iterator rbegin() const { return const_reverse_iterator(elems + N); } STL_LOCAL_CONSTEXPR const_reverse_iterator rend () const { return const_reverse_iterator(elems); } @@ -59,54 +59,54 @@ STL_LOCAL_CONSTEXPR const_reverse_iterator crbegin() const { return const_reverse_iterator(elems + N); } STL_LOCAL_CONSTEXPR const_reverse_iterator crend () const { return const_reverse_iterator(elems); } - STL_LOCAL_CONSTEXPR_ALGORITHMS reference operator[](const size_type i) { return elems[i]; } - STL_LOCAL_CONSTEXPR const_reference operator[](const size_type i) const { return elems[i]; } + STL_LOCAL_CONSTEXPR reference operator[](const size_type i) { return elems[i]; } + STL_LOCAL_CONSTEXPR const_reference operator[](const size_type i) const { return elems[i]; } - STL_LOCAL_CONSTEXPR_ALGORITHMS reference at(const size_type i) { return elems[i]; } - STL_LOCAL_CONSTEXPR const_reference at(const size_type i) const { return elems[i]; } + STL_LOCAL_CONSTEXPR reference at(const size_type i) { return elems[i]; } + STL_LOCAL_CONSTEXPR const_reference at(const size_type i) const { return elems[i]; } - STL_LOCAL_CONSTEXPR_ALGORITHMS reference front() { return elems[0U]; } - STL_LOCAL_CONSTEXPR const_reference front() const { return elems[0U]; } + STL_LOCAL_CONSTEXPR reference front() { return elems[0U]; } + STL_LOCAL_CONSTEXPR const_reference front() const { return elems[0U]; } - STL_LOCAL_CONSTEXPR_ALGORITHMS reference back() { return elems[N - 1U]; } - STL_LOCAL_CONSTEXPR const_reference back() const { return elems[N - 1U]; } + STL_LOCAL_CONSTEXPR reference back() { return elems[N - 1U]; } + STL_LOCAL_CONSTEXPR const_reference back() const { return elems[N - 1U]; } static STL_LOCAL_CONSTEXPR size_type size() { return N; } static STL_LOCAL_CONSTEXPR bool empty() { return false; } static STL_LOCAL_CONSTEXPR size_type max_size() { return N; } template - STL_LOCAL_CONSTEXPR_ALGORITHMS void swap(array& y) + STL_LOCAL_CONSTEXPR void swap(array& y) { std::swap_ranges(begin(), end(), y.begin()); } - STL_LOCAL_CONSTEXPR const_pointer data() const { return elems; } - STL_LOCAL_CONSTEXPR_ALGORITHMS pointer data() { return elems; } + STL_LOCAL_CONSTEXPR const_pointer data() const { return elems; } + STL_LOCAL_CONSTEXPR pointer data() { return elems; } pointer c_array() { return elems; } template - STL_LOCAL_CONSTEXPR_ALGORITHMS array& operator=(const array& y) + STL_LOCAL_CONSTEXPR array& operator=(const array& y) { std::copy(y.begin(), y.end(), begin()); return *this; } - STL_LOCAL_CONSTEXPR_ALGORITHMS void assign(const value_type& value) + STL_LOCAL_CONSTEXPR void assign(const value_type& value) { std::fill_n(elems, N, value); } - STL_LOCAL_CONSTEXPR_ALGORITHMS void fill(const value_type& value) + STL_LOCAL_CONSTEXPR void fill(const value_type& value) { std::fill_n(elems, N, value); } }; template - STL_LOCAL_CONSTEXPR_ALGORITHMS bool operator==(const array& left, const array& right) + STL_LOCAL_CONSTEXPR bool operator==(const array& left, const array& right) { return std::equal(left.begin(), left.end(), right.begin()); } @@ -121,31 +121,31 @@ } template - STL_LOCAL_CONSTEXPR_ALGORITHMS bool operator!=(const array& left, const array& right) + STL_LOCAL_CONSTEXPR bool operator!=(const array& left, const array& right) { return (!(left == right)); } template - STL_LOCAL_CONSTEXPR_ALGORITHMS bool operator>(const array& left, const array& right) + STL_LOCAL_CONSTEXPR bool operator>(const array& left, const array& right) { return (right < left); } template - STL_LOCAL_CONSTEXPR_ALGORITHMS bool operator>=(const array& left, const array& right) + STL_LOCAL_CONSTEXPR bool operator>=(const array& left, const array& right) { return (!(left < right)); } template - STL_LOCAL_CONSTEXPR_ALGORITHMS bool operator<=(const array& left, const array& right) + STL_LOCAL_CONSTEXPR bool operator<=(const array& left, const array& right) { return (!(right < left)); } template - STL_LOCAL_CONSTEXPR_ALGORITHMS void swap(array& x, array& y) + STL_LOCAL_CONSTEXPR void swap(array& x, array& y) { swap_ranges(x.begin(), x.end(), y.begin()); }