VC10 STL: std::pair template constructors ignore if elements are implicitly constructable or not - by Dávid Róbert

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.

Sign in
to vote
ID 649898 Comments
Status Closed Workarounds
Type Bug Repros 3
Opened 3/7/2011 3:58:05 AM
Access Restriction Public


According to C++0x working draft, all template constructors of std::pair (so the ones that are not receiving parameters of the class' template parameter types) shall not participate in the overload resolution when the class' template types are not implicitly constructable from the corresponding parameter type. (Reference to the standard's corresponding paragraphs: N3242 §, §, §

In VC10, these remarks are not followed, template constructors do compile even if the parameters are not implicitly convertible to the pair's elements.

(See steps to reproduce for example)
Sign in to post a comment.
Posted by Ulzii [MSFT] on 3/8/2011 at 12:01 PM
Hello David,

Thank you for reporting this bug. This indeed was a bug in Visual Studio 2010 and SP1 release. We've fixed the issue for the next release. Compiler gives this error:

t.cpp(9) : error C2664: 'std::pair<_Ty1,_Ty2>::pair(const _Ty1 &,const _Ty2 &)'
: cannot convert parameter 1 from 'int' to 'const Foo &'
        Reason: cannot convert from 'int' to 'const Foo'
        Constructor for struct 'Foo' is declared 'explicit'
t.cpp(14) : error C2374: 'e' : redefinition; multiple initialization
        t.cpp(12) : see declaration of 'e'

Ulzii Luvsanbat
Windows C++ Team
Posted by Helen [MSFT] on 3/7/2011 at 5:36 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.

Posted by Microsoft on 3/7/2011 at 4:12 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(