我无法理解委托构造函数的用途.简单地说,没有委派构造函数就无法实现的目标?
它可以做这样简单的事情
class M
{
int x, y;
char *p;
public:
M(int v) : x(v), y(0), p(new char [MAX]) {}
M(): M(0) {cout<<"delegating ctor"<<endl;}
};
Run Code Online (Sandbox Code Playgroud)
但我不认为值得为这么简单的事情引入新功能吗?可能是我无法认识到重要的一点.任何的想法?
我正试图为一个项目设置铿锵声.我希望能够提供干净的输出,并鼓励尽可能使用-fix模式.但是,在某些情况下需要例外.
很有可能使用
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-id-macro"
// Code that is being specially exempted
#pragma clang diagnostic pop
Run Code Online (Sandbox Code Playgroud)
对于想要在本地禁用编译器警告的等效情况,是否可以通过clang-tidy执行类似的操作?
我试过了
#pragma clang diagnostic push
#pragma clang diagnostic ignored "readability-identifier-naming"
// Code that is being specially exempted
#pragma clang diagnostic pop
Run Code Online (Sandbox Code Playgroud)
并且还clang替换为clang-tidy.不幸的是,当clang用作pragma目标并使用常规clang进行编译时,我得到了编译警告
warning: pragma diagnostic expected option name (e.g. "-Wundef") [-Wunknown-pragmas]
Run Code Online (Sandbox Code Playgroud)
和
warning: unknown pragma ignored [clang-diagnostic-unknown-pragmas]
Run Code Online (Sandbox Code Playgroud)
编译时,如果我用来clang-tidy代替clang.clang-tidy在源上运行时,都不会对自身的输出产生影响.
这与x86_64 Linux上的3.8 clang和clang-tidy.
在golang中,如果我有一个os.FileInfo,有没有办法在*os.File没有原始路径的情况下自己打开它?
假设我有这样的事情:
package main
import (
"os"
"path/filepath"
"strings"
)
var files []os.FileInfo
func walker(path string, info os.FileInfo, err error) error {
if strings.HasSuffix(info.Name(), ".txt") {
files = append(files, info)
}
return nil
}
func main() {
err := filepath.Walk("/tmp/foo", walker)
if err != nil {
println("Error", err)
} else {
for _, f := range files {
println(f.Name())
// This is where we'd like to open the file
}
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法转换FileInfo成* …
我试图将一个枚举类包装在c ++头文件中,以便在cython项目中使用.我已经google了一下,无法找到如何实现这一点 - 是否支持?