TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

C++11 Tuple Implementation Details (2012)

41 pointsby eklitzkeover 4 years ago

5 comments

CJeffersonover 4 years ago
Implementing C++03 Tuple was awful &#x2F; hilarious.<p>I wrote the tuple implementation which was included in g++ for a while (technically libstdc++) -- it used some reasonably awful preprocessor to generate the different arities of tuple.<p>Once you get to C++11, you at least didn&#x27;t need to do it with pre-processor magic.
raphaeljover 4 years ago
C++ makes simple concepts so complex some time. I can&#x27;t describe how disappointed I was when I used `std::variant` for the first time.
评论 #26046370 未加载
saurikover 4 years ago
I really hate the C++11 tuple implementation as I have never figured out a way to construct it from a recursive template algorithm. I end up giving up and letting the whole thing first default construct, at which point I assign into its fields; but I feel like a &quot;high quality&quot; data structure that understood the rest of the language would have given me at least an iterative way to construct the fields in order, wherein if I fail to provide an r-value to copy construct an element the whole thing gets rolled back (picture an internal iterator pattern giving me linear construction as if I were in some monad). Like, I appreciate in some cases I can do this using parameter pack expansion, but since execution of function arguments doesn&#x27;t have defined order it doesn&#x27;t really make sense for most of my use cases.
评论 #26043621 未加载
评论 #26045531 未加载
isoblvckover 4 years ago
a post from almost a decide ago? why do I care it&#x27;s what c++20 now.
FrozenVoidover 4 years ago
a modern tuple would be std::vector&lt;std::any&gt; except std::any doesn&#x27;t play nice with the rest of C++ ecosystem, such as iostream.
评论 #26046927 未加载
评论 #26046909 未加载