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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With