小编Jon*_*tti的帖子

使用 map cpp 创建成员变量

我正在尝试使用std::map键值对调用函数。我发现这篇 stackoverflow 文章根据变量调用函数?但解决方案

std::map<std::string, std::function<void()>> le_mapo;
Run Code Online (Sandbox Code Playgroud)

不起作用并导致错误,例如“错误:左值需要作为一元'&'操作数”使用它

std::map<std::string, std::function<void()>> le_mapo;
le_mapo["ftp"] = &ftp(); // ftp function is in the same class, this function is the constructor
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用此方法调用同一类中的函数,但它导致左值错误,不知道该怎么做

我也试过在顶部使用

#define BE_EVIL(map, function, x) map[ #x ] = & function ## x
Run Code Online (Sandbox Code Playgroud)

注意:我有所有适当的包括,例如

#include <iostream>
#include <map>
#include <functional>
Run Code Online (Sandbox Code Playgroud)

这是一个可重现的示例

#include <iostream>
#include <map>
#include <functional>


class stackoverflow
{
    private:
        void ftp();
    
    public:
        stackoverflow();
};

void ftp()
{
    std::cout << "Minimal reproduction" << std::endl;
}

stackoverflow::stackoverflow()
{
    std::map<std::string, …
Run Code Online (Sandbox Code Playgroud)

c++ dictionary functional-programming

2
推荐指数
1
解决办法
61
查看次数

POST 请求变量 powershell

我有一个 powershell post 请求,Invoke-WebRequest但是当我包含 ? 它认为它是一个变量,有任何方法可以逃避这个问题,这是我的代码

Invoke-WebRequest -UseBasicParsing -Method POST https://192.168.240.1:443/recive/$name?result=$sendback
Run Code Online (Sandbox Code Playgroud)

它认为 name 和后面的所有内容都是一个变量,我知道这一点,因为我可以看到它在 Windows 终端中全部突出显示为绿色

variables powershell escaping string-interpolation invoke-webrequest

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