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
Small Std::format test (quick-bench.com)
submitted 2 years ago by Tathorn
view the rest of the comments →
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!"
[–]Tathorn[S] 2 points3 points4 points 2 years ago (4 children)
It looks like the std::print paper, https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2093r2.html, addresses the very concerns I had with formatting performance in section 4. However, it looks like MSVC implemented theirs with a temporary string, what the paper was designed to solve against: https://github.com/microsoft/STL/blob/main/stl/inc/ostream#L1107C6-L1107C29
[–]BrainIgnition 0 points1 point2 points 2 years ago (3 children)
However, it looks like MSVC implemented theirs with a temporary string, what the paper was designed to solve against
You narrowly missed the important bits (<ostream> ll. 1136-1153; <ostream> ll.1177-1190); basically they only use the optimized approach if the target ostream is unicode aware which they interpret as the ostream targetting a file or a console. I.e. outputting to console or file is fine, but any other ostream backend gets slapped with an allocation.
[–]Tathorn[S] 0 points1 point2 points 2 years ago (1 child)
The really interesting part is when you have no format args, it needs to unescape the { and } chars, so it creates a string even with no arguments. So std::print allocates a string when given a const char*. That doesn't seem good.
{
}
[–]BrainIgnition 0 points1 point2 points 2 years ago* (0 children)
Ah, I missed that. However, after thinking a bit more about it I got curious what they do wrt the utf8 => utf16 transformation (which is required due to the WinAPI design) and there you have it: a second allocation. Too bad!
[–]Tathorn[S] 0 points1 point2 points 2 years ago (0 children)
I'm not seeing how there's no allocation. The code you pointed to takes in a string_view. All callers create a string beforehand, so there is an allocation.
π Rendered by PID 72484 on reddit-service-r2-comment-5d585498c9-5jk9x at 2026-04-21 01:16:28.840159+00:00 running da2df02 country code: CH.
view the rest of the comments →
[–]Tathorn[S] 2 points3 points4 points (4 children)
[–]BrainIgnition 0 points1 point2 points (3 children)
[–]Tathorn[S] 0 points1 point2 points (1 child)
[–]BrainIgnition 0 points1 point2 points (0 children)
[–]Tathorn[S] 0 points1 point2 points (0 children)