RAD Studio
ContentsIndex
PreviousUpNext
Stricter C++ Compiler: Template Changes

The C++ compiler no longer allows an explicit template without the 'template <>' prefix. Use the compiler switch -Vbe to allow this. The following example shows this:

template <class>  
class foo {    
 foo();    
}; 
foo<int>::foo();//Error
template<> foo<int>::foo();//OK

Also, the C++ compiler no longer allows explicit template specialization within a class. Use the compiler switch -Vbx to allow this. For example, the following generates an error:

struct S {}; 
  struct SP 
  { 
    template <typename> void foo(const T &) {} 
    template <> void foo(const S &) {} // Error 
  };

  template <> void SP::foo(const S &) {} //OK
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!