online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <array> #include <iostream> using namespace std; // Test that array has linkage template<auto& arr> void test() { for(auto& val : arr) cout << val << ", "; cout << endl; } // Get array with linkage template<size_t... vals> constexpr auto valsToArr = array<size_t, sizeof...(vals)>{ vals... }; int main() { // Just make the lambda return a reference to a constexpr array to begin with // Avoid the need to convert it to a param pack, then an array template variable // in order to obtain an array with linkage, that can be passed to test<>() auto lam = []() -> auto& { return valsToArr<1, 2, 3>; }; constexpr auto& res = lam(); test<res>(); 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