Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-07-08 10:51:28


The original case was exemplified by the following example:

<quote>

template<class U>
static void smart_cast_reference(U& u) {}

template <typename T>
void foo(int c)
{
   smart_cast_reference<int>(c);
}

Suppose (global) template foo is instantiated in more than one translation
unit. Since smart_cast_reference does not have external linkage, not all
instances of foo can refer to the same instance of
smart_cast_reference<int>,
and the ODR is violated.

I'm pretty sure there is a name-lookup rule that makes this test case
invalid,
but I haven't found it yet. (Still looking.)

</quote>

Note that this NOT what the serialization library is in fact doing. What is
typical in that library is:

template<class T>
class x {
    static Y y;
};

template<class T>
Y x:y;

and variations of the above. I don't see any relation between this and the
original example used above.

Robert Ramey


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