From bb6fea2e675eb126365baa324361c301ea79301f Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Wed, 26 Mar 2025 23:17:27 +0100 Subject: [PATCH] Upgraded to xtl 0.8.0 and C++17 --- CMakeLists.txt | 8 +- environment-dev.yml | 2 +- include/xtensor/containers/xadapt.hpp | 6 +- include/xtensor/containers/xscalar.hpp | 4 +- include/xtensor/core/xassign.hpp | 70 ++++---- include/xtensor/core/xexpression.hpp | 6 +- include/xtensor/core/xfunction.hpp | 19 +-- include/xtensor/core/xiterable.hpp | 152 ++++++++---------- include/xtensor/core/xiterator.hpp | 76 ++++----- include/xtensor/core/xmath.hpp | 30 ++-- include/xtensor/core/xoperation.hpp | 6 +- include/xtensor/core/xshape.hpp | 12 +- include/xtensor/generators/xbuilder.hpp | 12 +- include/xtensor/io/xjson.hpp | 4 +- include/xtensor/io/xnpy.hpp | 4 +- include/xtensor/misc/xexpression_holder.hpp | 1 - include/xtensor/misc/xmanipulation.hpp | 6 +- include/xtensor/misc/xpad.hpp | 2 +- .../xtensor/reducers/xblockwise_reducer.hpp | 12 +- include/xtensor/reducers/xnorm.hpp | 8 +- include/xtensor/reducers/xreducer.hpp | 30 ++-- include/xtensor/utils/xutils.hpp | 24 +-- include/xtensor/views/xdynamic_view.hpp | 17 +- include/xtensor/views/xfunctor_view.hpp | 2 +- include/xtensor/views/xslice.hpp | 2 +- include/xtensor/views/xstrided_view.hpp | 4 +- include/xtensor/views/xstrided_view_base.hpp | 20 +-- include/xtensor/views/xview.hpp | 79 ++++----- test/CMakeLists.txt | 29 +--- 29 files changed, 271 insertions(+), 376 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f59f0a8c7..d969a486b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ # The full license is in the file LICENSE, distributed with this software. # ############################################################################ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.29) project(xtensor CXX) set(XTENSOR_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) @@ -29,7 +29,7 @@ message(STATUS "Building xtensor v${${PROJECT_NAME}_VERSION}") # Dependencies # ============ -set(xtl_REQUIRED_VERSION 0.7.5) +set(xtl_REQUIRED_VERSION 0.8.0) if(TARGET xtl) set(xtl_VERSION ${XTL_VERSION_MAJOR}.${XTL_VERSION_MINOR}.${XTL_VERSION_PATCH}) # Note: This is not SEMVER compatible comparison @@ -194,7 +194,7 @@ target_include_directories(xtensor INTERFACE $ $) -target_compile_features(xtensor INTERFACE cxx_std_14) +target_compile_features(xtensor INTERFACE cxx_std_17) target_link_libraries(xtensor INTERFACE xtl) @@ -205,8 +205,6 @@ OPTION(BUILD_TESTS "xtensor test suite" OFF) OPTION(BUILD_BENCHMARK "xtensor benchmark" OFF) OPTION(DOWNLOAD_GBENCHMARK "download google benchmark and build from source" ON) OPTION(DEFAULT_COLUMN_MAJOR "set default layout to column major" OFF) -OPTION(DISABLE_VS2017 "disables the compilation of some test with Visual Studio 2017" OFF) -OPTION(CPP17 "enables C++17" OFF) OPTION(CPP20 "enables C++20 (experimental)" OFF) OPTION(XTENSOR_DISABLE_EXCEPTIONS "Disable C++ exceptions" OFF) OPTION(DISABLE_MSVC_ITERATOR_CHECK "Disable the MVSC iterator check" ON) diff --git a/environment-dev.yml b/environment-dev.yml index f320d623f..a594f896d 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -3,7 +3,7 @@ channels: - conda-forge dependencies: - cmake -- xtl=0.7.5 +- xtl=0.8.0 - xsimd=13.2.0 - nlohmann_json - doctest diff --git a/include/xtensor/containers/xadapt.hpp b/include/xtensor/containers/xadapt.hpp index 75cd7fc0d..725a75d42 100644 --- a/include/xtensor/containers/xadapt.hpp +++ b/include/xtensor/containers/xadapt.hpp @@ -52,13 +52,13 @@ namespace xt using default_allocator_for_ptr_t = typename default_allocator_for_ptr

::type; template - using not_an_array = xtl::negation>; + using not_an_array = std::negation>; template - using not_a_pointer = xtl::negation>; + using not_a_pointer = std::negation>; template - using not_a_layout = xtl::negation>; + using not_a_layout = std::negation>; } #ifndef IN_DOXYGEN diff --git a/include/xtensor/containers/xscalar.hpp b/include/xtensor/containers/xscalar.hpp index 497a2134d..bfeba09b7 100644 --- a/include/xtensor/containers/xscalar.hpp +++ b/include/xtensor/containers/xscalar.hpp @@ -322,13 +322,13 @@ namespace xt template struct all_xscalar { - static constexpr bool value = xtl::conjunction>...>::value; + static constexpr bool value = std::conjunction>...>::value; }; } // Note: MSVC bug workaround. Cannot just define // template - // using all_xscalar = xtl::conjunction>...>; + // using all_xscalar = std::conjunction>...>; template using all_xscalar = detail::all_xscalar; diff --git a/include/xtensor/core/xassign.hpp b/include/xtensor/core/xassign.hpp index ea8e1dbea..904113814 100644 --- a/include/xtensor/core/xassign.hpp +++ b/include/xtensor/core/xassign.hpp @@ -214,18 +214,15 @@ namespace xt template inline void assign_xexpression(xexpression& e1, const xexpression& e2) { - xtl::mpl::static_if::value>( - [&](auto self) - { - self(e2).derived_cast().assign_to(e1); - }, - /*else*/ - [&](auto /*self*/) - { - using tag = xexpression_tag_t; - xexpression_assigner::assign_xexpression(e1, e2); - } - ); + if constexpr (has_assign_to::value) + { + e2.derived_cast().assign_to(e1); + } + else + { + using tag = xexpression_tag_t; + xexpression_assigner::assign_xexpression(e1, e2); + } } template @@ -320,7 +317,7 @@ namespace xt template struct use_strided_loop> { - static constexpr bool value = xtl::conjunction>...>::value; + static constexpr bool value = std::conjunction>...>::value; }; /** @@ -585,31 +582,28 @@ namespace xt template inline bool xexpression_assigner::resize(E1& e1, const xfunction& e2) { - return xtl::mpl::static_if::shape_type>::value>( - [&](auto /*self*/) - { - /* - * If the shape of the xfunction is statically known, we can compute the broadcast triviality - * at compile time plus we can resize right away. - */ - // resize in case LHS is not a fixed size container. If it is, this is a NOP - e1.resize(typename xfunction::shape_type{}); - return detail::static_trivial_broadcast< - detail::is_fixed::shape_type>::value, - CT...>::value; - }, - /* else */ - [&](auto /*self*/) - { - using index_type = xindex_type_t; - using size_type = typename E1::size_type; - size_type size = e2.dimension(); - index_type shape = uninitialized_shape(size); - bool trivial_broadcast = e2.broadcast_shape(shape, true); - e1.resize(std::move(shape)); - return trivial_broadcast; - } - ); + if constexpr (detail::is_fixed::shape_type>::value) + { + /* + * If the shape of the xfunction is statically known, we can compute the broadcast triviality + * at compile time plus we can resize right away. + */ + // resize in case LHS is not a fixed size container. If it is, this is a NOP + e1.resize(typename xfunction::shape_type{}); + return detail::static_trivial_broadcast< + detail::is_fixed::shape_type>::value, + CT...>::value; + } + else + { + using index_type = xindex_type_t; + using size_type = typename E1::size_type; + size_type size = e2.dimension(); + index_type shape = uninitialized_shape(size); + bool trivial_broadcast = e2.broadcast_shape(shape, true); + e1.resize(std::move(shape)); + return trivial_broadcast; + } } /*********************************** diff --git a/include/xtensor/core/xexpression.hpp b/include/xtensor/core/xexpression.hpp index b9174cb5f..f32879035 100644 --- a/include/xtensor/core/xexpression.hpp +++ b/include/xtensor/core/xexpression.hpp @@ -168,7 +168,7 @@ namespace xt template