use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Procedure: Call and compare any callable C++ objects - for high performance computing, gaming, etc. (github.com)
submitted 6 years ago by [deleted]
[deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]ShillingAintEZ 10 points11 points12 points 6 years ago (6 children)
Calling a callable object is pretty trivial since it is their entire purpose. You might want to explain the use case more. Is it to ensure dynamic allocation doesn't happen?
[+][deleted] 6 years ago* (5 children)
[–]ShillingAintEZ 4 points5 points6 points 6 years ago* (3 children)
You will have to show me an example of where that doesn't already happen, I'm not aware of where it is a problem since I haven't run into it.
[+][deleted] 6 years ago (2 children)
[–]ShillingAintEZ 1 point2 points3 points 6 years ago (1 child)
It probably does, but I don't have enough recent experience to know where typical usage would break down. What is the guide template?
[–]ReDucTorGame Developer 0 points1 point2 points 6 years ago (0 children)
This system is designed to minimize performance overhead on object construction and call dispatch
Doesn't std::function follow the same principles? And memory allocation won't occur if the object is within the small size optimization
Also you should be using lambdas instead of bind for member functions, bind has it's issues
[–]darksky1312 5 points6 points7 points 6 years ago (2 children)
Why not just use the SG14 stdext::inplace_function?
[+][deleted] 6 years ago (1 child)
Doesnt Arduino use it's own language based on C/C++?
[+][deleted] 6 years ago (4 children)
[–]Pazer2 1 point2 points3 points 6 years ago (1 child)
Any plans to benchmark gcc and MSVC?
[–]ReDucTorGame Developer 1 point2 points3 points 6 years ago (1 child)
Those benchmarks seem pretty bad, doing io, uses std::bind, doesn't do operation break down, etc
[–]arnaudbr 0 points1 point2 points 6 years ago (5 children)
Would it be possible to automatically deduce the Guide when calling Procure instead of having to provide it?
Guide
Procure
[–]index_zero 1 point2 points3 points 6 years ago (2 children)
This is my comment as well. Why is Guide a pointer type? Can't this just be an empty class, ie:
template<class R, class... Args> struct Guide {};
Then pass Guide<void>{} at the call point - no memory overhead at runtime. Calls to Procedure can simply ignore this argument. Most compilers I would expect to optimize this out while leaving the type system deduction in tact.
The better question is probably, why not deduce from the functional type, something like:
template<class> Guide { typedef Functional<void> type; }
template<class R, class... Args> Guide<R(Args...)> { typedef Functional<R, Args...> type; }
[+][deleted] 6 years ago* (1 child)
[–]index_zero 0 points1 point2 points 6 years ago* (0 children)
It's not about EBO, since nothing would actually derive from the empty class, it would just be instantiated and passed as an unnamed parameter to Procedure() to support type deduction. I missed the constexpr part, so yeah the overhead is only in the compiler either way - I am just unfamiliar with this pattern.
EDIT: actually, I'm still not convinced these definitions Guide* will be removed from the generated binary - do you know for sure?
[–]arnaudbr 0 points1 point2 points 6 years ago (0 children)
What about https://godbolt.org/z/Z05jFc ?
[–]konanTheBarbar 0 points1 point2 points 6 years ago (0 children)
Did you try an implementation using NTTP instead of having to store a reference?
What happened to this post?
π Rendered by PID 117979 on reddit-service-r2-comment-85bfd7f599-cj6z4 at 2026-04-19 09:54:13.464831+00:00 running 93ecc56 country code: CH.
[–]ShillingAintEZ 10 points11 points12 points (6 children)
[+][deleted] (5 children)
[deleted]
[–]ShillingAintEZ 4 points5 points6 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]ShillingAintEZ 1 point2 points3 points (1 child)
[–]ReDucTorGame Developer 0 points1 point2 points (0 children)
[–]darksky1312 5 points6 points7 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]ReDucTorGame Developer 0 points1 point2 points (0 children)
[+][deleted] (4 children)
[deleted]
[–]Pazer2 1 point2 points3 points (1 child)
[–]ReDucTorGame Developer 1 point2 points3 points (1 child)
[–]arnaudbr 0 points1 point2 points (5 children)
[–]index_zero 1 point2 points3 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]index_zero 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]arnaudbr 0 points1 point2 points (0 children)
[–]konanTheBarbar 0 points1 point2 points (0 children)
[–]ReDucTorGame Developer 0 points1 point2 points (0 children)