2
我正在尝试在类Application
中创建一个LLVMContext
成员变量。 MCVE:LLVMContext作为类成员会破坏构造函数吗?
#include <llvm/IR/LLVMContext.h>
struct Foo {};
class Application {
public:
Application(int a, Foo foo, int b);
private:
llvm::LLVMContext context_;
};
void function() {
auto application = Application(12, Foo(), 21);
}
添加变量,但是,产生一些非常奇怪的错误:(4.0.1锵和苹果LLVM版本8.1.0)
toy.cpp:13:8: error: no matching constructor for initialization of 'Application' auto application = Application(12, Foo(), 21); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~ toy.cpp:5:7: note: candidate constructor (the implicit copy constructor) not viable: expects an l-value for 1st argument class Application { ^ toy.cpp:7:3: note: candidate constructor not viable: requires 3 arguments, but 1 was provided Application(int a, Foo foo, int b); ^ 1 error generated.
这到底是怎么回事?为什么Clang认为我试图使用带有一个参数的构造函数(“但提供了1个”)?
天哪。谢谢。我非常想到在类定义中发现一个错误,我完全忽略了这一点。 – idmean