Skip to content

copy assgin  #44

@vanehu

Description

@vanehu

Hello! Every next call do a copy, how to pass a ref value?

Example:

struct test_t {
    std::string v1;
    int         v2;
};
constexpr std::size_t benchmarkVectorSize{ 1000000 };
std::vector<test_t> vecCpp(benchmarkVectorSize);

srand(0xDEADBEEF);

for (unsigned i = 0; i < benchmarkVectorSize; i++) {
    const auto x = rand();
    vecCpp[i].v2 = x;
    vecCpp[i].v1 = std::to_string(x);
}
boolinq::from(vecCpp).for_each([](test_t a) {
    a.v1;
    int iii = 02;
});

every for_each make object copy about 2 times
how to aviod this, and how can i change value in for_each ops;

I want this work well:

boolinq::from(vecCpp).for_each([](test_t &a) {
    a.v1 = "123"
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions