This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: ordering of constructors
- From: Theodore Papadopoulo <Theodore dot Papadopoulo at sophia dot inria dot fr>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: Neal Becker <ndbecker2 at verizon dot net>, gcc at gcc dot gnu dot org
- Date: Fri, 09 Apr 2004 16:24:15 +0200
- Subject: Re: ordering of constructors
> Why not put a function call in the constructor for A that make sure B
> initialized?
A simpler technique is to wrap the static members into functions
returning the static member ie:
struct A {
typedef whatever B;
static B& get_member() {
static B static_member;
return B;
}
};
This has solved the problem of static member ordering for me once
for all. I just wonder why this approach is not used transparently
by the compiler for all static members.... Maybe there is some hidden
cost I do not see... Presumably, the implementation of function static
members requires a boolean per member... Never went to see how this
is done.
--------------------------------------------------------------------
Theodore Papadopoulo
Email: Theodore.Papadopoulo@sophia.inria.fr Tel: (33) 04 92 38 76 01
--------------------------------------------------------------------