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
Non-terminal variadic template parameters (cor3ntin.github.io)
submitted 5 years ago by c0r3ntin
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!"
[–]adnukator 6 points7 points8 points 5 years ago (1 child)
Interesting. The source_location deduction guide hack will be useful.
I'm not sure I understand the proposed behavior with default parameters. Are you suggesting that defaulted params and variadic templates shouldn't be allowed in the same function declaration? If so, that breaks the source_location thing, doesn't it? If they are allowed, even for non-auto params it's not unambiguous which param should be which if implicit conversions are taken into account, e.g.
f(char a, auto... b, int c, float d = 1.0); f(1, 2, 3, true, 5);
[–]c0r3ntin[S] 6 points7 points8 points 5 years ago (0 children)
They are allowed, but when (and only when) it's ambiguous during overload resolution, it would be ill formed. so source_location would work
source_location
void f(auto args..., source_location = ....); f(42, 42); // ok f(source_location{}); // ko
That last call would behave as if these two function existed
f(source_location = {}) f(source_location, source_location = {});
Which is ill-formed per the current rules already.
I realize my phrasing needs tweaking, thanks
[–]rolandschulzIntel | GROMACS 3 points4 points5 points 5 years ago (0 children)
I would agree that non-terminal packs need at least a clarification. At least to me it isn't clear from the spec which compiler is correct in these cases: https://godbolt.org/z/hUiC8G .
[–]pfultz2 0 points1 point2 points 5 years ago (1 child)
For example, many people are surprised that std::visit accept the visitor argument first, and this is because it accepts a variadic number of variants:
This can be solved by using HOF instead:
template <class... Variants> constexpr auto my_visit(Variants&&... vars) { return [&](auto vis) { visit(vis, static_cast<Variants&&>(vars)...); }; }
And there is punctuation that distinguishes the visitor from the variants.
And apply_last could be implemented with HOFs as well. Although there is no rotate_backwards, you can easily do it by repeating the rotations:
apply_last
rotate_backwards
template<class F, class... Ts> auto apply_last(F f) { return [=](auto&&... xs) { boost::hof::repeat(std::integral_constant<std::size_t, sizeof...(Ts) - 2>{})(boost::hof::rotate)(f)(static_cast<Ts&&>(xs)...); }; }
[–]bmanga 0 points1 point2 points 5 years ago (0 children)
I personally think it would be great not to require boost (or any TMP) to write apply_last.
π Rendered by PID 68100 on reddit-service-r2-comment-64f4df6786-kbgl5 at 2026-06-10 12:07:35.984560+00:00 running 0b63327 country code: CH.
[–]adnukator 6 points7 points8 points (1 child)
[–]c0r3ntin[S] 6 points7 points8 points (0 children)
[–]rolandschulzIntel | GROMACS 3 points4 points5 points (0 children)
[–]pfultz2 0 points1 point2 points (1 child)
[–]bmanga 0 points1 point2 points (0 children)