STL-pair-like triplet class - do I roll my own?

前端 未结 5 617
感动是毒
感动是毒 2021-01-03 18:52

I want to use a triplet class, as similar as possible to std::pair. STL doesn\'t seem to have one. I don\'t want to use something too heavy, like Boost. Is there some useful

5条回答
  •  粉色の甜心
    2021-01-03 19:12

    No, don't roll your own. Instead, take a look at std::tuple - it's a generalization of std::pair. So here's a value-initialized triple of ints:

    std::tuple triple;
    

    If you want, you can have a type alias for triples only:

    template
    using triple = std::tuple;
    

提交回复
热议问题