cplusplus / draft

C++ standards drafts
http://www.open-std.org/jtc1/sc22/wg21/
5.72k stars 751 forks source link

[complex.numbers.general] Is the effect of instantiating `complex<NonFP>` unspecified even if the specialization is program-defined? #7270

Open frederick-vs-ja opened 2 months ago

frederick-vs-ja commented 2 months ago

[complex.numbers.general]/2 currently states:

The effect of instantiating the template complex for any type that is not a cv-unqualified floating-point type ([basic.fundamental]) is unspecified.

Does this only cover the primary template, or even cover program-defined specializations? If the intent was the latter, I don't know how can this be correct due to the core language rules.

However, free functions in <complex> are unlikely to work for program-defined complex specializations, which is a possible cause the current specification.

jensmaurer commented 2 months ago

Using a program-defined specialization does not "instantiate the template" definition std::complex provided by the standard library.

I'm not seeing anything editorial here.

frederick-vs-ja commented 2 months ago

Using a program-defined specialization does not "instantiate the template" definition std::complex provided by the standard library.

Thanks. Should we clarify that [complex.numbers.general]/2 is restricted to the primary template of complex or leave the current wording as-is?

jensmaurer commented 2 months ago

It says "the template", not "a template named std::complex, so I'm not sure what clarification you seek. Are you talking about explicit specializations or partial specializations, by the way? The former are not templates.

frederick-vs-ja commented 2 months ago

It says "the template", not "a template named std::complex, so I'm not sure what clarification you seek.

I think the difference is somehow obscure if we just say "the template complex" (only the primary template) and "a template named std::complex“ (including program-defined partial specializations). Perhaps it would be clearer to say "the primary template of complex", which shouldn't change the meaning.

jwakely commented 2 months ago

Perhaps it would be clearer to say "the primary template of complex", which shouldn't change the meaning.

That seems reasonable to me.