Thread overview
Const error should be warning ??
Sep 22, 2002
Matthew Wilson
Sep 23, 2002
Walter
Sep 23, 2002
Matthew Wilson
September 22, 2002
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


September 23, 2002
"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.


September 23, 2002
> 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.