Hi,
Dirk Reiners wrote:
Hi Akos,
On Wed, 2005-07-13 at 14:28 +0200, Akos Balazs wrote:
OK, attached. I'm fairly confident about the patches to the header files,
but I'm still baffled why do you need to omit the static qualifier from
the templated function in OSGExtrusionGeometry.cpp.
It's little weird, but nothing I'm going to lose sleep over. Given that
there is no external prototype for that function I don't think it's a
problem.
I read something about this, on the boost mailing list (thread starts
here: http://article.gmane.org/gmane.comp.lib.boost.devel/127379).
I'll quote the two mails that cover the main point here:
****
quote from Steve Clamage <Stephen.Clamage <at> Sun.COM>
template <typename T>
struct S
{
void foo(int);
};
template<class T , class U>
static // static template ...
void smart_cast_reference(U& u)
{}
template <typename T>
void S<T>::foo(int c)
{
smart_cast_reference< T& >(c); // used in global function
}
int main()
{
S<int> s;
s.foo(1);
}
You can't use a static template in a global template function because it
violates the One-Definition Rule, among possibly other rules. I have
found that
other compilers accept this code, but reject it when you put them in
standard-conformning mode. (To see the rejection with some compilers,
you need
to build the executable.)
****
quote from Steve Clamage <Stephen.Clamage <at> Sun.COM>
Slightly different and simplified example:
template<class U>
static void smart_cast_reference(U& u) {}
template <typename T>
void foo(int c)
{
smart_cast_reference<int>(c);
}
Suppose (global) template foo is instantiated in more than one translation
unit. Since smart_cast_reference does not have external linkage, not all
instances of foo can refer to the same instance of
smart_cast_reference<int>,
and the one definition rule is violated.
***
Carsten
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users