Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > legal code?

Reply
Thread Tools

legal code?

 
 
Noah Roberts
Guest
Posts: n/a
 
      12-10-2008
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\boo st_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\boo st_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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it legal to write an logical equation for a FPGA LUT in claims of a patent? Weng Tianxiang VHDL 12 12-10-2005 03:49 PM
Research: File-sharers big legal download spenders. Silverstrand Front Page News 0 07-27-2005 03:00 PM
State machine transition on internal signals - is it legal? Divyang M VHDL 9 05-18-2005 03:58 PM
State machine transition on internal signals -- is it legal? Divyang M VHDL 1 05-15-2005 09:36 AM
Is this legal? Valentin Tihomirov VHDL 20 10-29-2003 10:31 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57