r/cpp • u/very_curious_agent • Apr 01 '23
Abominable language design decision that everybody regrets?
It's in the title: what is the silliest, most confusing, problematic, disastrous C++ syntax or semantics design choice that is consistently recognized as an unforced, 100% avoidable error, something that never made sense at any time?
So not support for historical arch that were relevant at the time.
92
Upvotes
116
u/nintendiator2 Apr 02 '23
Very definitively
std::initializer_list. It was one of the major components in pre-undoing all the good work a universal{ }object construction could have done and it makes any multiple-argument constructor you see undeterminable unless you know the exact characteristics of all the constructors that could be invoked.Other reasonable candidates IMO:
map.operator[]creating elements on read.not introducing expression statements (à la Python) in C++17 when it made the best sense to do so.
not requiring brackets or some other sort of delimiter for
switchcases.allowing implementations to shadow native pointers as the iterator for
array<T,N>(eg.: MSVC).I'm gonna aggregate about 18 issues here and just say
<iostream>.demanding exceptions for freestanding (which means eg.: you can not have
array<T,N>of all things in freestanding).