N
Noah Roberts
Someone in another list posted this code. It compiles in G++ and
apparently is absorbed by comeau as well. VS vomits.
#include <cstddef>
template < typename T, std :: size_t sz >
struct Block
{
typedef T type[ sz ][ sz ];
};
template < typename T >
void assign( T & assignee, const T & value )
{}
template < typename T, std :: size_t sz >
void assign( T ( & assignee )[ sz ], const T ( & value )[ sz ] )
{}
int main( )
{
Block< int, 16 > :: type a;
const Block< int, 16 > :: type b = { };
assign( a, b );
}
1>e:\dev_workspace\experimental\boost_msg_test\boost_msg_test\boost_msg_test.cpp(22)
: error C2782: 'void assign(T (&)[sz],const T (&)[sz])' : template
parameter 'T' is ambiguous
1>
e:\dev_workspace\experimental\boost_msg_test\boost_msg_test\boost_msg_test.cpp(14)
: see declaration of 'assign'
1> could be 'const int [16]'
1> or 'int [16]'
1>e:\dev_workspace\experimental\boost_msg_test\boost_msg_test\boost_msg_test.cpp(22)
: error C2782: 'void assign(T &,const T &)' : template parameter 'T' is
ambiguous
1>
e:\dev_workspace\experimental\boost_msg_test\boost_msg_test\boost_msg_test.cpp(10)
: see declaration of 'assign'
1> could be 'const int [16][16]'
1> or 'int [16][16]'
G++ compiles and calls the T[] version.
apparently is absorbed by comeau as well. VS vomits.
#include <cstddef>
template < typename T, std :: size_t sz >
struct Block
{
typedef T type[ sz ][ sz ];
};
template < typename T >
void assign( T & assignee, const T & value )
{}
template < typename T, std :: size_t sz >
void assign( T ( & assignee )[ sz ], const T ( & value )[ sz ] )
{}
int main( )
{
Block< int, 16 > :: type a;
const Block< int, 16 > :: type b = { };
assign( a, b );
}
1>e:\dev_workspace\experimental\boost_msg_test\boost_msg_test\boost_msg_test.cpp(22)
: error C2782: 'void assign(T (&)[sz],const T (&)[sz])' : template
parameter 'T' is ambiguous
1>
e:\dev_workspace\experimental\boost_msg_test\boost_msg_test\boost_msg_test.cpp(14)
: see declaration of 'assign'
1> could be 'const int [16]'
1> or 'int [16]'
1>e:\dev_workspace\experimental\boost_msg_test\boost_msg_test\boost_msg_test.cpp(22)
: error C2782: 'void assign(T &,const T &)' : template parameter 'T' is
ambiguous
1>
e:\dev_workspace\experimental\boost_msg_test\boost_msg_test\boost_msg_test.cpp(10)
: see declaration of 'assign'
1> could be 'const int [16][16]'
1> or 'int [16][16]'
G++ compiles and calls the T[] version.