[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.&nbsp; It returns a 
</FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>Error E2402 foo.cxx 13: Illegal 
base class type: formal type 'B&lt;T,V,TTraits&gt;' resolves to 
'B&lt;float,3,A&lt;float,3,V1&gt;&gt;' in function main(int,char * *)<BR>Error 
E2450 foo.cxx 23: Undefined structure 'C&lt;float,3,A&lt;float,3,V1&gt;&gt;' in 
function main(int,char * *)<BR></FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>When inheriting from 
B,&nbsp;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.&nbsp; Their workaround does not seem 
applicable in this case.</FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>This&nbsp;pattern occurs in the 
PointSet and Mesh classes with the MeshTraits template parameter.&nbsp; 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>&nbsp;</DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>template &lt;<BR>&nbsp; 
typename TPixelType,<BR>&nbsp; unsigned int VPointDimension = 3,<BR>&nbsp; 
unsigned int VMaxTopologicalDimension = VPointDimension,<BR>&nbsp; typename 
TCoordRep = float,<BR>&nbsp; typename TInterpolationWeight = float,<BR>&nbsp; 
typename TCellPixelType = TPixelType<BR>&nbsp; &gt;<BR>class 
DefaultStaticMeshTraits<BR>{};</FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN>&nbsp;</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>&nbsp;</DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>template &lt;<BR>&nbsp; 
typename TPixelType,<BR>&nbsp; unsigned int VDimension = 3,<BR>&nbsp; typename 
TMeshTraits = DefaultStaticMeshTraits&lt; TPixelType, VDimension &gt;<BR>&nbsp; 
&gt;<BR>class PointSet: public DataObject<BR>{};</FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>template &lt;<BR>&nbsp; 
typename TPixelType,<BR>&nbsp; unsigned int VDimension = 3,<BR>&nbsp; typename 
TMeshTraits = DefaultStaticMeshTraits&lt; TPixelType , VDimension &gt;<BR>&nbsp; 
&gt;<BR>class Mesh : public PointSet&lt;TPixelType, VDimension, 
TMeshTraits&gt;<BR>{};</FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN>&nbsp;</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>&nbsp;</DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2>
<DIV><SPAN class=585325813-05092002><FONT size=2>template &lt;<BR>&nbsp; 
typename TPixelType,<BR>&nbsp; unsigned int VDimension = 3,<BR>&nbsp; typename 
TMeshTraits = DefaultStaticMeshTraits&lt; TPixelType , VDimension, 
VDimension&gt;<BR>&nbsp; &gt;<BR>class Mesh : public PointSet&lt;TPixelType, 
VDimension, TMeshTraits&gt;<BR>{};</FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT 
size=2></FONT></SPAN>&nbsp;</DIV></FONT></SPAN></DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=585325813-05092002><FONT size=2></FONT></SPAN>&nbsp;</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 &lt;typename T, unsigned int V1 = 3, 
unsigned int V2 = V1&gt;<BR>struct A<BR>{<BR>};</FONT></P><FONT size=2>
<P class=MsoNormal><BR>template &lt;typename T, unsigned int V, typename TTraits 
= A&lt;T, V&gt; &gt;<BR>class B<BR>{<BR>};</P>
<P class=MsoNormal>template &lt;typename T, unsigned int V, typename TTraits = 
A&lt;T, V&gt; &gt;<BR>class C : public B&lt;T, V, TTraits&gt;<BR>{<BR>};</P>
<P class=MsoNormal>int main(int, char *[])<BR>{<BR>&nbsp; B&lt;float, 3&gt; 
b1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
// okay<BR>&nbsp; C&lt;float, 3, A&lt;float, 3, 5&gt; &gt; c1;&nbsp; // okay</P>
<P class=MsoNormal>&nbsp; C&lt;float, 3&gt; 
c2;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
// error: Illegal base class type <BR>&nbsp; // C&lt;float, 3, A&lt;float, 3&gt; 
&gt; c3;&nbsp;&nbsp;&nbsp;&nbsp; // 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>&nbsp;</DIV>
<DIV><o:p><FONT size=2></FONT></o:p>&nbsp;</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 &amp; 
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>&nbsp;<o:p></o:p></P>
<DIV>&nbsp;</DIV></BODY></HTML>

------_=_NextPart_001_01C254E7.07FE64E0--