@@ -235,9 +235,6 @@ template<class T> complex<T> tanh (const complex<T>&);
235
235
#ifndef __cuda_std__
236
236
#include < __config>
237
237
#include < stdexcept>
238
- #if !defined(_LIBCUDACXX_HAS_NO_LOCALIZATION)
239
- # include < sstream> // for _CUDA_VSTD::basic_ostringstream
240
- #endif
241
238
#endif // __cuda_std__
242
239
243
240
#include " __assert" // all public C++ headers provide the assertion handler
@@ -253,6 +250,11 @@ template<class T> complex<T> tanh (const complex<T>&);
253
250
#include " type_traits"
254
251
#include " version"
255
252
253
+ #if !defined(_LIBCUDACXX_HAS_NO_LOCALIZATION) \
254
+ && !defined(_LIBCUDACXX_COMPILER_NVRTC)
255
+ #include < sstream> // for std::basic_ostringstream
256
+ #endif // !_LIBCUDACXX_HAS_NO_LOCALIZATION && !_LIBCUDACXX_COMPILER_NVRTC
257
+
256
258
// Compatability helpers for thrust to convert between `std::complex` and `cuda::std::complex`
257
259
#if defined(__cuda_std__) && !defined(_LIBCUDACXX_COMPILER_NVRTC) && !defined(_LIBCUDACXX_COMPILER_MSVC)
258
260
#include < complex>
@@ -407,8 +409,10 @@ public:
407
409
: __re_ (__re), __im_ (__im) {}
408
410
_LIBCUDACXX_INLINE_VISIBILITY
409
411
explicit constexpr complex (const complex<double >& __c);
412
+ #ifdef _LIBCUDACXX_HAS_COMPLEX_LONG_DOUBLE
410
413
_LIBCUDACXX_INLINE_VISIBILITY
411
414
explicit constexpr complex (const complex<long double >& __c);
415
+ #endif // _LIBCUDACXX_HAS_COMPLEX_LONG_DOUBLE
412
416
413
417
#if defined(__cuda_std__) && !defined(_LIBCUDACXX_COMPILER_NVRTC) && !defined(_LIBCUDACXX_COMPILER_MSVC)
414
418
template <class _Up >
@@ -502,8 +506,11 @@ public:
502
506
: __re_ (__re), __im_ (__im) {}
503
507
_LIBCUDACXX_INLINE_VISIBILITY
504
508
constexpr complex (const complex<float >& __c);
509
+
510
+ #ifdef _LIBCUDACXX_HAS_COMPLEX_LONG_DOUBLE
505
511
_LIBCUDACXX_INLINE_VISIBILITY
506
512
explicit constexpr complex (const complex<long double >& __c);
513
+ #endif // _LIBCUDACXX_HAS_COMPLEX_LONG_DOUBLE
507
514
508
515
#if defined(__cuda_std__) && !defined(_LIBCUDACXX_COMPILER_NVRTC) && !defined(_LIBCUDACXX_COMPILER_MSVC)
509
516
template <class _Up >
@@ -585,20 +592,10 @@ public:
585
592
}
586
593
};
587
594
595
+ #ifdef _LIBCUDACXX_HAS_COMPLEX_LONG_DOUBLE
588
596
template <>
589
597
class _LIBCUDACXX_TEMPLATE_VIS _LIBCUDACXX_COMPLEX_ALIGNAS (2 *sizeof (long double )) complex<long double>
590
598
{
591
- #ifndef _LIBCUDACXX_HAS_COMPLEX_LONG_DOUBLE
592
- public:
593
- template <typename _Dummy = void >
594
- _LIBCUDACXX_INLINE_VISIBILITY constexpr complex (long double __re = 0.0 , long double __im = 0.0 )
595
- {static_assert (is_same<_Dummy, void >::value, " complex<long double> is not supported" );}
596
-
597
- template <typename _Tp, typename _Dummy = void >
598
- _LIBCUDACXX_INLINE_VISIBILITY constexpr complex (const complex<_Tp> &__c)
599
- {static_assert (is_same<_Dummy, void >::value, " complex<long double> is not supported" );}
600
-
601
- #else
602
599
long double __re_;
603
600
long double __im_;
604
601
public:
@@ -689,8 +686,8 @@ public:
689
686
*this = *this / complex (__c.real (), __c.imag ());
690
687
return *this ;
691
688
}
692
- #endif // _LIBCUDACXX_HAS_COMPLEX_LONG_DOUBLE
693
689
};
690
+ #endif // _LIBCUDACXX_HAS_COMPLEX_LONG_DOUBLE
694
691
695
692
#if defined(_LIBCUDACXX_USE_PRAGMA_MSVC_WARNING)
696
693
// MSVC complains about narrowing conversions on these copy constructors regardless if they are used
@@ -1191,6 +1188,7 @@ arg(const complex<_Tp>& __c)
1191
1188
return _CUDA_VSTD::atan2 (__c.imag (), __c.real ());
1192
1189
}
1193
1190
1191
+ #ifdef _LIBCUDACXX_HAS_COMPLEX_LONG_DOUBLE
1194
1192
template <class _Tp >
1195
1193
inline _LIBCUDACXX_INLINE_VISIBILITY
1196
1194
__enable_if_t <
@@ -1201,6 +1199,7 @@ arg(_Tp __re)
1201
1199
{
1202
1200
return _CUDA_VSTD::atan2l (0 .L , __re);
1203
1201
}
1202
+ #endif // _LIBCUDACXX_HAS_COMPLEX_LONG_DOUBLE
1204
1203
1205
1204
template <class _Tp >
1206
1205
inline _LIBCUDACXX_INLINE_VISIBILITY
@@ -1775,6 +1774,57 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)
1775
1774
return __os << __s.str ();
1776
1775
}
1777
1776
#endif // !_LIBCUDACXX_HAS_NO_LOCALIZATION
1777
+ #else // ^^^ !__cuda_std__ ^^^ / vvv __cuda_std__
1778
+ #ifndef _LIBCUDACXX_COMPILER_NVRTC
1779
+ template <typename ValueType,class charT , class traits >
1780
+ ::std::basic_ostream<charT, traits>& operator <<(::std::basic_ostream<charT, traits>& os, const complex<ValueType>& z)
1781
+ {
1782
+ os << ' (' << z.real () << ' ,' << z.imag () << ' )' ;
1783
+ return os;
1784
+ }
1785
+
1786
+ template <typename ValueType, typename charT, class traits >
1787
+ ::std::basic_istream<charT, traits>&
1788
+ operator >>(::std::basic_istream<charT, traits>& is, complex<ValueType>& z)
1789
+ {
1790
+ ValueType re, im;
1791
+
1792
+ charT ch;
1793
+ is >> ch;
1794
+
1795
+ if (ch == ' (' )
1796
+ {
1797
+ is >> re >> ch;
1798
+ if (ch == ' ,' )
1799
+ {
1800
+ is >> im >> ch;
1801
+ if (ch == ' )' )
1802
+ {
1803
+ z = complex<ValueType>(re, im);
1804
+ }
1805
+ else
1806
+ {
1807
+ is.setstate (::std::ios_base::failbit);
1808
+ }
1809
+ }
1810
+ else if (ch == ' )' )
1811
+ {
1812
+ z = re;
1813
+ }
1814
+ else
1815
+ {
1816
+ is.setstate (::std::ios_base::failbit);
1817
+ }
1818
+ }
1819
+ else
1820
+ {
1821
+ is.putback (ch);
1822
+ is >> re;
1823
+ z = re;
1824
+ }
1825
+ return is;
1826
+ }
1827
+ #endif // _LIBCUDACXX_COMPILER_NVRTC
1778
1828
#endif // __cuda_std__
1779
1829
1780
1830
#if _LIBCUDACXX_STD_VER > 11 && defined(_LIBCUDACXX_HAS_STL_LITERALS)
0 commit comments