std::bind and std::function generate a crazy number of copy. - by Thomas Petit

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


2
0
Sign in
to vote
ID 649268 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 3/3/2011 4:19:25 PM
Access Restriction Public

Description

Running the snippet below we can see that, even in release, a simple use of std::bind and std::function with a struct leads to *ten* calls to the copy constructor of that structure !

Such hidden performance penalty hit was very surprising to me. For example, GCC 4.6 with the same code generate only one call to the copy constructor (for std::bind) then one call to the move constructor (for std::function), which is the expected behavior.
Sign in to post a comment.
Posted by Microsoft on 6/28/2011 at 6:17 PM
Hi,

Thanks for reporting this bug. We've fixed it, and the fix will be available in VC11.

If you have any further questions, feel free to E-mail me at stl@microsoft.com .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by Microsoft on 3/3/2011 at 10:46 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.
Posted by Microsoft on 3/3/2011 at 5:15 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)