mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-10 06:00:45 +01:00
Simplify syntax with Grid::EnableIf post code review. Updated EnableIf so that ReturnType defaults to void in same way as std::enable_if see https://en.cppreference.com/w/cpp/types/enable_if
This commit is contained in:
parent
77063418da
commit
3215d88a91
@ -98,8 +98,7 @@ accelerator_inline void convertType(ComplexF & out, const std::complex<float> &
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
accelerator_inline typename std::enable_if<isGridFundamental<T>::value>::type
|
accelerator_inline EnableIf<isGridFundamental<T>> convertType(T & out, const T & in) {
|
||||||
convertType(T & out, const T & in) {
|
|
||||||
out = in;
|
out = in;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,14 +137,12 @@ accelerator_inline void convertType(iScalar<T1> & out, const iScalar<T2> & in) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T1,typename T2>
|
template<typename T1,typename T2>
|
||||||
accelerator_inline typename std::enable_if<!isGridScalar<T1>::value>::type
|
accelerator_inline NotEnableIf<isGridScalar<T1>> convertType(T1 & out, const iScalar<T2> & in) {
|
||||||
convertType(T1 & out, const iScalar<T2> & in) {
|
|
||||||
convertType(out,in._internal);
|
convertType(out,in._internal);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T1,typename T2>
|
template<typename T1,typename T2>
|
||||||
accelerator_inline typename std::enable_if<!isGridScalar<T2>::value>::type
|
accelerator_inline NotEnableIf<isGridScalar<T2>> convertType(iScalar<T1> & out, const T2 & in) {
|
||||||
convertType(iScalar<T1> & out, const T2 & in) {
|
|
||||||
convertType(out._internal,in);
|
convertType(out._internal,in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,8 +208,8 @@ struct RealPart<complex<T> > {
|
|||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
// type alias used to simplify the syntax of std::enable_if
|
// type alias used to simplify the syntax of std::enable_if
|
||||||
template <typename T> using Invoke = typename T::type;
|
template <typename T> using Invoke = typename T::type;
|
||||||
template <typename Condition, typename ReturnType> using EnableIf = Invoke<std::enable_if<Condition::value, ReturnType> >;
|
template <typename Condition, typename ReturnType = void> using EnableIf = Invoke<std::enable_if<Condition::value, ReturnType> >;
|
||||||
template <typename Condition, typename ReturnType> using NotEnableIf = Invoke<std::enable_if<!Condition::value, ReturnType> >;
|
template <typename Condition, typename ReturnType = void> using NotEnableIf = Invoke<std::enable_if<!Condition::value, ReturnType> >;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
// Check for complexity with type traits
|
// Check for complexity with type traits
|
||||||
|
Loading…
x
Reference in New Issue
Block a user