Search code examples
c++boost-tuples

Does `boost::make_tuple` make copies?


I have something like this in my code

val = boost::make_tuple(objA , objB);

My question is does boost::make_tuple make copies of objA and objB ?


Solution

  • Yes, the returned object is a boost::tuple<A, B> which contains an A object and a B object, so they have to be copied from the arguments.

    If you want a tuple of references, use boost::tie(objA, objB) instead, which returns a boost::tuple<A&, B&>.