我在这里有一个旧的代码库,他们使用受保护的成员变量.可以讨论这是否是一个好主意.但是,代码必须与gcc3编译良好.我有一个派生模板类Bar,它使用类模板Foo中的受保护成员x
template <class Something> class Foo {
public:
// stuff...
protected:
some::type x;
}
template <class Something> Bar : Foo<Something> {
public:
void cleanup();
}
Run Code Online (Sandbox Code Playgroud)
在cleanup()的方法声明中,有一些用x完成的事情
template <class Something> void Bar<Something>::cleanup() {
doSomeThingCleanUpLike (x);
}
Run Code Online (Sandbox Code Playgroud)
这不适用于gcc4,虽然它应该与gcc3一起使用.当我将其更改为时,它可以工作
doSomeThingCleanUpLike (this->x);
Run Code Online (Sandbox Code Playgroud)
为什么会这样?
当使用optparse我希望在一个选项后得到整个字符串,但我只能将它的一部分放到第一个空格.
例如:
python myprog.py --executable python someOtherProg.py
Run Code Online (Sandbox Code Playgroud)
我在'可执行'中得到的只是'python'.
是否可以使用optparse解析这些行,或者您是否必须使用argparse来执行此操作?
€:我已经尝试将其封装在"s中.但是在深入研究代码之后,我发现子进程调用无法处理参数.
带有命令行的字符串被塞入列表'args'.
args = [self.getExecutable()] + self.getArgs().split()
Run Code Online (Sandbox Code Playgroud)
就像是
"[python D:\\\workspace\\\myprog\\\src\\\myprog.py]"
Run Code Online (Sandbox Code Playgroud)
这给了我系统找不到文件异常.我用的时候
args[0]
Run Code Online (Sandbox Code Playgroud)
有用.但我放弃了可执行文件的参数.
如果第一个地方没有获得字符串,则子进程模块会从列表中构建cmdline,因此我暂时无法解释该行为.