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++ - typedef template: constant initializer expected error

In the code below, I am getting an error when trying to typedef a template.
The error is a "constant initializer expected". I see this is discussed on
the compiler error list web page, but that discussion is not regarding
templates. I'm a greenhorn when it comes to templates, so I was hoping
someone could explain why it doesn't, or if it should compile according to
the standard. For better or worse, it does compile with several other
compilers.

Thanks.


namespace SPACE {

template < typename ST, bool fp=false, bool gs=false >
struct PixelTraits {

};


template < typename PT >
class PixelAllocater {

};


template < typename BST,
           bool fp=false,
           typename PTT=PixelTraits< BST,fp >,
           typename PAT=PixelAllocater< PTT >
         >
struct BGRAPixel {

};




// Error: constant initializer expected --- errorlevel 1
typedef BGRAPixel<  unsigned char  > SysPixelType0;

// Error: constant initializer expected --- errorlevel 1
typedef BGRAPixel<  unsigned char, false  > SysPixelType1;


// Compiles with DMC
typedef BGRAPixel< unsigned char,
                   false,
                   PixelTraits< unsigned char, false >
                 > SysPixelType2;

// Compiles with DMC
typedef BGRAPixel< unsigned char,
                   false,
                   PixelTraits< unsigned char, false >,
                   PixelAllocater< PixelTraits< unsigned char, false >  >
                 > SysPixelType3;

};





int main()
{
 return 0;
}
Apr 20 2005