<div><br><div id="mb_0"><div><div>Hi, sorry for another problem... i have a simple question to ask... <br><br><br>lets say say i have base class<br><br><br>struct&nbsp;GeomObject<br>{</div>
<div>&nbsp; // draws an wire shape</div>
<div>&nbsp;&nbsp;&nbsp;virtual void drawAbstract(const GLfloat&amp; x, const GLfloat&amp; y, const GLfloat&amp; z) = 0; </div>
<div>&nbsp;&nbsp; // draws a solid shape.</div>
<div>&nbsp;&nbsp; virtual void drawSolid(const GLfloat&amp; x, const GLfloat&amp; y, const GLfloat&amp; z) = 0;</div>
<div>}<br><br><br>Now i have bunch of stuff that inherits it..<br><br>Like class Circle, class Sphere, class Cylinder, class Cone and all of them implement drawSolid and drawAbstract (radius base assumed). <br><br>I have a function call drawCircle(const std::string&amp; r, (someBoostFunctionParam)) 
</div>
<div>{</div>
<div>&nbsp;&nbsp;&nbsp; Circle cir(4.0, r); // construct a circle with radius 4.0 and name r</div>
<div>&nbsp;&nbsp;&nbsp; cir.someBoostFunctionParam(x, y, z);</div>
<div>}<br><br>thus if i say drawCircle(&quot;solid&quot;, &amp;Circle::drawSolid);<br>drawCircle(&quot;abstract&quot;, &amp;Circle::drawAbstract);<br></div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>How do you do that? Or whats the best way to do it. </div>

</div></div><br>&nbsp;</div>
<div><span class="gmail_quote">On 8/22/06, <b class="gmail_sendername">Fran�ois Duranleau</b> &lt;<a href="mailto:duranlef@iro.umontreal.ca" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">duranlef@iro.umontreal.ca
</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">On Mon, 21 Aug 2006, chun ping wang wrote:<br><br>[...]<br>&gt; template &lt;class T&gt;<br>
&gt; boost::function&lt;void*(const T&amp;, const T&amp;, const T&amp;)&gt; getVerxFunc3()
<br>&gt; {<br>&gt;&nbsp;&nbsp;BOOST_STATIC_ASSERT(boost::is_integral&lt;T&gt;::value ||<br>&gt; boost::is_floating_point&lt;T&gt;::value);<br>&gt;&nbsp;&nbsp;return (boost::is_integral&lt;T&gt;::value) ? &amp;glVertex3i : &amp;glVertex3d;<br>

&gt; }<br>&gt;<br>[...]<br>&gt;<br>&gt; template &lt;class T&gt;<br>&gt; void drawDot(const T&amp; x, const T&amp; y, const T&amp; z) {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;boost::function&lt;void(const T&amp;, const T&amp;, const T&amp;)&gt;<br>
&gt; myFunc(getVerxFunc3&lt;T&gt;());
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;glBegin(GL_POINTS);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myFunc(x, y, z);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;glEnd();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;glFlush();<br>&gt; }<br>&gt;<br>[just kept one example from the above]<br><br>Isn't using boost::function overkill here? I would rather do this:
<br><br>template &lt; typename T &gt;<br>void gl_vertex( const T&amp; x , const T&amp; y , const T&amp; z )<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;// you can use the BOOST_STATIC_ASSERT as above here, or use<br>&nbsp;&nbsp;&nbsp;&nbsp;// boost::enable_if with the same condition around the void return
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;if ( boost::is_floating_point&lt; T &gt;::value )<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glVertex3d( x , y , z ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glVertex3i( x , y , z ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<br><br>or even simply this:<br>
<br>
void gl_vertex( GLdouble x , GLdouble y , GLdouble z )<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;glVertex3d( x , y , z ) ;<br>}<br><br>void gl_vertex( GLint x , GLint y , GLint z )<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;glVertex3i( x , y , z ) ;<br>}<br><br>and then:<br><br>template &lt; typename T &gt;
<br>void drawDot( const T&amp; x , const T&amp; y , const T&amp; z )<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;glBegin( GL_POINTS ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;gl_vertex( x , y , z ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;glEnd() ;<br>}<br><br>That should be more efficient and, especially for the second case, is a
<br>simpler to read overall.<br><br>Anyway, just my two cents.<br><br>--<br>Fran�ois Duranleau<br>LIGUM, Universit� de Montr�al<br><br>&quot;Sacrifices are a necessary factor in creating a new destiny. A small<br>misfortune becomes the cornerstone of a greater happiness.&quot;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Emperor Dornkirk, in _The Vision of Escaflowne_<br><br>_______________________________________________<br>Boost-users mailing list<br><a href="mailto:Boost-users@lists.boost.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
Boost-users@lists.boost.org
</a><br><a href="http://lists.boost.org/mailman/listinfo.cgi/boost-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://lists.boost.org/mailman/listinfo.cgi/boost-users</a><br><br>_______________________________________________
<br>Boost-users mailing list<br><a href="mailto:Boost-users@lists.boost.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
Boost-users@lists.boost.org</a><br><a href="http://lists.boost.org/mailman/listinfo.cgi/boost-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://lists.boost.org/mailman/listinfo.cgi/boost-users
</a><br><br></blockquote></div><br>