Suppose I am a user of a Certain Template Library (CTL
) which defines a template, named, say, Hector
template <class T>
class Hector {...};
And in its documentation it gives many guarantees about Hector
template behavior.
But then it also defines a specialization for a certain type Cool
template <>
class Hector<Cool> {....};
The purpose of the specialization is a more optimized implementation of Hector
, but unfortunately because of this optimization many guarantees of Hector
are violated.
Currently I really don't need the optimization, I'd rather preserve all the guarantees of Hector
. Is there any way I could, without changing the library code (CTL
is a highly respectable library, you know), circumvent the specialization? Any way at all? Maybe write some sort of wrapper? Anything? I just want to the compiler to generate code for Hector<Cool>
in a normal, non-optimized way, with all the guarantees.
question from:
https://stackoverflow.com/questions/6499007/circumventing-template-specialization 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…