<HTML><HEAD><TITLE>Samsung Enterprise Portal mySingle</TITLE>
<META content=IE=5 http-equiv=X-UA-Compatible>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type>
<STYLE id=mysingle_style type=text/css>P {
        MARGIN-BOTTOM: 5px; FONT-SIZE: 9pt; FONT-FAMILY: Arial, arial; MARGIN-TOP: 5px
}
TD {
        MARGIN-BOTTOM: 5px; FONT-SIZE: 9pt; FONT-FAMILY: Arial, arial; MARGIN-TOP: 5px
}
LI {
        MARGIN-BOTTOM: 5px; FONT-SIZE: 9pt; FONT-FAMILY: Arial, arial; MARGIN-TOP: 5px
}
BODY {
        FONT-SIZE: 9pt; FONT-FAMILY: Arial, arial; MARGIN: 10px; LINE-HEIGHT: 1.4
}
</STYLE>

<META name=GENERATOR content=ActiveSquare></HEAD>
<BODY>
<P> </P><!--SP:rahul1.jain--><!--rahul1.jain:EP-->
<P>Hi all,</P>
<P> </P>
<P>This is regarding 14.5.6.2 Partial ordering of function template.</P>
<P> </P>
<P>Test case - 1</P>
<P>struct A { };</P>
<P>template<class T> struct B {</P>
<P>template<class R> int operator*(R&); // #1</P>
<P>};</P>
<P>template<class T, class R> int operator*(T&, R&); // #2</P>
<P> </P>
<P>// The declaration of B::operator* is transformed into the equivalent of</P>
<P>// template<class R> int operator*(B<A>&, R&); // #1a</P>
<P> </P>
<P>int main() {</P>
<P>A a;</P>
<P>B<A> b;</P>
<P>b * a; // calls #1a</P>
<P>}</P>
<P> </P>
<P>The above test case works fine as per standards as #1a is more specialized than #2.</P>
<P> </P>
<P>However when we tweak the test case in this way:</P>
<P> </P>
<P>struct A{};</P>
<P>template<class T> struct B<BR>{<BR>  template<class R> int operator*(R&); // #1<BR>};</P>
<P>template <class T> int operator*(T&, A&); // #2</P>
<P>// The declaration of B::operator* is transformed into the equivalent of<BR>// template<class R> int operator*(B<A>&, R&); // #1a</P>
<P><BR>int main()<BR>{<BR>  A a;<BR>  B<A> b;<BR>  b*a;<BR>}<BR></P>
<P>clang throws an error saying:</P>
<P>error: use of overloaded operator '*' is ambiguous (with operand types 'B<A>' and 'A')</P>
<P> </P>
<P>How is partial ordering done in this case? How is the specialization decided for the below mentioned</P>
<P>operator overloading declarations?</P>
<P> </P>
<P>template<class R> int operator*(B<A>&, R&); // #1a</P>
<P>template <class T> int operator*(T&, A&); // #2</P>
<P> </P>
<P>It would be great if someone could explain whether this behavior is correct and more importantly</P>
<P>how clang does partial ordering and judge specialization between two function template overloads?</P>
<P> </P>
<P>Thanks,</P>
<P>Rahul</P>
<P> </P>
<P> </P>
<TABLE id=confidentialsignimg>
<TBODY>
<TR>
<TD NAMO_LOCK>
<P><IMG border=0 src="cid:T9SZN3WZA6X7@namo.co.kr"></P></TD></TR></TBODY></TABLE></BODY></HTML><img src='http://ext.samsung.net/mailcheck/SeenTimeChecker?do=e3e1a57eba32dd3d8a2a3d94aaf0555fbc59a075886934ade56225dd835e375fc400edea8930898a434c6ebf74e200ff220d3e02ce1cb961d6250c6ef56fc7aacf878f9a26ce15a0' border=0 width=0 height=0 style='display:none'>