Re: char_traits bug

From: Kai Henning (henning_at_aut.tu-cottbus.de)
Date: 02/20/04


Date: Fri, 20 Feb 2004 09:12:11 +0100

It's a bug in MSVC.NET. Compile the following code. It produces the same
error.

#include <limits>
#undef max

template < typename T >
class A
{
protected:
    typedef std::numeric_limits< T > MinMaxTy;
private:
    T t_;
public:
    A(const T t= MinMaxTy::max()) : t_(t) {}
};

template < typename T >
class AA : public A< T >
{
    typedef A< T > inherited;
    typedef typename inherited::MinMaxTy MinMaxTy;
public:
    AA(const T t= MinMaxTy::max()) : inherited(t) {}
};

int main()
{
    AA< int > a;
}

Kai Henning

"Jason Winnebeck" <gillius@mail.rit.nspam.edu> schrieb im Newsbeitrag
news:#DlRuT08DHA.2752@TK2MSFTNGP09.phx.gbl...
> I haven't found any other place you can report a bug with Visual Studio,
> so I figured I'd try here, although I don't think any MS people read
these.
>
> I'm deriving a class from the templated std::streambuf. In MSVC.NET
> 2002 and also in GCC 3 and te Comeau compiler, this code compiles.
> However in MSVC.NET 2003 alone does it not compile.
>
> I had to implement a small workaround only for MSVC.NET 2003. The code
> for the class is as follows:
> class goutbuf : public std::streambuf {
> public:
> goutbuf();
> ~goutbuf();
>
> /**
> * If set, the next output will be an mlprintf instead of a mprintf,
with
> * the specified coordinates.
> */
> void setNextWriteLoc(int x, int y);
>
> protected:
> int sync();
> void flush_output();
>
> #if (_MSC_VER == 1310 )
> //While still technically correct and valid, it's not quite as robust
> as the
> //next line because this makes the assumption on what traits_type is
> defined
> //as.
> int_type overflow(int_type meta = std::char_traits<char>::eof());
> #else
> //For some reason, in MSVC.NET 2003 alone (not 2002), this line
generates
> //the following error:
> //error C2653: 'char_traits<char>' : is not a class or namespace name
> int_type overflow(int_type meta = traits_type::eof());
> #endif
>
> std::streamsize xsputn(const char_type *ptr, std::streamsize count);
>
> private:
> char* buf;
>
> int x; //the next coords to write to, if not -1.
> int y;
> };
>
> This is part of the header file. The class is in the namespace
> GNE::Console, and there is another class in the header.
>
> Jason Winnebeck



Relevant Pages