Homunculus Reticulli
Homunculus Reticulli

Reputation: 68476

C++ template class compilation error message: error: expected a qualified name after 'typename'

I am trying to compile code from https://github.com/Sami-Vuorela/aatc

I am compiling using LLVMs em++ compiler:

Here is the console error message:

/opt/emsdk_portable/emscripten/master/em++ -Qunused-arguments -U__STRICT_ANSI__ -Wall -fno-strict-aliasing -std=c++11 -DAS_WRITE_OPS=0 -DAS_USE_STLNAMES=1 -DAS_USE_FLOAT=0 -Iinclude/ -Iangelscript/sdk/angelscript/include/ -Iangelscript/sdk/add_on/scriptbuilder/ -Iangelscript/sdk/add_on/contextmgr/ -Iangelscript/sdk/add_on/scripthelper/ -Iangelscript/sdk/add_on/scriptany/ -Iangelscript/sdk/add_on/scriptstdstring/ -Iangelscript/sdk/add_on/scriptdictionary/ -Iangelscript/sdk/add_on/scriptarray/ -Iangelscript/sdk/add_on/scriptmath/ -Iangelscript/sdk/add_on/scriptgrid/  -c aatc/source/aatc_registration_tempspecs.cpp  -o aatc/source/aatc_registration_tempspecs.o
In file included from aatc/source/aatc_registration_tempspecs.cpp:40:
In file included from aatc/source/aatc_tempspecs.hpp:37:
aatc/source/aatc_shared_tempspec.hpp:52:11: error: expected a qualified name after 'typename'
        typename typedef T_container::iterator iteratortype;
                 ^
aatc/source/aatc_shared_tempspec.hpp:52:11: error: expected member name or ';' after declaration specifiers
        typename typedef T_container::iterator iteratortype;
                 ^
aatc/source/aatc_shared_tempspec.hpp:97:18: error: cannot specialize a function 'Push_Back' within class scope
        template<> void Push_Back<aatc_Y>(const T_content& value){
                        ^
aatc/source/aatc_shared_tempspec.hpp:101:18: error: cannot specialize a function 'Pop_Back' within class scope
        template<> void Pop_Back<aatc_Y>(){
                        ^
aatc/source/aatc_shared_tempspec.hpp:106:25: error: cannot specialize a function 'Register_func_back_write' within
      class scope
        template<> static void Register_func_back_write<aatc_Y>(asIScriptEngine* engine, int& r, char* text...
                               ^
aatc/source/aatc_shared_tempspec.hpp:114:24: error: cannot specialize a function 'Back' within class scope
        template<> T_content& Back<aatc_Y>(){
                              ^
aatc/source/aatc_shared_tempspec.hpp:119:25: error: cannot specialize a function 'Register_func_back_read' within
      class scope
        template<> static void Register_func_back_read<aatc_Y>(asIScriptEngine* engine, int& r, char* textb...
                               ^
aatc/source/aatc_shared_tempspec.hpp:126:18: error: cannot specialize a function 'Push_Front' within class scope
        template<> void Push_Front<aatc_Y>(const T_content& value){
                        ^
aatc/source/aatc_shared_tempspec.hpp:130:18: error: cannot specialize a function 'Pop_Front' within class scope
        template<> void Pop_Front<aatc_Y>(){
                        ^
aatc/source/aatc_shared_tempspec.hpp:135:25: error: cannot specialize a function 'Register_func_front_write' within
      class scope
        template<> static void Register_func_front_write<aatc_Y>(asIScriptEngine* engine, int& r, char* tex...
                               ^
aatc/source/aatc_shared_tempspec.hpp:143:24: error: cannot specialize a function 'Front' within class scope
        template<> T_content& Front<aatc_Y>(){
                              ^
aatc/source/aatc_shared_tempspec.hpp:148:25: error: cannot specialize a function 'Register_func_front_read' within
      class scope
        template<> static void Register_func_front_read<aatc_Y>(asIScriptEngine* engine, int& r, char* text...
                               ^
aatc/source/aatc_shared_tempspec.hpp:167:18: error: cannot specialize a function 'Erase_value' within class scope
        template<> void Erase_value<aatc_Y>(const T_content& value){
                        ^
aatc/source/aatc_shared_tempspec.hpp:172:25: error: cannot specialize a function 'Register_func_erase_value' within
      class scope
        template<> static void Register_func_erase_value<aatc_Y>(asIScriptEngine* engine, int& r, char* tex...
                               ^
aatc/source/aatc_shared_tempspec.hpp:180:24: error: cannot specialize a function 'op_index' within class scope
        template<> T_content& op_index<aatc_Y>(aatc_type_sizetype index){
                              ^
aatc/source/aatc_shared_tempspec.hpp:186:25: error: cannot specialize a function 'Register_func_op_index' within
      class scope
        template<> static void Register_func_op_index<aatc_Y>(asIScriptEngine* engine, int& r, char* textbu...
                               ^
aatc/source/aatc_shared_tempspec.hpp:192:18: error: cannot specialize a function 'Reserve' within class scope
        template<> void Reserve<aatc_Y>(aatc_type_sizetype count){
                        ^
aatc/source/aatc_shared_tempspec.hpp:197:25: error: cannot specialize a function 'Register_func_reserve' within
      class scope
        template<> static void Register_func_reserve<aatc_Y>(asIScriptEngine* engine, int& r, char* textbuf...
                               ^
aatc/source/aatc_shared_tempspec.hpp:203:18: error: cannot specialize a function 'Insert' within class scope
        template<> void Insert<aatc_Y>(const T_content& value){
                        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

How may I fix this issue?

Upvotes: 1

Views: 3451

Answers (1)

The order of typename and typedef is reversed, it should be:

typedef typename T_container::iterator iteratortype;

That's because the typename decorates the qualified name T_container::iterator, and the entire decorated thing is the subject of the typedef.

The other host of errors is pretty self-explanatory: the code apparently contains template specialisations declared inside a class, which is not legal C++. So instead of something like this:

class X
{
  template <class T>
  void Erase_value(const T_content& value);

  template <>
  void Erase_value<aatc_Y>(const T_content& value){ /* ... */ }
};

it must be like this:

class X
{
  template <class T>
  void Erase_value(const T_content& value);
};

template <>
void X::Erase_value<aatc_Y>(const T_content& value){ /* ... */ }

Upvotes: 5

Related Questions