Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-11-16 07:10:04


Rene Rivera <grafik.list_at_[hidden]> writes:

> Peter Dimov wrote:
>
>> Rene Rivera wrote:
>> [...]
>>
>>> #include <boost/named_params.hpp>
>>>
>>> struct name_t; // tag types
>>> struct value_t;
>>>
>>> namespace {
>>> boost::keyword<name_t> name; // keyword objects
>> boost::keyword<struct name_t> name;
>> is even better. ;-)
>
> Yes it is :-) -- But I was going under the suggestion in the docs:
>
> [Note: the tag types should generally not be declared in an unnamed
> namespace]
>
> It would be nice to see a rational for that note in the docs. Only one
> I can think of is the increased number of keyword objects, and
> possibly increased number of the function instantiations.

It's an ODR thing. If you then use the parameter names in a function
template that's not in an unnamed namespace but _is_ in multiple TU's,
you have technically violated the ODR.

In general, types in header files had better stay out of the unnamed
namespace.

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

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