[Insight-developers] Borland vs Mesh
Miller, James V (Research)
millerjv@crd.ge.com
Thu, 5 Sep 2002 10:17:56 -0400
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C254E7.07FE64E0
Content-Type: text/plain;
charset="iso-8859-1"
The code at the bottom of this email will not compiler under the Borland compiler. It returns a
Error E2402 foo.cxx 13: Illegal base class type: formal type 'B<T,V,TTraits>' resolves to
'B<float,3,A<float,3,V1>>' in function main(int,char * *)
Error E2450 foo.cxx 23: Undefined structure 'C<float,3,A<float,3,V1>>' in function main(int,char * *)
When inheriting from B, A's dependent default parameter V2 is not resolved to be the value of V1. The
Boost site indicates that dependent default parameters are not functional in the Borland compiler.
Their workaround does not seem applicable in this case.
This pattern occurs in the PointSet and Mesh classes with the MeshTraits template parameter. In the
various
Default*MeshTraits classes for the VMaxTopologicalDimension template parameter
template <
typename TPixelType,
unsigned int VPointDimension = 3,
unsigned int VMaxTopologicalDimension = VPointDimension,
typename TCoordRep = float,
typename TInterpolationWeight = float,
typename TCellPixelType = TPixelType
>
class DefaultStaticMeshTraits
{};
And PointSet and Mesh are defined as....
template <
typename TPixelType,
unsigned int VDimension = 3,
typename TMeshTraits = DefaultStaticMeshTraits< TPixelType, VDimension >
>
class PointSet: public DataObject
{};
template <
typename TPixelType,
unsigned int VDimension = 3,
typename TMeshTraits = DefaultStaticMeshTraits< TPixelType , VDimension >
>
class Mesh : public PointSet<TPixelType, VDimension, TMeshTraits>
{};
To get around this, I am providing DefaultStaticMeshTraits with the additional template parameter (as
opposed
to relying on the dependent default template parameter), ie.
template <
typename TPixelType,
unsigned int VDimension = 3,
typename TMeshTraits = DefaultStaticMeshTraits< TPixelType , VDimension, VDimension>
>
class Mesh : public PointSet<TPixelType, VDimension, TMeshTraits>
{};
// Simple code illustrating the problem
//
//
template <typename T, unsigned int V1 = 3, unsigned int V2 = V1>
struct A
{
};
template <typename T, unsigned int V, typename TTraits = A<T, V> >
class B
{
};
template <typename T, unsigned int V, typename TTraits = A<T, V> >
class C : public B<T, V, TTraits>
{
};
int main(int, char *[])
{
B<float, 3> b1; // okay
C<float, 3, A<float, 3, 5> > c1; // okay
C<float, 3> c2; // error: Illegal base class type
// C<float, 3, A<float, 3> > c3; // internal compiler error
}
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Jim Miller
_____________________________________
Visualization & Computer Vision
GE Research
Bldg. KW, Room C218B
P.O. Box 8, Schenectady NY 12301
millerjv@research.ge.com <mailto:millerjv@research.ge.com>
james.miller@research.ge.com
(518) 387-4005, Dial Comm: 8*833-4005,
Cell: (518) 505-7065, Fax: (518) 387-6981
------_=_NextPart_001_01C254E7.07FE64E0
Content-Type: text/html;
charset="iso-8859-1"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2715.400" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=585325813-05092002><FONT size=2>The code at the bottom of this
email will not compiler under the Borland compiler. It returns a
</FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>Error E2402 foo.cxx 13: Illegal
base class type: formal type 'B<T,V,TTraits>' resolves to
'B<float,3,A<float,3,V1>>' in function main(int,char * *)<BR>Error
E2450 foo.cxx 23: Undefined structure 'C<float,3,A<float,3,V1>>' in
function main(int,char * *)<BR></FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>When inheriting from
B, A's dependent default parameter V2 is not resolved to be the value of
V1. The Boost site indicates that dependent default parameters are not
functional in the Borland compiler. Their workaround does not seem
applicable in this case.</FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>This pattern occurs in the
PointSet and Mesh classes with the MeshTraits template parameter. In the
various </FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>Default*MeshTraits classes for
the VMaxTopologicalDimension template parameter</FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>template <<BR>
typename TPixelType,<BR> unsigned int VPointDimension = 3,<BR>
unsigned int VMaxTopologicalDimension = VPointDimension,<BR> typename
TCoordRep = float,<BR> typename TInterpolationWeight = float,<BR>
typename TCellPixelType = TPixelType<BR> ><BR>class
DefaultStaticMeshTraits<BR>{};</FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>And PointSet and Mesh are
defined as....</FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>template <<BR>
typename TPixelType,<BR> unsigned int VDimension = 3,<BR> typename
TMeshTraits = DefaultStaticMeshTraits< TPixelType, VDimension ><BR>
><BR>class PointSet: public DataObject<BR>{};</FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>template <<BR>
typename TPixelType,<BR> unsigned int VDimension = 3,<BR> typename
TMeshTraits = DefaultStaticMeshTraits< TPixelType , VDimension ><BR>
><BR>class Mesh : public PointSet<TPixelType, VDimension,
TMeshTraits><BR>{};</FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>To get around this, I am
providing DefaultStaticMeshTraits with the additional template parameter (as
opposed </FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>to relying on the dependent
default template parameter), ie.</FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>
<DIV><SPAN class=585325813-05092002><FONT size=2>template <<BR>
typename TPixelType,<BR> unsigned int VDimension = 3,<BR> typename
TMeshTraits = DefaultStaticMeshTraits< TPixelType , VDimension,
VDimension><BR> ><BR>class Mesh : public PointSet<TPixelType,
VDimension, TMeshTraits><BR>{};</FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT
size=2></FONT></SPAN> </DIV></FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>// Simple code illustrating the
problem</FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>//</FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>//</DIV></FONT></SPAN>
<DIV class=Section1>
<P class=MsoNormal><FONT size=2>template <typename T, unsigned int V1 = 3,
unsigned int V2 = V1><BR>struct A<BR>{<BR>};</FONT></P><FONT size=2>
<P class=MsoNormal><BR>template <typename T, unsigned int V, typename TTraits
= A<T, V> ><BR>class B<BR>{<BR>};</P>
<P class=MsoNormal>template <typename T, unsigned int V, typename TTraits =
A<T, V> ><BR>class C : public B<T, V, TTraits><BR>{<BR>};</P>
<P class=MsoNormal>int main(int, char *[])<BR>{<BR> B<float, 3>
b1;
// okay<BR> C<float, 3, A<float, 3, 5> > c1; // okay</P>
<P class=MsoNormal> C<float, 3>
c2;
// error: Illegal base class type <BR> // C<float, 3, A<float, 3>
> c3; // internal compiler
error<BR>}<BR></P></FONT><?xml:namespace prefix = o ns =
"urn:schemas-microsoft-com:office:office" /><o:p></o:p></DIV>
<DIV><o:p></o:p> </DIV>
<DIV><o:p><FONT size=2></FONT></o:p> </DIV>
<P class=Section1 style="MARGIN: 0in 0in 0pt"><B><SPAN
style="COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">Jim Miller</SPAN></B>
<BR><B><I><SPAN
style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Arial">_____________________________________</SPAN></I></B><BR><EM><SPAN
style="FONT-SIZE: 7.5pt; COLOR: black; FONT-FAMILY: Arial">Visualization &
Computer Vision</SPAN></EM><I><SPAN
style="FONT-SIZE: 7.5pt; COLOR: black; FONT-FAMILY: Arial"><BR><EM>GE
Research</EM><BR><EM>Bldg. KW, Room C218B</EM><BR><EM>P.O. Box 8, Schenectady NY
12301</EM><BR><BR></SPAN></I><EM><U><SPAN
style="FONT-SIZE: 7.5pt; COLOR: blue"><A
href="mailto:millerjv@research.ge.com">millerjv@research.ge.com</A></SPAN></U></EM></P>
<P class=Section1 style="MARGIN: 0in 0in 0pt"><EM><U><SPAN
style="FONT-SIZE: 7.5pt; COLOR: blue">james.miller@research.ge.com</SPAN></U></EM><BR><I><SPAN
style="FONT-SIZE: 7.5pt; COLOR: black; FONT-FAMILY: Arial">(518) 387-4005, Dial
Comm: 8*833-4005, </SPAN></I><BR><I><SPAN
style="FONT-SIZE: 7.5pt; COLOR: black; FONT-FAMILY: Arial">Cell: (518) 505-7065,
Fax: (518) 387-6981</SPAN></I> </P>
<P class=MsoNormal> <o:p></o:p></P>
<DIV> </DIV></BODY></HTML>
------_=_NextPart_001_01C254E7.07FE64E0--