Home Dashboard Directory Help
Search

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


Status: 

Closed
 as Fixed Help for as Fixed


3
0
Sign in
to vote
Type: Bug
ID: 649898
Opened: 3/7/2011 3:58:05 AM
Access Restriction: Public
0
Workaround(s)
view
3
User(s) can reproduce this bug

Description

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 §20.3.2.9, §20.3.2.12, §20.3.2.16)

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)
Details
Sign in to post a comment.
Posted by Microsoft 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 &'
        with
        [
            _Ty1=Foo,
            _Ty2=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'

Thanks,
Ulzii Luvsanbat
Windows C++ Team
Posted by Microsoft 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(http://support.microsoft.com)
Sign in to post a workaround.