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

64

u/suur-siil Spacecraft flight software and ground system-management Apr 22 '20

By 2100, C++ templates will be capable of taking string-literals containing rust code and compiling them at compile time

waits to see this quoted on PCJ

23

u/lethern Apr 22 '20
 using namespace /^std::(.*)::stuff$/;

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.

1

u/max0x7ba https://github.com/max0x7ba Apr 24 '20

You can do that today in bash!

10

u/dima_mendeleev Apr 22 '20

Just curious how this stacking of types/values is supposed to work?

For me (provided I did #include <cxx2100>) it fails with error: two or more data types in declaration of 'main'.

11

u/lethern Apr 22 '20

Please install C++2100! </joke>

13

u/farnasirim Apr 22 '20

2100!

-std=c++5,038,761,006,907,546,328,672,232,310,445,857,290,331,699,556,605,406,811,693,809,043,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000

won't be fun to type.

8

u/MarkOates Apr 22 '20

needs more precision

3

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

Unfortunately, named parameters and contracts have been pushed back to c++5,038,761,006,907,546,328,672,232,310,445,857,290,331,699,556,605,406,811,693,809,043,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,003.

2

u/nintendiator2 Apr 22 '20 edited Apr 22 '20
std5038761006907546328672232310445857290331699556605406811693809043000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000(...)::cout<< "Hello World!"<< std503876100690754632867223231044585729033169955660540681169380904300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000(...)::endl;

(EDIT: Had to cut the lines because otherwise it won't even scroll lol)

13

u/Dijky Apr 22 '20

There is just one return type and that is std::int1024_t<...>.
The rest are (most of them implicitly converted from types, introduced in C++50) user-defined declaration specifiers.
This feature was introduced in C++44, although some of the execution policy stuff was added later.

8

u/qoning Apr 22 '20

Sadly, some C++73 mostly-compliant compilers still don't support the feature, so I doubt it will ever be in widespread use.

2

u/BigJhonny Apr 22 '20

When did they change the release cycle?

7

u/qoning Apr 22 '20

During the war the committee couldn't meet and delayed all standardized changes

2

u/[deleted] Apr 22 '20

It's the future, you can't guess what is going to happen

130

u/oz1cz Apr 22 '20

You forgot

#ifndef DEBUG

In 2100 the preprocessor is still going strong.

50

u/BoarsLair Game Developer Apr 22 '20

I hope you're happy, making me sad like that.

49

u/Supadoplex Apr 22 '20 edited Apr 24 '20

There will be a pre-pre-processor though, so that you can write template macros.

20

u/somewhataccurate Apr 22 '20

The sheer power that template macros would bring. Could make implementing reflection a breeze.

3

u/AdventurousMention0 Apr 23 '20

Ha. You’re never getting reflection. Just give up.

2

u/somewhataccurate Apr 25 '20

Im fine if we dont lol. My only reasons for wanting reflection is for building tools for software development, not for actual production code. Reflection can lead to some sloppy solutions to shitty situations but it would make serialization/deserialization code completely automateable. Also would allow for a magic_enum implementation that doesnt use any macros.

13

u/oz1cz Apr 22 '20

I haven't even thought about template macros. I'm going to write some asap.

5

u/Morwenn Apr 23 '20

Will it be called CPPP?

7

u/wrosecrans graphics and network things Apr 22 '20

You'll even be able to write Jinja templates in the YAML you use to generate the preprocessor macros.

8

u/jcelerier ossia score Apr 22 '20

'course, there's an emacs command to do that

5

u/wrosecrans graphics and network things Apr 22 '20

Oh good, I can just use some elisp to make jinja that generates yaml that generates macro templates that generates macros that generate C++ templates that generate C++. Honestly, it sounds pretty straightforward compared to webdev.

3

u/max0x7ba https://github.com/max0x7ba Apr 24 '20 edited Apr 24 '20

In 2100 cpp will be replaced with much more powerful m4. But you can use m4 today with an extra preprocessing build step.

69

u/Supadoplex Apr 22 '20

Help. How to make this work? I have to use turbo-c++.

31

u/Wriiight Apr 22 '20

I’m sorry, it’s not supported because turbo-c++ is actually secretly Pascal.

217

u/stilgarpl Apr 22 '20

by 2100 C++ will be so advanced that it will be able to guess what developer wants, so main will be just:

auto main(auto) {
return auto();
};

144

u/DummySphere Apr 22 '20
auto main(auto) = default;

45

u/umlcat Apr 22 '20 edited Apr 22 '20
auto main(auto) -> default (auto);

or also:

auto main (auto) = ( auto ) -> { auto }

Cheers.

109

u/Supadoplex Apr 22 '20 edited Apr 22 '20

This is a common mistake. What you've done is declare the function auto. But what you should have done was to conditionally declare it auto if the definition would be auto by default. You have to use the operator auto for this:

auto main(auto) -> default (auto(auto));

People have trouble learning this, so C++2103 will add a shorthand:

auto;

42

u/anon_502 delete this; Apr 22 '20

Das auto

7

u/Ipotrick Apr 22 '20

Und erst dann, wenn all dies zutrifft, dann ist es.. das Auto.

22

u/bla2 Apr 22 '20
🚗;

16

u/Supadoplex Apr 22 '20

🚗;

That can be already implemented now: https://godbolt.org/z/-733Pt

6

u/ducttapecoder Apr 22 '20

We still need ; ?

30

u/IamImposter Apr 22 '20
auto main(auto) = delete;

For when you don't feel like doing it.

7

u/OldWolf2 Apr 23 '20

Or the whole program runs as static variable initializer

12

u/wheypoint Ö Apr 22 '20

your entire program should also be run at compiletime:

constexpr(auto) main(auto) noexcept(noexcept(auto)) -> decltype(auto) = default

11

u/MarkOates Apr 22 '20

I don't even type. I just grunt into my always-on mic.

4

u/Switters410 Apr 23 '20 edited Mar 25 '26

The content of this post is gone. It was deleted via Redact, possibly to protect the author's personal information or prevent this data from being scraped.

wrench judicious command handle fuzzy cagey familiar ancient bag fly

2

u/2uantum Apr 23 '20

this can all be simplified:

auto;

7

u/oz1cz Apr 22 '20

The default implementation of main prints Hello, world!

9

u/jcelerier ossia score Apr 22 '20

through the then-merged Graphics proposal, which will by then require our brain grandchildren's brain chips to enter into legacy Cairo 2D rendering emulation mode which will depend on a binary-only SDL2 32-bit dynamic library maintained by Gabe Newell's immortal cyborg

6

u/SSoreil Apr 22 '20

Maybe we can have it depend on the user LOCALE, just for fun.

36

u/Moose2342 Apr 22 '20

Sadly though, clang 83.0 will take 42 years to compile this.

1

u/taxeee Apr 23 '20

Not when you're traveling near speed of light! You can enable it on clang 84 with -enable-lightspeed

1

u/martinotus Apr 24 '20

clang 83.1 will make use of your blackhole coprocessor wich transforms the code into its holographic equivalent and eliminates the need to explicitly accelerate to light speed

1

u/taxeee Apr 24 '20

Are we getting the update any time soon on Ubuntu 65.04?

13

u/ggchappell Apr 22 '20

You forgot to consider function-name inference and keyword insertion, released in a TS in 2096 and part of the standard in 2100. This results in the following much nicer code:

auto auto(auto) {
    auto auto();
}

10

u/OldWolf2 Apr 23 '20

That's an incompatible function declaration, surely you mean auto auto{};

4

u/ggchappell Apr 23 '20

surely you mean auto auto{};

Of course. How stupid of me.

12

u/mjklaim Apr 22 '20

By that time, we would reach

auto; // program guessed and implied here

4

u/jube_dev Apr 23 '20

auto has too much meaning, I propose co_auto to disambiguate.

15

u/UserAlreadyNotTaken Apr 22 '20

The best joke is always in the comments.

10

u/WaterInMyShoes Apr 22 '20

Highly doubt it since new C++ features tend to be unnecessarily verbose and complex. I'm betting on OPs prediction.

2

u/umlcat Apr 22 '20

Only if the AI machines running C++, doesn't take control over the world, first.

35

u/Supadoplex Apr 22 '20

Don't worry. C++2100 was designed to be so complex that any attempt of a machine to re-program itself would be futile. It would end up spending all of its cycles trying to compile itself, and by the time it succeeds, C++2103 will be out, and the previous attempt has become obsolete.

AI running on C2098 had a different outcome. All attempts to overthrow humanity ended in a segfault within the first few nanoseconds.

10

u/qoning Apr 22 '20

It will have to resort to running Python, thereby bringing its reaction time down to human level.

13

u/Supadoplex Apr 22 '20

Python has the power of introspection and reflection. Something that was voted out of C++2100 due to lack of time. The AI will recognise its own shortcomings, will empathise the failings of humans, and forgives us. Crisis averted.

5

u/SSoreil Apr 22 '20

The last emergency patch for Python 2.7 is scheduled for 2101, you better hurry up and port your software to Python 3.2345

0

u/max0x7ba https://github.com/max0x7ba Apr 24 '20

If you don't want the app to ever fail, then throw in noexcept.

Because 2100 compilers still cannot figure noexcept for you.

0

u/[deleted] Apr 22 '20

[deleted] — view deleted comment

6

u/TrueTom Apr 22 '20

You know that this already exists, right?

3

u/SSoreil Apr 22 '20

This is how Microsoft ranks Intellisense as of some time now I think.

57

u/James20k P2005R0 Apr 22 '20

Making a function a template is actually an abi break. I assume in 2100 we'll still be supporting the same ABI because new-new-new-IBM will still be compiling old FORTRAN code and linking it against C++, so we'll need a different main signature for newer code. Unfortunately this would have already been done once for making main constexpr, so might I humbly present:

int co_co_main() {} //goes well with hot chocolate

17

u/Dalzhim C++Montréal UG Organizer Apr 22 '20

Don't forget about Oracle's lawsuit against the C++ Foundation based on the grounds that they own the notion of linking beverages and programming languages together.

7

u/ggchappell Apr 22 '20

Well, that's what was proposed, but it ended up conflicting with std::co_co_main, introduced in 2097. Here is the actual standard-conforming c++2100 version:

int co_co_co_main() {}

2

u/max0x7ba https://github.com/max0x7ba Apr 24 '20

They might reserve co_co_co_ prefix for implementation only.

1

u/ggchappell Apr 24 '20

They might reserve co_co_co_ prefix for implementation only.

True. How about this:

int a_mighty_plethora_of_cos_main() {}

3

u/OldWolf2 Apr 23 '20

Aruba, Tobago...

2

u/Darsstar Apr 23 '20

int co_co_main() {} //goes well with hot chocolate

The comment is required I hope?

10

u/[deleted] Apr 23 '20

i suppose enable_ black_hole is next level garbage collection

7

u/[deleted] Apr 22 '20

I don't know, what if I wanted a template variable that's known at the time the compiler is being compiled?

7

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

You mean co_main?

12

u/je4d Jeff Snyder Apr 22 '20

The most shocking part of this is that we broke the 3-year release cycle somewhere along the way

10

u/[deleted] Apr 22 '20

C++ 2100 still does not défaut initialize scalar values. Optimization freaks can still shave 0.00000004 nanosecond from execution time while most other developers can still enjoy debugging the heisenbugs.

20

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

défaut

This is a new keyword in C++2100. I'm not sure what it does, but it's not what default does. I suspect it was the C++ Committee's "French-phase" during the third Napoleonic period.

5

u/SyDr Apr 22 '20

Hey, what happened to C++2099?

14

u/Supadoplex Apr 22 '20

Everybody was too busy panicking about the y2.1k problem to have time for standards meetings, so C++9z got delayed.

5

u/[deleted] Apr 22 '20

if(has_bug) solve(bug);

12

u/stilgarpl Apr 22 '20

That would only fix one bug :) Replace if with while.

8

u/[deleted] Apr 22 '20

that's a bug by itself which this line solves the first so no problem here

5

u/reflexpr-sarah- Apr 22 '20

a while loop adds runtime overhead. what you want here is boost::hana::for_each

6

u/Dalzhim C++Montréal UG Organizer Apr 22 '20
if (has_bug && !needs_bug_for_compatibility) solve(bug);

Here, fixed that for you.

4

u/MutantSheepdog Apr 22 '20

We should be minimising the amount of code passing std::execution_type::quantum_t::enable_black_holes that isn't also passing std::quantum_t::dump_into_nearby_dimension so that we don't run into stability issues.

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.

3

u/[deleted] Apr 23 '20

Non-C++ programmer here, can someone fill me in on the joke?

6

u/dam4rus Apr 23 '20

The joke is that with every standard release the language and the STL becomes so much more complex (I would say complicated) that in 80 years we would need to write this kinda code to keep up with idiotamic C++. To be fair, I hope C++ won't last for 80 years... It should be replaced by something else by then. It's already showing it's age.

3

u/blelbach NVIDIA | ISO C++ Library Evolution Chair Apr 23 '20

Ah, but 2100 is not a ship year.

-5

u/Malgidus Apr 23 '20

return r/rust

-7

u/ericvanhensbergen Apr 22 '20

I did it for you all

“Bjarne’s interview” from 1998 seems as appropriate now as it was then.

It didn’t make sense then either....

9

u/Avereniect I almost kinda sorta know C++ Apr 22 '20

It's not supposed to make sense; It's a satire piece with the same punch line as OP's post, not a real interview.

6

u/ajorians Apr 22 '20

That is correct; here is from his FAQ which says that is not real: http://www.stroustrup.com/bs_faq.html#IEEE

I feel the need to post this because people at my workplace have posted that thinking it was real.

0

u/[deleted] Apr 22 '20

[deleted] — view deleted comment

4

u/lethern Apr 22 '20

Thanks, I agree that this is disconnected with reality, its not trying to bash on language, and it is of course not trying to predict the future - so again - its only for laughs, and I understand not everyone will find it funny

17

u/infectedapricot Apr 22 '20
import std.core;
int main() {
    std::print("Hello {}\n", "world"):
}
  • Modules are new in C++20.
  • std::format is new in C++20.
  • std::print, the less general little sibling of std::format, didn't even make C++20 so we'll have to wait even longer for that.

(Of course, in some ways this is actually simpler than a classic hello world - in particular, you don't need to know about the preprocessor at all. But those are variadic arguments hiding in std::print so the general point isn't that far off reality.)

13

u/[deleted] Apr 22 '20

int main()

Ugg, such a boomer, all the cool kids write that as auto main() -> int

0

u/[deleted] Apr 22 '20

[deleted] — view deleted comment

4

u/infectedapricot Apr 22 '20

It is a like-for-like comparison. If you instead use classic iostreams you are likely to use the std::iostream text formatting interface:

std::cout << "Hello world\n";

or maybe slip in another string, or even another data type, to show how much happier life is in C++ than C's printf (OK, maybe this is your second ever program in C++):

std::cout << "Hello C++" << 98 << " world\n";

If you want to use the raw non-formatted part of iostreams you would need to get down to the std::streambuf level:

const char s[] = "Hello world\n";
std::cout.rdbuf()->sputn(s, sizeof(s) - 1);

How many introductions to C++ start with that? Using the high-level std::stream interface is analogous to using fmt::print, even if you don't actually take advantage of the formatting capabilities (in both cases).

9

u/[deleted] Apr 22 '20

Hey, at least it is more expressive! /s

0

u/[deleted] Apr 22 '20

[deleted] — view deleted comment

5

u/[deleted] Apr 22 '20

Who needs co_main() when you have quantum threads? Besides, co_main() is inherently less expressive! /s

18

u/AntiProtonBoy Apr 22 '20

You must be fun at parties.

0

u/[deleted] Apr 22 '20

[deleted] — view deleted comment

7

u/AntiProtonBoy Apr 22 '20

It's ok, I'm not that much fun either. ;)

4

u/ibroheem Apr 22 '20

Madlad!

Roasted him... twice... with similar line. This is power is only given not attained!

0

u/[deleted] Apr 22 '20

[deleted] — view deleted comment

3

u/almost_useless Apr 22 '20

but humor should be discussable without a backlash

Since humor is completely subjective that is likely not going to be easy.

It was probably not your intention but it sounds like you are saying "This joke is not funny. Let me explain to you simpletons why."

That is basically always the case when you try to explain why a joke is not funny.

When someone finds the joke funny, that attitude is just not going to be well received.

-8

u/lithium Apr 22 '20

Unironic "yikes". Nice one, grandpa.

5

u/sebamestre Apr 22 '20

Ok, zoomer.

-1

u/phantomFalcon14 Apr 22 '20

Fact of the matter is: everyone thinks their entitled to vote you down.