Request Short Link
C++ 98
C++ 11
C++ 14
C++ 17
C++ 20
C++ 23
C++ 2c
for-loops as while-loops
array subscription
Show all implicit casts
Show all template parameters of a CallExpr
Use libc++
Transform std::initializer_list
Show noexcept internals
Show padding information
Show coroutine transformation
Show C++ to C transformation
Show object lifetime
Default
15
18
20
22
26
More
GitHub
Patreon
Issues
About
Policies
Examples
C++ Insights @ YouTube
Settings
Version
None
×
Made by
Andreas Fertig
Powered by
Flask
and
CodeMirror
Source:
#include <cstdio> #include <iostream> decltype(auto) bar() { int i; int& ref = i; return ref; } decltype(auto) bar1() { int i = 42; return i; } decltype(auto) bar2() { return 42; } decltype(auto) bar3() { int i; return std::move(i); } auto&& baz() { int i; int& ref = i; return ref; } auto&& baz1() { int i = 42; return i; } auto&& baz2() { return 42; } auto&& baz3() { int i; return std::move(i); } struct CLASS { CLASS(int i) : num{i} { std::cout << "ctor " << num << std::endl; } ~CLASS() { std::cout << "dtor " << num << std::endl; } int num; }; decltype(auto) get_class_decltype() { return CLASS(0); } auto&& get_class_auto() { return CLASS(42); } int main() { decltype(auto) a = get_class_decltype(); std::cout << "separator" << std::endl; decltype(auto) b = get_class_auto(); std::cout << "separator" << std::endl; }
Insight:
Console: