Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2008-07-11 10:28:46

on Thu Jul 10 2008, Steven Watanabe <> wrote:

> I'm looking at two recent posts:
> Either of these is fine by itself, but putting them both
> together makes it very easy to cause silent ODR
> problems.

Heh, I just noticed the same issue.

> For example in translation unit a.cpp we
> #include "boost/tuple/tuple_io.hpp"
> and translation unit b.cpp we forget. Then, along comes
> boost::any which detects operator<< in translation
> unit a.cpp, but uses its default in translation unit
> b.cpp. Ka-Boom.
> This is not a huge problem at the moment, because it's
> quite difficult to make the detection bullet-proof,

I don't think that accurately characterizes the issue. I think few
compilers do anything to detect ODR violations. However, link-time
stripping of common template instantiations (or link-time instantiation)
seems likely to cause only a single behavior in both TUs where two
behaviors may have been intended.

> but I'm very concerned because C++0x concepts
> are supposed to make such overloading easy.

I'm not sure I see the relationship to C++0x concepts. Care to say

Dave Abrahams
BoostPro Computing

Boost list run by bdawes at, gregod at, cpdaniel at, john at