Opened 12 years ago

Last modified 10 years ago

#4686 new Bugs

MSVC warning C4512 at /W4 (operator= can't be created)

Reported by: Stefan van Kessel <van_kessel@…> Owned by: Matias Capeletto
Milestone: To Be Determined Component: bimap
Version: Boost 1.44.0 Severity: Cosmetic
Keywords: C4512 warning bimap assignment operator operator= Cc: mateusz@…

Description

At /W4 msvc10 warns about not being able to generate the assignment operator for 4 classes.

Example code that generates the warnings:

#include <boost/bimap.hpp>
int main(){
	boost::bimap< int, char > bm;
}

As the boost warnings guidelineshttps://svn.boost.org/trac/boost/wiki/Guidelines/WarningsGuidelines state "Adding the declaration (not the definition) of the appropriate operator=() as a private member does the trick as well." (disabling the warning by pragma would have to still be active at the point of bimap instantiation and thus disable the warning in user code)

Attachments (1)

bimap_assignment_ops.patch (2.6 KB ) - added by Stefan van Kessel <van_kessel@…> 12 years ago.
patch declaring operator= for classes for which it can't be generated

Download all attachments as: .zip

Change History (4)

by Stefan van Kessel <van_kessel@…>, 12 years ago

Attachment: bimap_assignment_ops.patch added

patch declaring operator= for classes for which it can't be generated

comment:1 by Stefan van Kessel <van_kessel@…>, 12 years ago

There are template parameters for which the compiler can generate the operator= and for which just declaring it will therefore break some of the classes. A correct fix that works in all contexts is not as easy as I thought. A traits class like is_assignable for the member and base class types would be needed to only declare the operator= if either of the aforementioned is not assignable.

comment:2 by Stefan van Kessel <van_kessel@…>, 12 years ago

Type: PatchesBugs

comment:3 by Mateusz Loskot, 10 years ago

Cc: mateusz@… added
Note: See TracTickets for help on using tickets.