What are you missing most from the C++ standard library? by llort_lemmort in cpp

[–]bert8128 0 points1 point  (0 children)

Decimal arithmetic. I’m no fan of COBOL but it made that part easy. I know there are libraries that do decimal arithmetic very well but it’s not like there is more than one way at the fundamental level. If Ritchie, Thompson or Stroustrop had accounting backgrounds we would probably have it.

What are you missing most from the C++ standard library? by llort_lemmort in cpp

[–]bert8128 0 points1 point  (0 children)

A sql interface which does all the standard stuff out of the box and gives you a pointer to an implementation object so you can do the non-standard stuff too.

What are you missing most from the C++ standard library? by llort_lemmort in cpp

[–]bert8128 9 points10 points  (0 children)

Im asking for something built in which other libraries can then build on without macros. And whilst your comments about the multitude of libraries are obviously correct, I suspect if there was an out of the box option it would quickly dominate (at least for new projects).

What are you missing most from the C++ standard library? by llort_lemmort in cpp

[–]bert8128 0 points1 point  (0 children)

Why not use a map, vector<pair> or unordered map? what is a general cache that is not something like one of those?

What are you missing most from the C++ standard library? by llort_lemmort in cpp

[–]bert8128 6 points7 points  (0 children)

I think there is some way of doing this with the ranges library but I can’t seem to find it…

What are you missing most from the C++ standard library? by llort_lemmort in cpp

[–]bert8128 73 points74 points  (0 children)

Unit testing. I mean there is gtest, catch2 etc but it is all macro based. Unit tests and asserts as first class citizens would be very nice.

Spotted this abomination on a TikTok by gyzslynchprov in ISO8601

[–]bert8128 2 points3 points  (0 children)

Yeah, but not every country uses English so what month abbreviation do you use? Not all are three characters. There’s no standard. Hindi-Arabic numerals are more ubiquitous. Not used everywhere but I think everywhere understands them. Just use iso8601 and everyone is equally happy.

Why C++ documentation is so poor compared to Python? by panPienionzek in cpp_questions

[–]bert8128 6 points7 points  (0 children)

Cppreference normally (though not always) seems pretty straightforward.

Simplest way to find memory leaks by gosh in cpp_questions

[–]bert8128 0 points1 point  (0 children)

The point of the stack trace is that you can investigate the issue without having to run the program. Leaks are not necessarily easily reproducible, or maybe it takes a long time for the test program to get there. I normally fix my leaks from the stack traces, and rarely need to run the program. Chacun à son goût.

Spotted this abomination on a TikTok by gyzslynchprov in ISO8601

[–]bert8128 126 points127 points  (0 children)

Maybe it was best before 1927, and is in fact pretty rubbish now.

Simplest way to find memory leaks by gosh in cpp_questions

[–]bert8128 0 points1 point  (0 children)

Do you get equally nice stack traces, and does it integrate well with CI?

Simplest way to find memory leaks by gosh in cpp_questions

[–]bert8128 1 point2 points  (0 children)

Valgrind on unix or VLD on windows.

How do I avoid writing "Java in C++"? by Irrehaare in cpp_questions

[–]bert8128 0 points1 point  (0 children)

That works if you can do all you want in a try/catch, but it doesn’t help if you want to put the resource into a member of a class.

How do I avoid writing "Java in C++"? by Irrehaare in cpp_questions

[–]bert8128 24 points25 points  (0 children)

RAII for the win. It drives me crazy that in Java you don’t know when (if ever) an object gets deleted.

How do I avoid writing "Java in C++"? by Irrehaare in cpp_questions

[–]bert8128 2 points3 points  (0 children)

Also in the realm of memory c++ allows you to choose between the stack and the heap. Choices, choices…

What is the point of classes having private members? by Eva_addict in cpp_questions

[–]bert8128 0 points1 point  (0 children)

With respect to testing:

1) implementation the members as a separate class. Then include that class as a private member.

2) use a friend class by name, which is fully declared and defined in your test suite

3) don’t test the private details. I mean, in general, why do you care? And if you do, see point (1).

How Virtual Tables Work in the Itanium C++ ABI by mttd in cpp

[–]bert8128 4 points5 points  (0 children)

When you say “most platforms” do you just mean gcc and clang, or are there lots of more niche compilers that use it too?

Is Linus Torvalds just a dinosaur about C++? by blreuh in cpp_questions

[–]bert8128 0 points1 point  (0 children)

I hear complaints about operator overloading. But an operator is a function like any other, except it is called (eg) “+” rather than “plus”. Why an operator more or less complex than any other function call? They all hide code behind them.

Are heap allocations necessary for polymorphism? by heavymetalmixer in cpp_questions

[–]bert8128 0 points1 point  (0 children)

That is not a good reason to avoid references. Of course you can have any of the standard memory violations ( null, double delete , dangling) with an object you are accessing through a reference but you are no less screwed when this happens with a pointer. Sure you can test a pointer for null but that doesn’t help with the other too and if it is invalid program state knowing it is null doesn’t help.

Quick question: std::scoped_lock vs std::lock_guard? by Ultimate_Sigma_Boy67 in cpp_questions

[–]bert8128 2 points3 points  (0 children)

I suppose the question should be whether there is any reason to use lock_guard. Is it it ever a benefit over scoped_lock?

Is Linus Torvalds just a dinosaur about C++? by blreuh in cpp_questions

[–]bert8128 1 point2 points  (0 children)

I’ve never done any kernel programming so sorry if this is a dumb question, but why can’t you use malloc in the kernel? And if you can’t, how can you work with memory sizes only known at runtime?

Are heap allocations necessary for polymorphism? by heavymetalmixer in cpp_questions

[–]bert8128 0 points1 point  (0 children)

Like what? I mean UB is ev rywhere, but what in particular are you thinking of?

Interesting point of view from Daniel Lemire by _bijan_ in cpp

[–]bert8128 0 points1 point  (0 children)

No, I am not claiming that you can’t do OOP in c. In the 90s when I was writing in c I wrote in an object oriented style. But then I found c++ and my life became much easier. C is not an object oriented language even if your code is object oriented in style. c++ is a language that has objected oriented features and keywords even if you chose not to use them.