www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - Const error should be warning ??

↑ ↓ ← "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
↑ ↓ "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

 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

 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
↑ ↓ → "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