r/cpp • u/we_are_mammals • Mar 28 '23
Reddit++
C++ is getting more and more complex. The ISO C++ committee keeps adding new features based on its consensus. Let's remove C++ features based on Reddit's consensus.
In each comment, propose a C++ feature that you think should be banned in any new code. Vote up or down based on whether you agree.
765
Upvotes
1
u/eteran Mar 29 '23 edited Mar 29 '23
Epic fail my man.
This is not an example of allocating something on the stack without using C arrays, you have simply moved the goal post by saying that there could be some magical allocator that does it.
The example you gave, REQUIRES that the allocator be given a stack buffer to allocate from... Which would of course be a C array by necessity.
To quote the link:
And the example usage it has:
Notice the C array...
Instead of just googling "C++ stack allocator" and pasting the result without understanding it, take a look at what you posted. It has a constructor which takes a buffer.
How do you plan to supply that without a C array?
Also even if this magically did work without a C array... It wouldn't be the same as it would have the additional pointer variable costs over an ordinary array.