绵羊之国,黄山四绝是什么,炒股软件销售
//function_traits.h,获得函数返回值类型、参数tuple、成员函数指针中的对象类型
//参考https://github.com/qicosmos/cosmos/blob/master/function_traits.hpp,进行了精简和补充
#pragma once
#include <functional>
#include <tuple>
//类模板原型
template<typename t>
struct function_traits;
//普通函数
template<typename ret, typename... args>
struct function_traits<ret(args...)> {
typedef ret return_type;
typedef std::tuple<std::remove_const_t<std::remove_reference_t<args>>...> bare_tuple_type;
};
//函数指针
template<typename ret, typename... args>
struct function_traits<ret(*)(args...)> : function_traits<ret(args...)>{};
//std::function.
template <typename ret, typename... args>
struct function_traits<std::function<ret(args...)>> : function_traits<ret(args...)>{};
//成员函数,以及成员函数指针中的对象类型
#define function_traits(...)\
template <typename ret, typename obj, typename... args>\
struct function_traits<ret(obj::*)(args...) __va_args__> : function_traits<ret(args...)>\
{ typedef obj object_type; };
function_traits()
function_traits(const)
function_traits(volatile)
function_traits(const volatile)
//函数对象
template<typename callable>
struct function_traits : function_traits<decltype(&callable::operator())>{};
template <typename fun>
typename function_traits<fun>::stl_function_type to_function(const fun& lambda) {
return static_cast<typename function_traits<fun>::stl_function_type>(lambda);
}
template <typename fun>
typename function_traits<fun>::stl_function_type to_function(fun&& lambda) {
return static_cast<typename function_traits<fun>::stl_function_type>(std::forward<fun>(lambda));
}
template <typename fun>
typename function_traits<fun>::pointer to_function_pointer(const fun& lambda) {
return static_cast<typename function_traits<fun>::pointer>(lambda);
}
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
如何在没有core文件的情况下用dmesg+addr2line定位段错误
用QT制作3D点云显示器——QtDataVisualization
网友评论