online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <functional> struct Holder { std::function<void()> data; Holder() : data() { printf("Holder()\n"); } Holder(decltype(data)&& data) : data(data) { printf("Holder(..)\n"); } operator bool() const { return data.operator bool(); } void operator()() const { data(); } }; template <class T> struct Test { inline static Holder f; Test() { if (!f) { f = Holder([]() { std::cout << "it works\n"; }); initialized = true; } } static void check() { if (f) f(); else std::cout << "f is empty\n"; } T x{}; inline static bool initialized = false; }; Test<double> t; int main() { printf("entering main\n"); t.x = 1.5; std::cout << "t.x = " << t.x << "\n"; std::cout << std::boolalpha << "initalized: " << Test<double>::initialized << "\n"; Test<double>::check(); return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue