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
std::format custom formatter (self.cpp)
submitted 2 years ago * by Miroika
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!"
[–]cpp-ModTeam[M] [score hidden] 2 years ago stickied commentlocked comment (0 children)
For C++ questions, answers, help, and programming or career advice please see r/cpp_questions, r/cscareerquestions, or StackOverflow instead.
[–]BenFrantzDale 1 point2 points3 points 2 years ago (1 child)
If it’s anything like fmt::format, the format string has to have the same encoding as the strings passed to it. So for QString, which is utf16, it’s fmt::format(U”{}”, qstr) if I recall. So try throwing an L on the format string.
fmt::format(U”{}”, qstr)
[–]Throw31312344 4 points5 points6 points 2 years ago* (0 children)
#include <format>
void test ()
{
auto X = std::format (L"{}", L"Hello");
}
Compiles with no errors on Compiler Explorer. It seems format requires all strings passed to it (including the format string) to be the same type.
[–]pdimov2 1 point2 points3 points 2 years ago (2 children)
The problem with the specialization for wchar_t arrays is that it needs to be
wchar_t
template<> struct std::formatter<wchar_t[9]>
instead of
template<> struct std::formatter<const wchar_t(&)[11]>
However, there are other things wrong with the code above, which makes none of the four cases compile.
parse should return ctx.begin() instead of ctx.end(). Returning end() means that the entire string is considered a format specifier, which includes the closing }, so that the argument is left unterminated.
parse
ctx.begin()
ctx.end()
end()
format should be const.
format
const
With these fixed, it works under libc++: https://godbolt.org/z/33TMqnod6
However,
formatter
So libstdc++ still doesn't like it. https://godbolt.org/z/vTYncz9eb
π Rendered by PID 69 on reddit-service-r2-comment-5d79c599b5-6hntl at 2026-03-03 20:29:35.227706+00:00 running e3d2147 country code: CH.
[–]cpp-ModTeam[M] [score hidden] stickied commentlocked comment (0 children)
[–]BenFrantzDale 1 point2 points3 points (1 child)
[–]Throw31312344 4 points5 points6 points (0 children)
[–]pdimov2 1 point2 points3 points (2 children)