文章目录
约束模板友元函数变量命名规范
约束模板友元函数
template <class T, class Distance = ptrdiff_t
>
class istream_iterator {
friend bool
operator== __STL_NULL_TMPL_ARGS
(const istream_iterator
<T
, Distance
>& x
,
const istream_iterator
<T
, Distance
>& y
);
}
bound friend function template 译为约束模板友元函数
模板类的友元分 3 类:
非模板友元,无论模板类通过什么类型来进行实例化,都是这些实例化的友元。约束 (bound) 模板友元,即友元的类型取决于类被实例化时的类型。非约束 (unbound) 模板友元,即友元的所有具体化都是类的每一个具体化的友元。
详情可参考此文 模板类和友元函数再探 。
变量命名规范
template <class T>
class ostream_iterator {
protected:
ostream
* stream
;
const char* string
;
...
}
C++ 语言保留了一些名字供语言本身使用,这些名字不能被用作标识符。string 并不是 C++ 的关键字。
C++ Primer, p42 ↩︎