Boost logo

Boost :

From: Daniel James (daniel_at_[hidden])
Date: 2004-09-14 12:14:08


David Abrahams wrote:
> Daniel James <daniel_at_[hidden]> writes:
>>He adds an extra type parameter to get multiple counters. The function
>>overloads are generated by friend functions of a templated class,
>>which is probably not standard compliant - it doesn't work in strict
>>mode on EDG compilers.
>
>
> Right. Boost.Python used to do that. Came as a terrible shock when
> I discovered it can't work.

Peder Holt tried to fix this by making the class a parameter to the
function, here:

http://lists.boost.org/MailArchives/boost/msg70381.php

but it still doesn't work in strict mode. I guess because it relies on
an implicit cast from int to the type, but I'm not sure. I don't fully
understand why the operators library works and this doesn't.

>>Goran Mitrovic's version declares the functions
>>in macros, so it works in strict mode, but this means you can't use it
>>from inside classes
>
>
> Because the declaration disappears when the class scope is exited and
> the counter will be reused?

Yes.

Incidently, it could be used for registering types since the type
registration macros are invoked in the global namespace. I think that's
why it was posted in the first place.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk