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 <type_traits> #include <iostream> template<typename T> struct Wrapper { T value; operator T&() & { std::cout << "call const ref" << std::endl; return this->value; } operator const T&() const& { std::cout << "call const ref" << std::endl; return this->value; } operator T&&() && { std::cout << "call move" << std::endl; return std::move(this->value); } operator const T&() const&& = delete; operator T&&() & = delete; operator T&&() const& = delete; }; class A { public: A& operator=(const A&) { std::cout << "use copy" << std::endl; return *this; } A& operator=(A&&) { std::cout << "use move" << std::endl; return *this; } }; int main() { Wrapper<A> b; A bb; bb = std::move(b); }
Insight:
Console: