|
Boost : |
From: Iulian M (eti_at_[hidden])
Date: 2007-04-05 06:12:06
On Thursday 05 April 2007, Kevin Yuan wrote:
> > 2007/4/4, Martin Bonner <Martin.Bonner_at_[hidden]>:
> > Static variable in an inline function.
>
Am I missing something or static variables in inline functions are considered
BAD PRACTICE?
> Yes, I agree. Something like:
>
> // st.h
> class st
> {
> private:
> st(){}
> public:
> static st* get_instance()
> {
> static st* inst = new st;
> return inst;
> }
> };
IIRC if get_instance() will be inlined and 2 translation units will have their
own copy of get_instance() then there will be two st instances in the finall
app... witch in case of a singleton is BAD.
ps: i only had 2 zips of coffee so i might be missing something ...
-- Best Regards, Iulian Margarintescu http://www.erata.net eti_at_[hidden] (spamassassin & pf & spamd all said it's OK to make it public ;-) ) Key ID: 0x03176E5CEDEFF7AB I prefer plain text email
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk