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 <iostream> // std::cout #include <type_traits> template <class T> // deductions among universal reference void fun(T &&b) // fold reference, maintain const { std::cout << b << " "; std::cout << std::is_const<T>::value << " "; std::cout << std::is_lvalue_reference<T>::value << " "; std::cout << std::is_rvalue_reference<T>::value << std::endl; } int main() { int a = 1; fun(a); // lvalue: T=int& fun(std::move(a)); // rvalue: T=int const int ca = 1; fun(ca); // const_lvalue: T=int& (why no const?) fun(std::move(ca)); // const_rvalue: T=const int int &la = a; fun(la); // lvalue_ref: T=int& int &&ra = 1; fun(ra); // rvalue_ref: T=int& (r_ref is a lval) fun(std::forward<decltype(ra)>(ra)); // rvalue_ref + perfect forwarding T=int const int &cla = a; fun(cla); // const_lvalue_ref: T=int& (no const?) const int &&cra = 1; fun(cra); // const_rvalue_ref: T=int& (no const?) return 0; }
Insight:
Console: