问一下这里的using怎么理解

C++语言 码拜 7年前 (2017-04-14) 1158次浏览
本人在看c++ Primer中关于文本查询程序的时候看到这么一段代码:
class TextQuery
{
public:
using line_no = std::vector<std::string>::size_type;
private:
std::shared_ptr<std::vector<std::string>> file;
std::map<std::string, std::shared_ptr<std::set<line_no>>> wm;
public:
TextQuery (std::ifstream&);
QueryResult query(const std::string&) const;
};
本人不理解这里的用法。谁能指点一下?谢谢!
解决方案

10

相当于 typedef std::vector<std::string>::size_type line_no; 但 using 还可以接受模板参数

10

定义别名,相似typedef,Since C++11
http://en.cppreference.com/w/cpp/language/type_alias

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明问一下这里的using怎么理解
喜欢 (0)
[1034331897@qq.com]
分享 (0)