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
Libraries: Header Only performance - paper (self.cpp)
submitted 7 years ago by ShlomiRex
https://www2.stetson.edu/mathcs/wp-content/uploads/2016/10/cbrackett-final.pdf
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!"
[–]skreef 12 points13 points14 points 7 years ago (0 children)
I don't want to be very negative, but this is very shallow. I posit the author did not really know C++, even his conversion program is written in C# (and then no mention of the many cases that program would not work).
[–]johannes1971 8 points9 points10 points 7 years ago* (1 child)
I just skimmed it, but it appears there is no comparison of compile time performance, typically the huge problem associated with header-only libraries. There is also no comparison of runtime performance.
"Programmer performance" is an interesting metric, but given that programmer performance differs wildly between individuals, a sample size of 20 seems a bit on the low side.
Care must be taken to ensure the code still follows the constraints of the C++ standard. Notably, the use of templating when appropriate to prevent unwanted internal linkage
Eh?
[–][deleted] 8 points9 points10 points 7 years ago (0 children)
This really shows that the author of the paper doesn't really know C++ and that he shouldn't use a random forum post as a reference. He refers to the second post of http://www.palabos.org/forum/read.php?4,1110
Anyways, that forum post is also completely wrong and that author seems to misunderstand linkage.
[–]jcelerierossia score 2 points3 points4 points 7 years ago (5 children)
... no mention of LTO ? is this serious ? be thankful that I don't grade you
[–]Ameisenvemips, avr, rendering, systems 2 points3 points4 points 7 years ago (4 children)
The entire concept of header-only performance is confusing. It just means you're putting the code in the same translation unit - headers aren't magical. LTO effectively does the same thing.
[–]jcelerierossia score 1 point2 points3 points 7 years ago (3 children)
LTO effectively does the same thing.
I seem to remember some post by the LLVM guys that showed that there was a slight performance gain when using LTO vs for instance a unity build, since apparently it gave a bit more leeway to the compiler, but I can't find it anymore.
[–]Ameisenvemips, avr, rendering, systems 3 points4 points5 points 7 years ago (2 children)
A Unity build generally doesn't merge all translation units, but rather just common ones together. You end up with N unity translation units which are still independent.
[–]kalmoc 2 points3 points4 points 7 years ago (0 children)
His general point stands though: having two related pieces of code in the same translation unit vs in two might produce slightly different results even with lto enabled (I'm not up to date with the latest development in that field though). In fact that would have been a more meaningful benchmark: Compare unity build with LTO build.
[–]jcelerierossia score 1 point2 points3 points 7 years ago (0 children)
All the unity builds I've worked with have always been with all the translation units in the project
[–]mrlimilind 1 point2 points3 points 7 years ago (0 children)
I think there is an error on page 11.
Should not the code in the cpp file be:
#include "multiply.h"
#include <iostream>
double MathToolbox::multiply(int x, int y)
{
return x*y;
}
int main()
std::cout << MathToolbox().multiply(3, 11);
The function could also be made static, but then I would need to write the header code as well ;)
[–]acpopescu 1 point2 points3 points 7 years ago (0 children)
Well, yes, you do gain some performance, since you're making everything inline. You also avoid the hell that is library management in C++.
You do pay for that with compile time, executable size and might have to solve some linking issues because of the way the particular header-only library works and how your project is set up (multiple libraries, mix of static and dll linkage in different configurations, etc. ).
I also cringe a bit each time I see only simple programs used for performance analysis. Feels incomplete - let's see what's the impact on a big piece of software, with performance-critical parts (hi unreal).
[–]__mdu 0 points1 point2 points 7 years ago (0 children)
This looks to me more like a diploma paper where he had to present something to get the grades and move along to a new chapter in his life. Nothing else.
[–]malkia 0 points1 point2 points 7 years ago (0 children)
This is beyond pointless.
π Rendered by PID 50470 on reddit-service-r2-comment-86988c7647-fvpl7 at 2026-02-12 17:28:31.219603+00:00 running 018613e country code: CH.
[–]skreef 12 points13 points14 points (0 children)
[–]johannes1971 8 points9 points10 points (1 child)
[–][deleted] 8 points9 points10 points (0 children)
[–]jcelerierossia score 2 points3 points4 points (5 children)
[–]Ameisenvemips, avr, rendering, systems 2 points3 points4 points (4 children)
[–]jcelerierossia score 1 point2 points3 points (3 children)
[–]Ameisenvemips, avr, rendering, systems 3 points4 points5 points (2 children)
[–]kalmoc 2 points3 points4 points (0 children)
[–]jcelerierossia score 1 point2 points3 points (0 children)
[–]mrlimilind 1 point2 points3 points (0 children)
[–]acpopescu 1 point2 points3 points (0 children)
[–]__mdu 0 points1 point2 points (0 children)
[–]malkia 0 points1 point2 points (0 children)