On 09.11.2015 19:40, Nicolás Alvarez wrote:
> Hooold on. I hadn't seen the linked patch.
>
> for (int i=0; i<napps; i++) {
> DB_WORK_ITEM* wi = new DB_WORK_ITEM();
> work_items.push_back(*wi);
> delete wi;
> }
>
> That makes no sense. Why dynamically allocate the object if it's just
> temporary?
That's what I thought but I'm not that fluent with C++ yet so I went for
the least intrusive solution.
> You can just do this:
>
> for (int i=0; i<napps; i++) {
> DB_WORK_ITEM wi;
> work_items.push_back(wi);
> }
>
> But wait, if the DB_WORK_ITEM doesn't need arguments passed to the
> constructor (ie. you're adding default-constructed objects), you don't
> even need a loop!
>
> work_items.resize(napps);
I think I'm going to commit the resize() version tomorrow. I just did a
quick check with my example and it worked. This will also work nice with
my updated constructors. Thanks for the quick reply.
Regards
Christian
_______________________________________________
boinc_dev mailing list
[email protected]
http://lists.ssl.berkeley.edu/mailman/listinfo/boinc_dev
To unsubscribe, visit the above URL and
(near bottom of page) enter your email address.