#include <ostream>
template<typename ch = char, typename tr = std::char_traits<ch> >
class buffer : public std::basic_streambuf<ch, tr> {
virtual
int_type overflow(int_type c = tr::eof());
virtual
typename int_type overflow1(typename int_type c = tr::eof());
using std::basic_streambuf<ch, tr>::int_type;
virtual
int_type overflow2(int_type c = tr::eof());
virtual
typename int_type overflow3(typename int_type c = tr::eof());
virtual
std::basic_streambuf<ch, tr>::int_type overflow4(
std::basic_streambuf<ch, tr>::int_type c = tr::eof());
virtual
typename std::basic_streambuf<ch, tr>::int_type overflow5(
typename std::basic_streambuf<ch, tr>::int_type c = tr::eof());
};
int main() {
buffer<> b;
}
gets you:
~/ootbc/common/test/src$ g++ foo.cc
foo.cc:5: error: `int_type' does not name a type
foo.cc:5: error: (perhaps `typename std::basic_streambuf<_CharT,
_Traits>::int_type' was intended)
foo.cc:8: error: expected nested-name-specifier before "int_type"
foo.cc:8: error: `int_type' does not name a type
foo.cc:8: error: (perhaps `typename std::basic_streambuf<_CharT,
_Traits>::int_type' was intended)
foo.cc:13: error: `int_type' does not name a type
foo.cc:13: error: (perhaps `typename std::basic_streambuf<_CharT,
_Traits>::int_type' was intended)
foo.cc:16: error: expected nested-name-specifier before "int_type"
foo.cc:16: error: `int_type' does not name a type
foo.cc:16: error: (perhaps `typename std::basic_streambuf<_CharT,
_Traits>::int_type' was intended)
foo.cc:19: error: ISO C++ forbids declaration of `int_type' with no type
foo.cc:19: error: cannot declare member `std::basic_streambuf<_CharT,
_Traits>::int_type' within `buffer<ch, tr>'
foo.cc:19: error: expected `;' before "overflow4"
As suggested in the error for "overflow" (good message BTW), the form used in
"overflow5" works. But a "using" for the inherited name "int_type" does not
make
the name visible either directly (overflow2) or when tagged with "typename"
(overflow 3). But the "using" doesn't complain either. If I can "using" it I
should be able to "use" it :-)
Ivan
--
Summary: "using" fails to make name visible without qualification
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: igodard at pacbell dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18541