Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2007-12-03 10:38:09


Michael Marcin wrote:
> Tobias Schwinger wrote:
>> 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.
>>
>
> I think the compiler is allowed to check for an incomplete type before
> it is instantiated. I believe this is the same problem that fusion
> as_vector had a while ago.
>
> http://article.gmane.org/gmane.comp.lib.boost.devel/166502
>
>> Got some code that fails to compile?
>
> Yes,
>
> #include <boost/utility/singleton.hpp>

OK, I'll just move the definitions - the code also becomes more readable
this way.

>>> 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".
>
> Hmm didn't expect that since the standard says its the same as declaring
> it inline just after the class's closing ';' IIRC. Out of curiosity do
> you remember what compilers do this?

GCC's '-fno-default-inline' causes the compiler to stop inlining without
keyword (won't affect linkage).

BCC has a similar option, and I don't remember about MSVC but there
might be more compilers that have.

Regards,
Tobias


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