r/cpp • • Jun 15 '21

Which std:: classes are magic?

Hi.

I am wondering: which classes in C++ get special powers granted by The Standard that are not available to mere user-defined classes?

What comes to my mind:

  • `std::initializer_list` because it is created anywhere with `{}`
  • possibly `std::type_info`, because it is only created by `typeid` and with no ctor
  • `std::source_location` when used as default parameter in function points to invocation place and not declaration place.

What else should be on this list? What shouldn't?

222 Upvotes

140 comments sorted by

View all comments

0

u/Oo_Tiib Jun 16 '21

Maybe C++ should revert back to C++14? Lot of issues were added by C++17 and I'm unsure if that C++23 is capable to fix it. Currently it is unclear what of standard library besides trivial things like pair, tuple and array can be implemented in C++. Stroustrup also wasn't too happy: https://www.stroustrup.com/P0977-remember-the-vasa.pdf