我有这个代码:
#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)
我们可以迭代每个类吗?
我只想使用 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)