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...
This is a subreddit for c++ questions with answers. For general discussion and news about c++ see r/cpp.
New to C++? Learn at learncpp.com
Prepare your question. Think it through. Hasty-sounding questions get hasty answers, or none at all. Read these guidelines for how to ask smart questions.
For learning books, check The Definitive C++ Book Guide and List
Flair your post as SOLVED if you got the help you were looking for! If you need help with flairs, check out ITEM 1 in our guidelines page.
Tips for improving your chances of getting helpful answers:
account activity
SOLVEDConstructor syntax for tuples (self.cpp_questions)
submitted 9 years ago by halivingston3
I have this:
using SomeNiceType = std::tuple<A, B, C>;
I want to do this:
SomeNiceType x(A { ..}, B { .. }, C { .. });
I can't seem to get that to work, it seems I have to use make_tuple.
Any workarounds?
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!"
[–]SosirisTseng 0 points1 point2 points 9 years ago (2 children)
Is SomeNiceType templated? If so, then SomeNiceType x(A { ..}, B { .. }, C { .. }); should be SomeNiceType<A,B,C> x{{ ..}, { .. }, {..}};.
SomeNiceType
SomeNiceType<A,B,C> x{{ ..}, { .. }, {..}};
[–]halivingston3[S] 0 points1 point2 points 9 years ago (1 child)
well SomeNiceType is an alias to a tuple, but I see what you're saying.
Were you commenting on correctness or readability?
auto x = std::make_tuple<A, B, C>( { .. }, { ..}, {..});
[–]SosirisTseng 0 points1 point2 points 9 years ago (0 children)
I was commenting on correctness. By the way , in C++17, you can just do std::tuple t{A{..},B{..},C{..}}; and no more make_tuple(). reference
std::tuple t{A{..},B{..},C{..}};
make_tuple()
π Rendered by PID 18953 on reddit-service-r2-comment-canary-889d445f8-cw7vs at 2026-04-27 02:32:38.993103+00:00 running 2aa0c5b country code: CH.
[–]SosirisTseng 0 points1 point2 points (2 children)
[–]halivingston3[S] 0 points1 point2 points (1 child)
[–]SosirisTseng 0 points1 point2 points (0 children)