小编Dbi*_*Dbi的帖子

C++ 实例化模板可变参数类

我有这个代码:

#include <iostream>

template<class P>
void processAll() {
    P p = P();
    p.process();
}

class P1 {
public:
    void process() { std::cout << "process1" << std::endl; }
};

int main() {
    processAll<P1>();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

有没有办法使用模板变量将第二个类“P2”注入到我的函数“processAll”中?像这样的东西:

...

template<class... Ps>
void processAll() {
    // for each class, instantiate the class and execute the process method
}

...

class P2 {
public:
    void process() { std::cout << "process2" << std::endl; }
};

...

int main() {
    processAll<P1, P2>();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我们可以迭代每个类吗?

c++ templates variadic

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

BeautifulSoup,更改特定的样式属性

我只想使用 BeautifulSoup 更改背景颜色样式:

我的 HTML :

<td style="font-size: .8em; font-family: monospace; background-color: rgb(244, 244, 244);">
</td>
Run Code Online (Sandbox Code Playgroud)

我想做这样的事情:

soup_td = BeautifulSoup(html_td, "html.parser")
soup_td.td["style"]["background-color"] = "red;"
Run Code Online (Sandbox Code Playgroud)

python beautifulsoup

3
推荐指数
2
解决办法
4122
查看次数

标签 统计

beautifulsoup ×1

c++ ×1

python ×1

templates ×1

variadic ×1