Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2007-12-03 01:55:30


Michael,

Michael Marcin wrote:
> I ran into a compiler problem using the singleton library from the vault.
>
> singleton's constructor and destructor use instance_proxy before it is
> defined. The trivial fix is to make the definition of the constructor
> and destructor inline function at the bottom of the file (i.e. after
> instance_proxy is defined).

Actually, that shouldn't be a problem since 'singleton' is a template
and things are complete once it's instantiated.

Got some code that fails to compile?

>
> singleton_manager.hpp causes warning under msvc 8.0 in the
> singleton_manager::cleanup function:
>
> warning C4706: assignment within conditional expression
>
> for
>
> while (!!(i = ptr_instance->ptr_first))
>
> if this could be rewritten without much effort to silence the warning it
> would be nice.

Yes (where interestingly the compiler could figure out this is not a
typo here because of the '!!')...

Maybe

     while ((i = ptr_instance->ptr_first) != 0l)

will do the trick...

>
> Nit - there seems to be a lot of extraneous inline keywords for
> functions defined inside the class definition.

...intentionally, because some compilers (under certain configurations)
distinguish between "implicit" inline and "inline by keyword".

>
>
> The library has proven quite useful.
>

Thanks for your feedback.

Regards,
Tobias


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