Opened 10 years ago

Closed 10 years ago

#7749 closed Bugs (invalid)

In Assignment operator, argument should be passed by reference.

Reported by: Gaurav Gupta <g.gupta@…> Owned by: Joaquín M López Muñoz
Milestone: To Be Determined Component: multi_index
Version: Boost 1.52.0 Severity: Problem
Keywords: Cc: yogen.saini@…

Description

In file boost/multi_index_container.hpp When defining the assignment operator, argument is not passed by reference.

multi_index_container<Value,IndexSpecifierList,Allocator>& operator=(
    multi_index_container<Value,IndexSpecifierList,Allocator> x)
  {
    BOOST_MULTI_INDEX_CHECK_INVARIANT;
    this->swap(x);
    return *this;
  }

Attached patch is fix for it.

Attachments (1)

multi_index_container.hpp_patch (525 bytes ) - added by Gaurav Gupta <g.gupta@…> 10 years ago.
Proposed patch for the bug raised

Download all attachments as: .zip

Change History (2)

by Gaurav Gupta <g.gupta@…>, 10 years ago

Proposed patch for the bug raised

comment:1 by Joaquín M López Muñoz, 10 years ago

Resolution: invalid
Status: newclosed

This manner of implementing assignment operator is not a bug. It's described in Sutter and Alexandrescu's C++ Coding Standards and more briefly on the Wikipedia.

BTW, your patch is invalid: it'd rule out assignment from a const object.

Note: See TracTickets for help on using tickets.