Why is the use of tuples in C++ not more common?

前端 未结 12 551
-上瘾入骨i
-上瘾入骨i 2021-01-29 23:48

Why does nobody seem to use tuples in C++, either the Boost Tuple Library or the standard library for TR1? I have read a lot of C++ code, and very rarely do I see the use of tup

12条回答
  •  -上瘾入骨i
    2021-01-30 00:35

    For me, it's habit, hands down: Tuples don't solve any new problems for me, just a few I can already handle just fine. Swapping values still feels easier the old fashioned way -- and, more importantly, I don't really think about how to swap "better." It's good enough as-is.

    Personally, I don't think tuples are a great solution to returning multiple values -- sounds like a job for structs.

提交回复
热议问题