VS2012如何通过智能感知显示标准c++库的文档
VS2012 how to show documentation of standard C++ libraries via IntelliSense?
我几天前开始用Visual Studio 2012学习c++。我习惯于用IntelliJ IDEA编程Java,在调用方法时,你总是会看到文档和预期的参数。是否有一种方法也可以在VS2012中为c++做到这一点?
如果我理解正确的话,由于智能感知,这应该已经显示出来了但如果我调用向量或字符串的成员函数它只会显示如下内容:
public: std::vector<std::string, std::allocator<std::string>>::const_iterator std::vector<std::string, std::allocator<std::string>>::begin() const
但是没有指明返回什么,期望什么,这个函数做什么。我只是错过了文档文件吗?
任何帮助都非常感谢!
智能显示了返回的确切类型。如果您想知道如何使用这种类型,请尝试在cppreference中搜索,这是一个非常有用的STL资源
据我所知,visual Studio甚至在2019版本中也没有这个功能(没有尝试2022,但我想它也没有)。我认为这可能有两个原因:
- c++比Java复杂得多。历史问题太多了。它最初并没有设计文档注释语法。
- 标准库使用得太频繁,你应该记住它的API。没什么好记的,对吧?
当注释是氧格式时,一些ide可以向您显示提示。我知道VS Code和Qt Creator的c++插件。也许Visual Studio也可以做到这一点?但是visual Studio的STL实现不使用氧。
另外,如果使用模板,不要期望理解类型名称的含义,因为会有一些类型名称像这样 :
struct boost::fusion::vector<class boost::spirit::lex::lexertl::iterator<class boost::spirit::lex::lexertl::functor<struct boost::spirit::lex::lexertl::token<class std::_String_iterator<class std::_String_val<struct std::_Simple_types<char> > >,struct boost::mpl::vector<__int64,struct String,struct Symbol,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na>,struct boost::mpl::bool_<1>,unsigned __int64>,class boost::spirit::lex::lexertl::detail::data,class std::_String_iterator<class std::_String_val<struct std::_Simple_types<char> > >,struct boost::mpl::bool_<1>,struct boost::mpl::bool_<1> > > & __ptr64,class boost::spirit::lex::lexertl::iterator<class boost::spirit::lex::lexertl::functor<struct boost::spirit::lex::lexertl::token<class std::_String_iterator<class std::_String_val<struct std::_Simple_types<char> > >,struct boost::mpl::vector<__int64,struct String,struct Symbol,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na>,struct boost::mpl::bool_<1>,unsigned __int64>,class boost::spirit::lex::lexertl::detail::data,class std::_String_iterator<class std::_String_val<struct std::_Simple_types<char> > >,struct boost::mpl::bool_<1>,struct boost::mpl::bool_<1> > > const & __ptr64,class boost::spirit::lex::lexertl::iterator<class boost::spirit::lex::lexertl::functor<struct boost::spirit::lex::lexertl::token<class std::_String_iterator<class std::_String_val<struct std::_Simple_types<char> > >,struct boost::mpl::vector<__int64,struct String,struct Symbol,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na,struct boost::mpl::na>,struct boost::mpl::bool_<1>,unsigned __int64>,class boost::spirit::lex::lexertl::detail::data,class std::_String_iterator<class std::_String_val<struct std::_Simple_types<char> > >,struct boost::mpl::bool_<1>,struct boost::mpl::bool_<1> > > const & __ptr64,struct boost::spirit::info const & __ptr64>
正如这个答案所说,在您提供的示例中,Intellisense 提供了完整的函数签名,尽管由于返回值和函数名之前添加了完全限定的类型名(std::vector<std::string, std::allocator<std::string>>
),因此在视觉上很难解析。在这里,将类型替换为T
:
public:
T::const_iterator T::begin() const
在Visual Studio中没有太多的文档可以直接使用,但是微软确实有很好的在线资源,例如VS2015 vector类
很难遍历所有模板和std命名空间,但是返回类型是vector<string>::const_iterator
。
我听Stephan Lavavey(微软STL的维护者)提到,如果有些东西不能编译,他希望有更好的错误消息。也许这也会使智能感知更容易使用。
- 正在查找文档以获得PS4平台的C++中的设备信息
- 如何在文档文件夹中创建目录
- 当Microsoft文档仅包含 C# 示例时,如何查找 C++ 包含文件名
- 通过构造函数创建一些值并尝试添加到文档中使用 rapidjson 不起作用
- 关于类的 Python 文档 - 对C++的引用不正确
- C++/autoconf 等效于文档库要求.txt的要求是什么?
- mbed:使用 USB 文档库编译会导致错误
- C++ VISUAL STUDIO:GLFWwindow没有初始化,即使它是在文档中编写的并且以前工作过
- 使用 yaml-cpp 更新 YAML 文档的节点和值
- 在加载 MSHTML 文档之前从 MSHTML 文档中删除无效的 URL
- 如何在C++中表示JSON文档的递归对象结构?
- 如何查找 Redshift Maya API 文档?
- 如何使用值模板编写文档测试用例?
- 如何使用 Gradle DSL(领域特定语言)上的文档?
- ncurses 找不到任何关于cchar_t的文档
- 提取狮身人面像文档中的C++代码片段
- 关于 API 文档和设备操作 在助手-sdk-cpp 上
- 如何搜索提升文档?
- 使用 mongo c++ 驱动程序查询嵌套的 BSON 文档
- PIMAGE_DOS_HEADER上缺少MSDN文档