diff --git a/include/xtensor/containers/xscalar.hpp b/include/xtensor/containers/xscalar.hpp index 106a65923..2c5896c1b 100644 --- a/include/xtensor/containers/xscalar.hpp +++ b/include/xtensor/containers/xscalar.hpp @@ -159,12 +159,12 @@ namespace xt using accessible_base::shape; template - reference operator()(Args...) noexcept; + reference operator()(Args...); template reference unchecked(Args...) noexcept; template - const_reference operator()(Args...) const noexcept; + const_reference operator()(Args...) const; template const_reference unchecked(Args...) const noexcept; @@ -551,7 +551,7 @@ namespace xt template template - inline auto xscalar::operator()(Args...) noexcept -> reference + inline auto xscalar::operator()(Args...) -> reference { XTENSOR_CHECK_DIMENSION((std::array()), Args()...); return m_value; @@ -566,7 +566,7 @@ namespace xt template template - inline auto xscalar::operator()(Args...) const noexcept -> const_reference + inline auto xscalar::operator()(Args...) const -> const_reference { XTENSOR_CHECK_DIMENSION((std::array()), Args()...); return m_value; diff --git a/include/xtensor/core/xaccessible.hpp b/include/xtensor/core/xaccessible.hpp index 8ca55f8a4..6b94bebf7 100644 --- a/include/xtensor/core/xaccessible.hpp +++ b/include/xtensor/core/xaccessible.hpp @@ -37,7 +37,7 @@ namespace xt using size_type = typename inner_types::size_type; size_type size() const noexcept(noexcept(derived_cast().shape())); - size_type dimension() const noexcept; + size_type dimension() const noexcept(noexcept(derived_cast().shape())); size_type shape(size_type index) const; template @@ -147,7 +147,7 @@ namespace xt * Returns the number of dimensions of the expression. */ template - inline auto xconst_accessible::dimension() const noexcept -> size_type + inline auto xconst_accessible::dimension() const noexcept(noexcept(derived_cast().shape())) -> size_type { return derived_cast().shape().size(); } diff --git a/include/xtensor/core/xexpression.hpp b/include/xtensor/core/xexpression.hpp index 49a662f17..d9ffd5a09 100644 --- a/include/xtensor/core/xexpression.hpp +++ b/include/xtensor/core/xexpression.hpp @@ -424,29 +424,33 @@ namespace xt return m_ptr->name(); \ } -#define XTENSOR_FORWARD_CONST_ITERATOR_METHOD(name) \ - template \ - auto name() const noexcept -> decltype(std::declval>().template name()) \ - { \ - return m_ptr->template name(); \ - } \ - template \ - auto name(const S& shape) const noexcept \ - -> decltype(std::declval>().template name(shape)) \ - { \ - return m_ptr->template name(); \ +#define XTENSOR_FORWARD_CONST_ITERATOR_METHOD(name) \ + template \ + auto name() const noexcept(noexcept(std::declval>().template name())) \ + -> decltype(std::declval>().template name()) \ + { \ + return m_ptr->template name(); \ + } \ + template \ + auto name(const S& shape) \ + const noexcept(noexcept(std::declval>().template name(shape))) \ + -> decltype(std::declval>().template name(shape)) \ + { \ + return m_ptr->template name(); \ } -#define XTENSOR_FORWARD_ITERATOR_METHOD(name) \ - template \ - auto name(const S& shape) noexcept -> decltype(std::declval().template name(shape)) \ - { \ - return m_ptr->template name(); \ - } \ - template \ - auto name() noexcept -> decltype(std::declval().template name()) \ - { \ - return m_ptr->template name(); \ +#define XTENSOR_FORWARD_ITERATOR_METHOD(name) \ + template \ + auto name(const S& shape) noexcept(noexcept(std::declval().template name(shape))) \ + -> decltype(std::declval().template name(shape)) \ + { \ + return m_ptr->template name(); \ + } \ + template \ + auto name() noexcept(noexcept(std::declval().template name())) \ + -> decltype(std::declval().template name()) \ + { \ + return m_ptr->template name(); \ } namespace detail diff --git a/include/xtensor/core/xfunction.hpp b/include/xtensor/core/xfunction.hpp index 99144b377..30b6c458b 100644 --- a/include/xtensor/core/xfunction.hpp +++ b/include/xtensor/core/xfunction.hpp @@ -50,8 +50,8 @@ namespace xt bool is_trivial; bool is_initialized; - xfunction_cache_impl() - : shape(xtl::make_sequence(0, std::size_t(0))) + xfunction_cache_impl() noexcept + : shape() , is_trivial(false) , is_initialized(false) { @@ -272,10 +272,13 @@ namespace xt using const_reverse_iterator = typename iterable_base::const_reverse_iterator; template , self_type>::value>> - xfunction(Func&& f, CTA&&... e) noexcept; + xfunction(Func&& f, CTA&&... e) noexcept( + std::is_nothrow_constructible::value + && std::is_nothrow_constructible::value + ); template - xfunction(xfunction xf) noexcept; + xfunction(xfunction xf); ~xfunction() = default; @@ -498,7 +501,10 @@ namespace xt */ template template - inline xfunction::xfunction(Func&& f, CTA&&... e) noexcept + inline xfunction::xfunction(Func&& f, CTA&&... e) noexcept( + std::is_nothrow_constructible::value + && std::is_nothrow_constructible::value + ) : m_e(std::forward(e)...) , m_f(std::forward(f)) { @@ -511,7 +517,7 @@ namespace xt */ template template - inline xfunction::xfunction(xfunction xf) noexcept + inline xfunction::xfunction(xfunction xf) : m_e(xf.arguments()) , m_f(xf.functor()) { diff --git a/include/xtensor/core/xiterable.hpp b/include/xtensor/core/xiterable.hpp index 62f48173a..d10f3718e 100644 --- a/include/xtensor/core/xiterable.hpp +++ b/include/xtensor/core/xiterable.hpp @@ -74,40 +74,40 @@ namespace xt using const_reverse_iterator = const_reverse_layout_iterator; template - const_layout_iterator begin() const noexcept; + const_layout_iterator begin() const; template - const_layout_iterator end() const noexcept; + const_layout_iterator end() const; template - const_layout_iterator cbegin() const noexcept; + const_layout_iterator cbegin() const; template - const_layout_iterator cend() const noexcept; + const_layout_iterator cend() const; template - const_reverse_layout_iterator rbegin() const noexcept; + const_reverse_layout_iterator rbegin() const; template - const_reverse_layout_iterator rend() const noexcept; + const_reverse_layout_iterator rend() const; template - const_reverse_layout_iterator crbegin() const noexcept; + const_reverse_layout_iterator crbegin() const; template - const_reverse_layout_iterator crend() const noexcept; + const_reverse_layout_iterator crend() const; template - const_broadcast_iterator begin(const S& shape) const noexcept; + const_broadcast_iterator begin(const S& shape) const; template - const_broadcast_iterator end(const S& shape) const noexcept; + const_broadcast_iterator end(const S& shape) const; template - const_broadcast_iterator cbegin(const S& shape) const noexcept; + const_broadcast_iterator cbegin(const S& shape) const; template - const_broadcast_iterator cend(const S& shape) const noexcept; + const_broadcast_iterator cend(const S& shape) const; template - const_reverse_broadcast_iterator rbegin(const S& shape) const noexcept; + const_reverse_broadcast_iterator rbegin(const S& shape) const; template - const_reverse_broadcast_iterator rend(const S& shape) const noexcept; + const_reverse_broadcast_iterator rend(const S& shape) const; template - const_reverse_broadcast_iterator crbegin(const S& shape) const noexcept; + const_reverse_broadcast_iterator crbegin(const S& shape) const; template - const_reverse_broadcast_iterator crend(const S& shape) const noexcept; + const_reverse_broadcast_iterator crend(const S& shape) const; protected: @@ -116,19 +116,19 @@ namespace xt private: template - const_layout_iterator get_cbegin(bool end_index) const noexcept; + const_layout_iterator get_cbegin(bool end_index) const; template - const_layout_iterator get_cend(bool end_index) const noexcept; + const_layout_iterator get_cend(bool end_index) const; template - const_broadcast_iterator get_cbegin(const S& shape, bool end_index) const noexcept; + const_broadcast_iterator get_cbegin(const S& shape, bool end_index) const; template - const_broadcast_iterator get_cend(const S& shape, bool end_index) const noexcept; + const_broadcast_iterator get_cend(const S& shape, bool end_index) const; template - const_stepper get_stepper_begin(const S& shape) const noexcept; + const_stepper get_stepper_begin(const S& shape) const; template - const_stepper get_stepper_end(const S& shape, layout_type l) const noexcept; + const_stepper get_stepper_end(const S& shape, layout_type l) const; const derived_type& derived_cast() const; }; @@ -192,46 +192,46 @@ namespace xt using base_type::rend; template - layout_iterator begin() noexcept; + layout_iterator begin(); template - layout_iterator end() noexcept; + layout_iterator end(); template - reverse_layout_iterator rbegin() noexcept; + reverse_layout_iterator rbegin(); template - reverse_layout_iterator rend() noexcept; + reverse_layout_iterator rend(); template - broadcast_iterator begin(const S& shape) noexcept; + broadcast_iterator begin(const S& shape); template - broadcast_iterator end(const S& shape) noexcept; + broadcast_iterator end(const S& shape); template - reverse_broadcast_iterator rbegin(const S& shape) noexcept; + reverse_broadcast_iterator rbegin(const S& shape); template - reverse_broadcast_iterator rend(const S& shape) noexcept; + reverse_broadcast_iterator rend(const S& shape); private: template - layout_iterator get_begin(bool end_index) noexcept; + layout_iterator get_begin(bool end_index); template - layout_iterator get_end(bool end_index) noexcept; + layout_iterator get_end(bool end_index); template - broadcast_iterator get_begin(const S& shape, bool end_index) noexcept; + broadcast_iterator get_begin(const S& shape, bool end_index); template - broadcast_iterator get_end(const S& shape, bool end_index) noexcept; + broadcast_iterator get_end(const S& shape, bool end_index); template - stepper get_stepper_begin(const S& shape) noexcept; + stepper get_stepper_begin(const S& shape); template - stepper get_stepper_end(const S& shape, layout_type l) noexcept; + stepper get_stepper_end(const S& shape, layout_type l); template - const_stepper get_stepper_begin(const S& shape) const noexcept; + const_stepper get_stepper_begin(const S& shape) const; template - const_stepper get_stepper_end(const S& shape, layout_type l) const noexcept; + const_stepper get_stepper_end(const S& shape, layout_type l) const; derived_type& derived_cast(); }; @@ -367,60 +367,60 @@ namespace xt using const_reverse_iterator = select_const_reverse_iterator; template - select_iterator begin() noexcept; + select_iterator begin() noexcept(L == static_layout); template - select_iterator end() noexcept; + select_iterator end() noexcept(L == static_layout); template - select_const_iterator begin() const noexcept; + select_const_iterator begin() const noexcept(L == static_layout); template - select_const_iterator end() const noexcept; + select_const_iterator end() const noexcept(L == static_layout); template - select_const_iterator cbegin() const noexcept; + select_const_iterator cbegin() const noexcept(L == static_layout); template - select_const_iterator cend() const noexcept; + select_const_iterator cend() const noexcept(L == static_layout); template - select_reverse_iterator rbegin() noexcept; + select_reverse_iterator rbegin() noexcept(L == static_layout); template - select_reverse_iterator rend() noexcept; + select_reverse_iterator rend() noexcept(L == static_layout); template - select_const_reverse_iterator rbegin() const noexcept; + select_const_reverse_iterator rbegin() const noexcept(L == static_layout); template - select_const_reverse_iterator rend() const noexcept; + select_const_reverse_iterator rend() const noexcept(L == static_layout); template - select_const_reverse_iterator crbegin() const noexcept; + select_const_reverse_iterator crbegin() const noexcept(L == static_layout); template - select_const_reverse_iterator crend() const noexcept; + select_const_reverse_iterator crend() const noexcept(L == static_layout); template - broadcast_iterator begin(const S& shape) noexcept; + broadcast_iterator begin(const S& shape); template - broadcast_iterator end(const S& shape) noexcept; + broadcast_iterator end(const S& shape); template - const_broadcast_iterator begin(const S& shape) const noexcept; + const_broadcast_iterator begin(const S& shape) const; template - const_broadcast_iterator end(const S& shape) const noexcept; + const_broadcast_iterator end(const S& shape) const; template - const_broadcast_iterator cbegin(const S& shape) const noexcept; + const_broadcast_iterator cbegin(const S& shape) const; template - const_broadcast_iterator cend(const S& shape) const noexcept; + const_broadcast_iterator cend(const S& shape) const; template - reverse_broadcast_iterator rbegin(const S& shape) noexcept; + reverse_broadcast_iterator rbegin(const S& shape); template - reverse_broadcast_iterator rend(const S& shape) noexcept; + reverse_broadcast_iterator rend(const S& shape); template - const_reverse_broadcast_iterator rbegin(const S& shape) const noexcept; + const_reverse_broadcast_iterator rbegin(const S& shape) const; template - const_reverse_broadcast_iterator rend(const S& shape) const noexcept; + const_reverse_broadcast_iterator rend(const S& shape) const; template - const_reverse_broadcast_iterator crbegin(const S& shape) const noexcept; + const_reverse_broadcast_iterator crbegin(const S& shape) const; template - const_reverse_broadcast_iterator crend(const S& shape) const noexcept; + const_reverse_broadcast_iterator crend(const S& shape) const; private: @@ -445,7 +445,7 @@ namespace xt */ template template - inline auto xconst_iterable::begin() const noexcept -> const_layout_iterator + inline auto xconst_iterable::begin() const -> const_layout_iterator { return this->template cbegin(); } @@ -457,7 +457,7 @@ namespace xt */ template template - inline auto xconst_iterable::end() const noexcept -> const_layout_iterator + inline auto xconst_iterable::end() const -> const_layout_iterator { return this->template cend(); } @@ -468,7 +468,7 @@ namespace xt */ template template - inline auto xconst_iterable::cbegin() const noexcept -> const_layout_iterator + inline auto xconst_iterable::cbegin() const -> const_layout_iterator { return this->template get_cbegin(false); } @@ -480,7 +480,7 @@ namespace xt */ template template - inline auto xconst_iterable::cend() const noexcept -> const_layout_iterator + inline auto xconst_iterable::cend() const -> const_layout_iterator { return this->template get_cend(true); } @@ -497,7 +497,7 @@ namespace xt */ template template - inline auto xconst_iterable::rbegin() const noexcept -> const_reverse_layout_iterator + inline auto xconst_iterable::rbegin() const -> const_reverse_layout_iterator { return this->template crbegin(); } @@ -509,7 +509,7 @@ namespace xt */ template template - inline auto xconst_iterable::rend() const noexcept -> const_reverse_layout_iterator + inline auto xconst_iterable::rend() const -> const_reverse_layout_iterator { return this->template crend(); } @@ -520,7 +520,7 @@ namespace xt */ template template - inline auto xconst_iterable::crbegin() const noexcept -> const_reverse_layout_iterator + inline auto xconst_iterable::crbegin() const -> const_reverse_layout_iterator { return const_reverse_layout_iterator(get_cend(true)); } @@ -532,7 +532,7 @@ namespace xt */ template template - inline auto xconst_iterable::crend() const noexcept -> const_reverse_layout_iterator + inline auto xconst_iterable::crend() const -> const_reverse_layout_iterator { return const_reverse_layout_iterator(get_cbegin(false)); } @@ -552,7 +552,7 @@ namespace xt */ template template - inline auto xconst_iterable::begin(const S& shape) const noexcept -> const_broadcast_iterator + inline auto xconst_iterable::begin(const S& shape) const -> const_broadcast_iterator { return cbegin(shape); } @@ -566,7 +566,7 @@ namespace xt */ template template - inline auto xconst_iterable::end(const S& shape) const noexcept -> const_broadcast_iterator + inline auto xconst_iterable::end(const S& shape) const -> const_broadcast_iterator { return cend(shape); } @@ -580,7 +580,7 @@ namespace xt */ template template - inline auto xconst_iterable::cbegin(const S& shape) const noexcept -> const_broadcast_iterator + inline auto xconst_iterable::cbegin(const S& shape) const -> const_broadcast_iterator { return get_cbegin(shape, false); } @@ -594,7 +594,7 @@ namespace xt */ template template - inline auto xconst_iterable::cend(const S& shape) const noexcept -> const_broadcast_iterator + inline auto xconst_iterable::cend(const S& shape) const -> const_broadcast_iterator { return get_cend(shape, true); } @@ -614,8 +614,7 @@ namespace xt */ template template - inline auto xconst_iterable::rbegin(const S& shape) const noexcept - -> const_reverse_broadcast_iterator + inline auto xconst_iterable::rbegin(const S& shape) const -> const_reverse_broadcast_iterator { return crbegin(shape); } @@ -629,8 +628,7 @@ namespace xt */ template template - inline auto xconst_iterable::rend(const S& shape) const noexcept - -> const_reverse_broadcast_iterator + inline auto xconst_iterable::rend(const S& shape) const -> const_reverse_broadcast_iterator { return crend(shape); } @@ -644,8 +642,7 @@ namespace xt */ template template - inline auto xconst_iterable::crbegin(const S& shape) const noexcept - -> const_reverse_broadcast_iterator + inline auto xconst_iterable::crbegin(const S& shape) const -> const_reverse_broadcast_iterator { return const_reverse_broadcast_iterator(get_cend(shape, true)); } @@ -659,8 +656,7 @@ namespace xt */ template template - inline auto xconst_iterable::crend(const S& shape) const noexcept - -> const_reverse_broadcast_iterator + inline auto xconst_iterable::crend(const S& shape) const -> const_reverse_broadcast_iterator { return const_reverse_broadcast_iterator(get_cbegin(shape, false)); } @@ -669,21 +665,21 @@ namespace xt template template - inline auto xconst_iterable::get_cbegin(bool end_index) const noexcept -> const_layout_iterator + inline auto xconst_iterable::get_cbegin(bool end_index) const -> const_layout_iterator { return const_layout_iterator(get_stepper_begin(get_shape()), &get_shape(), end_index); } template template - inline auto xconst_iterable::get_cend(bool end_index) const noexcept -> const_layout_iterator + inline auto xconst_iterable::get_cend(bool end_index) const -> const_layout_iterator { return const_layout_iterator(get_stepper_end(get_shape(), L), &get_shape(), end_index); } template template - inline auto xconst_iterable::get_cbegin(const S& shape, bool end_index) const noexcept + inline auto xconst_iterable::get_cbegin(const S& shape, bool end_index) const -> const_broadcast_iterator { return const_broadcast_iterator(get_stepper_begin(shape), shape, end_index); @@ -691,7 +687,7 @@ namespace xt template template - inline auto xconst_iterable::get_cend(const S& shape, bool end_index) const noexcept + inline auto xconst_iterable::get_cend(const S& shape, bool end_index) const -> const_broadcast_iterator { return const_broadcast_iterator(get_stepper_end(shape, L), shape, end_index); @@ -699,15 +695,14 @@ namespace xt template template - inline auto xconst_iterable::get_stepper_begin(const S& shape) const noexcept -> const_stepper + inline auto xconst_iterable::get_stepper_begin(const S& shape) const -> const_stepper { return derived_cast().stepper_begin(shape); } template template - inline auto xconst_iterable::get_stepper_end(const S& shape, layout_type l) const noexcept - -> const_stepper + inline auto xconst_iterable::get_stepper_end(const S& shape, layout_type l) const -> const_stepper { return derived_cast().stepper_end(shape, l); } @@ -738,7 +733,7 @@ namespace xt */ template template - inline auto xiterable::begin() noexcept -> layout_iterator + inline auto xiterable::begin() -> layout_iterator { return get_begin(false); } @@ -750,7 +745,7 @@ namespace xt */ template template - inline auto xiterable::end() noexcept -> layout_iterator + inline auto xiterable::end() -> layout_iterator { return get_end(true); } @@ -767,7 +762,7 @@ namespace xt */ template template - inline auto xiterable::rbegin() noexcept -> reverse_layout_iterator + inline auto xiterable::rbegin() -> reverse_layout_iterator { return reverse_layout_iterator(get_end(true)); } @@ -779,7 +774,7 @@ namespace xt */ template template - inline auto xiterable::rend() noexcept -> reverse_layout_iterator + inline auto xiterable::rend() -> reverse_layout_iterator { return reverse_layout_iterator(get_begin(false)); } @@ -799,7 +794,7 @@ namespace xt */ template template - inline auto xiterable::begin(const S& shape) noexcept -> broadcast_iterator + inline auto xiterable::begin(const S& shape) -> broadcast_iterator { return get_begin(shape, false); } @@ -813,7 +808,7 @@ namespace xt */ template template - inline auto xiterable::end(const S& shape) noexcept -> broadcast_iterator + inline auto xiterable::end(const S& shape) -> broadcast_iterator { return get_end(shape, true); } @@ -833,7 +828,7 @@ namespace xt */ template template - inline auto xiterable::rbegin(const S& shape) noexcept -> reverse_broadcast_iterator + inline auto xiterable::rbegin(const S& shape) -> reverse_broadcast_iterator { return reverse_broadcast_iterator(get_end(shape, true)); } @@ -847,7 +842,7 @@ namespace xt */ template template - inline auto xiterable::rend(const S& shape) noexcept -> reverse_broadcast_iterator + inline auto xiterable::rend(const S& shape) -> reverse_broadcast_iterator { return reverse_broadcast_iterator(get_begin(shape, false)); } @@ -856,56 +851,56 @@ namespace xt template template - inline auto xiterable::get_begin(bool end_index) noexcept -> layout_iterator + inline auto xiterable::get_begin(bool end_index) -> layout_iterator { return layout_iterator(get_stepper_begin(this->get_shape()), &(this->get_shape()), end_index); } template template - inline auto xiterable::get_end(bool end_index) noexcept -> layout_iterator + inline auto xiterable::get_end(bool end_index) -> layout_iterator { return layout_iterator(get_stepper_end(this->get_shape(), L), &(this->get_shape()), end_index); } template template - inline auto xiterable::get_begin(const S& shape, bool end_index) noexcept -> broadcast_iterator + inline auto xiterable::get_begin(const S& shape, bool end_index) -> broadcast_iterator { return broadcast_iterator(get_stepper_begin(shape), shape, end_index); } template template - inline auto xiterable::get_end(const S& shape, bool end_index) noexcept -> broadcast_iterator + inline auto xiterable::get_end(const S& shape, bool end_index) -> broadcast_iterator { return broadcast_iterator(get_stepper_end(shape, L), shape, end_index); } template template - inline auto xiterable::get_stepper_begin(const S& shape) noexcept -> stepper + inline auto xiterable::get_stepper_begin(const S& shape) -> stepper { return derived_cast().stepper_begin(shape); } template template - inline auto xiterable::get_stepper_end(const S& shape, layout_type l) noexcept -> stepper + inline auto xiterable::get_stepper_end(const S& shape, layout_type l) -> stepper { return derived_cast().stepper_end(shape, l); } template template - inline auto xiterable::get_stepper_begin(const S& shape) const noexcept -> const_stepper + inline auto xiterable::get_stepper_begin(const S& shape) const -> const_stepper { return derived_cast().stepper_begin(shape); } template template - inline auto xiterable::get_stepper_end(const S& shape, layout_type l) const noexcept -> const_stepper + inline auto xiterable::get_stepper_end(const S& shape, layout_type l) const -> const_stepper { return derived_cast().stepper_end(shape, l); } @@ -930,7 +925,7 @@ namespace xt */ template template - inline auto xcontiguous_iterable::begin() noexcept -> select_iterator + inline auto xcontiguous_iterable::begin() noexcept(L == static_layout) -> select_iterator { if constexpr (L == static_layout) { @@ -949,7 +944,7 @@ namespace xt */ template template - inline auto xcontiguous_iterable::end() noexcept -> select_iterator + inline auto xcontiguous_iterable::end() noexcept(L == static_layout) -> select_iterator { if constexpr (L == static_layout) { @@ -967,7 +962,7 @@ namespace xt */ template template - inline auto xcontiguous_iterable::begin() const noexcept -> select_const_iterator + inline auto xcontiguous_iterable::begin() const noexcept(L == static_layout) -> select_const_iterator { return this->template cbegin(); } @@ -979,7 +974,7 @@ namespace xt */ template template - inline auto xcontiguous_iterable::end() const noexcept -> select_const_iterator + inline auto xcontiguous_iterable::end() const noexcept(L == static_layout) -> select_const_iterator { return this->template cend(); } @@ -990,7 +985,8 @@ namespace xt */ template template - inline auto xcontiguous_iterable::cbegin() const noexcept -> select_const_iterator + inline auto xcontiguous_iterable::cbegin() const noexcept(L == static_layout) + -> select_const_iterator { if constexpr (L == static_layout) { @@ -1009,7 +1005,7 @@ namespace xt */ template template - inline auto xcontiguous_iterable::cend() const noexcept -> select_const_iterator + inline auto xcontiguous_iterable::cend() const noexcept(L == static_layout) -> select_const_iterator { if constexpr (L == static_layout) { @@ -1033,7 +1029,7 @@ namespace xt */ template template - inline auto xcontiguous_iterable::rbegin() noexcept -> select_reverse_iterator + inline auto xcontiguous_iterable::rbegin() noexcept(L == static_layout) -> select_reverse_iterator { if constexpr (L == static_layout) { @@ -1052,7 +1048,7 @@ namespace xt */ template template - inline auto xcontiguous_iterable::rend() noexcept -> select_reverse_iterator + inline auto xcontiguous_iterable::rend() noexcept(L == static_layout) -> select_reverse_iterator { if constexpr (L == static_layout) { @@ -1070,7 +1066,8 @@ namespace xt */ template template - inline auto xcontiguous_iterable::rbegin() const noexcept -> select_const_reverse_iterator + inline auto xcontiguous_iterable::rbegin() const noexcept(L == static_layout) + -> select_const_reverse_iterator { return this->template crbegin(); } @@ -1082,7 +1079,8 @@ namespace xt */ template template - inline auto xcontiguous_iterable::rend() const noexcept -> select_const_reverse_iterator + inline auto xcontiguous_iterable::rend() const noexcept(L == static_layout) + -> select_const_reverse_iterator { return this->template crend(); } @@ -1093,7 +1091,8 @@ namespace xt */ template template - inline auto xcontiguous_iterable::crbegin() const noexcept -> select_const_reverse_iterator + inline auto xcontiguous_iterable::crbegin() const noexcept(L == static_layout) + -> select_const_reverse_iterator { if constexpr (L == static_layout) { @@ -1112,7 +1111,8 @@ namespace xt */ template template - inline auto xcontiguous_iterable::crend() const noexcept -> select_const_reverse_iterator + inline auto xcontiguous_iterable::crend() const noexcept(L == static_layout) + -> select_const_reverse_iterator { if constexpr (L == static_layout) { @@ -1140,7 +1140,7 @@ namespace xt //@{ template template - inline auto xcontiguous_iterable::begin(const S& shape) noexcept -> broadcast_iterator + inline auto xcontiguous_iterable::begin(const S& shape) -> broadcast_iterator { return iterable_base::template begin(shape); } @@ -1154,7 +1154,7 @@ namespace xt */ template template - inline auto xcontiguous_iterable::end(const S& shape) noexcept -> broadcast_iterator + inline auto xcontiguous_iterable::end(const S& shape) -> broadcast_iterator { return iterable_base::template end(shape); } @@ -1168,7 +1168,7 @@ namespace xt */ template template - inline auto xcontiguous_iterable::begin(const S& shape) const noexcept -> const_broadcast_iterator + inline auto xcontiguous_iterable::begin(const S& shape) const -> const_broadcast_iterator { return iterable_base::template begin(shape); } @@ -1182,7 +1182,7 @@ namespace xt */ template template - inline auto xcontiguous_iterable::end(const S& shape) const noexcept -> const_broadcast_iterator + inline auto xcontiguous_iterable::end(const S& shape) const -> const_broadcast_iterator { return iterable_base::template end(shape); } @@ -1196,8 +1196,7 @@ namespace xt */ template template - inline auto xcontiguous_iterable::cbegin(const S& shape) const noexcept - -> const_broadcast_iterator + inline auto xcontiguous_iterable::cbegin(const S& shape) const -> const_broadcast_iterator { return iterable_base::template cbegin(shape); } @@ -1211,7 +1210,7 @@ namespace xt */ template template - inline auto xcontiguous_iterable::cend(const S& shape) const noexcept -> const_broadcast_iterator + inline auto xcontiguous_iterable::cend(const S& shape) const -> const_broadcast_iterator { return iterable_base::template cend(shape); } @@ -1231,7 +1230,7 @@ namespace xt */ template template - inline auto xcontiguous_iterable::rbegin(const S& shape) noexcept -> reverse_broadcast_iterator + inline auto xcontiguous_iterable::rbegin(const S& shape) -> reverse_broadcast_iterator { return iterable_base::template rbegin(shape); } @@ -1245,7 +1244,7 @@ namespace xt */ template template - inline auto xcontiguous_iterable::rend(const S& shape) noexcept -> reverse_broadcast_iterator + inline auto xcontiguous_iterable::rend(const S& shape) -> reverse_broadcast_iterator { return iterable_base::template rend(shape); } @@ -1259,8 +1258,7 @@ namespace xt */ template template - inline auto xcontiguous_iterable::rbegin(const S& shape) const noexcept - -> const_reverse_broadcast_iterator + inline auto xcontiguous_iterable::rbegin(const S& shape) const -> const_reverse_broadcast_iterator { return iterable_base::template rbegin(shape); } @@ -1274,8 +1272,7 @@ namespace xt */ template template - inline auto xcontiguous_iterable::rend(const S& shape) const noexcept - -> const_reverse_broadcast_iterator + inline auto xcontiguous_iterable::rend(const S& shape) const -> const_reverse_broadcast_iterator { return iterable_base::template rend(shape); } @@ -1289,7 +1286,7 @@ namespace xt */ template template - inline auto xcontiguous_iterable::crbegin(const S& shape) const noexcept + inline auto xcontiguous_iterable::crbegin(const S& shape) const -> const_reverse_broadcast_iterator { return iterable_base::template crbegin(shape); @@ -1304,8 +1301,7 @@ namespace xt */ template template - inline auto xcontiguous_iterable::crend(const S& shape) const noexcept - -> const_reverse_broadcast_iterator + inline auto xcontiguous_iterable::crend(const S& shape) const -> const_reverse_broadcast_iterator { return iterable_base::template crend(shape); } diff --git a/include/xtensor/core/xmath.hpp b/include/xtensor/core/xmath.hpp index 6b86c4b74..36734d8ea 100644 --- a/include/xtensor/core/xmath.hpp +++ b/include/xtensor/core/xmath.hpp @@ -1772,7 +1772,7 @@ namespace xt * @return a boolean */ template - inline auto allclose(E1&& e1, E2&& e2, double rtol = 1e-05, double atol = 1e-08) noexcept + inline auto allclose(E1&& e1, E2&& e2, double rtol = 1e-05, double atol = 1e-08) { return xt::all(isclose(std::forward(e1), std::forward(e2), rtol, atol)); } diff --git a/include/xtensor/core/xshape.hpp b/include/xtensor/core/xshape.hpp index 1380f4e07..8668c72fd 100644 --- a/include/xtensor/core/xshape.hpp +++ b/include/xtensor/core/xshape.hpp @@ -124,7 +124,7 @@ namespace xt * @return bool */ template - inline bool has_shape(const E& e, std::initializer_list shape) noexcept + inline bool has_shape(const E& e, std::initializer_list shape) { return e.shape().size() == shape.size() && std::equal(e.shape().cbegin(), e.shape().cend(), shape.begin()); diff --git a/include/xtensor/generators/xbuilder.hpp b/include/xtensor/generators/xbuilder.hpp index 1026b21c7..e4041df23 100644 --- a/include/xtensor/generators/xbuilder.hpp +++ b/include/xtensor/generators/xbuilder.hpp @@ -993,7 +993,7 @@ namespace xt { template - inline auto meshgrid_impl(std::index_sequence, E&&... e) noexcept + inline auto meshgrid_impl(std::index_sequence, E&&... e) { return std::make_tuple(detail::make_xgenerator( detail::repeat_impl>(std::forward(e), I), @@ -1011,7 +1011,7 @@ namespace xt * @returns tuple of xgenerator expressions. */ template - inline auto meshgrid(E&&... e) noexcept + inline auto meshgrid(E&&... e) { return detail::meshgrid_impl(std::make_index_sequence(), std::forward(e)...); } diff --git a/include/xtensor/generators/xgenerator.hpp b/include/xtensor/generators/xgenerator.hpp index 57d7d5d6c..878a25d57 100644 --- a/include/xtensor/generators/xgenerator.hpp +++ b/include/xtensor/generators/xgenerator.hpp @@ -166,7 +166,7 @@ namespace xt const_stepper stepper_end(const O& shape, layout_type) const noexcept; template - void assign_to(xexpression& e) const noexcept + void assign_to(xexpression& e) const requires(assignable_to_expression); const functor_type& functor() const noexcept; @@ -373,7 +373,7 @@ namespace xt template template - inline void xgenerator::assign_to(xexpression& e) const noexcept + inline void xgenerator::assign_to(xexpression& e) const requires(assignable_to_expression) { e.derived_cast().resize(m_shape); diff --git a/include/xtensor/misc/xcomplex.hpp b/include/xtensor/misc/xcomplex.hpp index c803bb77c..fbed8928c 100644 --- a/include/xtensor/misc/xcomplex.hpp +++ b/include/xtensor/misc/xcomplex.hpp @@ -36,7 +36,7 @@ namespace xt decltype(auto) real(E&& e) noexcept; template - decltype(auto) imag(E&& e) noexcept; + decltype(auto) imag(E&& e); /******************************** * real and imag implementation * @@ -72,7 +72,7 @@ namespace xt } template - inline static auto imag(E&& e) noexcept + inline static auto imag(E&& e) { return zeros::value_type>(e.shape()); } @@ -90,7 +90,7 @@ namespace xt } template - inline static decltype(auto) imag(E&& e) noexcept + inline static decltype(auto) imag(E&& e) { return detail::complex_helper::value_type>::value>::imag( std::forward(e) @@ -141,7 +141,7 @@ namespace xt * @tparam e The xt::xexpression */ template - inline decltype(auto) imag(E&& e) noexcept + inline decltype(auto) imag(E&& e) { return detail::complex_expression_helper>::value>::imag(std::forward(e )); diff --git a/include/xtensor/misc/xmanipulation.hpp b/include/xtensor/misc/xmanipulation.hpp index db4125e01..614854160 100644 --- a/include/xtensor/misc/xmanipulation.hpp +++ b/include/xtensor/misc/xmanipulation.hpp @@ -42,7 +42,7 @@ namespace xt } template - auto transpose(E&& e) noexcept; + auto transpose(E&& e); template auto transpose(E&& e, S&& permutation, Tag check_policy = Tag()); @@ -236,7 +236,7 @@ namespace xt * @param e the input expression */ template - inline auto transpose(E&& e) noexcept + inline auto transpose(E&& e) { using shape_type = xindex_type_t::shape_type>; shape_type shape; diff --git a/include/xtensor/misc/xset_operation.hpp b/include/xtensor/misc/xset_operation.hpp index 94c64cd62..3e4777f34 100644 --- a/include/xtensor/misc/xset_operation.hpp +++ b/include/xtensor/misc/xset_operation.hpp @@ -53,7 +53,7 @@ namespace xt template static auto make(E&& e) { - return [e](const auto& t) + return [e = std::forward(e)](const auto& t) { return std::find(e.begin(), e.end(), t) != e.end(); }; @@ -133,7 +133,7 @@ namespace xt * @return a boolean array */ template - inline auto in1d(E&& element, std::initializer_list test_elements) noexcept + inline auto in1d(E&& element, std::initializer_list test_elements) { XTENSOR_ASSERT(element.dimension() == 1ul); return isin(std::forward(element), std::forward>(test_elements)); @@ -150,7 +150,7 @@ namespace xt * @return a boolean array */ template - inline auto in1d(E&& element, F&& test_elements) noexcept + inline auto in1d(E&& element, F&& test_elements) requires(iterable_expression) { XTENSOR_ASSERT(element.dimension() == 1ul); @@ -170,7 +170,7 @@ namespace xt * @return a boolean array */ template - inline auto in1d(E&& element, I&& test_elements_begin, I&& test_elements_end) noexcept + inline auto in1d(E&& element, I&& test_elements_begin, I&& test_elements_end) { XTENSOR_ASSERT(element.dimension() == 1ul); return isin( diff --git a/include/xtensor/reducers/xnorm.hpp b/include/xtensor/reducers/xnorm.hpp index b883573f6..c5ccb303b 100644 --- a/include/xtensor/reducers/xnorm.hpp +++ b/include/xtensor/reducers/xnorm.hpp @@ -368,7 +368,7 @@ namespace xt #define XTENSOR_NORM_FUNCTION_AXES(NAME) \ template \ - inline auto NAME(E&& e, const I(&axes)[N], EVS es = EVS()) noexcept \ + inline auto NAME(E&& e, const I(&axes)[N], EVS es = EVS()) \ { \ using axes_type = std::array::size_type, N>; \ return NAME(std::forward(e), xtl::forward_sequence(axes), es); \ @@ -396,7 +396,7 @@ namespace xt #define XTENSOR_COMMA , #define XTENSOR_NORM_FUNCTION(NAME, RESULT_TYPE, REDUCE_EXPR, REDUCE_OP, MERGE_FUNC) \ template >)> \ - inline auto NAME(E&& e, X&& axes, EVS es = EVS()) noexcept \ + inline auto NAME(E&& e, X&& axes, EVS es = EVS()) \ { \ using value_type = typename std::decay_t::value_type; \ using result_type = detail::norm_value_type_t; \ @@ -415,7 +415,7 @@ namespace xt } \ \ template )> \ - inline auto NAME(E&& e, EVS es = EVS()) noexcept \ + inline auto NAME(E&& e, EVS es = EVS()) \ { \ return NAME(std::forward(e), arange(e.dimension()), es); \ } \ @@ -450,7 +450,7 @@ namespace xt * the reducer represents a scalar result, otherwise an array of appropriate dimension. */ template - auto norm_l0(E&& e, X&& axes, EVS es) noexcept; + auto norm_l0(E&& e, X&& axes, EVS es); /** * @ingroup red_functions @@ -465,7 +465,7 @@ namespace xt * the reducer represents a scalar result, otherwise an array of appropriate dimension. */ template - auto norm_l1(E&& e, X&& axes, EVS es) noexcept; + auto norm_l1(E&& e, X&& axes, EVS es); /** * @ingroup red_functions @@ -480,7 +480,7 @@ namespace xt * the reducer represents a scalar result, otherwise an array of appropriate dimension. */ template - auto norm_sq(E&& e, X&& axes, EVS es) noexcept; + auto norm_sq(E&& e, X&& axes, EVS es); /** * @ingroup red_functions @@ -491,7 +491,7 @@ namespace xt * otherwise: implemented as sqrt(norm_sq(t)). */ template )> - inline auto norm_l2(E&& e, EVS es = EVS()) noexcept + inline auto norm_l2(E&& e, EVS es = EVS()) { using std::sqrt; return sqrt(norm_sq(std::forward(e), es)); @@ -513,13 +513,13 @@ namespace xt class X, class EVS = DEFAULT_STRATEGY_REDUCERS, XTL_REQUIRES(is_xexpression, std::negation>)> - inline auto norm_l2(E&& e, X&& axes, EVS es = EVS()) noexcept + inline auto norm_l2(E&& e, X&& axes, EVS es = EVS()) { return sqrt(norm_sq(std::forward(e), std::forward(axes), es)); } template - inline auto norm_l2(E&& e, const I (&axes)[N], EVS es = EVS()) noexcept + inline auto norm_l2(E&& e, const I (&axes)[N], EVS es = EVS()) { using axes_type = std::array::size_type, N>; return sqrt(norm_sq(std::forward(e), xtl::forward_sequence(axes), es)); @@ -538,7 +538,7 @@ namespace xt * the reducer represents a scalar result, otherwise an array of appropriate dimension. */ template - auto norm_linf(E&& e, X&& axes, EVS es) noexcept; + auto norm_linf(E&& e, X&& axes, EVS es); /** * @ingroup red_functions @@ -554,7 +554,7 @@ namespace xt * the reducer represents a scalar result, otherwise an array of appropriate dimension. */ template >)> - inline auto norm_lp_to_p(E&& e, double p, X&& axes, EVS es = EVS()) noexcept + inline auto norm_lp_to_p(E&& e, double p, X&& axes, EVS es = EVS()) { using value_type = typename std::decay_t::value_type; using result_type = norm_type_t>; @@ -572,13 +572,13 @@ namespace xt } template )> - inline auto norm_lp_to_p(E&& e, double p, EVS es = EVS()) noexcept + inline auto norm_lp_to_p(E&& e, double p, EVS es = EVS()) { return norm_lp_to_p(std::forward(e), p, arange(e.dimension()), es); } template - inline auto norm_lp_to_p(E&& e, double p, const I (&axes)[N], EVS es = EVS()) noexcept + inline auto norm_lp_to_p(E&& e, double p, const I (&axes)[N], EVS es = EVS()) { using axes_type = std::array::size_type, N>; return norm_lp_to_p(std::forward(e), p, xtl::forward_sequence(axes), es); diff --git a/include/xtensor/views/xfunctor_view.hpp b/include/xtensor/views/xfunctor_view.hpp index bedbbe828..73d674af2 100644 --- a/include/xtensor/views/xfunctor_view.hpp +++ b/include/xtensor/views/xfunctor_view.hpp @@ -169,8 +169,9 @@ namespace xt template xfunctor_applier_base(Func&&, E&&) noexcept; - size_type size() const noexcept; - const inner_shape_type& shape() const noexcept; + size_type size() const noexcept(noexcept(std::declval().size())); + const inner_shape_type& shape() const + noexcept(noexcept(std::declval().shape())); const inner_strides_type& strides() const noexcept; const inner_backstrides_type& backstrides() const noexcept; using accessible_base::dimension; @@ -266,60 +267,60 @@ namespace xt } template - auto begin() noexcept; + auto begin(); template - auto end() noexcept; + auto end(); template - auto begin() const noexcept; + auto begin() const; template - auto end() const noexcept; + auto end() const; template - auto cbegin() const noexcept; + auto cbegin() const; template - auto cend() const noexcept; + auto cend() const; template - auto rbegin() noexcept; + auto rbegin(); template - auto rend() noexcept; + auto rend(); template - auto rbegin() const noexcept; + auto rbegin() const; template - auto rend() const noexcept; + auto rend() const; template - auto crbegin() const noexcept; + auto crbegin() const; template - auto crend() const noexcept; + auto crend() const; template - broadcast_iterator begin(const S& shape) noexcept; + broadcast_iterator begin(const S& shape); template - broadcast_iterator end(const S& shape) noexcept; + broadcast_iterator end(const S& shape); template - const_broadcast_iterator begin(const S& shape) const noexcept; + const_broadcast_iterator begin(const S& shape) const; template - const_broadcast_iterator end(const S& shape) const noexcept; + const_broadcast_iterator end(const S& shape) const; template - const_broadcast_iterator cbegin(const S& shape) const noexcept; + const_broadcast_iterator cbegin(const S& shape) const; template - const_broadcast_iterator cend(const S& shape) const noexcept; + const_broadcast_iterator cend(const S& shape) const; template - reverse_broadcast_iterator rbegin(const S& shape) noexcept; + reverse_broadcast_iterator rbegin(const S& shape); template - reverse_broadcast_iterator rend(const S& shape) noexcept; + reverse_broadcast_iterator rend(const S& shape); template - const_reverse_broadcast_iterator rbegin(const S& shape) const noexcept; + const_reverse_broadcast_iterator rbegin(const S& shape) const; template - const_reverse_broadcast_iterator rend(const S& shape) const noexcept; + const_reverse_broadcast_iterator rend(const S& shape) const; template - const_reverse_broadcast_iterator crbegin(const S& shape) const noexcept; + const_reverse_broadcast_iterator crbegin(const S& shape) const; template - const_reverse_broadcast_iterator crend(const S& shape) const noexcept; + const_reverse_broadcast_iterator crend(const S& shape) const; linear_iterator linear_begin() noexcept; linear_iterator linear_end() noexcept; @@ -706,7 +707,8 @@ namespace xt * Returns the size of the expression. */ template - inline auto xfunctor_applier_base::size() const noexcept -> size_type + inline auto xfunctor_applier_base::size() const + noexcept(noexcept(std::declval().size())) -> size_type { return m_e.size(); } @@ -715,7 +717,8 @@ namespace xt * Returns the shape of the expression. */ template - inline auto xfunctor_applier_base::shape() const noexcept -> const inner_shape_type& + inline auto xfunctor_applier_base::shape() const + noexcept(noexcept(std::declval().shape())) -> const inner_shape_type& { return m_e.shape(); } @@ -933,7 +936,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::begin() noexcept + inline auto xfunctor_applier_base::begin() { return xfunctor_iterator())>( m_e.template begin(), @@ -948,7 +951,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::end() noexcept + inline auto xfunctor_applier_base::end() { return xfunctor_iterator())>(m_e.template end(), &m_functor); } @@ -959,7 +962,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::begin() const noexcept + inline auto xfunctor_applier_base::begin() const { return this->template cbegin(); } @@ -971,7 +974,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::end() const noexcept + inline auto xfunctor_applier_base::end() const { return this->template cend(); } @@ -982,7 +985,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::cbegin() const noexcept + inline auto xfunctor_applier_base::cbegin() const { return xfunctor_iterator())>( m_e.template cbegin(), @@ -997,7 +1000,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::cend() const noexcept + inline auto xfunctor_applier_base::cend() const { return xfunctor_iterator())>( m_e.template cend(), @@ -1020,7 +1023,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::begin(const S& shape) noexcept -> broadcast_iterator + inline auto xfunctor_applier_base::begin(const S& shape) -> broadcast_iterator { return broadcast_iterator(m_e.template begin(shape), &m_functor); } @@ -1034,7 +1037,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::end(const S& shape) noexcept -> broadcast_iterator + inline auto xfunctor_applier_base::end(const S& shape) -> broadcast_iterator { return broadcast_iterator(m_e.template end(shape), &m_functor); } @@ -1048,8 +1051,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::begin(const S& shape) const noexcept - -> const_broadcast_iterator + inline auto xfunctor_applier_base::begin(const S& shape) const -> const_broadcast_iterator { return cbegin(shape); } @@ -1063,7 +1065,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::end(const S& shape) const noexcept -> const_broadcast_iterator + inline auto xfunctor_applier_base::end(const S& shape) const -> const_broadcast_iterator { return cend(shape); } @@ -1077,8 +1079,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::cbegin(const S& shape) const noexcept - -> const_broadcast_iterator + inline auto xfunctor_applier_base::cbegin(const S& shape) const -> const_broadcast_iterator { return const_broadcast_iterator(m_e.template cbegin(shape), &m_functor); } @@ -1092,7 +1093,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::cend(const S& shape) const noexcept -> const_broadcast_iterator + inline auto xfunctor_applier_base::cend(const S& shape) const -> const_broadcast_iterator { return const_broadcast_iterator(m_e.template cend(shape), &m_functor); } @@ -1109,7 +1110,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::rbegin() noexcept + inline auto xfunctor_applier_base::rbegin() { return xfunctor_iterator())>( m_e.template rbegin(), @@ -1124,7 +1125,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::rend() noexcept + inline auto xfunctor_applier_base::rend() { return xfunctor_iterator())>( m_e.template rend(), @@ -1138,7 +1139,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::rbegin() const noexcept + inline auto xfunctor_applier_base::rbegin() const { return this->template crbegin(); } @@ -1150,7 +1151,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::rend() const noexcept + inline auto xfunctor_applier_base::rend() const { return this->template crend(); } @@ -1161,7 +1162,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::crbegin() const noexcept + inline auto xfunctor_applier_base::crbegin() const { return xfunctor_iterator())>( m_e.template crbegin(), @@ -1176,7 +1177,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::crend() const noexcept + inline auto xfunctor_applier_base::crend() const { return xfunctor_iterator())>( m_e.template crend(), @@ -1199,7 +1200,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::rbegin(const S& shape) noexcept -> reverse_broadcast_iterator + inline auto xfunctor_applier_base::rbegin(const S& shape) -> reverse_broadcast_iterator { return reverse_broadcast_iterator(m_e.template rbegin(shape), &m_functor); } @@ -1213,7 +1214,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::rend(const S& shape) noexcept -> reverse_broadcast_iterator + inline auto xfunctor_applier_base::rend(const S& shape) -> reverse_broadcast_iterator { return reverse_broadcast_iterator(m_e.template rend(shape), &m_functor); } @@ -1227,7 +1228,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::rbegin(const S& shape) const noexcept + inline auto xfunctor_applier_base::rbegin(const S& shape) const -> const_reverse_broadcast_iterator { return crbegin(shape); @@ -1242,7 +1243,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::rend(const S& /*shape*/) const noexcept + inline auto xfunctor_applier_base::rend(const S& /*shape*/) const -> const_reverse_broadcast_iterator { return crend(); @@ -1257,7 +1258,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::crbegin(const S& /*shape*/) const noexcept + inline auto xfunctor_applier_base::crbegin(const S& /*shape*/) const -> const_reverse_broadcast_iterator { return const_reverse_broadcast_iterator(m_e.template crbegin(), &m_functor); @@ -1272,8 +1273,7 @@ namespace xt */ template template - inline auto xfunctor_applier_base::crend(const S& shape) const noexcept - -> const_reverse_broadcast_iterator + inline auto xfunctor_applier_base::crend(const S& shape) const -> const_reverse_broadcast_iterator { return const_reverse_broadcast_iterator(m_e.template crend(shape), &m_functor); } diff --git a/include/xtensor/views/xindex_view.hpp b/include/xtensor/views/xindex_view.hpp index 6701d3bf3..c806c4908 100644 --- a/include/xtensor/views/xindex_view.hpp +++ b/include/xtensor/views/xindex_view.hpp @@ -818,7 +818,7 @@ namespace xt * \sa filtration */ template - inline auto filter(E&& e, O&& condition) noexcept + inline auto filter(E&& e, O&& condition) { auto indices = argwhere(std::forward(condition)); using view_type = xindex_view, decltype(indices)>; diff --git a/include/xtensor/views/xslice.hpp b/include/xtensor/views/xslice.hpp index 6cd2865a4..4e6fa611f 100644 --- a/include/xtensor/views/xslice.hpp +++ b/include/xtensor/views/xslice.hpp @@ -327,12 +327,12 @@ namespace xt xkeep_slice(std::initializer_list t); template S> - operator xkeep_slice() const noexcept; + operator xkeep_slice() const; // Same as implicit conversion operator but more convenient to call // from a variant visitor template S> - xkeep_slice convert() const noexcept; + xkeep_slice convert() const; size_type operator()(size_type i) const noexcept; size_type size() const noexcept; @@ -435,12 +435,12 @@ namespace xt xdrop_slice(std::initializer_list t); template S> - operator xdrop_slice() const noexcept; + operator xdrop_slice() const; // Same as implicit conversion operator but more convenient to call // from a variant visitor template S> - xdrop_slice convert() const noexcept; + xdrop_slice convert() const; size_type operator()(size_type i) const noexcept; size_type size() const noexcept; @@ -1310,7 +1310,7 @@ namespace xt template template S> - inline xkeep_slice::operator xkeep_slice() const noexcept + inline xkeep_slice::operator xkeep_slice() const { xkeep_slice ret; using us_type = typename container_type::size_type; @@ -1340,7 +1340,7 @@ namespace xt template template S> - inline xkeep_slice xkeep_slice::convert() const noexcept + inline xkeep_slice xkeep_slice::convert() const { return xkeep_slice(*this); } @@ -1454,7 +1454,7 @@ namespace xt template template S> - inline xdrop_slice::operator xdrop_slice() const noexcept + inline xdrop_slice::operator xdrop_slice() const { xdrop_slice ret; ret.m_raw_indices.resize(m_raw_indices.size()); @@ -1492,7 +1492,7 @@ namespace xt template template S> - inline xdrop_slice xdrop_slice::convert() const noexcept + inline xdrop_slice xdrop_slice::convert() const { return xdrop_slice(*this); } diff --git a/test/test_xbuilder.cpp b/test/test_xbuilder.cpp index d35847a8e..9fb5c5e4e 100644 --- a/test/test_xbuilder.cpp +++ b/test/test_xbuilder.cpp @@ -12,6 +12,7 @@ #endif #include +#include #include "xtensor/containers/xarray.hpp" #include "xtensor/containers/xfixed.hpp" @@ -706,4 +707,20 @@ namespace xt b = std::is_same>::value; EXPECT_TRUE(b); } + + TEST(xbuilder, meshgrid_broadcast_error) + { + xarray a = {1, 2, 3}; + xarray b = {1, 2}; + XT_EXPECT_THROW(meshgrid(a + b, a), broadcast_error); + } + +#ifdef XTENSOR_ENABLE_ASSERT + TEST(xbuilder, arange_fixed_shape_mismatch) + { + xtensor_fixed> a; + XT_EXPECT_THROW(a = arange(5), std::runtime_error); + } +#endif + } diff --git a/test/test_xcomplex.cpp b/test/test_xcomplex.cpp index 920d21b8e..0a2547dd6 100644 --- a/test/test_xcomplex.cpp +++ b/test/test_xcomplex.cpp @@ -356,4 +356,16 @@ namespace xt xtensor exp_im = {double(1), double(1), double(-2)}; EXPECT_EQ(im, exp_im); } + + TEST(xcomplex, broadcast_error) + { + using cpx = std::complex; + xarray a = {cpx(1., 1.), cpx(2., 2.), cpx(3., 3.)}; + xarray b = {cpx(1., 1.), cpx(2., 2.)}; + XT_EXPECT_THROW(real(a + b).shape(), broadcast_error); + xarray c = {1., 2., 3.}; + xarray d = {1., 2.}; + XT_EXPECT_THROW(imag(c + d), broadcast_error); + } + } diff --git a/test/test_xfunction.cpp b/test/test_xfunction.cpp index ddf08758c..1fd27c304 100644 --- a/test/test_xfunction.cpp +++ b/test/test_xfunction.cpp @@ -515,4 +515,15 @@ namespace xt xtensor res{r1, r2, r3}; EXPECT_EQ(c, res); } + + TEST(xfunction, iterator_broadcast_error) + { + xarray a = {1, 2, 3}; + xarray b = {1, 2}; + auto f = a + b; + XT_EXPECT_THROW(f.begin(), broadcast_error); + XT_EXPECT_THROW(f.cend(), broadcast_error); + XT_EXPECT_THROW(f.rbegin(), broadcast_error); + } + } diff --git a/test/test_xindex_view.cpp b/test/test_xindex_view.cpp index cdf22c1f6..0e959cc54 100644 --- a/test/test_xindex_view.cpp +++ b/test/test_xindex_view.cpp @@ -187,4 +187,12 @@ namespace xt xarray expected = {{1, 2, 3}, {5, 7, 9}}; EXPECT_EQ(expected, b); } + + TEST(xindex_view, filter_broadcast_error) + { + xarray a = {1., 2., 3.}; + xarray b = {1., 2.}; + XT_EXPECT_THROW(filter(a, a > b), broadcast_error); + } + } diff --git a/test/test_xmanipulation.cpp b/test/test_xmanipulation.cpp index 32f5d4370..f93293758 100644 --- a/test/test_xmanipulation.cpp +++ b/test/test_xmanipulation.cpp @@ -637,4 +637,12 @@ namespace xt TEST(xmanipulation, zzzzzz) { } + + TEST(xmanipulation, transpose_broadcast_error) + { + xarray a = {1, 2, 3}; + xarray b = {1, 2}; + XT_EXPECT_THROW(transpose(a + b), broadcast_error); + } + } diff --git a/test/test_xmath.cpp b/test/test_xmath.cpp index 57771859b..520ffa8ed 100644 --- a/test/test_xmath.cpp +++ b/test/test_xmath.cpp @@ -1025,4 +1025,12 @@ namespace xt xt::xtensor expected_sums = {1.0, 1.0}; EXPECT_TRUE(xt::allclose(row_sums, expected_sums)); } + + TEST(xmath, allclose_broadcast_error) + { + xarray a = {1., 2., 3.}; + xarray b = {1., 2.}; + XT_EXPECT_THROW(allclose(a, b), broadcast_error); + } + } diff --git a/test/test_xnorm.cpp b/test/test_xnorm.cpp index 632114530..f32b15462 100644 --- a/test/test_xnorm.cpp +++ b/test/test_xnorm.cpp @@ -185,4 +185,13 @@ namespace xt EXPECT_EQ(norm_induced_l1(a, evaluation_strategy::immediate)(), 6.0); EXPECT_EQ(norm_induced_linf(a, evaluation_strategy::immediate)(), 7.0); } + + TEST(xnorm, invalid_axis) + { + xarray a = {1., 2., 3.}; + XT_EXPECT_ANY_THROW(norm_l1(a, {1})); + XT_EXPECT_ANY_THROW(norm_l2(a, {1})); + XT_EXPECT_ANY_THROW(norm_lp_to_p(a, 3., {1})); + } + } // namespace xt diff --git a/test/test_xset_operation.cpp b/test/test_xset_operation.cpp index 07cbde18d..8d3c6da3d 100644 --- a/test/test_xset_operation.cpp +++ b/test/test_xset_operation.cpp @@ -8,6 +8,7 @@ ****************************************************************************/ #include +#include #include "xtensor/containers/xarray.hpp" #include "xtensor/containers/xtensor.hpp" @@ -25,6 +26,7 @@ namespace xt EXPECT_EQ(xt::isin(a, b), res); EXPECT_EQ(xt::isin(a, b.begin(), b.end()), res); EXPECT_EQ(xt::isin(a, {1, 2}), res); + EXPECT_EQ(xt::isin(a, xt::xtensor({1, 2})), res); } TEST(xset_operation, in1d) @@ -37,6 +39,17 @@ namespace xt EXPECT_EQ(xt::in1d(a, {1, 2}), res); } +#ifdef XTENSOR_ENABLE_ASSERT + TEST(xset_operation, in1d_not_1d) + { + xt::xtensor a = {{1, 2}, {3, 4}}; + xt::xtensor b = {1, 2}; + XT_EXPECT_THROW(xt::in1d(a, b), std::runtime_error); + XT_EXPECT_THROW(xt::in1d(a, b.begin(), b.end()), std::runtime_error); + XT_EXPECT_THROW(xt::in1d(a, {1, 2}), std::runtime_error); + } +#endif + TEST(xset_operation, searchsorted) { xt::xtensor a = {1, 2, 7, 8, 20}; diff --git a/test/test_xshape.cpp b/test/test_xshape.cpp index a00db785e..5af4c6d3e 100644 --- a/test/test_xshape.cpp +++ b/test/test_xshape.cpp @@ -66,4 +66,12 @@ namespace xt ASSERT_TRUE(xt::has_shape(A, shape)); ASSERT_TRUE(xt::has_shape(A, {2, 3})); } + + TEST(xshape, has_shape_broadcast_error) + { + xarray a = {1, 2, 3}; + xarray b = {1, 2}; + XT_EXPECT_THROW(has_shape(a + b, {3}), broadcast_error); + } + }