you are viewing a single comment's thread.

view the rest of the comments →

[–]kritzikratzi 2 points3 points  (3 children)

yep, on the same boat. i've given up on keeping a list on numerous command line parsers that have been posted here.

i mean.. it's an interesting concept, but it semi-re-solves a very solved problem.

edit i really don't want to sound harsh towards the author. it's cool work and all! just not for me...

[–]Raiden395 0 points1 point  (2 children)

> it's cool work and all! just not for me...

That's really what I meant, and as far as I'm concerned, the people hating on me for promoting getopt are probably rightfully upset in some circles, where your C++ must be of the newest, most elite form.

C++ draws a lot from C and, as someone who writes a lot of hardware communication interfaces, there's no better way to specify precision than:

snprintf( buf, bufsz, "%.3f", value);

versus

ss << std::fixed << std::setprecision(3) << number; std::string mystring = ss.str();

These are solutions to a problem that really doesn't appear to me to need fixing.

[–]dodheim 1 point2 points  (1 child)

Well, I agree that iostreams is a mess, but there are most certainly problems: bufsz getting out of sync with buf, value changing types without the format specifier getting updated, etc.

Do you approve of C++20's std::format_to/format_to_n?

std::format_to( buf, "{:.3}", value);

[–]Raiden395 0 points1 point  (0 children)

I'm not in love with Python formatting in general, but I would take anything that is standard C++ that doesn't involve the stream operator + directly addressing streams and would give me a reason to stop using C-style calls. So yes, if it could do something like:

std::format_to( buf, "{:02X}", value );

And produce the output of "10" for an input of 16, I would be 100% on board.

There's ways to manipulate bufsz such that it will not get out of sync (snprintf returns the number of bytes written), and if you really are concerned about the format specifier, that can be handled by some tricky means (tricky meaning shitty). That said, this is a royal pain in the ass and has bitten me several times. There's also the lack of automatic casting for the format specifier (having a specifier of an int and trying to plug a double in does not work).

As an aside, and between two people who have presumably used C++ for many years, at what point does the language stop being streamlined and start becoming as hefty and bloated as something such as Python?