Hacker News new | ask | show | jobs
by pavlov 4080 days ago
C++ has left the horrors of the '90s largely behind it, and I'm rather liking it these days... But every time I work on a C++ project, I soon get "array angst" -- a feeling of profound incompetence because I feel uncertain about basic array operations.

Seems like every project has its own take on array classes and their ownership semantics. Std::vector appears to be largely useless (or at least it's not used anywhere in practice, so the effect is the same). Boost is just scary. Qt is almost like a different language by now.

I wish the C++ standard had something like Cocoa's NSArray/CFArrayRef -- a general-purpose ordered container that is consistently used everywhere in APIs and does the job everywhere, even though it may not be quite the optimal data structure. But I guess it's 15 years too late for that.

2 comments

Could you explain why you think std::vector is useless?
Like I wrote in my comment, it doesn't seem to be used in the real-world projects and SDKs that I deal with.
Not if those projects/SDK's have to interface with C, but that's just the reality.
> I wish the C++ standard had something like Cocoa's NSArray/CFArrayRef

I think the proposed array_view is a much better choice in C++ land. The actual storage format of data (the data structure) should be an implementation detail, but there should be standard ways to share that data across various unrelated pieces of code.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n417...