有个参数,需要判断其Value是否为指针,如果是做相应的处理。

代码示例如下,后来发现is_pointer在std空间中。

#include <stdio.h>
#include<iostream>
#include<vector>
template<typename T>
struct is_pointer { static const bool value = false; };

template<typename T>
struct is_pointer<T*> { static const bool value = true; };

template<typename T>
void func(T& v) {
    std::cout << "is it a pointer? " << is_pointer<T>::value << std::endl;
}
int main(int argc, char *argv[])
{
    __uint128_t x = 1111UL;
    printf("%llu\n", x);
    func(x);
    return 0;
}

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-13
  • 2021-10-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-21
  • 2022-12-23
相关资源
相似解决方案