Boost logo

Boost :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2006-09-29 09:44:15


"David Abrahams" <dave_at_[hidden]> wrote

> Yeah, but be really careful, because there are only a few good ways
> to use an unnamed namespace in a header. In fact, the only legitimate
> way to fix the Boost.Bind placeholder issue for header-only libs,
> without ODR or order-of-initialization issues, is:
>
> // placeholders.hpp
> template <class SomePOD>
> static pod_singleton
> {
> const SomePOD instance;
> };
>
> template <class SomePOD>
> SomePOD const pod_singleton::instance = { /*optional contents*/ };
>
> namespace
> {
> some_pod const& _1 = pod_singleton<some_pod>::instance;
> }
>
> That's an unnamed namespace in a header.

Why doesn't it have ODR issues? Isn't it still possible to cause ODR
violation by using _1 inside a class/template definition in a header?

Regards,
Arkadiy


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