On Sunday 24 November 2024 05:18:33 Pacific Standard Time Volker Hilsheimer via 
Interest wrote:
> Also, some things that are constexpr in a test might not be constexpr in a
> real program. E.g. std::string can only be constexpr as long as the string
> fits into whatever size the library uses for its small-string optimization.
> As soon as that space is not sufficient, std::string has to allocate using
> operator new, and your code will no longer build.

C++20 does support dynamic memory allocation at constexpr time

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0784r7.html

It must be freed before the evaluation terminates, though.

We can detect std::is_constant_evaluated() and use calls to new instead of 
QArrayData::allocate, but every use of std::is_constant_evaluated() implies 
that the code that was checked at constexpr time is not the code that is run 
at runtime.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Principal Engineer - Intel DCAI Platform & System Engineering

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

_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to