Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

Template code compilation issue #2

de666
Beginner
277 Views
this code does not compile with icc11 however is valid c++
it compiles with msvc versions 7, 7.1 & 8

[cpp]#include    
  
template struct s;   
template<> struct s {};   
template<> struct s : public s   
{};   
  
struct Int : public s {};   
  
template   
void foo(const s&)   
{ std::cout << "in foo(const s<" << typeid(type).name() << ">&)n"; }   
  
int main()   
{   
  Int i;   
  foo(i);  //here an error appears   
  return 0;   
}[/cpp]

previous discussion: http://software.intel.com/en-us/forums/showthread.php?t=70491
0 Kudos
2 Replies
Judith_W_Intel
Employee
277 Views
Quoting - de666
this code does not compile with icc11 however is valid c++
it compiles with msvc versions 7, 7.1 & 8

[cpp]#include    
  
template struct s;   
template<> struct s {};   
template<> struct s : public s   
{};   
  
struct Int : public s {};   
  
template   
void foo(const s&)   
{ std::cout << "in foo(const s<" << typeid(type).name() << ">&)n"; }   
  
int main()   
{   
  Int i;   
  foo(i);  //here an error appears   
  return 0;   
}[/cpp]

previous discussion: http://software.intel.com/en-us/forums/showthread.php?t=70491

this is the same issue as in the previous discussion (link above)
0 Kudos
de666
Beginner
277 Views
ok
let's continue in the old thread
you may want to delete this one
0 Kudos
Reply