logoalt Hacker News

jstimpfle • today at 4:29 PM • 2 replies • view on HN

It's a slow generic data structure with an unintuitive API. You can use it for leetcode or for CRUD. For anything more demanding it's horrifically bloated and bad. std::string too. Whenever you see STL datatypes like even string and map, you have to deal with RAII, implicit allocations, weird operator syntax, unexpected mutation (invalidation) and so on.

(Spporting or even encouraging destructive mutation, and by this I mean not incrementing counters or anything harmless but allowing iterator invalidations and crashes, are also why std::vector is bad in my opinion, these are idiomatic APIs for 90s and 2000s programming, which we should know better to avoid in 2026).


Replies

Panzerschrek • today at 4:56 PM

> For anything more demanding it's horrifically bloated and bad

C++ containers are designed for average demands. If you need something more specific, you can always use an alternative implementation. And it's better than messing with macros in pure C.

> you have to deal with RAII

What's problematic with it?

> implicit allocations

Allocations aren't implicit. It's usually clear from the documentation where allocation takes place (like in concatenating strings or copying strings).

> unexpected mutation (invalidation)

It's not the case with standard library containers. Mutating methods aren't const-qualified, so that it's clear where mutation can take place. And in C++ it's strictly recommended to mark as const everything in regular user code which shouldn't be mutated.

➕ show 1 reply
pif • today at 5:06 PM

> you have to deal with RAII

If you find that RAII is a problem, I pity how poor a programmer you must be...

➕ show 1 reply