fork download
  1. #include <complex>
  2. #include <map>
  3.  
  4.  
  5. template<typename T>
  6. struct math_parser{
  7. static const std::map<std::string, T(*)(const T& )> functions;
  8.  
  9. void evaluate(){
  10. functions.begin()->second(T(-1));
  11. }
  12. };
  13.  
  14.  
  15. template<typename T>
  16. const std::map<std::string, T(*)(const T& )> math_parser<T>::functions = {
  17. {std::string("SQRT"), (T(*)(const T& ))&std::sqrt}
  18. };
  19.  
  20.  
  21. int main(){
  22. math_parser<std::complex<long double>> x;
  23. x.evaluate();
  24. }
  25.  
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
Standard output is empty