4 ms·
I admit, I was curious about the `some_struct foo[1];` thing. This is all I could find. It isn't terribly compelling.[1] [1] https://stackoverflow.com/questio
by eximius 8y ago
I admit, I was curious about the `some_struct foo[1];` thing.
This is all I could find. It isn't terribly compelling.[1]
[1] https://stackoverflow.com/questions/6390331/why-use-array-size-1-instead-of-pointer https://stackoverflow.com/questions/6390331/why-use-array-si...
- GuB-42 8y agoThe stack overflow link is about a different mater. And it is compelling. I managed lower memory usage and improve performance very significantly using this technique. That kind of control over memory is what C is very good at, and it is, I think, the main reason why C tops almost every benchmark. Note that modern C++ offers everything C has to offer plus even better, more advanced tools. As a result, it should be even faster. However, "proper" C++ is a bit more hands off when it comes to memory management, with things like generic containers, smart pointers, ... It tends to result in a slightly worse performance. As for the "foo[1]" as it is described in the article, it is just syntax. Some people may find it more readable than &foo, it doesn't matter. Kind of like &table[1] vs table+1. Use the form you prefer, or even 1[table] if you are making an IOCCC entry.