diff --git a/README.md b/README.md index 0bc823eaa..797dd1681 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ library: | `xtensor` | `xtl` |`xsimd` (optional) | |-----------|---------|-------------------| | master | ^0.8.0 | ^13.2.0 | +| 0.27.2 | ^0.8.0 | ^13.2.0 | | 0.27.1 | ^0.8.0 | ^13.2.0 | | 0.27.0 | ^0.8.0 | ^13.2.0 | | 0.26.0 | ^0.8.0 | ^13.2.0 | diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 982773051..8118485ea 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -7,6 +7,11 @@ Changelog ========= +0.27.2 +------ + +- Fixed xexpression_holder generic constructor + 0.27.1 ------ diff --git a/include/xtensor/core/xtensor_config.hpp b/include/xtensor/core/xtensor_config.hpp index 959a3b2a4..a3fb00081 100644 --- a/include/xtensor/core/xtensor_config.hpp +++ b/include/xtensor/core/xtensor_config.hpp @@ -12,7 +12,7 @@ #define XTENSOR_VERSION_MAJOR 0 #define XTENSOR_VERSION_MINOR 27 -#define XTENSOR_VERSION_PATCH 1 +#define XTENSOR_VERSION_PATCH 2 // Define if the library is going to be using exceptions. diff --git a/include/xtensor/misc/xexpression_holder.hpp b/include/xtensor/misc/xexpression_holder.hpp index f720cc006..283b331ce 100644 --- a/include/xtensor/misc/xexpression_holder.hpp +++ b/include/xtensor/misc/xexpression_holder.hpp @@ -10,7 +10,9 @@ #ifndef XTENSOR_XEXPRESSION_HOLDER_HPP #define XTENSOR_XEXPRESSION_HOLDER_HPP +#include #include +#include #include @@ -38,6 +40,7 @@ namespace xt xexpression_holder() = default; template + requires(!std::same_as, xexpression_holder>) xexpression_holder(E&& expr); xexpression_holder(implementation_type* holder); @@ -118,6 +121,7 @@ namespace xt } template + requires(!std::same_as, xexpression_holder>) inline xexpression_holder::xexpression_holder(E&& expr) : p_holder(new detail::xexpression_wrapper(std::forward(expr))) { @@ -181,30 +185,29 @@ namespace xt inline void xexpression_holder::init_pointer_from_json(const nlohmann::json& j) { - if (j.is_array()) + if (j.is_array() && !j.empty()) { - return init_pointer_from_json(j[0]); + init_pointer_from_json(j[0]); } - - if (j.is_number()) + else if (j.is_number()) { xt::xarray empty_arr; p_holder.reset(new detail::xexpression_wrapper>(std::move(empty_arr))); } - - if (j.is_boolean()) + else if (j.is_boolean()) { xt::xarray empty_arr; p_holder.reset(new detail::xexpression_wrapper>(std::move(empty_arr))); } - - if (j.is_string()) + else if (j.is_string()) { xt::xarray empty_arr; p_holder.reset(new detail::xexpression_wrapper>(std::move(empty_arr))); } - - XTENSOR_THROW(std::runtime_error, "Received a JSON with a tensor that contains unsupported data type"); + else + { + XTENSOR_THROW(std::runtime_error, "Received a JSON with a tensor that contains unsupported data type"); + } } inline void xexpression_holder::check_holder() const