C++ hate thread

I know you can't write code, I'm just entertaining myself.

Coming from a guy who thinks a hash is complicated. Bruh

Compared to a flat array? Yes, Pajeet. It is.

You're embarrassing yourself by borrowing terms from this brainlet who is confused by basic type concepts.

Am I being kidded? Have you looked at gcc's unordered_map implementation? It's a dynamically allocated set of buckets containing dynamically allocated singly linked lists with dynamically allocated value pairs. Go read c++/6/tr1/hashtable.h, look for how they use _Node_allocator_type, _Bucket_allocator_type, and _Value_allocator_type.

A hash table is not interchangeable with an array.


I'm pretty sure the entire purpose of a "scoped" enum is to effectively treat an enum as a unique type ("strong typing") rather than an implicit int so you actually have to be forced to cast. It's an abstraction thing (e.g. you can't do an implicit cast between a "Color" enum and a "Direction" enum). As of C++11 you can declare an "unscoped" enum with a fixed underlying type (has nothing to do with inheritance), and all "unscoped" enums are implicitly castable to int. If you still want it to be confined to an actual scope you can put it in a namespace or a class or a struct or whatever.

#include #include enum foo: int8_t { //valid as of c++11 X, Y};namespace bar { enum aaa: long long { A, B, Y };}struct thats3as { enum aaa: unsigned long { H, J, Y, A = 4294967292 };};int main(int argc, char* argv[]) { int A = thats3as::A; //should bork std::cout

Why are you this retarded? Enum classes exist exactly to prevent implicit conversions, if you want them to do what you think they should do, just use a plain enum or a static_cast.

I don't need to read the implementation, it's O(1) insertion and retrieval, and given that you're writing a networked program, worrying about muh dynamic buckets is a useless micro-optimization.


I never said it was. But he's only using the array in parallel with the enum indices, which is a violation of the enum abstraction.

The history of enum:
- (C) enums are a loosely defined integral type and assign increasing values automatically
- (C++) enums can be strongly typed, have scope
- (C++11) enums can be even stronglyer typed, given a base integral type
That last one is the relatively recent addition I'm talking about, not the strong typing. They're still fixing type issues with it, C++17 fixes some of the brain damage with initialization not honoring the base type, but not what I'm calling out in the OP. Maybe in C++20..
It is actually meant to look like inheritance.
No, only those 'enum class' variants have a default base type of int, regular enums are still loosely defined. Example:
#include enum Foo { X = 2147483647};enum Foo64 { Y = 4294967296};int main() { Foo foo; Foo64 foo64; std::cout

You really do, as you're advocating something that will be easily 10 times slower, take 10 times more ram, have O(n) worst cases, require runtime initialization, and can throw.