Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions stl/inc/complex
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,23 @@ constexpr complex<long double>::complex(const complex<float>& _Right) noexcept /
constexpr complex<long double>::complex(const complex<double>& _Right) noexcept // strengthened
: _Complex_base<long double, _Lcomplex_value>(_Right.real(), _Right.imag()) {}

#if !_HAS_NONFLOATING_COMPLEX
_EXPORT_STD template <class _Ty>
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. "
Comment on lines +1329 to +1330
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to say "a cv-unqualified floating-point type" (see [complex.numbers.general]/2) which looks more future-proof?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. I copied that from the deprecation message.

"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 <class _Other>
constexpr complex(const complex<_Other>&) = delete;
};
#else // ^^^ !_HAS_NONFLOATING_COMPLEX / _HAS_NONFLOATING_COMPLEX vvv
_EXPORT_STD template <class _Ty>
class complex : public _Complex_base<_Ty, _Complex_value<_Ty>> {
public:
Expand Down Expand Up @@ -1413,6 +1430,7 @@ public:
return *this;
}
};
#endif // ^^^ _HAS_NONFLOATING_COMPLEX ^^^

_EXPORT_STD template <class _Ty>
_NODISCARD _CONSTEXPR20 complex<_Ty> operator+(const complex<_Ty>& _Left, const complex<_Ty>& _Right)
Expand Down
6 changes: 6 additions & 0 deletions stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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: " \
Expand All @@ -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 <meow> are available only with C++NN or later."

Expand Down
2 changes: 1 addition & 1 deletion tests/libcxx/usual_matrix.lst
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down