Re: Compiler chooses conv ctor - why?
- From: "Cezary H. Noweta" <chncc@xxxxxxxxxxxxxxx>
- Date: Wed, 16 Apr 2008 11:49:23 +0200
Hello,
Charles Wang[MSFT] wrote:
Thank you for your explaining on this according to ISO standard. I think that I understand your meaning. Your main concern should be that at least the compiler should throw an warning to tell developers this potential issue, right? Could you please give Microsoft feedback via https://connect.microsoft.com/visualstudio so that our product team can hear your voice and improve our product? You may also be able to get email notifications when Microsoft product team responds you.
OK - but before, could somebody confirm that in the following code (similar to the code provided by Alex but conv foo is without const qualifier):
======
#include <stdio.h>
struct B;
struct A {
operator B(); /* implicit object parameter: A & */
};
struct B {
B() {}
B(const A&) { printf("conv ctor\n"); }
};
A::operator B()
{
printf("conv foo\n");
return (B());
}
void foo(B) {}
int main()
{
A a;
B b = a; /* 25 */
foo(a); /* 27 */
return 0;
}
======
conversion function should be chosen, as according to 13.3.3.2[3] of the standard, it is better function due to qualification conversion required by conversion constructor (non-const A& to const A&)?
-- best regards
Cezary Noweta
.
- Follow-Ups:
- Re: Compiler chooses conv ctor - why?
- From: Alex Blekhman
- Re: Compiler chooses conv ctor - why?
- References:
- Compiler chooses conv ctor - why?
- From: Cezary H. Noweta
- Re: Compiler chooses conv ctor - why?
- From: Alex Blekhman
- Re: Compiler chooses conv ctor - why?
- From: Charles Wang[MSFT]
- Re: Compiler chooses conv ctor - why?
- From: Cezary H. Noweta
- Re: Compiler chooses conv ctor - why?
- From: Charles Wang[MSFT]
- Compiler chooses conv ctor - why?
- Prev by Date: Multiple initialization of template static data members?
- Next by Date: The C++ standard's rule for selecting a constructor
- Previous by thread: Re: Compiler chooses conv ctor - why?
- Next by thread: Re: Compiler chooses conv ctor - why?
- Index(es):
Relevant Pages
|