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. csc一些命令简记

    C#在命令行进行编译的一些命令: csc使用详解 @echo off cd / cd C:\Program Files (x86)\MSBuild\12.0\Bin set /p var= 请输入文件 ...

  2. ajax异步请求Response.Redirect重定向

    一个ajax异步请求报错->捕获异常->重定向错误提示页面.  一个简单的流程 结果一直搞不定.重定向无效.各种百度之. 后来突然想起 ajax的请求是不能在后台重定向的. 如果硬要重定向 ...

  3. IFrame 高度自适应的两种方式 .

    iframe 高度自适应一般是指: iframe 本身的高度 =  内容高度. 这样做可以使最外层不出现滚动条. 如果网页内容使用了Ajax方式填充内容的话. 由于内容是动态的. 以上方式应该变为: ...

  4. console.log 被重写覆盖以后如何恢复

    有时候一些项目中会使用类似如下的方式覆盖掉console对象: var console = {}; console.log = function(){}; console.info = functio ...

  5. [ACM_几何] UVA 11300 Spreading the Wealth [分金币 左右给 最终相等 方程组 中位数]

    Problem A Communist regime is trying to redistribute wealth in a village. They have have decided to ...

  6. 【原】关于使用Sklearn进行数据预处理 —— 缺失值(Missing Value)处理

    关于缺失值(missing value)的处理 在sklearn的preprocessing包中包含了对数据集中缺失值的处理,主要是应用Imputer类进行处理. 首先需要说明的是,numpy的数组中 ...

  7. mysql 5.6.17 x64 安装

    下载地址 百度网盘地址:http://pan.baidu.com/share/link?shareid=1895747668&uk=3257050114&fid=234538452 官 ...

  8. MVC 添加 httpHandlers 支持 .aspx 页面访问

    <?xml version="1.0"?> <!-- For more information on how to configure your ASP.NET ...

  9. python中的metaclass

    首先看下面的代码: # coding: utf-8 class Test(object): pass print Test.__class__ # type print Test.__base__ # ...

  10. JPA 不在 persistence.xml 文件中配置每个Entity实体类的2种解决办法

    在Spring 集成 Hibernate 的JPA方式中,需要在persistence配置文件中定义每一个实体类,这样非常地不方便,远哥目前找到了2种方法.   这2种方式都可以实现不用persist ...