#include <iostream>
#include <vector>
#include <algorithm>

struct Dummy {
    char x;
    int y;
};

int main()
{
    std::vector<int> a = {1, 2, 3, 4, 5};
    std::vector<Dummy> b(5);

    std::transform(b.begin(), b.end(), a.begin(), a.begin(), [](Dummy& c, int d) { 
        c.y = d; return d; });

    for (auto& i : b) {
        std::cout << "{" << i.x << "; " << i.y << "} "  ;
    }

    std::cout << std::endl;
}
Edit Report
Pub: 17 Jul 2020 18:45 UTC
Views: 212