Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-07-04 19:25:52

Bronek Kozicki wrote:
> Peter Dimov wrote:
>> I suspect there is something I'm missing. Let's use examples:
>> // file1
>> struct tag1;
>> set<tag1>();
>> // file2
>> struct tagl;
>> get<tagl>(); // NULL
>> How can the compiler know that you misspelled tag1 as tagl? It can't.
> Indeed, but you can put tag1 in a separate header file and then
> include it. Had you used name nested into namespace (or type) that
> solution would be more obvious. To force it I even proposed to
> require complete type, but I do not insist that it's better (it's
> just different). The point of using tag is that compiler CAN help you
> to guarantee name uniqueness and provide name check. Compiler will
> not help you if you do not ask for it (like in your example). But at
> least you CAN use it, it will provide benefits and will NOT force you
> to use centralized location for all tags or build complex
> infrastructure - simple C++ design with nested names will suffice.
> If you use string, compiler will NOT help at all - no name check and
> no uniqueness warranties, unless you have single centralized location
> to store all strings and/or build complex infrastructure to manage
> their uniqueness.

How does your compiler help you spot duplicate tags? Most don't diagnose ODR
violations, and if your tags aren't complete, there isn't even an ODR

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