online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <cassert> #include <iostream> #include <string> #include <cmath> #include <functional> // Works with std::function ! //std::function<double(double)> set_unary_operation(const std::string& unary) auto set_unary_operation(const std::string& unary) { if(unary == "EXP") return [](const double& x){ return std::exp(x);}; if(unary == "LOG") return [](const double& x){ return std::log10(x);}; if(unary == "_LN") return [](const double& x){ return std::log(x);}; if(unary == "ABS") return [](const double& x){ return std::abs(x);}; return [](const double& x){return x;}; } bool is_equal(double&& value, double&& test) { double epsilon = 0.0000001; return (value-epsilon < test) && (value+epsilon > test); } int main() { // TEST OPERATOR -------------------------------------------------------------------------- { std::string in = "EXP"; auto f = set_unary_operation(in); std::cout << "f = EXP ; f(1) = "<< f(1) << "; f(2.5) = " << f(2.5) << std::endl; assert(is_equal(f(1) , 2.71828182)); assert(is_equal(f(2.5), 12.1824939607)); } 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