std::vector<int> vec;
auto i = vec.begin(), j = std::next(i);
Error: in a declarator-list 'auto' must always deduce to the same type
To use the auto keyword, use it instead of a type to declare a variable, and specify an initialization expression. In addition, you can modify the auto keyword by using specifiers and declarators such as const , volatile , pointer ( * ), reference ( & ), and rvalue reference ( && ).
The auto keyword in C++ automatically detects and assigns a data type to the variable with which it is used. The compiler analyses the variable's data type by looking at its initialization. It is necessary to initialize the variable when declaring it using the auto keyword.
You can initialize any auto variable except function parameters. If you do not explicitly initialize an automatic object, its value is indeterminate. If you provide an initial value, the expression representing the initial value can be any valid C or C++ expression.
Compiles fine in g++ on Linux, so it appears to be a compiler bug. Probably this one.
This appears to be a compiler error. See this link below. http://connect.microsoft.com/VisualStudio/feedback/details/728741 May already have been fixed judging by the comments in the link.
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