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> #include <functional> class A { const std::function<void()>* m_Lambda = nullptr; public: A(const std::function<void()>& lambda) : m_Lambda(&lambda) {} void ExecuteLambda() { (*m_Lambda)(); } }; int main(void) { int i1 = 1; int i2 = 2; const auto lambda = [&]() { std::cout << "i1 == " << i1 << std::endl; std::cout << "i2 == " << i2 << std::endl; }; A a(lambda); a.ExecuteLambda(); }
Insight:
Console: