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

Show parent comments

14

u/redditsoaddicting Apr 22 '20

Correct me if I'm wrong, but you should be able to do this in C++20. The thing is you have to access everything via strings (though I believe you can still make it type-safe with strings checked at compile-time and correct existing types returned). With reification, there's a chance for it to produce new types (e.g., compiling a Rust class to produce a new C++ class).

1

u/martinotus Apr 24 '20

as template meta programming is Turing Complete already (read that somewhere) I see no problem here :)

1

u/redditsoaddicting Apr 24 '20

For parsing a language like Rust, I'll stick with my constexpr new etc. thanks.

1

u/serghov Apr 30 '20

Actually there is a compile time compiler implementation already, constexpr-8cc

1

u/redditsoaddicting Apr 30 '20

I've seen this before. The fact that it was generated instead of handwritten says something.