Skip to content

Commit 5d8d276

Browse files
author
Alexandre Hoffmann
committed
johan revisions
1 parent 1b4abdf commit 5d8d276

File tree

6 files changed

+55
-74
lines changed

6 files changed

+55
-74
lines changed

include/xtensor/misc/xtl_concepts.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,15 @@ namespace xtl
1717
{
1818
template <typename T>
1919
concept integral_concept = xtl::is_integral<T>::value;
20+
2021
template <typename T>
2122
concept non_integral_concept = !xtl::is_integral<T>::value;
23+
2224
template <typename T>
2325
concept complex_concept = xtl::is_complex<typename std::decay<T>::type::value_type>::value;
26+
27+
template <typename T>
28+
concept pointer_concept = std::is_pointer<T>::value;
2429
}
2530

2631
#endif // XTENSOR_CONCEPTS_HPP

include/xtensor/views/xaxis_iterator.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ namespace xt
124124
template <class T, class CTA>
125125
inline T xaxis_iterator<CT>::get_storage_init(CTA&& e) const
126126
{
127-
if constexpr (std::is_pointer<T>::value)
127+
if constexpr (xtl::pointer_concept<T>)
128128
{
129129
return &e;
130130
}

include/xtensor/views/xaxis_slice_iterator.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ namespace xt
9898
template <class T, class CTA>
9999
T xaxis_slice_iterator<CT>::get_storage_init(CTA&& e) const
100100
{
101-
if constexpr (std::is_pointer<T>::value)
101+
if constexpr (xtl::pointer_concept<T>)
102102
{
103103
return &e;
104104
}

include/xtensor/views/xslice.hpp

Lines changed: 36 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,13 @@ namespace xt
109109
xrange() = default;
110110
xrange(size_type start_val, size_type stop_val) noexcept;
111111

112-
template <class S>
113-
operator xrange<S>() const noexcept
114-
requires std::convertible_to<S, T>;
112+
template <std::convertible_to<T> S>
113+
operator xrange<S>() const noexcept;
115114

116115
// Same as implicit conversion operator but more convenient to call
117116
// from a variant visitor
118-
template <class S>
119-
xrange<S> convert() const noexcept
120-
requires std::convertible_to<S, T>;
117+
template <std::convertible_to<T> S>
118+
xrange<S> convert() const noexcept;
121119

122120
size_type operator()(size_type i) const noexcept;
123121

@@ -155,15 +153,13 @@ namespace xt
155153
xstepped_range() = default;
156154
xstepped_range(size_type start_val, size_type stop_val, size_type step) noexcept;
157155

158-
template <class S>
159-
operator xstepped_range<S>() const noexcept
160-
requires std::convertible_to<S, T>;
156+
template <std::convertible_to<T> S>
157+
operator xstepped_range<S>() const noexcept;
161158

162159
// Same as implicit conversion operator but more convenient to call
163160
// from a variant visitor
164-
template <class S>
165-
xstepped_range<S> convert() const noexcept
166-
requires std::convertible_to<S, T>;
161+
template <std::convertible_to<T> S>
162+
xstepped_range<S> convert() const noexcept;
167163

168164
size_type operator()(size_type i) const noexcept;
169165

@@ -202,15 +198,13 @@ namespace xt
202198
xall() = default;
203199
explicit xall(size_type size) noexcept;
204200

205-
template <class S>
206-
operator xall<S>() const noexcept
207-
requires std::convertible_to<S, T>;
201+
template <std::convertible_to<T> S>
202+
operator xall<S>() const noexcept;
208203

209204
// Same as implicit conversion operator but more convenient to call
210205
// from a variant visitor
211-
template <class S>
212-
xall<S> convert() const noexcept
213-
requires std::convertible_to<S, T>;
206+
template <std::convertible_to<T> S>
207+
xall<S> convert() const noexcept;
214208

215209
size_type operator()(size_type i) const noexcept;
216210

@@ -274,15 +268,13 @@ namespace xt
274268

275269
xnewaxis() = default;
276270

277-
template <class S>
278-
operator xnewaxis<S>() const noexcept
279-
requires std::convertible_to<S, T>;
271+
template <std::convertible_to<T> S>
272+
operator xnewaxis<S>() const noexcept;
280273

281274
// Same as implicit conversion operator but more convenient to call
282275
// from a variant visitor
283-
template <class S>
284-
xnewaxis<S> convert() const noexcept
285-
requires std::convertible_to<S, T>;
276+
template <std::convertible_to<T> S>
277+
xnewaxis<S> convert() const noexcept;
286278

287279
size_type operator()(size_type i) const noexcept;
288280

@@ -344,15 +336,13 @@ namespace xt
344336
template <class S>
345337
xkeep_slice(std::initializer_list<S> t);
346338

347-
template <class S>
348-
operator xkeep_slice<S>() const noexcept
349-
requires std::convertible_to<S, T>;
339+
template <std::convertible_to<T> S>
340+
operator xkeep_slice<S>() const noexcept;
350341

351342
// Same as implicit conversion operator but more convenient to call
352343
// from a variant visitor
353-
template <class S>
354-
xkeep_slice<S> convert() const noexcept
355-
requires std::convertible_to<S, T>;
344+
template <std::convertible_to<T> S>
345+
xkeep_slice<S> convert() const noexcept;
356346

357347
size_type operator()(size_type i) const noexcept;
358348
size_type size() const noexcept;
@@ -454,15 +444,13 @@ namespace xt
454444
template <class S>
455445
xdrop_slice(std::initializer_list<S> t);
456446

457-
template <class S>
458-
operator xdrop_slice<S>() const noexcept
459-
requires std::convertible_to<S, T>;
447+
template <std::convertible_to<T> S>
448+
operator xdrop_slice<S>() const noexcept;
460449

461450
// Same as implicit conversion operator but more convenient to call
462451
// from a variant visitor
463-
template <class S>
464-
xdrop_slice<S> convert() const noexcept
465-
requires std::convertible_to<S, T>;
452+
template <std::convertible_to<T> S>
453+
xdrop_slice<S> convert() const noexcept;
466454

467455
size_type operator()(size_type i) const noexcept;
468456
size_type size() const noexcept;
@@ -1006,9 +994,8 @@ namespace xt
1006994
}
1007995

1008996
template <class T>
1009-
template <class S>
997+
template <std::convertible_to<T> S>
1010998
inline xrange<T>::operator xrange<S>() const noexcept
1011-
requires std::convertible_to<S, T>
1012999
{
10131000
xrange<S> ret;
10141001
ret.m_start = static_cast<S>(m_start);
@@ -1017,9 +1004,8 @@ namespace xt
10171004
}
10181005

10191006
template <class T>
1020-
template <class S>
1007+
template <std::convertible_to<T> S>
10211008
inline xrange<S> xrange<T>::convert() const noexcept
1022-
requires std::convertible_to<S, T>
10231009
{
10241010
return xrange<S>(*this);
10251011
}
@@ -1087,9 +1073,8 @@ namespace xt
10871073
}
10881074

10891075
template <class T>
1090-
template <class S>
1076+
template <std::convertible_to<T> S>
10911077
inline xstepped_range<T>::operator xstepped_range<S>() const noexcept
1092-
requires std::convertible_to<S, T>
10931078
{
10941079
xstepped_range<S> ret;
10951080
ret.m_start = static_cast<S>(m_start);
@@ -1099,9 +1084,8 @@ namespace xt
10991084
}
11001085

11011086
template <class T>
1102-
template <class S>
1087+
template <std::convertible_to<T> S>
11031088
inline xstepped_range<S> xstepped_range<T>::convert() const noexcept
1104-
requires std::convertible_to<S, T>
11051089
{
11061090
return xstepped_range<S>(*this);
11071091
}
@@ -1165,17 +1149,15 @@ namespace xt
11651149
}
11661150

11671151
template <class T>
1168-
template <class S>
1152+
template <std::convertible_to<T> S>
11691153
inline xall<T>::operator xall<S>() const noexcept
1170-
requires std::convertible_to<S, T>
11711154
{
11721155
return xall<S>(static_cast<S>(m_size));
11731156
}
11741157

11751158
template <class T>
1176-
template <class S>
1159+
template <std::convertible_to<T> S>
11771160
inline xall<S> xall<T>::convert() const noexcept
1178-
requires std::convertible_to<S, T>
11791161
{
11801162
return xall<S>(*this);
11811163
}
@@ -1233,17 +1215,15 @@ namespace xt
12331215
***************************/
12341216

12351217
template <class T>
1236-
template <class S>
1218+
template <std::convertible_to<T> S>
12371219
inline xnewaxis<T>::operator xnewaxis<S>() const noexcept
1238-
requires std::convertible_to<S, T>
12391220
{
12401221
return xnewaxis<S>();
12411222
}
12421223

12431224
template <class T>
1244-
template <class S>
1225+
template <std::convertible_to<T> S>
12451226
inline xnewaxis<S> xnewaxis<T>::convert() const noexcept
1246-
requires std::convertible_to<S, T>
12471227
{
12481228
return xnewaxis<S>(*this);
12491229
}
@@ -1331,9 +1311,8 @@ namespace xt
13311311
}
13321312

13331313
template <class T>
1334-
template <class S>
1314+
template <std::convertible_to<T> S>
13351315
inline xkeep_slice<T>::operator xkeep_slice<S>() const noexcept
1336-
requires std::convertible_to<S, T>
13371316
{
13381317
xkeep_slice<S> ret;
13391318
using us_type = typename container_type::size_type;
@@ -1362,9 +1341,8 @@ namespace xt
13621341
}
13631342

13641343
template <class T>
1365-
template <class S>
1344+
template <std::convertible_to<T> S>
13661345
inline xkeep_slice<S> xkeep_slice<T>::convert() const noexcept
1367-
requires std::convertible_to<S, T>
13681346
{
13691347
return xkeep_slice<S>(*this);
13701348
}
@@ -1477,9 +1455,8 @@ namespace xt
14771455
}
14781456

14791457
template <class T>
1480-
template <class S>
1458+
template <std::convertible_to<T> S>
14811459
inline xdrop_slice<T>::operator xdrop_slice<S>() const noexcept
1482-
requires std::convertible_to<S, T>
14831460
{
14841461
xdrop_slice<S> ret;
14851462
ret.m_raw_indices.resize(m_raw_indices.size());
@@ -1516,9 +1493,8 @@ namespace xt
15161493
}
15171494

15181495
template <class T>
1519-
template <class S>
1496+
template <std::convertible_to<T> S>
15201497
inline xdrop_slice<S> xdrop_slice<T>::convert() const noexcept
1521-
requires std::convertible_to<S, T>
15221498
{
15231499
return xdrop_slice<S>(*this);
15241500
}

include/xtensor/views/xstrided_view.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ namespace xt
180180
using simd_value_type = xt_simd::simd_type<value_type>;
181181
using bool_load_type = typename base_type::bool_load_type;
182182

183-
static constexpr bool providedSimdInterface = has_simd_interface<xexpression_type>::value
184-
&& L != layout_type::dynamic;
183+
static constexpr bool provides_simd_interface = has_simd_interface<xexpression_type>::value
184+
&& L != layout_type::dynamic;
185185

186186
template <class CTA, class SA>
187187
xstrided_view(CTA&& e, SA&& shape, strides_type&& strides, std::size_t offset, layout_type layout) noexcept;
@@ -259,11 +259,11 @@ namespace xt
259259

260260
template <class align, class simd>
261261
void store_simd(size_type i, const simd& e)
262-
requires providedSimdInterface;
262+
requires provides_simd_interface;
263263

264264
template <class align, class requested_type = value_type, std::size_t N = xt_simd::simd_traits<requested_type>::size>
265265
simd_return_type<requested_type> load_simd(size_type i) const
266-
requires providedSimdInterface;
266+
requires provides_simd_interface;
267267

268268
reference data_element(size_type i);
269269
const_reference data_element(size_type i) const;
@@ -673,7 +673,7 @@ namespace xt
673673
template <class CT, class S, layout_type L, class FST>
674674
template <class alignment, class simd>
675675
inline void xstrided_view<CT, S, L, FST>::store_simd(size_type i, const simd& e)
676-
requires providedSimdInterface
676+
requires provides_simd_interface
677677
{
678678
using align_mode = driven_align_mode_t<alignment, data_alignment>;
679679
xt_simd::store_as(&(storage()[i]), e, align_mode());
@@ -682,7 +682,7 @@ namespace xt
682682
template <class CT, class S, layout_type L, class FST>
683683
template <class alignment, class requested_type, std::size_t N>
684684
inline auto xstrided_view<CT, S, L, FST>::load_simd(size_type i) const -> simd_return_type<requested_type>
685-
requires providedSimdInterface
685+
requires provides_simd_interface
686686
{
687687
using align_mode = driven_align_mode_t<alignment, data_alignment>;
688688
return xt_simd::load_as<requested_type>(&(storage()[i]), align_mode());
@@ -826,7 +826,7 @@ namespace xt
826826
template <class S>
827827
inline void recalculate_shape_impl(S& shape, size_t size)
828828
{
829-
if constexpr (std::is_signed<get_value_type_t<typename std::decay<S>::type>>::value)
829+
if constexpr (std::is_signed_v<get_value_type_t<typename std::decay<S>::type>>)
830830
{
831831
using value_type = get_value_type_t<typename std::decay_t<S>>;
832832
XTENSOR_ASSERT(std::count(shape.cbegin(), shape.cend(), -1) <= 1);

include/xtensor/views/xstrided_view_base.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ namespace xt
134134
&& xexpression_type::contiguous_layout;
135135

136136
static constexpr bool
137-
providedDataInterface = detail::provides_data_interface<xexpression_type, storage_type>::value;
137+
provides_data_interface = detail::provides_data_interface<xexpression_type, storage_type>::value;
138138

139139
template <class CTA, class SA>
140140
xstrided_view_base(CTA&& e, SA&& shape, strides_type&& strides, size_type offset, layout_type layout) noexcept;
@@ -175,9 +175,9 @@ namespace xt
175175
const storage_type& storage() const noexcept;
176176

177177
pointer data() noexcept
178-
requires(providedDataInterface);
178+
requires(provides_data_interface);
179179
const_pointer data() const noexcept
180-
requires(providedDataInterface);
180+
requires(provides_data_interface);
181181

182182
size_type data_offset() const noexcept;
183183

@@ -583,7 +583,7 @@ namespace xt
583583
*/
584584
template <class D>
585585
inline auto xstrided_view_base<D>::data() noexcept -> pointer
586-
requires(providedDataInterface)
586+
requires(provides_data_interface)
587587
{
588588
return m_e.data();
589589
}
@@ -594,7 +594,7 @@ namespace xt
594594
*/
595595
template <class D>
596596
inline auto xstrided_view_base<D>::data() const noexcept -> const_pointer
597-
requires(providedDataInterface)
597+
requires(provides_data_interface)
598598
{
599599
return m_e.data();
600600
}

0 commit comments

Comments
 (0)