Skip to content

Commit 2a446ed

Browse files
Move to C++14: Use type alias for standard types
1 parent b06d46e commit 2a446ed

21 files changed

+68
-66
lines changed

include/xsimd/arch/common/xsimd_common_math.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace xsimd
6060
// Inspired by
6161
// https://stackoverflow.com/questions/5697500/take-the-average-of-two-signed-numbers-in-c
6262
auto t = (x & y) + ((x ^ y) >> 1);
63-
auto t_u = bitwise_cast<typename std::make_unsigned<T>::type>(t);
63+
auto t_u = bitwise_cast<std::make_unsigned_t<T>>(t);
6464
auto avg = t + (bitwise_cast<T>(t_u >> (8 * sizeof(T) - 1)) & (x ^ y));
6565
return avg;
6666
}

include/xsimd/arch/xsimd_avx.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ namespace xsimd
367367
{
368368
return _mm256_castsi256_pd(self);
369369
}
370-
template <class A, class T, class Tp, class = std::enable_if_t<std::is_integral<typename std::common_type<T, Tp>::type>::value>>
370+
template <class A, class T, class Tp, class = std::enable_if_t<std::is_integral<std::common_type_t<T, Tp>>::value>>
371371
XSIMD_INLINE batch<Tp, A> bitwise_cast(batch<T, A> const& self, batch<Tp, A> const&, requires_arch<avx>) noexcept
372372
{
373373
return batch<Tp, A>(self.data);

include/xsimd/arch/xsimd_avx2.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ namespace xsimd
143143
load_masked(T const* mem, batch_bool_constant<T, A, Values...> mask, convert<T>, Mode, requires_arch<avx2>) noexcept
144144
{
145145
static_assert(sizeof(T) == 4 || sizeof(T) == 8, "load_masked supports only 32/64-bit integers on AVX2");
146-
using int_t = typename std::conditional<sizeof(T) == 4, int32_t, long long>::type;
146+
using int_t = std::conditional_t<sizeof(T) == 4, int32_t, long long>;
147147
// Use the raw register-level maskload helpers for the remaining cases.
148148
return detail::maskload(reinterpret_cast<const int_t*>(mem), mask.as_batch());
149149
}

include/xsimd/arch/xsimd_avx512dq.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,9 @@ namespace xsimd
236236
XSIMD_IF_CONSTEXPR(dup_lo || dup_hi)
237237
{
238238
const batch<float, avx2> half = _mm512_extractf32x8_ps(self, dup_lo ? 0 : 1);
239-
constexpr typename std::conditional<dup_lo, batch_constant<uint32_t, avx2, V0 % 8, V1 % 8, V2 % 8, V3 % 8, V4 % 8, V5 % 8, V6 % 8, V7 % 8>,
240-
batch_constant<uint32_t, avx2, V8 % 8, V9 % 8, V10 % 8, V11 % 8, V12 % 8, V13 % 8, V14 % 8, V15 % 8>>::type half_mask {};
239+
constexpr std::conditional_t<dup_lo, batch_constant<uint32_t, avx2, V0 % 8, V1 % 8, V2 % 8, V3 % 8, V4 % 8, V5 % 8, V6 % 8, V7 % 8>,
240+
batch_constant<uint32_t, avx2, V8 % 8, V9 % 8, V10 % 8, V11 % 8, V12 % 8, V13 % 8, V14 % 8, V15 % 8>>
241+
half_mask {};
241242
auto permuted = swizzle(half, half_mask, avx2 {});
242243
// merge the two slices into an AVX512F register:
243244
return _mm512_broadcast_f32x8(permuted); // duplicates the 256-bit perm into both halves

include/xsimd/arch/xsimd_avx512f.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ namespace xsimd
816816
{
817817
return _mm512_castsi512_pd(self);
818818
}
819-
template <class A, class T, class Tp, class = std::enable_if_t<std::is_integral<typename std::common_type<T, Tp>::type>::value>>
819+
template <class A, class T, class Tp, class = std::enable_if_t<std::is_integral<std::common_type<T, Tp>>::value>>
820820
XSIMD_INLINE batch<Tp, A> bitwise_cast(batch<T, A> const& self, batch<Tp, A> const&, requires_arch<avx512f>) noexcept
821821
{
822822
return batch<Tp, A>(self.data);
@@ -2405,8 +2405,9 @@ namespace xsimd
24052405
XSIMD_IF_CONSTEXPR(dup_lo || dup_hi)
24062406
{
24072407
const batch<double, avx2> half = _mm512_extractf64x4_pd(self, dup_lo ? 0 : 1);
2408-
constexpr typename std::conditional<dup_lo, batch_constant<uint64_t, avx2, V0 % 4, V1 % 4, V2 % 4, V3 % 4>,
2409-
batch_constant<uint64_t, avx2, V4 % 4, V5 % 4, V6 % 4, V7 % 4>>::type half_mask {};
2408+
constexpr std::conditional_t<dup_lo, batch_constant<uint64_t, avx2, V0 % 4, V1 % 4, V2 % 4, V3 % 4>,
2409+
batch_constant<uint64_t, avx2, V4 % 4, V5 % 4, V6 % 4, V7 % 4>>
2410+
half_mask {};
24102411
return _mm512_broadcast_f64x4(swizzle(half, half_mask, avx2 {}));
24112412
}
24122413
// General case

include/xsimd/arch/xsimd_scalar.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,15 @@ namespace xsimd
148148
#endif
149149

150150
template <class T, class Tp>
151-
XSIMD_INLINE typename std::common_type<T, Tp>::type add(T const& x, Tp const& y) noexcept
151+
XSIMD_INLINE std::common_type_t<T, Tp> add(T const& x, Tp const& y) noexcept
152152
{
153153
return x + y;
154154
}
155155

156156
template <class T, class Tp>
157-
XSIMD_INLINE typename std::common_type<T, Tp>::type avg(T const& x, Tp const& y) noexcept
157+
XSIMD_INLINE std::common_type_t<T, Tp> avg(T const& x, Tp const& y) noexcept
158158
{
159-
using common_type = typename std::common_type<T, Tp>::type;
159+
using common_type = std::common_type_t<T, Tp>;
160160
if (std::is_floating_point<common_type>::value)
161161
return (x + y) / 2;
162162
else if (std::is_unsigned<common_type>::value)
@@ -168,16 +168,16 @@ namespace xsimd
168168
// Inspired by
169169
// https://stackoverflow.com/questions/5697500/take-the-average-of-two-signed-numbers-in-c
170170
auto t = (x & y) + ((x ^ y) >> 1);
171-
auto t_u = static_cast<typename std::make_unsigned<common_type>::type>(t);
171+
auto t_u = static_cast<std::make_unsigned_t<common_type>>(t);
172172
auto avg = t + (static_cast<T>(t_u >> (8 * sizeof(T) - 1)) & (x ^ y));
173173
return avg;
174174
}
175175
}
176176

177177
template <class T, class Tp>
178-
XSIMD_INLINE typename std::common_type<T, Tp>::type avgr(T const& x, Tp const& y) noexcept
178+
XSIMD_INLINE std::common_type_t<T, Tp> avgr(T const& x, Tp const& y) noexcept
179179
{
180-
using common_type = typename std::common_type<T, Tp>::type;
180+
using common_type = std::common_type_t<T, Tp>;
181181
if (std::is_floating_point<common_type>::value)
182182
return avg(x, y);
183183
else
@@ -379,7 +379,7 @@ namespace xsimd
379379
}
380380

381381
template <class T, class Tp>
382-
XSIMD_INLINE typename std::common_type<T, Tp>::type div(T const& x, Tp const& y) noexcept
382+
XSIMD_INLINE std::common_type_t<T, Tp> div(T const& x, Tp const& y) noexcept
383383
{
384384
return x / y;
385385
}
@@ -391,7 +391,7 @@ namespace xsimd
391391
}
392392

393393
template <class T, class Tp>
394-
XSIMD_INLINE typename std::common_type<T, Tp>::type mul(T const& x, Tp const& y) noexcept
394+
XSIMD_INLINE std::common_type_t<T, Tp> mul(T const& x, Tp const& y) noexcept
395395
{
396396
return x * y;
397397
}
@@ -880,7 +880,7 @@ namespace xsimd
880880
}
881881

882882
template <class T, class Tp>
883-
XSIMD_INLINE typename std::common_type<T, Tp>::type sub(T const& x, Tp const& y) noexcept
883+
XSIMD_INLINE std::common_type_t<T, Tp> sub(T const& x, Tp const& y) noexcept
884884
{
885885
return x - y;
886886
}
@@ -921,7 +921,7 @@ namespace xsimd
921921

922922
// numpy defines minimum operator on complex using lexical comparison
923923
template <class T0, class T1>
924-
XSIMD_INLINE std::complex<typename std::common_type<T0, T1>::type>
924+
XSIMD_INLINE std::complex<std::common_type_t<T0, T1>>
925925
min(std::complex<T0> const& self, std::complex<T1> const& other) noexcept
926926
{
927927
return (self.real() < other.real()) ? (self) : (self.real() == other.real() ? (self.imag() < other.imag() ? self : other) : other);
@@ -935,7 +935,7 @@ namespace xsimd
935935

936936
// numpy defines maximum operator on complex using lexical comparison
937937
template <class T0, class T1>
938-
XSIMD_INLINE std::complex<typename std::common_type<T0, T1>::type>
938+
XSIMD_INLINE std::complex<std::common_type_t<T0, T1>>
939939
max(std::complex<T0> const& self, std::complex<T1> const& other) noexcept
940940
{
941941
return (self.real() > other.real()) ? (self) : (self.real() == other.real() ? (self.imag() > other.imag() ? self : other) : other);

include/xsimd/arch/xsimd_sse2.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ namespace xsimd
551551
{
552552
return _mm_castsi128_ps(self);
553553
}
554-
template <class A, class T, class Tp, class = std::enable_if_t<std::is_integral<typename std::common_type<T, Tp>::type>::value>>
554+
template <class A, class T, class Tp, class = std::enable_if_t<std::is_integral<std::common_type_t<T, Tp>>::value>>
555555
XSIMD_INLINE batch<Tp, A> bitwise_cast(batch<T, A> const& self, batch<Tp, A> const&, requires_arch<sse2>) noexcept
556556
{
557557
return batch<Tp, A>(self.data);

include/xsimd/arch/xsimd_sve.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ namespace xsimd
8787
namespace detail
8888
{
8989
// "char" is not allowed in SVE load/store operations
90-
using sve_fix_char_t_impl = typename std::conditional<std::is_signed<char>::value, int8_t, uint8_t>::type;
90+
using sve_fix_char_t_impl = std::conditional_t<std::is_signed<char>::value, int8_t, uint8_t>;
9191

9292
template <class T>
93-
using sve_fix_char_t = typename std::conditional<std::is_same<char, typename std::decay<T>::type>::value,
94-
sve_fix_char_t_impl, T>::type;
93+
using sve_fix_char_t = std::conditional_t<std::is_same<char, std::decay_t<T>>::value,
94+
sve_fix_char_t_impl, T>;
9595
}
9696

9797
template <class A, class T, detail::sve_enable_all_t<T> = 0>
@@ -150,7 +150,7 @@ namespace xsimd
150150
template <class A, class T, detail::sve_enable_floating_point_t<T> = 0>
151151
XSIMD_INLINE void store_complex_aligned(std::complex<T>* dst, batch<std::complex<T>, A> const& src, requires_arch<sve>) noexcept
152152
{
153-
using v2type = typename std::conditional<(sizeof(T) == 4), svfloat32x2_t, svfloat64x2_t>::type;
153+
using v2type = std::conditional_t<(sizeof(T) == 4), svfloat32x2_t, svfloat64x2_t>;
154154
v2type tmp {};
155155
tmp = svset2(tmp, 0, src.real());
156156
tmp = svset2(tmp, 1, src.imag());

include/xsimd/config/xsimd_arch.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ namespace xsimd
133133
template <class L, class Arch, class... Archs>
134134
struct supported_helper<L, arch_list<Arch, Archs...>>
135135
: supported_helper<
136-
typename std::conditional<Arch::supported(),
137-
typename L::template add<Arch>, L>::type,
136+
std::conditional_t<Arch::supported(),
137+
typename L::template add<Arch>, L>,
138138
arch_list<Archs...>>
139139
{
140140
};

include/xsimd/memory/xsimd_aligned_allocator.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ namespace xsimd
341341
}
342342

343343
template <class T, class A = default_arch>
344-
using default_allocator = typename std::conditional<A::requires_alignment(),
345-
aligned_allocator<T, A::alignment()>,
346-
std::allocator<T>>::type;
344+
using default_allocator = std::conditional_t<A::requires_alignment(),
345+
aligned_allocator<T, A::alignment()>,
346+
std::allocator<T>>;
347347
}
348348

349349
#endif

0 commit comments

Comments
 (0)