
----- Mensaje original ----- De: Eric Niebler <eric@boost-consulting.com> Fecha: Jueves, Junio 14, 2007 10:57 pm Asunto: Re: [boost] Unnamed namespaces? Para: boost@lists.boost.org
David Abrahams wrote:
on Thu Jun 14 2007, Eric Niebler <eric-AT-boost-consulting.com> wrote:>
template<typename T> struct static_const { static T const value; };
template<typename T> T const static_const<T>::value = {};
struct placeholder {};
// This is *supposed* to be statically initialized but many // compilers do dynamic initialization for it. :-( placeholder const &_1 = static_const<placeholder>::value;
I thought it was just MSVC. Any others?
Shoot, now I can't remember. How many did we test? Well, this much is certain, there is at least one compiler that does dynamic initialization for it. :-/
I also seem to recall that there was still some question as to whether the use of the reference violated the ODR, if the reference is not optimized away. I don't think we ever got an answer to that question.
Maybe the following is not relevant to the discussion, but I recall a post by Anthony Williams which shows how to create a _1-like global entity in an entirely ODR-abiding way: http://lists.boost.org/Archives/boost/2006/07/108355.php HTH, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo