Re: [boost] [any] new version

Mathias Gaunard wrote:
You could make next_id a function with weak extern linkage, which should be able to make it work.
Thanks for the replies, I hope I fixed the linkage problems now, by making next_id() inline. There were other linker related issues, which are hopefully fixed now as well. The modified any.hpp header and a simple linker test are attached -- NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie! Jetzt informieren: http://www.gmx.net/de/go/freephone

On 01/09/2011 12:57, Martin Bidlingmaier wrote:
Mathias Gaunard wrote:
You could make next_id a function with weak extern linkage, which should be able to make it work.
Thanks for the replies,
I hope I fixed the linkage problems now, by making next_id() inline. There were other linker related issues, which are hopefully fixed now as well. The modified any.hpp header and a simple linker test are attached
Ok, so we'll assume that it works on most compilers. Now why is that better than using the standard mechanism to do this, apart from removing the requirement of having RTTI enabled?

Mathias Gaunard wrote:
Ok, so we'll assume that it works on most compilers.
Now why is that better than using the standard mechanism to do this, apart from removing the requirement of having RTTI enabled?
Performance of any_cast. In the current version of any, it looks something like this: if( content && content->type() == typeid( T ) ) return static_cast< ... >( content ); else return 0; Performancewise, it has to do the following: - check the content pointer for NULL - call virtual function type() - compare type_information Especially the latter is on the platforms I tested extremely slow. This is the proposed version: if( id == type_id< T >::value ) return static_cast< ... >( content ); else return 0; , where id is an unsigned int member variable of any. It's just an integer comparison. I've done very simple tests on gcc and vc++2010 with std::clock, and my version took about 75% less ticks than the old version on gcc and 99.8% (!) less on vc++ (I think this happened because of compiler optimizations in my special test case). I know the tests I ran were not nearly professional or accurate, but the trend is clear I guess. Testing performance is something I'm completely unexperienced with, that's why I asked for help there. In addition to changing the performance of any_cast, I added move constructors (at least on gcc), which will hopefully increase move performance. On the other hand, sizeof( any ) is now 8, not 4 ( 16/8, depending on architecture) so I suppose copying will be a little bit slower. -- NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie! Jetzt informieren: http://www.gmx.net/de/go/freephone
participants (2)
-
Martin Bidlingmaier
-
Mathias Gaunard