TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

C++11 Tuple Implementation Details (2012)

41 点作者 eklitzke超过 4 年前

5 条评论

CJefferson超过 4 年前
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.
raphaelj超过 4 年前
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 未加载
saurik超过 4 年前
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 未加载
isoblvck超过 4 年前
a post from almost a decide ago? why do I care it&#x27;s what c++20 now.
FrozenVoid超过 4 年前
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 未加载