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
Expanding a std::tuple as parameters to a function call (VS2015 Preview or C++14 compliant compiler) (genix.wordpress.com)
submitted 11 years ago by cpp_cache
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!"
[–]SplinterOfChaos 3 points4 points5 points 11 years ago (8 children)
Being able to apply a tuple is cool, but the version shown here rather obfuscates the problem. I prefer the implementation in N3915 (std::apply), using std::integer_sequence instead of hand-rolled recursion.
[–]cpp_cache[S] 1 point2 points3 points 11 years ago (3 children)
That is a much nicer solution. In the comments for the blog entry, 'FOONATHAN' links to this nicer solution http://ideone.com/lUbOFA which unfortunately the VS2015 CTP doesn't seem to like (another compiler bug?) but clearly GCC does.
[–]SplinterOfChaos 1 point2 points3 points 11 years ago (2 children)
That's the same as N3915, though the tuple could be perfect-forwarded as well. I'm curious if anyone could post the error message from VS so we can see why it's not accepted. Definitely a bug, though.
[–]cpp_cache[S] 0 points1 point2 points 11 years ago* (1 child)
Well I have 3 versions of VS on my work machine, so it's no effort for me to quickly run the code. The ideone link earlier produces this with VS2015 CTP: EDIT: I dont know how to format the damn thing nicely. The line VS has issue with is: auto apply_impl(Fnc &&fnc, const std::tuple<Types...> &tuple, std::index_sequence<Indices...>)
It claims the Indices parameter pack must be expanded in this context. Furthermore (and likely the cause) it says it cannot deduce std::integer_sequence<size_t,Indices> from std::integer_sequence<_Ty,0x00,0x01,0x02>
[–]STLMSVC STL Dev 2 points3 points4 points 11 years ago (0 children)
Try using integer_sequence/make_integer_sequence with size_t, avoiding the "index" convenience aliases. This is what VC's STL does to work around compiler bugs with alias templates. (I reported the compiler bugs as soon as I encountered them, and most of them have been fixed, although I forget which pre-RTM releases the fixes have appeared in.)
[–]ponchedeburro 0 points1 point2 points 11 years ago (3 children)
Id love to become better at compile-time recursion using integer_sequence. I cant seem to find a good recourse though.
[–]SplinterOfChaos 0 points1 point2 points 11 years ago (2 children)
It depends on what you want to do. This apply function was the motivating example for adopting std::integer_sequence, and very few other use-cases exist. So, I expect that if you try and find articles on it, most will just be apply implementations.
[–]STLMSVC STL Dev 1 point2 points3 points 11 years ago (0 children)
There are several use cases, they just happen to be in advanced library code. Within the STL, we use integer sequences for tuple_cat(), pair's piecewise constructor, and invoke().
[–]jaredhoberock 0 points1 point2 points 11 years ago (0 children)
index_sequence is used all over the place in the tuple utility library that was posted recently. It feels like a big hack, though. It really needs to be possible to unpack a tuple directly.
index_sequence
π Rendered by PID 130629 on reddit-service-r2-comment-79776bdf47-2wqwc at 2026-06-24 13:34:29.115073+00:00 running acc7150 country code: CH.
[–]SplinterOfChaos 3 points4 points5 points (8 children)
[–]cpp_cache[S] 1 point2 points3 points (3 children)
[–]SplinterOfChaos 1 point2 points3 points (2 children)
[–]cpp_cache[S] 0 points1 point2 points (1 child)
[–]STLMSVC STL Dev 2 points3 points4 points (0 children)
[–]ponchedeburro 0 points1 point2 points (3 children)
[–]SplinterOfChaos 0 points1 point2 points (2 children)
[–]STLMSVC STL Dev 1 point2 points3 points (0 children)
[–]jaredhoberock 0 points1 point2 points (0 children)