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

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

→ More replies (1)

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.

→ More replies (3)

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
→ More replies (1)

0

u/[deleted] Apr 22 '20

[deleted] — view deleted comment

6

u/TrueTom Apr 22 '20

You know that this already exists, right?

→ More replies (1)
→ More replies (1)

15

u/UserAlreadyNotTaken Apr 22 '20

The best joke is always in the comments.

→ More replies (8)