Skip to content

Commit 6c8daf4

Browse files
committed
Fix unused, extra-semi, mismatched-tags and bitwise warnings in headers
- argsort_iter only reads data_end in assertions. Mark it [[maybe_unused]] and drop the (void) idx_end cast, which was dead code since idx_end is passed to std::iota. - The flat argmin and argmax overloads declared a value_type alias they never used. Remove it. - initializer_shape does not read its argument when the shape has no dimensions. Mark it [[maybe_unused]]. - accumulate_impl wrapped f in a lambda that was never called for an empty tuple. Fold over the assignments directly. - optional_bitwise combined bool flags with &. The operands are values that are already computed, so && gives the same result. It is also correct for flag types other than bool, where & could clear a set flag (2 & true is 0). The simd path keeps & for batch_bool. - Remove a stray ';' in xreducer_temporary_type<xoptional>. - index_mapper was declared as a struct and defined as a class. Declare it as a class.
1 parent a57bcc1 commit 6c8daf4

5 files changed

Lines changed: 5 additions & 13 deletions

File tree

‎include/xtensor/core/xshape.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ namespace xt
197197
};
198198

199199
template <class R, class U, std::size_t... I>
200-
constexpr R initializer_shape(U t, std::index_sequence<I...>)
200+
constexpr R initializer_shape([[maybe_unused]] U t, std::index_sequence<I...>)
201201
{
202202
using size_type = typename R::value_type;
203203
return {size_type(initializer_shape_impl<I>::value(t))...};

‎include/xtensor/misc/xsort.hpp‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ namespace xt
294294
template <class ConstRandomIt, class RandomIt, class Compare, class Method>
295295
inline void argsort_iter(
296296
ConstRandomIt data_begin,
297-
ConstRandomIt data_end,
297+
[[maybe_unused]] ConstRandomIt data_end,
298298
RandomIt idx_begin,
299299
RandomIt idx_end,
300300
Compare comp,
@@ -303,7 +303,6 @@ namespace xt
303303
{
304304
XTENSOR_ASSERT(std::distance(data_begin, data_end) >= 0);
305305
XTENSOR_ASSERT(std::distance(idx_begin, idx_end) == std::distance(data_begin, data_end));
306-
(void) idx_end; // TODO(C++17) [[maybe_unused]] only used in assertion.
307306

308307
std::iota(idx_begin, idx_end, 0);
309308
switch (method)
@@ -1237,7 +1236,6 @@ namespace xt
12371236
template <layout_type L = XTENSOR_DEFAULT_TRAVERSAL, class E>
12381237
inline auto argmin(const xexpression<E>& e)
12391238
{
1240-
using value_type = typename E::value_type;
12411239
auto&& ed = eval(e.derived_cast());
12421240
auto begin = ed.template begin<L>();
12431241
auto end = ed.template end<L>();
@@ -1267,7 +1265,6 @@ namespace xt
12671265
template <layout_type L = XTENSOR_DEFAULT_TRAVERSAL, class E>
12681266
inline auto argmax(const xexpression<E>& e)
12691267
{
1270-
using value_type = typename E::value_type;
12711268
auto&& ed = eval(e.derived_cast());
12721269
auto begin = ed.template begin<L>();
12731270
auto end = ed.template end<L>();

‎include/xtensor/optional/xoptional.hpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ namespace xt
199199
template <class U, class... Args>
200200
constexpr result_type apply_impl(const U& t, const Args&... args) const
201201
{
202-
return t & apply_impl(args...);
202+
return t && apply_impl(args...);
203203
}
204204

205205
template <class B>
@@ -242,7 +242,6 @@ namespace xt
242242
struct xreducer_temporary_type<xtl::xoptional<T, B>>
243243
{
244244
using type = xtl::xoptional<std::decay_t<T>, bool>;
245-
;
246245
};
247246
}
248247

‎include/xtensor/utils/xutils.hpp‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,7 @@ namespace xt
193193
)
194194
{
195195
R res = init;
196-
auto wrapper = [&](const auto& i, const auto& j)
197-
{
198-
res = f(i, j);
199-
};
200-
(wrapper(res, std::get<I>(t)), ...);
196+
((res = f(res, std::get<I>(t))), ...);
201197
return res;
202198
}
203199
}

‎include/xtensor/views/index_mapper.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace xt
1818
{
1919

2020
template <class UndefinedView>
21-
struct index_mapper;
21+
class index_mapper;
2222

2323
/**
2424
* @enum access_t

0 commit comments

Comments
 (0)