
On Thu, Feb 12, 2009 at 6:13 PM, vicente.botet <vicente.botet@wanadoo.fr>wrote:
----- Original Message ----- From: "Gokulakannan Somasundaram" <gokul007@gmail.com> To: <boost@lists.boost.org> Sent: Thursday, February 12, 2009 1:33 PM Subject: Re: [boost] Request For a feature - Templated virtual functions
On Thu, Feb 12, 2009 at 4:00 PM, Mathias Gaunard < mathias.gaunard@ens-lyon.org> wrote:
Gokulakannan Somasundaram wrote:
Thanks for pointing me to Boost.Variant. But let me just try to clarify
my
understanding on Boost Variant. It is a kind of union data type, where we store the data and its type together. Whenever we retrieve the data, it does a switch-case lookup and type-casts the data to that type. In my opinion, the switch-case is equivalent to a virtual table lookup. They should be having more or less the same runtime penalty.
Indeed. A switch-case is actually faster than a virtual table lookup, however.
I did a small test in my system and the virtual function method proved to be slightly better than using boost::variant. The difference can be ignored, but then there is no use in switching to boost::variant. The method i suggest is simple, it just replaces the virtual function overloading with templates and hence it would provide better performance and better maintenance.
Hi,
I'm interested.
Could you show more :) Best, Vicente
Hi, Sorry! I don't get you. i have just made a feature request, to allow templates in virtual functions, if the knowledge of the classes involved is known at Compile time and waiting for someone to take up my request :) Thanks, Gokul.