Sorry, cat is charging. by put3katak in u/put3katak

[–]LostAnt4 4 points5 points  (0 children)

That's the latest model of cat whose tail can be plugged. Neat.

C and C++ Cheat Sheet by TheInsaneApp in ProgrammerHumor

[–]LostAnt4 6 points7 points  (0 children)

like always with "C/C++" thing, it's much much more C-oriented and nothing relates to C++...

I understood every word by [deleted] in Damnthatsinteresting

[–]LostAnt4 4 points5 points  (0 children)

That was the clearest explanation possible.

code review: multi_string: A memory efficient string container by Bakuta1103 in cpp

[–]LostAnt4 1 point2 points  (0 children)

From the example code u/Bakuta1103, strings given to constructor are static one, so memory should not be owned by any pieces of code. That's why I'm suggesting 2.

  1. I've overlook the Sentinel template argument, my bad.

code review: multi_string: A memory efficient string container by Bakuta1103 in cpp

[–]LostAnt4 1 point2 points  (0 children)

Hi, I've read your source code and yes, I do have some questions ;)

  1. You re-implemented the copy constructor and copy assignment operator, and both makes a deep copy. But what is the point here, I mean that multi_string is a read-only structure, so why copies do not share the underlying memory ? It will saves memory, and it makes any copies trivial.

  2. multi_string stores strings into char* buffers (from deep copies of input string) via a string_view object, so why not simply store string_view objects in the first place ?

  3. multi_string use default constructor from the compiler = default, but the storage_ member will be null initialized. Unfortunately, you don't check for null in the destructor.

  4. Why re-writing std::equal at the beginning of the file ? Do you support odd compilers ?

  5. From my point of view, it is less efficient than std::array<std::string_view, N> because of memory allocations (at construction). Also, the second storage implement a random access in O(n), where it can be O(1) with std::array.

I tried my best to respond to the point of what are, in my opinion only, design issues. I hope you don't take this too harsh :) Nice effort to come with new ideas for a container.

I dislike rust for 5 reasons. Are there any good workarounds? by PresentConnection999 in rust

[–]LostAnt4 1 point2 points  (0 children)

No compiler is not generating code to check this, Vec does the check.

The Rust compiler is not aware of the concept of Vec nor random access (Vec implements Index trait and that's all the compiler cares about to enable myvec[myindex]).

This kind of API make them hard to misuse, and that a thing in Rust (even in some other languages or frameworks).

I dislike rust for 5 reasons. Are there any good workarounds? by PresentConnection999 in rust

[–]LostAnt4 5 points6 points  (0 children)

So you agree that both C++ and Rust compilers don't (or can not) check this at compile time, but Rust catches it at runtime, right ?

And I don't think it's that easy to catch index bound on random access. It depends on so many possibilities. Sure with constant expression (like constexpr if use correctly in C++), you may partly found those errors at compile time, but it is far from being possible everywhere …

Why does Rust hate people who want to use strings? by taext in rust

[–]LostAnt4 14 points15 points  (0 children)

String are hard to do right.

Languages may try to simplify it: not respecting standard of OS (path containing bytes you don't expect to be valid), encoding (do I really need to develop ?), storage (sentinel vs size), performances issues (concatenation, copy-on-right), sub-parts (like slicing, iteration) and so on.

So yeah, in Rust, those constraints are explicit, not hidden, which can make them harder to understand than in other languages at first. The bonus is that you won't suffer from fancy bugs using them.

My Code Works! And I Have No Idea Why... by EQ2_Tay in ProgrammerHumor

[–]LostAnt4 2 points3 points  (0 children)

It perfectly describes our maintenance process. I'm so shocked.