
On Fri, Nov 9, 2012 at 12:18 PM, Matt Calabrese <rivorus@gmail.com> wrote:
While the above code might seem contrived, it could definitely happen when dealing with forward declarations of classes. Because of this, I'd recommend in general only using a completeness checker with something like a static_assert anyway, forcing compilation to fail when you don't get the result that you'd expect, otherwise you have to be extremely careful.
In case it wasn't clear, I was implying in the code sample that the template was instantiated with foo in both translation units (forgot to show that). Since in one translation unit foo is incomplete and in the other it is complete, you could potentially violate ODR by producing a different definition for you_code< foo > in each translation unit. Of course, you could get around this by using the ODR trick from the completeness checker (putting the call to the metafunction in a default argument to the template), but then you're effectively pushing out the problem to a higher-level. In order to be completely safe, you'd have to propagate the checking all the way out to the top level instantiation. -- -Matt Calabrese