在 C++ 中评估数学表达式的最佳方法是什么?

问题描述:

例如,评估任何自定义数学表达式的最佳方法是什么

What is the best way to evaluate any custom math expression, for example

3+sqrt(5)+pow(3)+log(5)

我知道将 Python 嵌入 C++ 可以做到这一点;有没有更好的办法?

I know that embedding Python into C++ can do that; is there any better way?

谢谢!

Boost.Spirit 是一个 C++ 解析器库.

Boost.Spirit is a C++ parser library.

示例:

  • in its distribution: classic version and current version (look for "calc");
  • on Rosetta wiki;
  • some applications using it.