小编cco*_*r83的帖子

将C++成员函数指针传递给STL算法

我有一个成员函数如下:

class XYZ{
public:
    float function(float x);
private:
    float m_DensityMin;
    float m_DensityMax;
};
Run Code Online (Sandbox Code Playgroud)

现在,我试图通过传递成员函数并将结果值存储在向量中std::vector<float> foo来使用std::transformSTL算法转换a .functionbar

如果我将函数用作全局函数,使用应该表示类的成员变量的随机数据,它可以正常工作.

但是,由于函数需要使用成员变量m_DensityMinm_DensityMax类,我需要将它用作成员函数.这就是我尝试过的:

std::transform(foo.begin(), foo.end(), bar.begin(), &XYZ::function);
Run Code Online (Sandbox Code Playgroud)

但我最终得到VS2010中的错误:

error C2065: term does not evaluate to a function taking 1 arguments
Run Code Online (Sandbox Code Playgroud)

据我所知,我只传了一个论点.有什么指针吗?这是一个类似的问题,我尝试过使用std :: mem_fun,因为std :: mem_fn对我来说无法使用,但无济于事.

c++ stl member-functions stl-algorithm

5
推荐指数
1
解决办法
2642
查看次数

在与 Webpack 捆绑的 VS Code 中调试 Node JS 代码

我是 Node JS 和 JS 开发的新手。我有一个由 WebPack 捆绑的 app-bundle.js 文件,它是通过 app.js 文件调用的。

我正在尝试使用 Visual Studio Code 进行调试。我为 VS 代码配置创建了 launch.json 文件。但是,当我在单个 js 文件中插入断点时,我得到

Breakpoints set, but not yet bound

但是,当我在 app.js 或 app.bundle.js 中设置断点时,它工作正常。

我的launch.json如下:

{
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "program": "${workspaceFolder}/app.js"
}
Run Code Online (Sandbox Code Playgroud)

如何让 VS 代码调试器处理单个 js 文件?

javascript debugging node.js webpack visual-studio-code

5
推荐指数
1
解决办法
7142
查看次数