how to implement is_pointer?

后端 未结 4 1290
长情又很酷
长情又很酷 2020-12-31 19:09

I want to implement is_pointer. I want something like this:

template 
bool is_pointer( T t )
{
   // implementation
} // return true or fa         


        
4条回答
  •  有刺的猬
    2020-12-31 19:35

    You can use "typeid" operator defined in typeinfo.h for this. check this link : http://en.wikipedia.org/wiki/Typeid

    The typeid operator will give an object of std::type_info class, which has a name() function returning char *. Once you get the type in string form, you can identify the pointer easily.

    Hope it helps.

    Romil.

提交回复
热议问题