Opened 10 years ago

Last modified 8 years ago

#2312 new Patches

intrusive_ptr::operator= should have by-value argument

Reported by: Niels Dekker Owned by: Peter Dimov
Milestone: To Be Determined Component: smart_ptr
Version: Boost 1.36.0 Severity: Optimization
Keywords: Cc: Niels Dekker


When a copy assignment operator is implemented simply by doing copy-and-swap, it should pass its argument by value, instead of doing the copy inside the body of the function, to allow the compiler to do copy elision. As was discussed at the Boost developer mailing list, Improving the assignment operators of various Boost types.

So please consider the attached patch.

Attachments (2)

intrusive_ptr_assignment.patch (416 bytes) - added by Niels Dekker 10 years ago.
intrusive_ptr.ass.value.patch (1.2 KB) - added by Georg Sauthoff <gsauthof@…> 9 years ago.

Download all attachments as: .zip

Change History (7)

Changed 10 years ago by Niels Dekker

comment:1 Changed 10 years ago by Peter Dimov

Component: Nonesmart_ptr
Owner: set to Peter Dimov
Severity: ProblemOptimization
Status: newassigned
Type: BugsPatches

comment:2 Changed 10 years ago by Peter Dimov

This ticket depends on #2314.

Changing the assignment operator as suggested also allows us to eliminate the converting assignment.

comment:3 Changed 10 years ago by Peter Dimov

Milestone: Boost 1.37.0To Be Determined

comment:4 Changed 9 years ago by Georg Sauthoff <gsauthof@…>

I updated #2314 and attach a new trivial patch which includes elimination of the converting assignments.

Best regards

Changed 9 years ago by Georg Sauthoff <gsauthof@…>

comment:5 Changed 8 years ago by Peter Dimov

Status: assignednew
Note: See TracTickets for help on using tickets.