diff --git a/stl/inc/complex b/stl/inc/complex index acd727f40c..3f68015915 100644 --- a/stl/inc/complex +++ b/stl/inc/complex @@ -1322,6 +1322,23 @@ constexpr complex::complex(const complex& _Right) noexcept / constexpr complex::complex(const complex& _Right) noexcept // strengthened : _Complex_base(_Right.real(), _Right.imag()) {} +#if !_HAS_NONFLOATING_COMPLEX +_EXPORT_STD template +class complex { + static_assert(_Always_false<_Ty>, + "The effect of instantiating the template std::complex for any type other than float, double, or long double " + "is unspecified. The possibility of such instantiation will be removed in a future version. " + "You can define _HAS_NONFLOATING_COMPLEX to 1 to enable such instantiation " + "and define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress its deprecation warning."); + + // For deduction, primary template is used, so keeping couple of constructors around + + constexpr complex(const _Ty& = _Ty(), const _Ty& = _Ty()) = delete; + + template + constexpr complex(const complex<_Other>&) = delete; +}; +#else // ^^^ !_HAS_NONFLOATING_COMPLEX / _HAS_NONFLOATING_COMPLEX vvv _EXPORT_STD template class complex : public _Complex_base<_Ty, _Complex_value<_Ty>> { public: @@ -1413,6 +1430,7 @@ public: return *this; } }; +#endif // ^^^ _HAS_NONFLOATING_COMPLEX ^^^ _EXPORT_STD template _NODISCARD _CONSTEXPR20 complex<_Ty> operator+(const complex<_Ty>& _Left, const complex<_Ty>& _Right) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index ea67cde8d2..76fc411949 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -952,6 +952,10 @@ _EMIT_STL_ERROR(STL1001, "Unexpected compiler version, expected MSVC Compiler 19 #error /GR implies _HAS_STATIC_RTTI. #endif // defined(_CPPRTTI) && !_HAS_STATIC_RTTI +#ifndef _HAS_NONFLOATING_COMPLEX +#define _HAS_NONFLOATING_COMPLEX 0 +#endif // !defined(_HAS_NONFLOATING_COMPLEX) + // N4950 [dcl.constexpr]/1: "A function or static data member declared with the // constexpr or consteval specifier is implicitly an inline function or variable" @@ -1417,6 +1421,7 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect #define _CXX20_REMOVE_CISO646 #endif // ^^^ warning disabled ^^^ +#if _HAS_NONFLOATING_COMPLEX #if !defined(_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING) #define _DEPRECATE_NONFLOATING_COMPLEX \ [[deprecated("warning STL4037: " \ @@ -1427,6 +1432,7 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect #else // ^^^ warning enabled / warning disabled vvv #define _DEPRECATE_NONFLOATING_COMPLEX #endif // ^^^ warning disabled ^^^ +#endif // ^^^ _HAS_NONFLOATING_COMPLEX ^^^ // STL4038 is used to warn that "The contents of are available only with C++NN or later." diff --git a/tests/libcxx/usual_matrix.lst b/tests/libcxx/usual_matrix.lst index 73a362feaf..ce02482cf6 100644 --- a/tests/libcxx/usual_matrix.lst +++ b/tests/libcxx/usual_matrix.lst @@ -3,7 +3,7 @@ RUNALL_INCLUDE ..\universal_prefix.lst RUNALL_CROSSLIST -* PM_CL="/EHsc /MTd /std:c++latest /permissive- /utf-8 /FImsvc_stdlib_force_include.h /wd4643" +* PM_CL="/EHsc /MTd /std:c++latest /permissive- /utf-8 /FImsvc_stdlib_force_include.h /wd4643 /D_HAS_NONFLOATING_COMPLEX=1" RUNALL_CROSSLIST PM_CL="/Zc:preprocessor" ASAN PM_CL="-fsanitize=address /Zi" PM_LINK="/debug"