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

2021-12-17 00:00:00 math expression 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.

示例:

  • 在其发行版中:经典版本和当前 版本(查找calc");
  • 在罗塞塔维基;
  • 一些使用它的应用程序.
  • in its distribution: classic version and current version (look for "calc");
  • on Rosetta wiki;
  • some applications using it.

相关文章