c++ - Compare pointers by type? -
how compare 2 pointers see if of same type?
say have...
int * a; char * b;
i want know whether or not these 2 pointers differ in type.
details:
i'm working on lookup table (implemented 2d void pointer array) store pointers structs of various types. want use 1 insert function compares pointer type given types stored in first row of table. if match want add pointer table in column.
basically want able store each incoming type own column.
alternative methods of accomplishing welcomed.
in case, since know types before hand, doesn't make sense check. can proceed knowing different types.
however, assuming perhaps types may dependent on compile-time properties template arguments, use std::is_same
:
std::is_same<decltype(a), decltype(b)>::value
this true
if same type , false
otherwise.
Comments
Post a Comment