Boost logo

Boost :

Subject: Re: [boost] [type_traits] is_complete<T> possible realization
From: John Maddock (boost.regex_at_[hidden])
Date: 2012-11-09 12:17:09

>> What if I do in another TU is_complete<incomplete, __LINE__> at the same
>> line number and when incomplete is actually complete?
> You can always add some more misc template parameters:
> void foo1() {
> struct unique_foo1_tag;
> cout
> << is_complete<incomplete, __LINE__, unique_foo1_tag>::value
> << is_complete<incomplete_template<0> , __LINE__,
> unique_foo1_tag>::value
> << is_complete<incomplete_template<1> , __LINE__,
> unique_foo1_tag>::value
> << is_complete<complete, __LINE__, unique_foo1_tag>::value
> << is_complete<complete_abstract, __LINE__,
> unique_foo1_tag>::value
> << endl;
> }
> And you can also use __COUNTER__ on MSVC.

__COUNTER__ won't do what you want across multiple TU's. The problem runs

Translation Units a.cpp and b.cpp each instantiate a function foo<T> which
uses is_complete<U>, but U is complete in TU a.cpp, and incomplete in b.cpp
(because they include different headers). You now have an insidious ODR
violation which would be very hard to diagnose and track down - which
version of foo<T> is the correct one?


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