On Wednesday 19 January 2005 06:53, Christian Mayer wrote:
> Thanks for all the replies.
>
> They brought me on the right track.
>
> The solution I've got now is also known as the "Barton and Nackman Trick".
>
> It's a bit pervert - but totaly legal C++ code:
>
> template<typename leaftype>
> class A
> {
>   leaftype& asLeaf()
>   { return static_cast<leaftype&>(*this); }
>
> public:
>   bool foo( leaftype bar )
>   { return asLeaf().foo( bar ); }
> };
>
> class B : public A<B>
> {
> public:
>   bool foo( B bar )
>   { return /*...*/; }
> }
>
>
> The Barton and Nackman trick is important to avoid virtual function
> where they are too slow (i.e. when the additional pointer lookup hurts
> performance)
>
> CU,
> Christian
Thanks for sharing this. This prompted me to go look at my copy
of Barton and Nackman (Scientific and Engineering C++). Reminds that it
is a rather good book and I should read it more often. But I couldn't find
this trick in more than a half day trying.
Richard Harke


_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d

Reply via email to