Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy assgin #44

Open
vanehu opened this issue Jul 30, 2020 · 2 comments
Open

copy assgin #44

vanehu opened this issue Jul 30, 2020 · 2 comments

Comments

@vanehu
Copy link

vanehu commented Jul 30, 2020

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"
});
@Gargony
Copy link

Gargony commented May 21, 2021

@vanehu what about this?

for (auto & it : boolinq::from(vecCpp)) {
    it.v1 = "123";
}

@k06a
Copy link
Owner

k06a commented Dec 29, 2021

I do not see any way to have non-const refs to items. This issue is related to this one: #22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants