6 ms·
Could someone comment on the following C++14 feature on the list here: "Avoiding/fusing memory allocations" It lists Clang but nothing else as supporting it.
by silentvoice 12y ago
Could someone comment on the following C++14 feature on the list here:
"Avoiding/fusing memory allocations"
It lists Clang but nothing else as supporting it.
This sounds like a compiler optimization and not a language feature, and since it's talking about C++14 (not C++11) I know this isn't referring to move semantics/rvalue references.
What exactly is this?
- pbsd 12y agoThat is a clarification [1] to the standard, to make it legal to avoid or fuse memory allocations if the compiler can prove it's OK. For example, int f() { int * x = new int(0); return *x; } does not really need to allocate memory, and so that `new` is now explicitly allowed not to. Similarly, int f() { int * x = new int(0); int * y = new int(1); return *x + *y; } Here the standard allows not only to elide both allocations, but also to fuse them into a single (faster) allocation. [1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3664.html http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n366...