C++ Logo

std-discussion

Advanced search

Re: Fwd: P0781 on command line arguments and standard entry point.

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sun, 13 Mar 2022 12:52:02 -0700
On Sunday, 13 March 2022 12:23:41 PDT Farid Mehrabi via Std-Discussion wrote:
> Basically you need to capture the arguments in a span of pointers. But the
> accessor functions need to be of strin_view type to minimize risk of
> misusage. The 'main' function can be put in a header forwarding its
> parameter to the actual entry point function, which is defined in the only
> cpp file that includes main header.

Changing from a count + C array to span is easy and can be done in O(1) time.
Creating string_views is O(n) on the length of the command-line and requires
O(n) memory on the number of arguments. This is what doomed these types of
proposals before: everyone agrees that the C interface needs update, but
raising it up to C++ level meets resistance on just how much work is
acceptable before we get to main().

And then there's Windows.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DPG Cloud Engineering

Received on 2022-03-13 19:52:05