Norman J. Goldstein
unread,Mar 10, 2015, 9:35:09 PM3/10/15You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Below, is code that has 4 different conditional compilation blocks.
When the first block is chosen, the compilation breaks with the msg:
error: template-id ‘copy<>’ for
‘bool copy(WD&, WD::IoRefrType<A>)’
does not match any template declaration
template bool copy( WD&,
which refers to the inability of the compiler to explicitly instantiate,
as requested at the bottom of the source code.
However, when any of the last 3 blocks is chosen, instead,
the compilation is fine. I am using gcc 4.8.3 on linux x86-64.
Explanations or suggestions much appreciated!
/////////////////////// source code ///////////////
struct WD
{
template< typename T >
using IoRefrType = const T&;
};
class A;
#if 1 // Two template parameters: Error
template< typename S, typename T >
bool copy( S& s,
typename S:: template IoRefrType< T > t )
{ return true; }
#elif 1 // Only the first template parameter: OK
template< typename S >
bool copy( S& s,
typename S:: template IoRefrType<A> )
{ return true; }
#elif 1 // Only the second template parameter: OK
template< typename T >
bool copy( WD& ,
typename WD:: template IoRefrType< T > t )
{ return true; }
#else // Simpler two template parameters: OK
template< typename S, typename T >
bool copy( S& s,
const T& t )
{ return true; }
#endif
template bool
copy( WD&,
typename WD:: template IoRefrType<A> );
/////////////////////////////////////////////////////