template<typename T>
struct has_member_foo11
{
private:
template<typename U> static auto check(int) -> decltype(std::declval<U>().foo(), std::true_type()); template<typename U> static std::false_type check(...);
public:
enum { value = std::is_same<decltype(check<T>()), std::true_type>::value };
}; //more universal template<typename T, typename... Args>
struct has_member_foo11
{
private:
template<typename U> static auto check(int) -> decltype(std::declval<U>().foo(std::declval<Args>()...), std::true_type()); template<typename U> static std::false_type check(...);
public:
enum { value = std::is_same<decltype(check<T>()), std::true_type>::value };
}; //Improve
#define HAS_MEMBER(member)\
template<typename T, typename... Args>struct has_member_##member\
{\
private:\
template<typename U> static auto Check(int) -> decltype(std::declval<U>().member(std::declval<Args>()...), std::true_type());\
template<typename U> static std::false_type Check(...);\
public:\
enum{value = std::is_same<decltype(Check<T>()), std::true_type>::value};\
}; //test code
HAS_MEMBER(foo)
HAS_MEMBER(func) struct MyStruct
{
string foo() { return ""; }
int func(int i) { return i; }
}; static_assert(has_member_foo<MyStruct>::value, "true");
static_assert(has_member_func<MyStruct, int>::value, "true");

check member function的更多相关文章

  1. Thinkphp---------Call to a member function free_result() on a non-object

    1.平时用框架用久了,直接执行原生的sql反而做起来反应迟钝了.今天遇到一个问题,就是直接执行一个添加的sql语句,然后我用了TP框架的M()->query();方法.运行以后,会报Call t ...

  2. :( Call to a member function Table() on a non-object 错误位置

    :( Call to a member function Table() on a non-object 错误位置 $Model不是模板,是你自己先前链接数据库返回的对象...我的是改为$Form

  3. Fatal error: Call to a member function bind_param() on a non-object in

    今天在练习 mysql是出现错误:   Fatal error: Call to a member function bind_param() on a non-object in 解决步骤: 1. ...

  4. Make the “Check out” function available in the office document opened with Document ID link

    I found a solution to make the “Check out” function available in the office document opened with Doc ...

  5. ECmall错误:Call to a member function get_users_count() on a non-object

    问题描述: 在后台添加了一个app报错:Call to a member function get_users_count()Fatal error: Call to a member functio ...

  6. magento后台 Fatal error: Call to a member function getId() on a non-object in错误

    后台分类管理出现错误 Fatal error: Call to a member function getId() on a non-object in 在数据库中运行以下sql语句 INSERT I ...

  7. Function语义学之member function

    之前我们讲过编译器会对 nonmember functions 进行怎样的扩充和该写,今天我们来讲一下 member functions 函数调用方式 一.Nonstatic Member Funct ...

  8. Timer.4 - Using a member function as a handler

    In this tutorial we will see how to use a class member function as a callback handler. The program s ...

  9. C++ - 模板类模板成员函数(member function template)隐式处理(implicit)变化

    模板类模板成员函数(member function template)隐式处理(implicit)变化 本文地址: http://blog.csdn.net/caroline_wendy/articl ...

随机推荐

  1. PropertyChangedCallback 只触发了一次?

    在自定义的用户控件中,添加一个依赖属性,如下: public static readonly DependencyProperty ItemsSourceProperty = DependencyPr ...

  2. 用c#开发微信 (15) 微活动 1 大转盘

    微信营销是一种新型的营销模式,由于微信更重视用户之间的互动,故而这种营销推广不不能盲目地套用微博营销的单纯大量广告推送方式.这种方式在微信营销中的效果非常差,会令用户反感,继而取消去企业或商家的微信公 ...

  3. 【ASP.NET Web API教程】6.4 模型验证

    本文是Web API系列教程的第6.4小节 6.4 Model Validation 6.4 模型验证 摘自:http://www.asp.net/web-api/overview/formats-a ...

  4. NUnit-Console 命令行选项详解

    本文为 Dennis Gao 原创或翻译技术文章,发表于博客园博客,未经作者本人允许禁止任何形式的转载. NUnit-Console 命令行选项 NUnit-Console 命令行选项列表 指定运行哪 ...

  5. Wix 安装部署(二)自定义安装界面和行为

    上一篇介绍了如何联合MSBuild来自动生成打包文件和对WIX的一些初步认识,http://www.cnblogs.com/stoneniqiu/p/3355086.html . 这篇会在上篇的基础上 ...

  6. [异常] Download interrupted: Connection to https://dl-ssl.google.com refused 安卓SDK下载被拒 3步解决

    1.SDK Manager 的 Tools ->Options打开SDK Manager的Settings,选中“Force https://… sources to be fetched us ...

  7. spring常用jar包总结(转载)

    spring.jar是包含有完整发布的单个jar 包,spring.jar中包含除了spring-mock.jar里所包含的内容外其它所有jar包的内容,因为只有在开发环境下才会用到 spring-m ...

  8. java web module of login

    Reffer to the book<java web整合开发王者归来>. It's jsp page. Offer the values of username and password ...

  9. java-一个小练习

    输出自己的姓名: public class test01 { public static void main(String[] args) { System.out.println(" # ...

  10. iOS开发---iPhone SDK 包含哪些东西?

    第一部分: 在使用Intel芯片的Macintosh计算机开发iOS应用程序所需的全部接口.工具以及资源全都包含于iPhone SDK. 苹果公司将大部分系统接口发布在框架这种特殊的数据包.一个框架就 ...