tags:

views:

98

answers:

2

I have these errors i could not fixed it:

template< class char_type, class traits_type>
class invalid_streambuf : public std::basic_streambuf< char_type, traits_type>
{   
 typedef std::basic_streambuf< char_type, traits_type> base_class;
 using typename base_class::int_type;
 ...
 virtual int_type overflow(int_type nChar)
 { return 0; }
 ...
}

‘int_type’ does not name a type

template< class char_type, class traits_type>
class basic_thread_safe_log
: protected basic_message_handler_log< char_type, traits_type>
{
typedef basic_message_handler_log< char_type, traits_type> base_class;
using typename base_class::string_type;

void on_last_message( const string_type & str)
{
    assert ( str.empty());
}
...
}

ISO C++ forbids declaration of ‘string_type’ with no type

A: 

Is that your code or somebody else's code? The compiler is telling you that int_type and string_type are not known types -- in that code there are no declarations or definitions of those types, so what the compiler is saying makes perfect sense.

Do note that char_type and traits_type are not standard C++ types, as you may be believing they are (and thus trying to use the similarly-named int_type and string_type). They are type parameters to the template in question here. In other words the bit of code template< class char_type, class traits_type> contains the declarations of the type names that the rest of the template code is using.

It might help, however, if you ask a (separate) question about what you're trying to achieve on a higher level.

Josh Petrie
its not my code the problem is not with char_type and traits_type but with int_type which is defined like this typedef std::basic_streambuf< char_type, traits_type> base_class; using typename base_class::int_type;
Yassine
+1  A: 

You seem to try to use types that should be known at generation of the class but they are not parametters of your template class, so they don't exist.

Here, you could fix the problem simply by using typedef instead of using.

Klaim
i tried typedef std::basic_streambuf< char_type, traits_type>::int_type int_typ; but causes new error expected ‘;’ before ‘int_typ’
Yassine
You have a typo, it's int_type with a e. If it still don't work then your problem is before that.
Klaim
your tipp was good ok it is working now as follow: typedef std::basic_streambuf< char_type, traits_type> base_class; typedef typename base_class::int_type int_type;
Yassine