Skip to content

Commit 92331bf

Browse files
Move to C++14: take advantage of auto type deduction for functions
As a side effect also cleanup some instances where auto was unneeded or redundant.
1 parent 69c102c commit 92331bf

File tree

7 files changed

+49
-66
lines changed

7 files changed

+49
-66
lines changed

include/xsimd/arch/common/xsimd_common_memory.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ namespace xsimd
222222
}
223223

224224
template <class A, size_t I, class T>
225-
XSIMD_INLINE auto get(batch<std::complex<T>, A> const& self, ::xsimd::index<I>, requires_arch<common>) noexcept -> typename batch<std::complex<T>, A>::value_type
225+
XSIMD_INLINE typename batch<std::complex<T>, A>::value_type get(batch<std::complex<T>, A> const& self, ::xsimd::index<I>, requires_arch<common>) noexcept
226226
{
227227
alignas(A::alignment()) T buffer[batch<std::complex<T>, A>::size];
228228
self.store_aligned(&buffer[0]);
@@ -246,7 +246,7 @@ namespace xsimd
246246
}
247247

248248
template <class A, class T>
249-
XSIMD_INLINE auto get(batch<std::complex<T>, A> const& self, std::size_t i, requires_arch<common>) noexcept -> typename batch<std::complex<T>, A>::value_type
249+
XSIMD_INLINE typename batch<std::complex<T>, A>::value_type get(batch<std::complex<T>, A> const& self, std::size_t i, requires_arch<common>) noexcept
250250
{
251251
using T2 = typename batch<std::complex<T>, A>::value_type;
252252
alignas(A::alignment()) T2 buffer[batch<std::complex<T>, A>::size];
@@ -268,7 +268,7 @@ namespace xsimd
268268
}
269269

270270
template <class A, class T>
271-
XSIMD_INLINE auto first(batch<std::complex<T>, A> const& self, requires_arch<common>) noexcept -> typename batch<std::complex<T>, A>::value_type
271+
XSIMD_INLINE typename batch<std::complex<T>, A>::value_type first(batch<std::complex<T>, A> const& self, requires_arch<common>) noexcept
272272
{
273273
return { first(self.real(), A {}), first(self.imag(), A {}) };
274274
}

include/xsimd/arch/xsimd_avx2.hpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,17 +1287,16 @@ namespace xsimd
12871287
}
12881288

12891289
template <typename T, typename A, T... Vals, std::size_t... Ids>
1290-
constexpr auto swizzle_make_self_batch_impl(std::index_sequence<Ids...>)
1291-
-> batch_constant<T, A, swizzle_self_val(Vals, T(Ids), static_cast<T>(sizeof...(Vals)))...>
1290+
constexpr batch_constant<T, A, swizzle_self_val(Vals, T(Ids), static_cast<T>(sizeof...(Vals)))...>
1291+
swizzle_make_self_batch_impl(std::index_sequence<Ids...>)
12921292
{
12931293
return {};
12941294
}
12951295

12961296
template <typename T, typename A, T... Vals>
12971297
constexpr auto swizzle_make_self_batch()
1298-
-> decltype(swizzle_make_self_batch_impl<T, A, Vals...>(std::make_index_sequence<sizeof...(Vals)>()))
12991298
{
1300-
return {};
1299+
return swizzle_make_self_batch_impl<T, A, Vals...>(std::make_index_sequence<sizeof...(Vals)>());
13011300
}
13021301

13031302
template <typename T>
@@ -1309,17 +1308,16 @@ namespace xsimd
13091308
}
13101309

13111310
template <typename T, typename A, T... Vals, std::size_t... Ids>
1312-
constexpr auto swizzle_make_cross_batch_impl(std::index_sequence<Ids...>)
1313-
-> batch_constant<T, A, swizzle_cross_val(Vals, T(Ids), static_cast<T>(sizeof...(Vals)))...>
1311+
constexpr batch_constant<T, A, swizzle_cross_val(Vals, T(Ids), static_cast<T>(sizeof...(Vals)))...>
1312+
swizzle_make_cross_batch_impl(std::index_sequence<Ids...>)
13141313
{
13151314
return {};
13161315
}
13171316

13181317
template <typename T, typename A, T... Vals>
13191318
constexpr auto swizzle_make_cross_batch()
1320-
-> decltype(swizzle_make_cross_batch_impl<T, A, Vals...>(std::make_index_sequence<sizeof...(Vals)>()))
13211319
{
1322-
return {};
1320+
return swizzle_make_cross_batch_impl<T, A, Vals...>(std::make_index_sequence<sizeof...(Vals)>());
13231321
}
13241322
}
13251323

include/xsimd/arch/xsimd_emulated.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace xsimd
4646
namespace detail
4747
{
4848
template <size_t I, class F, class... Bs>
49-
auto emulated_apply(F func, Bs const&... bs) -> decltype(func(bs.data[I]...))
49+
auto emulated_apply(F func, Bs const&... bs)
5050
{
5151
return func(bs.data[I]...);
5252
}
@@ -58,7 +58,7 @@ namespace xsimd
5858
}
5959

6060
template <class B, class F, class... Bs>
61-
auto emulated_apply(F func, B const& b, Bs const&... bs) -> std::array<decltype(func(b.data[0], bs.data[0]...)), B::size>
61+
auto emulated_apply(F func, B const& b, Bs const&... bs)
6262
{
6363
return emulated_apply(func, std::make_index_sequence<B::size>(), b, bs...);
6464
}

include/xsimd/arch/xsimd_scalar.hpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ namespace xsimd
385385
}
386386

387387
template <class T, class Tp>
388-
XSIMD_INLINE auto mod(T const& x, Tp const& y) noexcept -> decltype(x % y)
388+
XSIMD_INLINE auto mod(T const& x, Tp const& y) noexcept
389389
{
390390
return x % y;
391391
}
@@ -403,7 +403,7 @@ namespace xsimd
403403
}
404404

405405
template <class T>
406-
XSIMD_INLINE auto pos(T const& x) noexcept -> decltype(+x)
406+
XSIMD_INLINE auto pos(T const& x) noexcept
407407
{
408408
return +x;
409409
}
@@ -627,7 +627,7 @@ namespace xsimd
627627
#endif
628628

629629
template <class T, class = typename std::enable_if<std::is_scalar<T>::value>::type>
630-
XSIMD_INLINE auto rsqrt(const T& x) noexcept -> decltype(std::sqrt(x))
630+
XSIMD_INLINE auto rsqrt(const T& x) noexcept
631631
{
632632
using float_type = decltype(std::sqrt(x));
633633
return static_cast<float_type>(1) / std::sqrt(x);
@@ -770,10 +770,9 @@ namespace xsimd
770770
return detail::ipow(x, n);
771771
}
772772

773-
template <class T0, class T1>
773+
template <class T0, class T1, class = typename std::enable_if<std::is_scalar<T0>::value && std::is_floating_point<T1>::value>::type>
774774
XSIMD_INLINE auto
775775
pow(const T0& t0, const T1& t1) noexcept
776-
-> typename std::enable_if<std::is_scalar<T0>::value && std::is_floating_point<T1>::value, decltype(std::pow(t0, t1))>::type
777776
{
778777
return std::pow(t0, t1);
779778
}
@@ -792,10 +791,9 @@ namespace xsimd
792791
return std::pow(t0, t1);
793792
}
794793

795-
template <class T0, class T1>
794+
template <class T0, class T1, class = typename std::enable_if<std::is_scalar<T0>::value>::type>
796795
XSIMD_INLINE auto
797796
pow(const T0& t0, const std::complex<T1>& t1) noexcept
798-
-> typename std::enable_if<std::is_scalar<T0>::value, decltype(std::pow(t0, t1))>::type
799797
{
800798
return std::pow(t0, t1);
801799
}
@@ -822,7 +820,7 @@ namespace xsimd
822820
}
823821

824822
template <class T>
825-
XSIMD_INLINE auto signbit(T const& v) noexcept -> decltype(bitofsign(v))
823+
XSIMD_INLINE auto signbit(T const& v) noexcept
826824
{
827825
return bitofsign(v);
828826
}
@@ -915,10 +913,8 @@ namespace xsimd
915913
}
916914
#endif
917915

918-
template <class T0, class T1>
916+
template <class T0, class T1, class = typename std::enable_if<std::is_scalar<T0>::value && std::is_scalar<T1>::value>::type>
919917
XSIMD_INLINE auto min(T0 const& self, T1 const& other) noexcept
920-
-> typename std::enable_if<std::is_scalar<T0>::value && std::is_scalar<T1>::value,
921-
typename std::decay<decltype(self > other ? other : self)>::type>::type
922918
{
923919
return self > other ? other : self;
924920
}
@@ -931,10 +927,8 @@ namespace xsimd
931927
return (self.real() < other.real()) ? (self) : (self.real() == other.real() ? (self.imag() < other.imag() ? self : other) : other);
932928
}
933929

934-
template <class T0, class T1>
930+
template <class T0, class T1, class = typename std::enable_if<std::is_scalar<T0>::value && std::is_scalar<T1>::value>::type>
935931
XSIMD_INLINE auto max(T0 const& self, T1 const& other) noexcept
936-
-> typename std::enable_if<std::is_scalar<T0>::value && std::is_scalar<T1>::value,
937-
typename std::decay<decltype(self > other ? other : self)>::type>::type
938932
{
939933
return self < other ? other : self;
940934
}

include/xsimd/config/xsimd_arch.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,14 @@ namespace xsimd
198198
F functor;
199199

200200
template <class Arch, class... Tys>
201-
XSIMD_INLINE auto walk_archs(arch_list<Arch>, Tys&&... args) noexcept -> decltype(functor(Arch {}, std::forward<Tys>(args)...))
201+
XSIMD_INLINE auto walk_archs(arch_list<Arch>, Tys&&... args) noexcept
202202
{
203203
assert(Arch::available() && "At least one arch must be supported during dispatch");
204204
return functor(Arch {}, std::forward<Tys>(args)...);
205205
}
206206

207207
template <class Arch, class ArchNext, class... Archs, class... Tys>
208-
XSIMD_INLINE auto walk_archs(arch_list<Arch, ArchNext, Archs...>, Tys&&... args) noexcept -> decltype(functor(Arch {}, std::forward<Tys>(args)...))
208+
XSIMD_INLINE auto walk_archs(arch_list<Arch, ArchNext, Archs...>, Tys&&... args) noexcept
209209
{
210210
if (availables_archs.has(Arch {}))
211211
return functor(Arch {}, std::forward<Tys>(args)...);
@@ -221,7 +221,7 @@ namespace xsimd
221221
}
222222

223223
template <class... Tys>
224-
XSIMD_INLINE auto operator()(Tys&&... args) noexcept -> decltype(functor(default_arch {}, std::forward<Tys>(args)...))
224+
XSIMD_INLINE auto operator()(Tys&&... args) noexcept
225225
{
226226
return walk_archs(ArchList {}, std::forward<Tys>(args)...);
227227
}

include/xsimd/types/xsimd_api.hpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ namespace xsimd
8383
* @return the sum of \c x and \c y
8484
*/
8585
template <class T, class A>
86-
XSIMD_INLINE auto add(batch<T, A> const& x, batch<T, A> const& y) noexcept -> decltype(x + y)
86+
XSIMD_INLINE batch<T, A> add(batch<T, A> const& x, batch<T, A> const& y) noexcept
8787
{
8888
detail::static_check_supported_config<T, A>();
8989
return x + y;
@@ -287,7 +287,7 @@ namespace xsimd
287287
* @return the result of the bitwise and.
288288
*/
289289
template <class T, class A>
290-
XSIMD_INLINE auto bitwise_and(batch<T, A> const& x, batch<T, A> const& y) noexcept -> decltype(x & y)
290+
XSIMD_INLINE batch<T, A> bitwise_and(batch<T, A> const& x, batch<T, A> const& y) noexcept
291291
{
292292
detail::static_check_supported_config<T, A>();
293293
return x & y;
@@ -302,7 +302,7 @@ namespace xsimd
302302
* @return the result of the bitwise and.
303303
*/
304304
template <class T, class A>
305-
XSIMD_INLINE auto bitwise_and(batch_bool<T, A> const& x, batch_bool<T, A> const& y) noexcept -> decltype(x & y)
305+
XSIMD_INLINE batch_bool<T, A> bitwise_and(batch_bool<T, A> const& x, batch_bool<T, A> const& y) noexcept
306306
{
307307
detail::static_check_supported_config<T, A>();
308308
return x & y;
@@ -417,7 +417,7 @@ namespace xsimd
417417
* @return the result of the bitwise or.
418418
*/
419419
template <class T, class A>
420-
XSIMD_INLINE auto bitwise_or(batch<T, A> const& x, batch<T, A> const& y) noexcept -> decltype(x | y)
420+
XSIMD_INLINE batch<T, A> bitwise_or(batch<T, A> const& x, batch<T, A> const& y) noexcept
421421
{
422422
detail::static_check_supported_config<T, A>();
423423
return x | y;
@@ -432,7 +432,7 @@ namespace xsimd
432432
* @return the result of the bitwise or.
433433
*/
434434
template <class T, class A>
435-
XSIMD_INLINE auto bitwise_or(batch_bool<T, A> const& x, batch_bool<T, A> const& y) noexcept -> decltype(x | y)
435+
XSIMD_INLINE batch_bool<T, A> bitwise_or(batch_bool<T, A> const& x, batch_bool<T, A> const& y) noexcept
436436
{
437437
detail::static_check_supported_config<T, A>();
438438
return x | y;
@@ -474,7 +474,7 @@ namespace xsimd
474474
* @return the result of the bitwise xor.
475475
*/
476476
template <class T, class A>
477-
XSIMD_INLINE auto bitwise_xor(batch<T, A> const& x, batch<T, A> const& y) noexcept -> decltype(x ^ y)
477+
XSIMD_INLINE batch<T, A> bitwise_xor(batch<T, A> const& x, batch<T, A> const& y) noexcept
478478
{
479479
detail::static_check_supported_config<T, A>();
480480
return x ^ y;
@@ -489,7 +489,7 @@ namespace xsimd
489489
* @return the result of the bitwise xor.
490490
*/
491491
template <class T, class A>
492-
XSIMD_INLINE auto bitwise_xor(batch_bool<T, A> const& x, batch_bool<T, A> const& y) noexcept -> decltype(x ^ y)
492+
XSIMD_INLINE batch_bool<T, A> bitwise_xor(batch_bool<T, A> const& x, batch_bool<T, A> const& y) noexcept
493493
{
494494
detail::static_check_supported_config<T, A>();
495495
return x ^ y;
@@ -699,7 +699,7 @@ namespace xsimd
699699
* @return the result of the division.
700700
*/
701701
template <class T, class A>
702-
XSIMD_INLINE auto div(batch<T, A> const& x, batch<T, A> const& y) noexcept -> decltype(x / y)
702+
XSIMD_INLINE batch<T, A> div(batch<T, A> const& x, batch<T, A> const& y) noexcept
703703
{
704704
detail::static_check_supported_config<T, A>();
705705
return x / y;
@@ -714,7 +714,7 @@ namespace xsimd
714714
* @return a boolean batch.
715715
*/
716716
template <class T, class A>
717-
XSIMD_INLINE auto eq(batch<T, A> const& x, batch<T, A> const& y) noexcept -> decltype(x == y)
717+
XSIMD_INLINE auto eq(batch<T, A> const& x, batch<T, A> const& y) noexcept
718718
{
719719
detail::static_check_supported_config<T, A>();
720720
return x == y;
@@ -729,7 +729,7 @@ namespace xsimd
729729
* @return a boolean batch.
730730
*/
731731
template <class T, class A>
732-
XSIMD_INLINE auto eq(batch_bool<T, A> const& x, batch_bool<T, A> const& y) noexcept -> decltype(x == y)
732+
XSIMD_INLINE batch_bool<T, A> eq(batch_bool<T, A> const& x, batch_bool<T, A> const& y) noexcept
733733
{
734734
detail::static_check_supported_config<T, A>();
735735
return x == y;
@@ -1607,7 +1607,7 @@ namespace xsimd
16071607
* @return the result of the modulo.
16081608
*/
16091609
template <class T, class A>
1610-
XSIMD_INLINE auto mod(batch<T, A> const& x, batch<T, A> const& y) noexcept -> decltype(x % y)
1610+
XSIMD_INLINE batch<T, A> mod(batch<T, A> const& x, batch<T, A> const& y) noexcept
16111611
{
16121612
detail::static_check_supported_config<T, A>();
16131613
return x % y;
@@ -1623,7 +1623,7 @@ namespace xsimd
16231623
* @return the result of the product.
16241624
*/
16251625
template <class T, class A>
1626-
XSIMD_INLINE auto mul(batch<T, A> const& x, batch<T, A> const& y) noexcept -> decltype(x * y)
1626+
XSIMD_INLINE batch<T, A> mul(batch<T, A> const& x, batch<T, A> const& y) noexcept
16271627
{
16281628
detail::static_check_supported_config<T, A>();
16291629
return x * y;
@@ -1671,7 +1671,7 @@ namespace xsimd
16711671
* @return a boolean batch.
16721672
*/
16731673
template <class T, class A>
1674-
XSIMD_INLINE auto neq(batch<T, A> const& x, batch<T, A> const& y) noexcept -> decltype(x != y)
1674+
XSIMD_INLINE auto neq(batch<T, A> const& x, batch<T, A> const& y) noexcept
16751675
{
16761676
detail::static_check_supported_config<T, A>();
16771677
return x != y;
@@ -1686,7 +1686,7 @@ namespace xsimd
16861686
* @return a boolean batch.
16871687
*/
16881688
template <class T, class A>
1689-
XSIMD_INLINE auto neq(batch_bool<T, A> const& x, batch_bool<T, A> const& y) noexcept -> decltype(x != y)
1689+
XSIMD_INLINE batch_bool<T, A> neq(batch_bool<T, A> const& x, batch_bool<T, A> const& y) noexcept
16901690
{
16911691
detail::static_check_supported_config<T, A>();
16921692
return x != y;
@@ -2572,7 +2572,7 @@ namespace xsimd
25722572
* @return the difference between \c x and \c y
25732573
*/
25742574
template <class T, class A>
2575-
XSIMD_INLINE auto sub(batch<T, A> const& x, batch<T, A> const& y) noexcept -> decltype(x - y)
2575+
XSIMD_INLINE batch<T, A> sub(batch<T, A> const& x, batch<T, A> const& y) noexcept
25762576
{
25772577
detail::static_check_supported_config<T, A>();
25782578
return x - y;

0 commit comments

Comments
 (0)