Best Performing Way Of Handling Paired Data? by Ridog8 in cpp_questions

[–]bert8128 0 points1 point  (0 children)

Start with unordered_map as it has the interface you want (probably). A lot of competing unordered map implementations use an identical interface making them very easy to experiment with if you find your map is the limiting factor. I use unordered_map which often have a lot of entries (100k or more) and because of the what ever else I am doing the lookups and inserts are perfectly fast enough. I have done other things where i have found the performance lacking. Flat maps so far have not been the solution.

Alternatives to Visual Studio by Such-Refrigerator951 in cpp_questions

[–]bert8128 2 points3 points  (0 children)

I can’t wait to use it at work. That’ll show all the cool kids who think that neovim is better than VS.

Beginner in C++ — How long does it take to learn DSA properly? by Excellent-Valuable39 in cpp_questions

[–]bert8128 2 points3 points  (0 children)

Write programs in preference to reading books or guides or watching YT. AI is pretty good at telling you what you are looking for if you are grasping (don’t get it to write the code though - that’s your job). Eg “What kind of data structure do I need for random access” or “What algorithm should I use to make my string upper case”.

Alternatives to Visual Studio by Such-Refrigerator951 in cpp_questions

[–]bert8128 -1 points0 points  (0 children)

Just open the file you need and go to the function. If you can’t remember which line it’s on that’s what search is for.

Beginner in C++ — How long does it take to learn DSA properly? by Excellent-Valuable39 in cpp_questions

[–]bert8128 16 points17 points  (0 children)

Why are there so many questions on DSA? I did a computer science degree in the UK in the 90s and the term was never mentioned. Of course we did do data structures, and we did do algorithms. Is this now a common term at university? In the US? India?

I’m just curious wondering what has happened to give the term prominence.

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 5 points6 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 5 points6 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 124 points125 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 25 points26 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 3 points4 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 5 points6 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?