This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v3] complex comparison operators


On Wed, Nov 10, 2010 at 12:22 AM, Benjamin Kosnik <bkoz@redhat.com> wrote:
>
>> > So, I went looking for other areas in the library that might benefit
>> > from constexpr comparison operators.
>> >
>> > Audit rubric:
>> > 1) if static constexpr function can return it
>> > 2) if some other class can contain it as a static constexpr data
>> > 3) has one of operator ==, !=, >, >=, <, <=
>> > 4) implementation of comparison operators calls only constexpr
>> > functions
>> >
>> > This turns up std::complex operators == and != as candidates.
>>
>> good catch. ?They should be marked constexpr. ?Since we now have the
>> close that `constexpr' is silently ignored if the function template
>> specialization
>> fails to be constexpr, that would be hamless.
>
> Done.
>
> Isn't this exactly the reason the primary template for complex should
> be marked constexpr in the same way that the specializations are?

I do not know.  The reason I do not know is that a contructor or a function
member of a class template is not a template.  Ask LWG what they think
and then persuade CWG (hello Jason) to make the change if that is what
LWG wants.

> For user-defined literal types, it's a win! Then these types could
> actually use the primary template, if desired, and still take advantage
> of constexpr'd goodness.

It also means that one can't count on constexpr in class templates -- that
is a downside that has always bothered me.

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]