【问题标题】:How to resolve C++ Error C2039 using Sciplot modern C++ library?如何使用 Sciplot 现代 C++ 库解决 C++ 错误 C2039?
【发布时间】:2021-05-16 16:49:09
【问题描述】:

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

使用 Visual Studio 社区 2017。 将标头的 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': is not a member of 'std'

...\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\valarray(16):注意:参见“std”的声明

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

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

感谢您的反馈。

【问题讨论】:

  • 不相关:不要这样做将标​​头的 sciplot 文件夹复制到我的项目依赖项文件夹中。。将标题放在中心位置并将项目指向该中心位置。有助于减少跨项目的蔓延和重复。
  • 糟糕 - 我说:“微软文档说尝试将找到的 util.hpp 放在命名空间 std 内”。但我的意思是,在 util.hpp 里面,我去了它有 #include 的地方,并将 #include 放在命名空间 std.
  • Update the question。评论太短暂了。

标签: c++ visual-studio dependencies


【解决方案1】:

这解决了 C2039 错误:

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

【讨论】:

    猜你喜欢
    • 2020-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多