I have this template class:
template <class Tin, class Tout>
class Foo
{
Tin input;
Tout output;
static inline void __ensure_type_consistency
{
int16_t* p = (int16_t *)0;
Tin* check_type_in = p;
Tout* check_type_out = p;
}
public:
...
}
I want to make sure Tin, and Toutboth types of typedef'd gain int16_trather than any other type. ( NOTE: read the full question before proceeding to the conclusions)
If I uncomment the commented line, I get the error as expected; the compiler does not allow to assign pointers of different types to each other without casting:
"src\foo.h", line 47: error
cannot be used to initialize an entity of type "uint16_t *"
But if I leave it commented out and I create an instance:
Foo<uint16_t, int32_t> illegalFoo;
I don't get compiler errors, although the same type of check is used (creating an incompatible pointer assignment in a static function that never gets called, but which should cause compiler errors)
? , , ?
. . "" , , typedefs : , Foo.input Tin, Tin int16_t, typedef, int16_t, Foo.output Tout. , typedef'd , ++ .
edit:, , , Boost. ++ 0x.