Zip-like construction of objects from parameter collections This little function can make object creation much easier.
Sometimes you need to switch between representing your data as objects vs. having the members in separate containers.

Example:

class Foo {
public:
    Foo(int a_, double b_): a(a_), b(b_){}

    int a;
    double b;
};


And then:

std::vector&lt;int&gt; as = {1,2,3,4,5};
std::vector&lt;double&gt; bs = {6.0,7.0,8.0,9.0,10.0};
std::vector&lt;Foo&gt; foos = zipConstruct&lt;Foo&gt;(as, bs);

cout &lt;&lt; foos[3].a &lt;&lt; ", " &lt;&lt; foos[3].b &lt;&lt; endl; // 4, 9


Using:

template &lt;typename T, typename... Arg&gt;
std::vector&lt;T&gt; zipConstruct(std::vector&lt;Arg&gt; const&amp;... argVec)
{
    std::vector&lt;size_t&gt; sizes = {argVec.size()...};
    assert(std::all_of(sizes.begin(), sizes.end(), [&amp;](size_t s){return s=sizes[0];}));
    size_t size = sizes[0];

    std::vector&lt;T&gt; result;
    result.reserve(size);

    for (size_t i = 0; i &lt; size; ++i)
    {
        result.emplace_back((argVec[i])...);
    }

    return result;
}


Does this make sense?
I see one error:

assert(std::all_of(sizes.begin(), sizes.end(), [&amp;](size_t s){return s=sizes[0];}));
                                                                     ^


This is an assignment, not a test. You probably meant s == sizes[0].
You can help this by passing s as a const value:

assert(std::all_of(sizes.begin(), sizes.end(), [&amp;](size_t const s){return s == sizes[0];}));


Additionally, you may not mind destroying your old vectors (via move). So it may be worth looking at using move construction on the result vector:

std::vector&lt;T&gt; zipConstruct(std::vector&lt;Arg&gt;&amp;... argVec)
{                                //        ^^^  pass by reference as you may modify them

      result.emplace_back(std::move(argVec[i])...);
                      //  ^^^^^^^^^^   Add standard move to get move semantics.