Some deduction examples about auto/decltype lvalue12345678910111213int i{0};auto a = i; // intdecltype(auto) b = i; // intauto c = (i); // intdecltype(auto) d = (i); // int&auto& e = i; // int&auto& f = (i); // int&auto&& g = i; // int&auto&& h = (i); // int& rvalue12345678910111213auto a = 1; // intdecltype(auto) b = 1; // intauto c = (1); // intdecltype(auto) d = (1); // int// auto& e = 1; // wrong// auto& f = (1); // wrongconst auto& e = 1; // const int&const auto& f = (1); // const int&auto&& g = 1; // int&&auto&& h = (1); // int&& xvalue123456789101112131415struct Foo {};auto a = Foo{}; // Foodecltype(auto) b = Foo{}; // Fooauto c = (Foo{}); // Foodecltype(auto) d = (Foo{}); // Foo// auto& e = Foo{}; // wrong// auto& f = (Foo{}); // wrongconst auto& e = Foo{}; // const Foo&const auto& f = (Foo{}); // const Foo&auto&& g = Foo{}; // Foo&&auto&& h = (Foo{}); // Foo&& dev > cpp #cpp #cpp11 #auto #decltype Some deduction examples about auto/decltype http://wasprime.github.io/Dev/C++/Miscellaneous/Some-deduction-examples-about-auto-decltype/ Author wasPrime Posted on May 11, 2023 Updated on May 11, 2023 Licensed under Some examples about CTAD Previous Introduction to some interesting operator overloads Next