cpp可变参笔记

C:

void war(int m,...){
    printf("%d\n",m);
    printf("%d\n",*(&m+1));
    printf("%d\n",*(&m+2));
}
//就像数组一样取。原理麻 就是m的地址+1,当然,由于数组的数量未知,很容易多取,所以在传的时候未尾加NULL


 Cpp:

template<typename... Types>
void ADbLink::PrintfLog(char* s, Types ...Args) {
    Printf(s,Args)
}

 

为了确定每个参数的类型(SIZE),得以从正确位置读取参数,

其中class... Args 表示变长参数模板,函数参数中Args&& 为右值引用。std::forward<Args> 实现参数的完美转发。

Cpp 可变参模板  解释

https://www.cnblogs.com/kevonyang/p/5932059.html

 

Cpp可变参 使用

https://www.cnblogs.com/qicosmos/p/4325949.html

by 2019/12

posted @ 2013-09-29 15:00  晨祷  阅读(254)  评论(0编辑  收藏  举报