M
ma740988
I was trying to garner a feel for typeid and it's use with polymorphic
types
#include <iostream>
template <class T>
bool is_polymorphic() {
bool result(false);
typeid( (result=true), *(T*)0);
return result;
}
struct non_polymorphic {};
struct polymorphic { virtual ~polymorphic() {} };
int main() {
std::cout << is_polymorphic<int>() << '\n';
std::cout << is_polymorphic<non_polymorphic>() << '\n';
std::cout << is_polymorphic<polymorphic>() << '\n'; //
3
}
..NET throws an bad_typeid exception when it encounters the line ' //3.
The exception:
// file dbgheap.c
pvBlk = _heap_alloc_dbg(nSize, nBlockUse, szFileName, nLine);
Now the use of typeid " typeid( (result=true), *(T*)0); " - seems
funny to me so I'm still trying to understand it, nonetheless the
question: Why would I get a bad_typeid exception here?
Perhaps OT hence my apologies upfront.
The entire boost library if memory serves is 7 mebibytes when built.
It's appears that because of all the dependencies, it's not possible
for me to pick out piece parts - for instance the serialization (at
present that's all I'm interested in using) library. Am I incorrect on
this?
types
#include <iostream>
template <class T>
bool is_polymorphic() {
bool result(false);
typeid( (result=true), *(T*)0);
return result;
}
struct non_polymorphic {};
struct polymorphic { virtual ~polymorphic() {} };
int main() {
std::cout << is_polymorphic<int>() << '\n';
std::cout << is_polymorphic<non_polymorphic>() << '\n';
std::cout << is_polymorphic<polymorphic>() << '\n'; //
3
}
..NET throws an bad_typeid exception when it encounters the line ' //3.
The exception:
// file dbgheap.c
pvBlk = _heap_alloc_dbg(nSize, nBlockUse, szFileName, nLine);
Now the use of typeid " typeid( (result=true), *(T*)0); " - seems
funny to me so I'm still trying to understand it, nonetheless the
question: Why would I get a bad_typeid exception here?
Perhaps OT hence my apologies upfront.
The entire boost library if memory serves is 7 mebibytes when built.
It's appears that because of all the dependencies, it's not possible
for me to pick out piece parts - for instance the serialization (at
present that's all I'm interested in using) library. Am I incorrect on
this?