I get an error message when I try to compile the code below:
======================== Error message ========================================
error C2664: 'f' : cannot convert parameter 1 from 'c<t1,t2>' to 'const c<t1,t2> &'
with
[
t1=char,
t2=int
]
and
[
t1=const char,
t2=int
]
===================================== Code ====================================
template< typename t1, typename t2 >
struct c
{
c( ) { }
operator c< t1 const, t2 >( ) const { return c< t1 const, t2 >( ); }
};
template< typename t2 >
void f( c< char const, t2 > const& )
{
}
int __cdecl main
(
)
{
c< char, int > C;
f( C );
}
Why is the conversion operator not used in this context?