fork(1) download
  1. #include <type_traits>
  2. #include <complex>
  3.  
  4. template<class> struct IsComplex_impl : std::false_type {};
  5. template<class T> struct IsComplex_impl<std::complex<T>> : std::true_type {};
  6.  
  7. template <typename T>
  8. constexpr bool IsComplex() {return IsComplex_impl<T>::value;}
  9.  
  10.  
  11. /**
  12.  * Evaluates to a true type if the given complex type is an Array of Structs, false otherwise
  13.  * Defaults to false for Real values
  14.  */
  15. template<typename T, bool T_isComplex = IsComplex<T>()>
  16. struct IsAoS;
  17.  
  18. /**
  19.  * Undefined for (unknown) complex types
  20.  */
  21. template< typename T >
  22. struct IsAoS< T, false>: std::false_type{};
  23.  
  24. template<>
  25. struct IsAoS< std::complex<double>>: std::true_type{};
  26.  
  27.  
  28. int main() {
  29. static_assert(!IsAoS<int>::value , "");
  30. static_assert(IsAoS<std::complex<double>>::value , "");
  31. //static_assert(IsAoS<std::complex<float>>::value , "");
  32. }
  33.  
Success #stdin #stdout 0s 3092KB
stdin
Standard input is empty
stdout
Standard output is empty