templates and self-references[resolved?]
Ok, I got a a template class. One of the parameters is again supposed to be a class that I write myself. Looks like this:
Code:
template<typename _C>
class standard_config_formatter;
template<typename _C, typename _Formatter = standard_config_formatter<_C> >
class basic_configfile : public _Formatter
// ...
Then in the actual definition of the class standard_config_formatter I have this:
Code:
template<typename _C>
class standard_config_formatter
{
private:
typedef basic_configfile<_C, standard_config_formatter<_C> > my_type;
So I'm referencing standard_config_formatter from within standard_config_formatter. This seems to cause problems as VC++7 (6 would probably crash compiling this ;) ) gives me an error whenever I try using this typedef:
Code:
int get_int_prop(const my_type::string_type &name) {
The error is:
Quote:
d:\work\daten\c++\fwrite\config.h(299) : error C2027: use of undefined type 'config_files::basic_configfile<_C,_Formatter>'
with
[
_C=char,
_Formatter=config_files::standard_config_formatter<char>
]
which seems strange to be because standard_config_formatter is the undefined type, not basic_configfile.
Anyone has an idea as to why this error occurs? I've got an idea to solve it, but it would take away some of the elegance of the code.
edit: The idea worked.