哪些IDE和文本编辑器可以推断在C ++ 11中使用auto关键字声明的变量类型 [英] Which IDEs and text editors can deduce type of variables declared using auto keyword in C++11
问题描述
在几乎一律自动文章Herb Sutter列出了使用auto关键字声明变量的几个原因。
他说实际的变量类型可以由IDE自动推导出来,并通过悬停在变量名称上。 p>
我想知道哪些IDE和文本编辑器(或插件)当前支持自动变量类型的扣除。
修改:
- Visual Studio 201x
- Eclipse
- Qt Creator 2.7.0
- KDevelop 4.5.1
文字编辑器
Vim,Emacs,Sublime Text等等 - 有支持类型推导的插件吗?
Visual Studio 2010,Visual Studio 2012和Visual Studio 2013支持类型扣除使用 auto
关键字声明的变量。这适用于IntelliSense工具提示以及自动完成建议。
从Visual Studio 2010开始,C ++ IntelliSense支持被完全重做了(参见重建Intellisense )。 IntelliSense现在由Edison Design Group(EDG) C ++编译器前端驱动。
请注意,IntelliSense工具提示将显示 auto
的底层类型。变量。它不会再次处理树和用适当的typedef替换部分。在Visual Studio 2012下面的代码
std :: string str;
std :: string :: iterator i1 = str.begin();
auto i2 = str.begin();
将显示迭代器为
std :: basic_string< char,std :: char_traits< char>,std :: allocator< char> > :: iterator i1
和
std :: _ String_iterator< std :: _ String_val< std :: _ String_base_types< char,std :: allocator< char> > :: _ Val_types> :: _ Myt> i2
鉴于我很高兴地不同意Herb Sutter的评估,认为IDE足以推论出类型,当你需要它。 auto
在稳健性,正确性和灵活性方面是非常好的,但它肯定不能满足开发人员在大代码库上的需要。
In "Almost always auto" article Herb Sutter lists several reasons for declaring variables using auto keyword.
He says that actual variable type can be automatically deduced by IDE and shown by hovering over variable name.
I would like to know which IDEs and text editors (or plugins) currently support "auto" variable type deduction.
Edit:
List of IDEs from answers:
- Visual Studio 201x
- Eclipse
- Qt Creator 2.7.0
- KDevelop 4.5.1
Text editors
What about Vim, Emacs, Sublime Text, etc. - are there plugins which supports type deduction?
Visual Studio 2010, Visual Studio 2012, and Visual Studio 2013 support type deduction for variables declared with the auto
keyword. This applies both to the IntelliSense tooltips as well as auto-complete suggestions.
Starting with Visual Studio 2010 the C++ IntelliSense support was completely reworked (see Rebuilding Intellisense). IntelliSense is now driven by the Edison Design Group (EDG) C++ compiler frontend. Whatever EDG can do you will see reflected in IntelliSense.
Note that IntelliSense tooltips will display the underlying type for auto
variables. It will not work up the tree again and replace portions with appropriate typedefs. On Visual Studio 2012 the following code
std::string str;
std::string::iterator i1 = str.begin();
auto i2 = str.begin();
will display the iterators as
std::basic_string<char,std::char_traits<char>,std::allocator<char> >::iterator i1
and
std::_String_iterator<std::_String_val<std::_String_base_types<char,std::allocator<char> >::_Val_types>::_Myt> i2
Given that I would happily disagree with Herb Sutter on his assessment that an IDE is enough to deduce a type when you need it. auto
is great with respect to robustness, correctness and flexibility, but it surely fails to meet a developer's needs working on a large code base.
这篇关于哪些IDE和文本编辑器可以推断在C ++ 11中使用auto关键字声明的变量类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!