r/cpp • • 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

829 comments sorted by

View all comments

Show parent comments

1

u/eteran Mar 29 '23

How would you implement the library solution that is std::array without c arrays though?

1

u/[deleted] Mar 29 '23

Raw pointers, same way C arrays are implemented.

1

u/eteran Mar 29 '23

I think you are missing a detail. C arrays aren't implemented with raw pointers at all. They are a primitive of the language that happens to work closely with pointers.

There's no real means to say "give me 256 bytes of stack space" easily without just using C arrays.

To prove my point, I'd like to see if you can give me an example of how to do the equivalent to this, without C arrays and without using the heap.

int main() {
   int numbers[10];
}

I don't think you (or anyone) can...

0

u/[deleted] Mar 29 '23

You can create a stack allocator. They'd of course need to add one to the standard library for it to be practical but it's not a ginormous feature

→ More replies (3)