Boost logo

Boost :

From: Andrey Semashev (andysem_at_[hidden])
Date: 2007-04-05 14:43:36


Hello Michael,

Thursday, April 5, 2007, 10:17:29 PM, you wrote:

> On 4/5/07, Matthias Schabel <boost_at_[hidden]> wrote:
>> > http://thread.gmane.org/gmane.comp.lib.boost.devel/101946/focus=102070
>> >
>> > Would that be enough? Usage would look like:
>> >
>> > #include BOOST_UNITS_ORDINAL_GENERATOR()
>> > struct my_unit : ordinal<BOOST_UNITS_NEXT_ORDINAL>
>> > {
>> > };
>>
>> I believe the problem with this is that it doesn't guarantee
>> uniqueness across translation units; Steven understands these issues
>> better than I do, though.

> I think that problem only arises if you actually define units in a
> source file instead of a header file. That shortcoming could just be
> documented, since it seems pretty rare that someone would define their
> custom unit in a source file instead of a header. If they really
> wanted to do that, they could still just use the current method.

> A quick test with VC8.0 just now shows that even __COUNTER__ has that
> problem when used in source files, but in headers Paul M.'s method
> works just fine.

Does it work if headers are included in different order? I.e.

// file1.cpp
#include "header1.h" // Here I use ordinal<BOOST_UNITS_NEXT_ORDINAL>
#include "header2.h" // Here I use it too

// file2.cpp
#include "header2.h"
#include "header1.h"

I should have the same ordinals for corresponding units in both TUs.

-- 
Best regards,
 Andrey                            mailto:andysem_at_[hidden]

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