On Tuesday, 7 November 2023 06:28:51 PST Ivan Solovev via Development wrote:
> Hi,
> 
> I'd like to discuss one more topic regarding the C++20 comparison.
> 
> Can we allow an `auto` return type in helper functions and the three-way
> comparison implementation for the built-in types?

Answering the question as asked: yes. 

So long it always resolves to the same thing.

> The idea is that these methods can return `Q*Ordering` types in C++17 mode,
> and `std::*_ordering` types in C++20 mode.

No. They must return the same thing. Choose one and stick to it until Qt 7.

> The main reason to use `auto` is that it will allow us to avoid unnecessary
> `std::*_ordering -> Q*Ordering -> std::*_ordering` conversions in the C++20
> case, which will hopefully be the common case going forward.
> 
> The main argument agains it is the possible ODR violation when mixing C++17
> and C++20 in one binary.
> 
> So, my question is - shoud we support mixing C++17 and C++20 in one binary?

Yes. Remember that "one binary" is the process as loaded into memory, 
including all the libraries. Depending on compilation modes, inline functions 
may be merged from multiple independent libraries at runtime.

So don't violate ODR.

At worst, you can make them overload each other by having different parameters. 
So the Qt functions can switch between the two return type families. But you 
can't overload operators, so operators must return one family only.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Cloud Software Architect - Intel DCAI Cloud Engineering

Attachment: smime.p7s
Description: S/MIME cryptographic signature

-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development

Reply via email to