online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <array> #include <string> #include <type_traits> #include <iomanip> const int ARRAY_SIZE = 5; template <typename C> class ValArray { public: ValArray() { if constexpr (std::is_same_v<C, bool>) { _values.fill(false); } } ValArray(const ValArray&) = delete; C& operator[](size_t pos) { return _values[pos]; } // ... private: std::array<C, ARRAY_SIZE> _values; }; int main() { std::cout << std::boolalpha; ValArray<int> val1; for(int i = 0; i < ARRAY_SIZE; ++i) { std::cout << "val1[" << i << "] = " << val1[i] << std::endl; } std::cout << std::endl; ValArray<bool> val2; for(int i = 0; i < ARRAY_SIZE; ++i) { std::cout << "val2[" << i << "] = " << val2[i] << std::endl; } std::cout << std::endl; ValArray<std::string> val3; for(int i = 0; i < ARRAY_SIZE; ++i) { std::cout << "val3[" << i << "] = \"" << val3[i] << "\"" << std::endl; } std::cout << std::endl; 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