www.digitalmars.com         C & C++   DMDScript  

c++ - Const error should be warning ??

reply "Matthew Wilson" <dmd synesis.com.au> writes:
Not sure whether this should only be a warning (haven't mustered the effort
to trawl the standard this early in the morning)

class X
{
public:
    operator const char const * () const
    {
        return 0;
    }
};

gives

 Error: ...: illegal combination of types

I expected it to simply tell me that the first (or second) const was
superfluous.

I don't object to this one in its current form, but am concerned as to
whether it means that the compiler would balk in a template class defintion
where that template defines a member typedef an a constant type with which
it is parameterised, and the parameterising type is itself const. Borland
does have problems in this area.

Matthew
Sep 22 2002
parent reply "Walter" <walter digitalmars.com> writes:
"Matthew Wilson" <dmd synesis.com.au> wrote in message
news:amlfgi$p8$1 digitaldaemon.com...
 Not sure whether this should only be a warning (haven't mustered the
effort
 to trawl the standard this early in the morning)

 class X
 {
 public:
     operator const char const * () const
     {
         return 0;
     }
 };

 gives

  Error: ...: illegal combination of types

 I expected it to simply tell me that the first (or second) const was
 superfluous.
I believe the standard says it's supposed to be an error, just like short short is an error, and short int short is an error.
 I don't object to this one in its current form, but am concerned as to
 whether it means that the compiler would balk in a template class
defintion
 where that template defines a member typedef an a constant type with which
 it is parameterised, and the parameterising type is itself const. Borland
 does have problems in this area.
This should work fine.
Sep 23 2002
parent "Matthew Wilson" <dmd synesis.com.au> writes:
 I believe the standard says it's supposed to be an error, just like short
 short is an error, and short int short is an error.
In which case I prefer the DMC version. Helps me that bit more to validate the code.
Sep 23 2002