Skip to main content
6 votes
1 answer
152 views

While looking at this example: https://github.com/PacktPublishing/Hands-On-Design-Patterns-with-CPP-Second-Edition/blob/main/Chapter06/09_function.C which is an implementation of std::function with ...
luczzz's user avatar
  • 446
1 vote
3 answers
274 views

I came across below code in a project I am working on. In class XYZ, I do not understand the need for std::unique_ptr on abstract class ABC. ABC has no data members; and the class Derived has only a ...
PaulH's user avatar
  • 325
10 votes
1 answer
244 views

I try to apply std::not_fn wrapper to an immediate consteval function. But even the simplest C++20 example #include <functional> consteval bool f() { return false; } // ok in GCC and Clang, ...
Fedor's user avatar
  • 24.7k
5 votes
1 answer
226 views

I'm implementing factory method for my polymorphic class. The "traditional" way to do so would be to have two families of classes: for objects themselves and for their factories. In this ...
legokol's user avatar
  • 83
1 vote
1 answer
44 views

Here is my simplified code: S.h class SBase { ... public: virtual std::vector<int32_t> getNumbersSet1(); virtual std::vector<int32_t> getNumbersSet2(); } class SDerived : public ...
jambodev's user avatar
  • 361
3 votes
1 answer
253 views

What are the differences between the new std::function_ref, that was added to C++26, and a "delegate"? Are they the same? By "delegate" I mean: A type that has sizeof(...) == 16. ...
levzettelin's user avatar
  • 3,062
1 vote
1 answer
148 views

could you please help me how to handle (initialize, call) std::array of structs of std::function. Code like below: class A { struct Functions { std::function<bool()> handler1; std::...
sin's user avatar
  • 13
4 votes
2 answers
183 views

Summary: Earlier, I asked this question: Why does C++ allow std::function assignments to imply an object copy? Now that I understand why the code works the way it does, I would like to know how to fix ...
srm's user avatar
  • 3,361
4 votes
1 answer
113 views

My question concerns the line of code below marked with the // WHY??? comment. Below is a toy example of some code I was expecting to break: a std::function variable is assigned a function pointer ...
srm's user avatar
  • 3,361
6 votes
3 answers
413 views

So this question explains why it's required that the target of a std::function requires that a valid copy constructor be callable. But the thing is, I know with the compilers I've dealt with that it's ...
Zebrafish's user avatar
  • 16.3k
0 votes
1 answer
308 views

i have a class template called "guard_if" that is supposed to enable guards against function execution if specific criteria are not met. This class template takes two main parameters, a std::...
Alex Frankland's user avatar
1 vote
2 answers
118 views

I'm relatively new to C++, please forgive some imperfections in my formulation. Summary: Basically I have a class member function and a variable of type std::function<void(void *)>. I want to ...
Stefan's user avatar
  • 1,367
0 votes
3 answers
249 views

I want to handover a class member as a callback function in C-style to an external DLL. What I got so far: void MyCallback(double a, unsigned char b, unsigned char* c) { // do something } The DLL ...
rhb's user avatar
  • 1
0 votes
3 answers
99 views

This is the code for submitting tasks in the thread pool that I implemented, which is used to submit tasks to the thread pool. tasks_ is the task queue. This is the modified code. using Task = std::...
牛牪犇's user avatar
1 vote
1 answer
125 views

When debugging and breaking inside a called std::function, 5 out of the 4 frames are unnecessary implementation details. E.g.: #0 operator() # my lambda #1 std::__invoke_impl #2 std::__invoke_r #3 ...
jozxyqk's user avatar
  • 17.7k

15 30 50 per page
1
2 3 4 5
60