Skip to content

Commit bb6fea2

Browse files
committed
Upgraded to xtl 0.8.0 and C++17
1 parent 647a483 commit bb6fea2

29 files changed

+271
-376
lines changed

CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# The full license is in the file LICENSE, distributed with this software. #
88
############################################################################
99

10-
cmake_minimum_required(VERSION 3.5)
10+
cmake_minimum_required(VERSION 3.29)
1111
project(xtensor CXX)
1212

1313
set(XTENSOR_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
@@ -29,7 +29,7 @@ message(STATUS "Building xtensor v${${PROJECT_NAME}_VERSION}")
2929
# Dependencies
3030
# ============
3131

32-
set(xtl_REQUIRED_VERSION 0.7.5)
32+
set(xtl_REQUIRED_VERSION 0.8.0)
3333
if(TARGET xtl)
3434
set(xtl_VERSION ${XTL_VERSION_MAJOR}.${XTL_VERSION_MINOR}.${XTL_VERSION_PATCH})
3535
# Note: This is not SEMVER compatible comparison
@@ -194,7 +194,7 @@ target_include_directories(xtensor INTERFACE
194194
$<BUILD_INTERFACE:${XTENSOR_INCLUDE_DIR}>
195195
$<INSTALL_INTERFACE:include>)
196196

197-
target_compile_features(xtensor INTERFACE cxx_std_14)
197+
target_compile_features(xtensor INTERFACE cxx_std_17)
198198

199199
target_link_libraries(xtensor INTERFACE xtl)
200200

@@ -205,8 +205,6 @@ OPTION(BUILD_TESTS "xtensor test suite" OFF)
205205
OPTION(BUILD_BENCHMARK "xtensor benchmark" OFF)
206206
OPTION(DOWNLOAD_GBENCHMARK "download google benchmark and build from source" ON)
207207
OPTION(DEFAULT_COLUMN_MAJOR "set default layout to column major" OFF)
208-
OPTION(DISABLE_VS2017 "disables the compilation of some test with Visual Studio 2017" OFF)
209-
OPTION(CPP17 "enables C++17" OFF)
210208
OPTION(CPP20 "enables C++20 (experimental)" OFF)
211209
OPTION(XTENSOR_DISABLE_EXCEPTIONS "Disable C++ exceptions" OFF)
212210
OPTION(DISABLE_MSVC_ITERATOR_CHECK "Disable the MVSC iterator check" ON)

environment-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ channels:
33
- conda-forge
44
dependencies:
55
- cmake
6-
- xtl=0.7.5
6+
- xtl=0.8.0
77
- xsimd=13.2.0
88
- nlohmann_json
99
- doctest

include/xtensor/containers/xadapt.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ namespace xt
5252
using default_allocator_for_ptr_t = typename default_allocator_for_ptr<P>::type;
5353

5454
template <class T>
55-
using not_an_array = xtl::negation<is_array<T>>;
55+
using not_an_array = std::negation<is_array<T>>;
5656

5757
template <class T>
58-
using not_a_pointer = xtl::negation<std::is_pointer<T>>;
58+
using not_a_pointer = std::negation<std::is_pointer<T>>;
5959

6060
template <class T>
61-
using not_a_layout = xtl::negation<std::is_same<layout_type, T>>;
61+
using not_a_layout = std::negation<std::is_same<layout_type, T>>;
6262
}
6363

6464
#ifndef IN_DOXYGEN

include/xtensor/containers/xscalar.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,13 @@ namespace xt
322322
template <class... E>
323323
struct all_xscalar
324324
{
325-
static constexpr bool value = xtl::conjunction<is_xscalar<std::decay_t<E>>...>::value;
325+
static constexpr bool value = std::conjunction<is_xscalar<std::decay_t<E>>...>::value;
326326
};
327327
}
328328

329329
// Note: MSVC bug workaround. Cannot just define
330330
// template <class... E>
331-
// using all_xscalar = xtl::conjunction<is_xscalar<std::decay_t<E>>...>;
331+
// using all_xscalar = std::conjunction<is_xscalar<std::decay_t<E>>...>;
332332

333333
template <class... E>
334334
using all_xscalar = detail::all_xscalar<E...>;

include/xtensor/core/xassign.hpp

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,15 @@ namespace xt
214214
template <class E1, class E2>
215215
inline void assign_xexpression(xexpression<E1>& e1, const xexpression<E2>& e2)
216216
{
217-
xtl::mpl::static_if<has_assign_to<E1, E2>::value>(
218-
[&](auto self)
219-
{
220-
self(e2).derived_cast().assign_to(e1);
221-
},
222-
/*else*/
223-
[&](auto /*self*/)
224-
{
225-
using tag = xexpression_tag_t<E1, E2>;
226-
xexpression_assigner<tag>::assign_xexpression(e1, e2);
227-
}
228-
);
217+
if constexpr (has_assign_to<E1, E2>::value)
218+
{
219+
e2.derived_cast().assign_to(e1);
220+
}
221+
else
222+
{
223+
using tag = xexpression_tag_t<E1, E2>;
224+
xexpression_assigner<tag>::assign_xexpression(e1, e2);
225+
}
229226
}
230227

231228
template <class E1, class E2>
@@ -320,7 +317,7 @@ namespace xt
320317
template <class F, class... CT>
321318
struct use_strided_loop<xfunction<F, CT...>>
322319
{
323-
static constexpr bool value = xtl::conjunction<use_strided_loop<std::decay_t<CT>>...>::value;
320+
static constexpr bool value = std::conjunction<use_strided_loop<std::decay_t<CT>>...>::value;
324321
};
325322

326323
/**
@@ -585,31 +582,28 @@ namespace xt
585582
template <class E1, class F, class... CT>
586583
inline bool xexpression_assigner<Tag>::resize(E1& e1, const xfunction<F, CT...>& e2)
587584
{
588-
return xtl::mpl::static_if<detail::is_fixed<typename xfunction<F, CT...>::shape_type>::value>(
589-
[&](auto /*self*/)
590-
{
591-
/*
592-
* If the shape of the xfunction is statically known, we can compute the broadcast triviality
593-
* at compile time plus we can resize right away.
594-
*/
595-
// resize in case LHS is not a fixed size container. If it is, this is a NOP
596-
e1.resize(typename xfunction<F, CT...>::shape_type{});
597-
return detail::static_trivial_broadcast<
598-
detail::is_fixed<typename xfunction<F, CT...>::shape_type>::value,
599-
CT...>::value;
600-
},
601-
/* else */
602-
[&](auto /*self*/)
603-
{
604-
using index_type = xindex_type_t<typename E1::shape_type>;
605-
using size_type = typename E1::size_type;
606-
size_type size = e2.dimension();
607-
index_type shape = uninitialized_shape<index_type>(size);
608-
bool trivial_broadcast = e2.broadcast_shape(shape, true);
609-
e1.resize(std::move(shape));
610-
return trivial_broadcast;
611-
}
612-
);
585+
if constexpr (detail::is_fixed<typename xfunction<F, CT...>::shape_type>::value)
586+
{
587+
/*
588+
* If the shape of the xfunction is statically known, we can compute the broadcast triviality
589+
* at compile time plus we can resize right away.
590+
*/
591+
// resize in case LHS is not a fixed size container. If it is, this is a NOP
592+
e1.resize(typename xfunction<F, CT...>::shape_type{});
593+
return detail::static_trivial_broadcast<
594+
detail::is_fixed<typename xfunction<F, CT...>::shape_type>::value,
595+
CT...>::value;
596+
}
597+
else
598+
{
599+
using index_type = xindex_type_t<typename E1::shape_type>;
600+
using size_type = typename E1::size_type;
601+
size_type size = e2.dimension();
602+
index_type shape = uninitialized_shape<index_type>(size);
603+
bool trivial_broadcast = e2.broadcast_shape(shape, true);
604+
e1.resize(std::move(shape));
605+
return trivial_broadcast;
606+
}
613607
}
614608

615609
/***********************************

include/xtensor/core/xexpression.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ namespace xt
168168

169169
template <template <class> class B, class E, template <class> class F>
170170
struct is_crtp_base_of_impl<B, F<E>>
171-
: xtl::disjunction<std::is_base_of<B<E>, F<E>>, std::is_base_of<B<F<E>>, F<E>>>
171+
: std::disjunction<std::is_base_of<B<E>, F<E>>, std::is_base_of<B<F<E>>, F<E>>>
172172
{
173173
};
174174
}
@@ -186,7 +186,7 @@ namespace xt
186186
using disable_xexpression = typename std::enable_if<!is_xexpression<E>::value, R>::type;
187187

188188
template <class... E>
189-
using has_xexpression = xtl::disjunction<is_xexpression<E>...>;
189+
using has_xexpression = std::disjunction<is_xexpression<E>...>;
190190

191191
template <class E>
192192
using is_xsharable_expression = is_crtp_base_of<xsharable_expression, E>;
@@ -405,7 +405,7 @@ namespace xt
405405

406406
template <class... E>
407407
struct xoptional_comparable
408-
: xtl::conjunction<xtl::disjunction<is_xtensor_expression<E>, is_xoptional_expression<E>>...>
408+
: std::conjunction<std::disjunction<is_xtensor_expression<E>, is_xoptional_expression<E>>...>
409409
{
410410
};
411411

include/xtensor/core/xfunction.hpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace xt
3838
{
3939

4040
template <bool... B>
41-
using conjunction_c = xtl::conjunction<std::integral_constant<bool, B>...>;
41+
using conjunction_c = std::conjunction<std::integral_constant<bool, B>...>;
4242

4343
/************************
4444
* xfunction_cache_impl *
@@ -155,7 +155,7 @@ namespace xt
155155
};
156156

157157
template <class T, class F, class... CT>
158-
struct has_simd_interface<xfunction<F, CT...>, T> : xtl::conjunction<
158+
struct has_simd_interface<xfunction<F, CT...>, T> : std::conjunction<
159159
has_simd_type<T>,
160160
has_simd_apply<F, xt_simd::simd_type<T>>,
161161
has_simd_interface<std::decay_t<CT>, T>...>
@@ -589,16 +589,13 @@ namespace xt
589589
template <class F, class... CT>
590590
inline auto xfunction<F, CT...>::shape() const -> const inner_shape_type&
591591
{
592-
xtl::mpl::static_if<!detail::is_fixed<inner_shape_type>::value>(
593-
[&](auto self)
592+
if constexpr (!detail::is_fixed<inner_shape_type>::value)
593+
{
594+
if (!m_cache.is_initialized)
594595
{
595-
if (!m_cache.is_initialized)
596-
{
597-
self(this)->compute_cached_shape();
598-
}
599-
},
600-
[](auto /*self*/) {}
601-
);
596+
compute_cached_shape();
597+
}
598+
}
602599
return m_cache.shape;
603600
}
604601

0 commit comments

Comments
 (0)