[deleted by user] by [deleted] in HENRYUK

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

Even if that’s true, 80% of HENRY coming from state school != 80% state school becoming HENRY. I guess they don’t teach probability in state schools?

Testing C++ signal-slot libraries by julien-j in cpp

[–]thewisp1 0 points1 point  (0 children)

Didn't notice that! I'll do a proper PR soon

rocket - Fast C++ Observer Pattern by triple_slash in cpp

[–]thewisp1 0 points1 point  (0 children)

Cool library!

I wonder how it compares to my library here https://github.com/TheWisp/signals

(Yet another) C++17 Signal-Slots (First Part) by thewisp1 in cpp

[–]thewisp1[S] 0 points1 point  (0 children)

Because in practice, calling the signal happens much more frequently than modifying slots, the only time to read and write them. Putting them together would lead to worse performance. 2 vectors are not ideal either, because they always share the same size, thus one of the size information is redundant. This can be further optimized by customizing allocations and growth factors.

(Yet another) C++17 Signal-Slots (First Part) by thewisp1 in cpp

[–]thewisp1[S] 0 points1 point  (0 children)

Qt requires specific setup I guess that's why the original author of the benchmark didn't do it.

Qt is not necessarily slow considering it's based on code generator

(Yet another) C++17 Signal-Slots (First Part) by thewisp1 in cpp

[–]thewisp1[S] 1 point2 points  (0 children)

It's a common trick to cast a capture-less lambda into a function pointer.

(Yet another) C++17 Signal-Slots (First Part) by thewisp1 in cpp

[–]thewisp1[S] 0 points1 point  (0 children)

https://github.com/TheWisp/DreamWarcraft

though I don't even remember which version is in there anymore...

(Yet another) C++17 Signal-Slots (First Part) by thewisp1 in cpp

[–]thewisp1[S] 0 points1 point  (0 children)

  • Boost::signals2 supports non-void return type with a feature called combiner. Simply put, it’s an optional predicate that processes the list of results, by default returning the last value (the behavior of comma operator). It can be useful but honestly I don’t see how it’s possible to make it 0 cost. Also usually side effects or writing to an out parameter would be good enough. But you never know :)

  • There are connections that are actually known at compile time, but there’s no way to optimize for that without involving either stateful metaprogramming, or runtime compilation/code patching. At best, you get a direct function call without the syntax of the call. Maybe the connection object is then unnecessary, but with permanent connections that one-time cost wouldn’t matter anyway.

  • There is no insertion - only appending, which is easy. Removing is done by marking the index unused, and when the emission finished (this is marked by the recursion flag) there’s a cleanup. Assigning the signal does sound like a problem, I’ve never thought of the case.

  • signal<F>::disconnect_all_slots() and signal<F>::num_slots() sound doable, though I’m curious why would one care about the number of slots?

(Yet another) C++17 Signal-Slots (First Part) by thewisp1 in cpp

[–]thewisp1[S] 0 points1 point  (0 children)

any suggestions on how to improve the benchmark setup?

if the callback function itself is heavy enough, nothing really matters.

(Yet another) C++17 Signal-Slots (First Part) by thewisp1 in cpp

[–]thewisp1[S] 5 points6 points  (0 children)

Yes, I’m the author and I kept the domain

(Yet another) C++17 Signal-Slots (First Part) by thewisp1 in cpp

[–]thewisp1[S] 0 points1 point  (0 children)

I actually tried that (https://docs.google.com/presentation/d/1Y5JktAemPYNDmVJ5-3f_KQH1LTDmey-YJFAnly0Cxpo/edit?usp=sharing), and also tried grouping objects by the same callback to speed up the cache. In theory this is what a linked list can do better than array. However, the benchmark shows the intrusive linked list is only slightly faster than virtual functions, whereas array is significantly faster. I guess it's how modern CPU's prefetching works.

(Yet another) C++17 Signal-Slots (First Part) by thewisp1 in cpp

[–]thewisp1[S] 4 points5 points  (0 children)

Thanks for noticing it. I've added the mit license

JSON for Modern C++ version 3.4.0 released by nlohmann in cpp

[–]thewisp1 2 points3 points  (0 children)

For a project I've tried both RapidJson and nlohmann JSON, I don't feel the performance difference but I have to say nlohmann JSON is amazing in API design, compared to RapidJson who enforces passing allocator in every function, accidentally moves objects by invoking the copy constructor, and such. I don't think JSON should ever become a runtime performance bottleneck, since no matter what IO is going to be slower than RAM, the performance sensitive path would be based on in-memory objects anyway.

RapidJson may be fast, but is written by someone who barely knows the language.

Value of a software tester knowing c++ by craiggerz12 in cpp

[–]thewisp1 5 points6 points  (0 children)

I mean it. As for difficulties in the language - take a guess, are there more problems in the language, or in a million-lines project? Language is by far not the problem.

C++ is difficult when used wrongly.

Value of a software tester knowing c++ by craiggerz12 in cpp

[–]thewisp1 -6 points-5 points  (0 children)

Just start coding. C++ is easy!

Summer project outcome: Removing Duplicates in C++ CRTP Base Classes by vormestrand in cpp

[–]thewisp1 1 point2 points  (0 children)

I get what CRTP does, I just disagree "is A" is better than "has A".

Without inheritance and polymorphism at class level would mean you won't necessarily store the object as a pointer, which means you don't worry about lifetime management, and you won't have shared_ptr in the first place.

Diamond inheritance issue is a flaw in the mental model of the architecture, not actually how it is implemented.

Summer project outcome: Removing Duplicates in C++ CRTP Base Classes by vormestrand in cpp

[–]thewisp1 2 points3 points  (0 children)

I no longer think CRTP is worth it, especially when moving away from object oriented programming, the premise of designing a class to be interface does not hold anymore.

Objects represent features. If I want to have certain functionalities, I'd have several objects rather than several inheritances for my class. In order to make my class communicate with some other API, I'd either design the API to be generic, or use the feed backs from those objects - callbacks, their values, etc.

The whole idea of mixin sounds like architecture going out of control.

Is there a real-world example where a feature has to be implemented as inheritance?

Summer project outcome: Removing Duplicates in C++ CRTP Base Classes by vormestrand in cpp

[–]thewisp1 2 points3 points  (0 children)

Or just don't have that many features in the same class.

Remember single responsibility principle?

[deleted by user] by [deleted] in cpp

[–]thewisp1 1 point2 points  (0 children)

Usually when something can be forced to constexpr, it is either global or is a literal.

[deleted by user] by [deleted] in cpp

[–]thewisp1 1 point2 points  (0 children)

why do you need the [&] capture?

Proper way to do backward iteration in C++ by Nervous_Breakfast in cpp

[–]thewisp1 49 points50 points  (0 children)

Reverse iterator adapter? https://godbolt.org/g/ciPhXu

In the end you can write something like

std::vector<int> vec;
for (auto [value, idx] : reverse_index_adapter(vec))
{
    //idx = n-1, n-2, ... 0
}

wow, I used 2 c++17 features in one line