class A {
public:
int a;
};
class B: private A {
};
class C: public A {
};
class D: public B, public C {
D() {
B::a = 0;
}
};
Run Code Online (Sandbox Code Playgroud)
即使B私有继承A,这也会编译.如果我删除D的继承,编译器会说a是无法访问的,就像我期望的那样.那么C的继承会让我的编译器感到困惑吗?
编译器是gcc 4.4.7
我创建了一个具有 Web 服务器容器的 Fargate 任务。该任务有一个 eni,它似乎有一个公共 IP。Web 服务器的容器定义具有端口 443 的端口映射。但是当我检查容器时,未配置网络绑定。而且我无法使用公共 IP 地址访问 Web 服务器。我缺少什么?
您可以使用可变参数模板编写一个函数,该函数接受任意元组列表,每个元组都有一组不同的参数吗?所以你会得到类似的东西:
template< /* some crazy variadic thing...*/ >
void func( ... ) {}
func(make_tuple(1,2), make_tuple("hello"));
Run Code Online (Sandbox Code Playgroud)
SFINAE 来救援!进一步考虑杰弗里的回答,我写了这个小片段。您可以将元组以外的类型放在 func 的参数列表中的任何位置,它将编译并运行,当它遇到第一个不是模板类的类型时,它只会破坏我的打印链。seq并gens从这里来。
template<typename T>
int print(T& t) {
cout << t << " ";
return 0;
}
template<typename... T> void dumby(T...) {}
// so other template classes don't cause error (see bar below)
template<typename... A>
void expand(A... a) {}
template<typename... A, int... S>
void expand(tuple<A...> a, seq<S...>) {
dumby(print(get<S>(a))...);
cout << endl;
}
template<class... Types>
void func(Types...) …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 docker-compose 中运行 python selenium。我有以下文件:
docker-compose.yml:
version: '3'
services:
app:
build:
context: .
dockerfile: Dockerfile
depends_on:
- chrome
ports:
- '8443:8443'
chrome:
image: selenium/node-chrome:3.14.0-gallium
volumes:
- /dev/shm:/dev/shm
depends_on:
- hub
environment:
HUB_HOST: hub
hub:
image: selenium/hub:3.14.0-gallium
ports:
- "4444:4444"
Run Code Online (Sandbox Code Playgroud)
Dockerfile:
FROM python:latest
COPY test.py /code/test.py
WORKDIR /code
RUN pip install --upgrade pip
RUN pip install pytest
RUN pip install pytest-asyncio
RUN pip install selenium
Run Code Online (Sandbox Code Playgroud)
测试.py:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
driver = webdriver.Remote(
command_executor='http://hub:4444/wd/hub',
desired_capabilities=DesiredCapabilities.CHROME,
)
print(driver) …Run Code Online (Sandbox Code Playgroud)