Boost logo

Boost :

Subject: Re: [boost] Request For a feature - Templated virtual functions
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-02-12 07:43:06

----- Original Message -----
From: "Gokulakannan Somasundaram" <gokul007_at_[hidden]>
To: <boost_at_[hidden]>
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_at_[hidden]> 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.


I'm interested.

Could you show more :)

Boost list run by bdawes at, gregod at, cpdaniel at, john at