Skip to content

Commit 6178efd

Browse files
committed
...
1 parent 3733f42 commit 6178efd

File tree

12 files changed

+101
-97
lines changed

12 files changed

+101
-97
lines changed

include/xtensor/utils/xutils.hpp

Lines changed: 68 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@
3333
#if (defined(_MSC_VER) && _MSC_VER >= 1910)
3434
#define NOEXCEPT(T)
3535
#else
36+
#ifdef XTENSOR_ENABLE_ASSERT
37+
#define NOEXCEPT(T)
38+
#else
3639
#define NOEXCEPT(T) noexcept(T)
3740
#endif
41+
#endif
3842

3943
namespace xt
4044
{
@@ -268,8 +272,8 @@ namespace xt
268272
************************/
269273

270274
template <class R, class F, class... S>
271-
inline R apply(std::size_t index, F&& func, const std::tuple<S...>& s)
272-
NOEXCEPT(noexcept(func(std::get<0>(s))))
275+
inline R
276+
apply(std::size_t index, F&& func, const std::tuple<S...>& s) NOEXCEPT(noexcept(func(std::get<0>(s))))
273277
{
274278
XTENSOR_ASSERT(sizeof...(S) > index);
275279
return std::apply(
@@ -378,14 +382,16 @@ namespace xt
378382
res[i] = normalize_axis(expr.dimension(), axes[i]);
379383
}
380384

381-
XTENSOR_ASSERT(std::all_of(
382-
res.begin(),
383-
res.end(),
384-
[&expr](auto ax_el)
385-
{
386-
return ax_el < expr.dimension();
387-
}
388-
));
385+
XTENSOR_ASSERT(
386+
std::all_of(
387+
res.begin(),
388+
res.end(),
389+
[&expr](auto ax_el)
390+
{
391+
return ax_el < expr.dimension();
392+
}
393+
)
394+
);
389395

390396
return res;
391397
}
@@ -397,14 +403,16 @@ namespace xt
397403
normalize_axis(E& expr, C&& axes)
398404
{
399405
static_cast<void>(expr);
400-
XTENSOR_ASSERT(std::all_of(
401-
axes.begin(),
402-
axes.end(),
403-
[&expr](auto ax_el)
404-
{
405-
return ax_el < expr.dimension();
406-
}
407-
));
406+
XTENSOR_ASSERT(
407+
std::all_of(
408+
axes.begin(),
409+
axes.end(),
410+
[&expr](auto ax_el)
411+
{
412+
return ax_el < expr.dimension();
413+
}
414+
)
415+
);
408416
return std::forward<C>(axes);
409417
}
410418

@@ -425,14 +433,16 @@ namespace xt
425433
}
426434
);
427435

428-
XTENSOR_ASSERT(std::all_of(
429-
res.begin(),
430-
res.end(),
431-
[&expr](auto ax_el)
432-
{
433-
return ax_el < expr.dimension();
434-
}
435-
));
436+
XTENSOR_ASSERT(
437+
std::all_of(
438+
res.begin(),
439+
res.end(),
440+
[&expr](auto ax_el)
441+
{
442+
return ax_el < expr.dimension();
443+
}
444+
)
445+
);
436446

437447
return res;
438448
}
@@ -447,14 +457,16 @@ namespace xt
447457
R res;
448458
xt::resize_container(res, std::size(axes));
449459
std::copy(std::begin(axes), std::end(axes), std::begin(res));
450-
XTENSOR_ASSERT(std::all_of(
451-
res.begin(),
452-
res.end(),
453-
[&expr](auto ax_el)
454-
{
455-
return ax_el < expr.dimension();
456-
}
457-
));
460+
XTENSOR_ASSERT(
461+
std::all_of(
462+
res.begin(),
463+
res.end(),
464+
[&expr](auto ax_el)
465+
{
466+
return ax_el < expr.dimension();
467+
}
468+
)
469+
);
458470
return res;
459471
}
460472

@@ -464,14 +476,16 @@ namespace xt
464476
R&&>
465477
{
466478
static_cast<void>(expr);
467-
XTENSOR_ASSERT(std::all_of(
468-
std::begin(axes),
469-
std::end(axes),
470-
[&expr](auto ax_el)
471-
{
472-
return ax_el < expr.dimension();
473-
}
474-
));
479+
XTENSOR_ASSERT(
480+
std::all_of(
481+
std::begin(axes),
482+
std::end(axes),
483+
[&expr](auto ax_el)
484+
{
485+
return ax_el < expr.dimension();
486+
}
487+
)
488+
);
475489
return std::move(axes);
476490
}
477491

@@ -905,18 +919,18 @@ namespace xt
905919
{
906920
explicit overlapping_memory_checker(const Dst& aDst)
907921
: overlapping_memory_checker_base(
908-
[&]()
909-
{
910-
if (aDst.size() == 0)
911-
{
912-
return memory_range();
913-
}
914-
else
915-
{
916-
return memory_range(std::addressof(*aDst.begin()), std::addressof(*aDst.rbegin()));
917-
}
918-
}()
919-
)
922+
[&]()
923+
{
924+
if (aDst.size() == 0)
925+
{
926+
return memory_range();
927+
}
928+
else
929+
{
930+
return memory_range(std::addressof(*aDst.begin()), std::addressof(*aDst.rbegin()));
931+
}
932+
}()
933+
)
920934
{
921935
}
922936
};

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DXSIMD_ENABLE_XTL_COMPLEX=1")
6363
if(MSVC)
6464
set(CMAKE_CXX_FLAGS_WARNINGS "/W4 /WX")
6565
else()
66-
set(CMAKE_CXX_FLAGS_WARNINGS "-Werror -Wextra -Wpedantic")
66+
set(CMAKE_CXX_FLAGS_WARNINGS "-Werror -Wextra -Wall")
6767
endif()
6868

6969
# Helper macro to reduce MSVC-specific boilerplate

test/test_common.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ namespace xt
459459
}
460460

461461
template <class V>
462-
void test_bound_check(V& vec)
462+
void test_bound_check([[maybe_unused]] V& vec)
463463
{
464464
#if XTENSOR_ENABLE_ASSERT
465465
XT_EXPECT_ANY_THROW(vec(10, 10, 10));
@@ -469,7 +469,7 @@ namespace xt
469469
}
470470

471471
template <class V>
472-
void test_access_check(V& vec)
472+
void test_access_check([[maybe_unused]] V& vec)
473473
{
474474
XT_EXPECT_ANY_THROW(vec.at(10, 10, 10));
475475
XT_EXPECT_ANY_THROW(vec.at(0, 0, 0, 0, 0, 0));
@@ -769,7 +769,7 @@ namespace xt
769769

770770
{
771771
INFO("incompatible shapes");
772-
shape_type s4 = {2, 1, 3, 2};
772+
[[maybe_unused]] shape_type s4 = {2, 1, 3, 2};
773773
XT_EXPECT_THROW(vec.broadcast_shape(s4), broadcast_error);
774774
}
775775
}
@@ -980,8 +980,9 @@ namespace xt
980980
EXPECT_TRUE((std::is_same<rm_layout_iterator, exp_rm_layout_iterator>::value));
981981
EXPECT_TRUE((std::is_same<rm_const_layout_iterator, exp_rm_const_layout_iterator>::value));
982982
EXPECT_TRUE((std::is_same<rm_reverse_layout_iterator, exp_rm_reverse_layout_iterator>::value));
983-
EXPECT_TRUE((std::is_same<rm_const_reverse_layout_iterator, exp_rm_const_reverse_layout_iterator>::value
984-
));
983+
EXPECT_TRUE(
984+
(std::is_same<rm_const_reverse_layout_iterator, exp_rm_const_reverse_layout_iterator>::value)
985+
);
985986

986987
using cm_layout_iterator = typename C::template layout_iterator<layout_type::column_major>;
987988
using cm_const_layout_iterator = typename C::template const_layout_iterator<layout_type::column_major>;
@@ -997,8 +998,9 @@ namespace xt
997998
EXPECT_TRUE((std::is_same<cm_layout_iterator, exp_cm_layout_iterator>::value));
998999
EXPECT_TRUE((std::is_same<cm_const_layout_iterator, exp_cm_const_layout_iterator>::value));
9991000
EXPECT_TRUE((std::is_same<cm_reverse_layout_iterator, exp_cm_reverse_layout_iterator>::value));
1000-
EXPECT_TRUE((std::is_same<cm_const_reverse_layout_iterator, exp_cm_const_reverse_layout_iterator>::value
1001-
));
1001+
EXPECT_TRUE(
1002+
(std::is_same<cm_const_reverse_layout_iterator, exp_cm_const_reverse_layout_iterator>::value)
1003+
);
10021004

10031005
using linear_iterator = typename C::linear_iterator;
10041006
using const_linear_iterator = typename C::const_linear_iterator;

test/test_common_macros.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "test_utils.hpp"
1212

1313
#if defined(XTENSOR_DISABLE_EXCEPTIONS)
14-
#warning "XT_EXPECT_THROW, XT_ASSERT_THROW, XT_EXPECT_ANY_THROW and XT_ASSERT_ANY_THROW are disabled"
14+
// #warning "XT_EXPECT_THROW, XT_ASSERT_THROW, XT_EXPECT_ANY_THROW and XT_ASSERT_ANY_THROW are disabled"
1515
#define XT_EXPECT_THROW(x, y)
1616
#define XT_ASSERT_THROW(x, y)
1717
#define XT_EXPECT_ANY_THROW(x)

test/test_xbuffer_adaptor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ namespace xt
198198
double* data1 = new double[size1];
199199
buffer_adaptor adapt(data1, size1);
200200

201-
size_t size2 = 50;
201+
[[maybe_unused]] size_t size2 = 50;
202202
XT_EXPECT_THROW(adapt.resize(size2), std::runtime_error);
203203
EXPECT_EQ(adapt.size(), size1);
204204
}

test/test_xcomplex.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,9 @@ namespace xt
133133
};
134134
EXPECT_TRUE(allclose(cmplexpected_angle, cmplres_angle));
135135

136-
using assign_t_angle = xassign_traits<xarray<double>, decltype(cmplres_angle)>;
137-
(void) sizeof(assign_t_angle); // to avoid unused warning
138136

139137
#if XTENSOR_USE_XSIMD
138+
using assign_t_angle = xassign_traits<xarray<double>, decltype(cmplres_angle)>;
140139
EXPECT_TRUE(assign_t_angle::simd_linear_assign());
141140
#endif
142141

@@ -148,10 +147,9 @@ namespace xt
148147
};
149148
EXPECT_TRUE(allclose(cmplexpected_conj, cmplres_conj));
150149

151-
using assign_t_conj = xassign_traits<xarray<std::complex<double>>, decltype(cmplres_conj)>;
152-
(void) sizeof(assign_t_conj); // to avoid unused warning
153150

154151
#if XTENSOR_USE_XSIMD
152+
using assign_t_conj = xassign_traits<xarray<std::complex<double>>, decltype(cmplres_conj)>;
155153
auto b1 = cmplres_angle.template load_simd<xsimd::aligned_mode>(0);
156154
auto b2 = cmplres_conj.template load_simd<xsimd::aligned_mode>(0);
157155
static_cast<void>(b1);
@@ -166,10 +164,9 @@ namespace xt
166164
{0.57322529, 0.62248637, 0.14673763}
167165
};
168166

169-
using assign_t_norm = xassign_traits<xarray<double>, decltype(cmplres_norm)>;
170-
(void) sizeof(assign_t_norm); // to avoid unused warning
171167

172168
#if XTENSOR_USE_XSIMD
169+
using assign_t_norm = xassign_traits<xarray<double>, decltype(cmplres_norm)>;
173170
EXPECT_TRUE(assign_t_norm::simd_linear_assign());
174171
#endif
175172

@@ -195,10 +192,9 @@ namespace xt
195192
++it;
196193
}
197194

198-
using assign_t_arg = xassign_traits<xarray<double>, decltype(cmplres)>;
199-
(void) sizeof(assign_t_arg); // to avoid unused warning
200195

201196
#if XTENSOR_USE_XSIMD
197+
using assign_t_arg = xassign_traits<xarray<double>, decltype(cmplres)>;
202198
EXPECT_TRUE(assign_t_arg::simd_linear_assign());
203199
#endif
204200
}

test/test_xmath.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ namespace xt
4343
xarray<double> res2 = xt::abs(b);
4444

4545
auto f = abs(b);
46-
using assign_traits = xassign_traits<xarray<double>, decltype(f)>;
47-
(void) sizeof(assign_traits); // Suppress unused typedef warning
4846

4947
#if XTENSOR_USE_XSIMD
48+
using assign_traits = xassign_traits<xarray<double>, decltype(f)>;
5049
EXPECT_TRUE(assign_traits::simd_linear_assign());
5150
#endif
5251
}

test/test_xreducer.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@
3434
namespace xt
3535
{
3636

37-
#define CHECK_RESULT_TYPE(EXPRESSION, EXPECTED_TYPE) \
38-
{ \
39-
using result_type = typename std::decay_t<decltype(EXPRESSION)>::value_type; \
40-
EXPECT_TRUE((std::is_same<result_type, EXPECTED_TYPE>::value)); \
37+
#define CHECK_RESULT_TYPE(EXPRESSION, EXPECTED_TYPE) \
38+
{ \
39+
using result_type_ = typename std::decay_t<decltype(EXPRESSION)>::value_type; \
40+
EXPECT_TRUE((std::is_same<result_type_, EXPECTED_TYPE>::value)); \
4141
}
4242

43-
#define CHECK_TAG_TYPE(EXPRESSION, EXPECTED_TYPE) \
44-
{ \
45-
using result_type = typename std::decay_t<decltype(EXPRESSION)>::expression_tag; \
46-
EXPECT_TRUE((std::is_same<result_type, EXPECTED_TYPE>::value)); \
43+
#define CHECK_TAG_TYPE(EXPRESSION, EXPECTED_TYPE) \
44+
{ \
45+
using result_type_ = typename std::decay_t<decltype(EXPRESSION)>::expression_tag; \
46+
EXPECT_TRUE((std::is_same<result_type_, EXPECTED_TYPE>::value)); \
4747
}
4848

49-
#define CHECK_TYPE(VALUE, EXPECTED_TYPE) \
50-
{ \
51-
using result_type = typename std::decay_t<decltype(VALUE)>; \
52-
EXPECT_TRUE((std::is_same<result_type, EXPECTED_TYPE>::value)); \
49+
#define CHECK_TYPE(VALUE, EXPECTED_TYPE) \
50+
{ \
51+
using result_type_ = typename std::decay_t<decltype(VALUE)>; \
52+
EXPECT_TRUE((std::is_same<result_type_, EXPECTED_TYPE>::value)); \
5353
}
5454

5555
struct xreducer_features
@@ -157,8 +157,6 @@ namespace xt
157157

158158
#define TEST_VALUE_HAS_VALUE(INPUT, V_TYPE, OPTIONAL) \
159159
using result_type = std::conditional_t<OPTIONAL, xtl::xoptional<double>, double>; \
160-
(void) sizeof(result_type); \
161-
\
162160
auto res = xt::sum(INPUT, feats.m_axes); \
163161
CHECK_RESULT_TYPE(res, result_type); \
164162
CHECK_TYPE(xt::value(res)(1, 1, 1), V_TYPE); \

test/test_xstrided_view.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,10 +687,9 @@ namespace xt
687687
xtensor<double, 2> par = xt::reshape_view<XTENSOR_DEFAULT_LAYOUT>(xt::arange(9), {3, 3});
688688
EXPECT_EQ(a, par);
689689
}
690-
using assign_traits = xassign_traits<xarray<double>, decltype(av)>;
691-
(void) sizeof(assign_traits); // to avoid unused warning
692690

693691
#if XTENSOR_USE_XSIMD
692+
using assign_traits = xassign_traits<xarray<double>, decltype(av)>;
694693
EXPECT_TRUE(assign_traits::simd_linear_assign());
695694
#endif
696695

test/test_xtensor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ namespace xt
217217
#ifdef XTENSOR_ENABLE_ASSERT
218218
xtensor_dynamic b;
219219
std::vector<size_t> s = {2u, 2u};
220-
xtensor_dynamic::strides_type strides = {2u, 1u};
220+
[[maybe_unused]] xtensor_dynamic::strides_type strides = {2u, 1u};
221221
EXPECT_THROW(b.resize(s), std::runtime_error);
222222
EXPECT_THROW(b.resize(s, layout_type::dynamic), std::runtime_error);
223223
EXPECT_THROW(b.resize(s, strides), std::runtime_error);

0 commit comments

Comments
 (0)