Visual Studio and .NET Framework Home
Thank you for your feedback!
Conversion operators/constructors do not work for arguments passed by reference
- by mnvm
as By Design
The product team believes this item works according to its intended design.
A more detailed explanation for the resolution of this particular item may have been provided in the comments section.
3/25/2013 9:47:22 AM
Conversion operators/constructors do not work for arguments passed by reference.
ATTACH A FILE
EDIT THIS ITEM
Item can only be reassigned when it is active.
to post a comment.
Please enter a comment.
on 3/27/2013 at 11:30 AM
The extension fixes a bug in the standard. There is no reason to prevent a temporary from being passed by reference. This useless limitation of the standard results only in more lines of code and more bugs. Microsoft should push the extension to the standard.
The extension is not reported as legacy by the compiler. Why should conversions work only for const references? This is a bug.
[MSFT] on 3/26/2013 at 11:41 AM
Thanks for reporting the issue.
This is by design. According to the C++ standard, a temporary can't bind to non-const reference. In your code, the conversion from 'A' to 'B &' has a temporary B (the result of 'A::operator B') which can't bind to 'B &'.
Note that VC has an extension to allow the binding in some cases, but it is for legacy code and doesn't apply here. Conformant code should not rely on the extension.
Visual C++ Team
on 3/25/2013 at 8:54 PM
Thanks for your feedback.
We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
on 3/25/2013 at 9:50 AM
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)
to post a workaround.
Please enter a workaround.
Attach a file
© 2016 Microsoft