template <class T> class A;
template <class T> void f3(A<T>& a) { ... }
template class<T>
class A
{ T x,y;
......
friend void f1(A<T>& a); //友元f1不是模板!
template <class T1> friend void f2(A<T1>& a); //f2与A多对多实例化
friend void f3<T>(A<T>& a); //f3与A一对一实例化(用相同参数类型)
};
void f1(A<int>& a) { ... }
template <class T> void f2(A<T>& a) {...}
......
A<int> a1; //实例化A<int>
A<double> a2; //实例化A<double>
f1(a1); //OK,调用f1(A<int>&)
f1(a2); //链接错误! 调用f1(A<double>&),但它不存在!
f2(a1); //实例f2<int>是A<int>和A<double>的友元
f2(a2); //实例f2<double>是A<int>和A<double>的友元
f3(a1); //实例f3<int>是A<int>的友元,但不是A<double>的友元!
f3(a2); //实例f3<double>是A<double>的友元,但不是A<int>的友元!
size();
T& front();
T& back();
void push_front(const T& x);
void pop_front();
void push_back(const T& x);
void pop_back();
void push(const T& x);
void pop();
T& top();
iterator begin();
iterator end();
iterator insert(iterator pos, const T&x );
iterator insert(iterator pos, InputIt first, InputIt last);
iterator erase(iterator pos);
iterator erase(iterator first, iterator last);
T& operator[](size_type pos);
ValueType& operator[](const KeyType& key);
T& at(size_type pos); //越界检查
iterator find(const T& key);
//调序算法
void sort(RanIt first, RandIt last); //<
void sort(RanIt first, RandIt last, BinPred less);
//编辑算法
OutIt copy(InIt src_first, InIt src_last, OutIt dst_first);
//查找算法
//算术算法
size_t count_if(InIt first, InIt last, Pred cond);
//集合算法
//堆算法
//元素遍历算法
Fun for_each(InIt first, InIt last, Fun f);
T accumulate(InIt first, InIt last, T val); //+
T accumulate(InIt first, InIt last, T val, BinOp op);
OutIt transform(InIt src_first, InIt src_last, OutIt dst_first, Op f);
OutIt transform(InIt1 src_first1, InIt1 src_last1, InIt2 src_first2, OutIt dst_first, BinOp f);
//lambda 表达式
count_if(students.begin(),students.end(),[](Student &st) { return (st.get_major() == COMPUTER) && (st.get_sex() == FEMALE); });