c++模板中的百分号(%)和尖号(#)是什么意思?
what is the meaning of percent symbol(%) and sharp symbol(#) in c++ template
下面是来自MS VC的代码:
template<typename _Fun_t,
typename _Arg_t> inline
binder1st<_Fun_t> bind1st(_Fun_t% _Func, _Arg_t _Left)
{ // return a binder1st functor adapter
typename _Fun_t::first_argument_type _Val = _Left;
return (binder1st<_Fun_t>(_Func, _Val));
}
和QT:
#define Q_ARG(type, data) QArgument<type >(#type, data)
这些都不是模板所特有的。
'%'是c++的Microsoft扩展,是c++/CLI的一部分。它定义了一个跟踪引用。T&
类型的正常左值引用变量是对另一个变量的引用;T%
也是如此,除了它指向一个可能被垃圾回收器移动的托管对象;GC知道,当它移动对象时,它必须修补对该对象的所有跟踪引用。
'#'是C预处理器的字符串化操作符。它表示下面的宏参数的值,用双引号括起来。所以这:
Q_ARG(MyType, 12345)
将展开为:
QArgument<MyType >("MyType", 12345);
相关文章:
- 这个语法std::class<>{}(arg1, arg2) 在C++中是什么意思?
- 标准 N3337 5.2.10 第 7 条中的C++"类型"是什么意思?
- "类模板示例<int>;"语句对 C++11 是什么意思?
- 线应该是什么意思
- "CID"在AT+HTTPPARA= "CID" ,1中是什么意思
- 表达式"b=(b-x)&x"是什么意思?
- 这个表达是什么意思?
- 此代码验证公式是什么意思?
- 跟踪日志中的T.11803()是什么意思?
- 这个额外的关键字在这个 c++ 类声明中是什么意思?
- * 和 ** 在 C++ 函数声明中是什么意思?
- _T("xyz")是什么意思?
- #define Dbg(fmt,..) (0) 是什么意思? 警告:表达式无效
- 这行代码到底是什么意思?
- 在命名空间名称之前加上 :: 是什么意思?
- 从字符数组的元素中减去'a'是什么意思
- "friend"关键字在C++中是什么意思?
- 减法中的"0"是什么意思?
- 字符数组前面的加号是什么意思?
- 这里的字符串函数是什么意思