如何使用 Sciplot 现代 C++ 库解决 C++ 错误 C2039?

How to resolve C++ Error C2039 using Sciplot modern C++ library?

我刚刚尝试使用 Sciplot for C++,在此处找到: https://sciplot.github.io/

使用 Visual Studio 社区 2017。 将 headers 的 sciplot 文件夹复制到我的项目依赖项文件夹中。 在项目设置中添加了包含文件夹。 复制了他们 git.

上提供的示例代码
#include <sciplot/sciplot.hpp>
using namespace sciplot;

int main(int argc, char** argv)
{
    // Create values for your x-axis
    const vec x = linspace(0.0, 5.0, 100);

    // Create a plot object
    plot plt;

    // Set color palette
    plt.palette("set2");

    // Draw a sine graph putting x on the x-axis and sin(x) on the y-axis
    plt.draw(x, std::sin(x)).title("sin(x)").linewidth(4);

    // Draw a cosine graph putting x on the x-axis and cos(x) on the y-axis
    plt.draw(x, std::cos(x)).title("cos(x)").linewidth(4);

    // Show the plot in a popup window
    plt.show();

    // Save the plot to a PDF file
    plt.save("figure.pdf");
}

它抛出这个错误。

...\dependencies\sciplot\util.hpp(285):错误 C2039:'remove_if':不是 'std'

的成员

...\microsoft visual studio17\community\vc\tools\msvc.16.27023\include\valarray(16):注意:参见 'std'

的声明

...\dependencies\sciplot\util.hpp(285):错误 C3861:'remove_if':找不到标识符

Microsoft 文档说尝试将 found 放入命名空间 std 内的 util.hpp 中,但这没有用。 我还尝试将语言标准设置为 C++14 、 C++17 和最新版本,并在项目设置中设置为空白,因为 git 表示它需要 C++14 (或我认为更高)。

感谢您的反馈。

这解决了 C2039 错误:

#include <algorithm>
#include <sciplot/sciplot.hpp>
using namespace sciplot;