
on Thu Jun 14 2007, Eric Niebler <eric-AT-boost-consulting.com> wrote:
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.
I don't think there ever was any question about that. At least, I never had a question about it. References don't have any identity distinct from the object they reference. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com The Astoria Seminar ==> http://www.astoriaseminar.com