Re: boost::function_types::parameter_types 怎麼 …
※ 引述《yoco315 (眠月)》之銘言:
: boost::function_types::parameter_types<int(int,double)>::type
: 可以取到 mpl::vector2<int, double>
: 實在很好奇他是怎麼做到的
: 我看了一下 source code 但是看不出個毛 /_\
: 有沒有前輩可以稍微提示一下....
: 一般的 traits 我都還可以想像他是怎麼做的,
: 但是把函數的參數串列取出來到底是怎麼弄的 T_T
我猜是這樣
template<typename F>
struct parameter_of;
template<>
struct parameter_of<int()>
{
typedef void type;
};
template<typename FArgs>
struct parameter_of<int(FArgs)>
{
typedef FArgs type;
};
int main()
{
std::vector<parameter_of<int(double)>::type> vec;
return 0;
}
然後列舉所有不同回傳型別的function...(逃~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.204.92.148
→
07/19 00:33, , 1F
07/19 00:33, 1F
→
07/19 00:33, , 2F
07/19 00:33, 2F
→
07/19 00:34, , 3F
07/19 00:34, 3F
→
07/19 00:34, , 4F
07/19 00:34, 4F
→
07/19 00:35, , 5F
07/19 00:35, 5F
→
07/19 00:35, , 6F
07/19 00:35, 6F
→
07/19 00:37, , 7F
07/19 00:37, 7F
→
07/19 00:37, , 8F
07/19 00:37, 8F
推
07/19 00:39, , 9F
07/19 00:39, 9F
推
07/19 01:35, , 10F
07/19 01:35, 10F
→
07/19 09:32, , 11F
07/19 09:32, 11F
推
07/19 12:57, , 12F
07/19 12:57, 12F
討論串 (同標題文章)