Top "Auto" questions

The `auto` keyword was repurposed in C++11 for a deduced type.

arrow operator (->) in function heading

I came across the following code: template <typename T, typename T1> auto compose(T a, T1 b) -&…

c++ c++11 auto decltype
Why does auto a=1; compile in C?

The code: int main(void) { auto a=1; return 0; } gets compiled without errors by the MS Visual Studio 2012 compiler, when the …

c auto c11
Does 'auto' type assignments of a pointer in c++11 require '*'?

Given my variable being a pointer, if I assign it to a variable of "auto" type, do I specify the "*" ? …

c++ pointers c++11 auto
C++11 auto: what if it gets a constant reference?

Please take a look at the following simple code: class Foo { public: Foo(){} ~Foo(){} Foo(const Foo&){} Foo& …

c++ reference c++11 auto
C++11 Range-based for-loop efficiency "const auto &i" versus "auto i"

In C++11, I can iterate over some container like so: for(auto i : vec){ std::cout << i <&…

c++ for-loop c++11 auto
Using auto in a lambda function

#include <vector> #include <algorithm> void foo( int ) { } int main() { std::vector< int > v( { 1,2,3 } ); std::…

c++ c++11 auto lambda
Is there a way to pass auto as an argument in C++?

Is there a way to pass auto as an argument to another function? int function(auto data) { //DOES something }

c++ function arguments auto
How do I get a const_iterator using auto?

First question: is it possible to "force" a const_iterator using auto? For example: map<int> usa; //...init …

c++ c++11 auto
Is it possible to have an "auto" member variable?

For example I wanted to have a variable of type auto because I'm not sure what type it will be. …

c++ struct auto
Should the trailing return type syntax style become the default for new C++11 programs?

C++11 supports a new function syntax: auto func_name(int x, int y) -> int; Currently this function would …

c++ c++11 auto trailing-return-type