C++11 书籍符号

C++11 book notation

本文关键字:符号 C++11      更新时间:2023-10-16

有人可以向我解释Stroustrup书中的这个符号吗?

template<typename Cont, typename Pred>
std::vector<Value_type<Cont>*>
find_all(Cont& c, Pred p)
{
std::vector<Value_type<Cont>*> res;
for(auto& x :c)
if(p(x)) res.push_back(&x);
return res;
}

我应该如何理解这里的value_type?这不是来自C++的关键字,也不是Cont::value_type,然后呢?

例子是C11 Bjarne Starstroup书。 第 32.2 章 算法片段 4th.

参见本书的28.2.4。

template<typename T>
using Value_type = typename std::iterator_trait<T>::value_type;