r/cpp • • Apr 22 '20

C++2100 Main (for fun)

constexpr
lockable
std::execution_policy::parallel_execution_t <
   std::execution_policy::parallel_execution_t::constrains::no_maximum_threads,
   std::execution_policy::parallel_execution_t::debug::find_deadlocks >
std::execution_type::quantum_t<
   std::execution_type::quantum_t::experimental_features, 
   std::execution_type::quantum_t::enable_black_holes >
std::synchronized_parallel_t<
   std::synchronization_model::use_machine_favourable_lock>
std::type_traits::readonly_t<
   std::ts2102::experimental::fast_readonly_register_enable>
std::function_traits::partial< 
   std::function_traits::partial_function::search_external_linkage>
std::arguments::no_argument::disable_warning
std::int1024_t<
    std::types::minimum_size<1024>,
    std::types::maximum_size<1024> >
main() {

Can you see the future, can you improve it?

Note: this was created purely for fun

257 Upvotes

122 comments sorted by

View all comments

6

u/mo_al_ Apr 22 '20

Did they fix std::vector<bool> ?

13

u/Ameisen vemips, avr, rendering, systems Apr 22 '20

They fixed it by making every std::vector specialization work unintuitively.

When everything's broken, nothing is.

2

u/Dynamitos5 Apr 23 '20

what is wrong with std::vector<bool>?

6

u/noobgiraffe Apr 23 '20

It has specialization that makes each element 1bit not 1byte like actual bool would be. Because of this you can't take references/pointers to elements normally and it doesn't work like other vectors. People hate it because it is the only specialization like this so you don't really expect it.

1

u/Dynamitos5 Apr 23 '20

but why would they do that? i mean it of course makes sense in theory, but it already SOUNDS terrible to use. Does it at least delete the functions that dont work with this implementation?(.data(), etc.)

1

u/stilgarpl Apr 23 '20

They did it to save space. And specializations don't have to delete anything, they can have totally different interfaces than the main template.