ISO C++ Template Parser kicking my behind...

ISO C++ Template Parser kicking my behind...

Post by Conrad Wey » Thu, 12 Aug 2004 23:35:29


I'd like to keep the "ISO C++ Template Parser" checked but the following
code is giving me trouble:


Error : illegal use of type-name
(point of instantiation: 'compile_time_enumerators()')
(instantiating: 'GetEnumerator<ECompileTest>(const char *)')
main.cpp line 35 bad_enumerator(i_EnumeratorName);


This works in ms vc7.1, but it's probably not as strict.
Help much appreciated.
regards,
Conrad Weyns

-------- here is the code (strippet to the bone!) ------

template <typename PEnumerator> class TEnum
{
public:
class bad_enumerator : public std::exception
{
public:
bad_enumerator(char const*)
{
}
};
};

template <typename PEnumerator> PEnumerator GetEnumerator(char const*
i_EnumeratorName) throw(std::exception)
{
throw TEnum<PEnumerator>::bad_enumerator(i_EnumeratorName);

return PEnumerator();
}

enum ECompileTest
{
};

void compile_test()
{
// Next statement gives error when "ISO C++ Template Parser" is checked:
ECompileTest e = GetEnumerator<ECompileTest>("Rubbish");

// Following is however ok:
throw TEnum<ECompileTest>::bad_enumerator("More rubbish");
}

// Beats me!
 
 
 

ISO C++ Template Parser kicking my behind...

Post by Howard Hin » Fri, 13 Aug 2004 00:56:05

In article <37qSc.330$ XXXX@XXXXX.COM >,



Rule #1: Just keep writing "typename" until the program compiles. ;-)

throw typename TEnum<PEnumerator>::bad_enumerator(i_EnumeratorName);

-Howard

 
 
 

ISO C++ Template Parser kicking my behind...

Post by Conrad Wey » Fri, 13 Aug 2004 02:12:02


----- Original Message -----
From: "Howard Hinnant" < XXXX@XXXXX.COM >
Newsgroups: codewarrior.windows
Sent: Wednesday, August 11, 2004 5:56 PM
Subject: Re: ISO C++ Template Parser kicking my behind...



[]

Hehe, believe me, first thing I tried, but not right after the throw :-(
I have been following a recent thread in c.l.c++.moderated (When to use
typename keyword) and I must admit, some of it is beyond me.
I just move such posts to a "keepers" folder thinking it might come in handy
sooner or later.


Thanks again Howard, project settings are back to "normal" now.
(Sorry for replying to you privately first - hit the wrong button)
Conrad