问题描述
DocumentReference::DocumentReference(model::ResourcePath path,std::shared_ptr<Firestore> firestore)
: firestore_{std::move(firestore)} {
// code here removed for https://stackoverflow.com/
}
return DocumentReference{
ResourcePath::FromString(document_path),shared_from_this()
};
解决方法
这不是“调用函数”。 DocumentReference::DocumentReference
是一个构造函数。构造对象的方法有很多,{}
是其中一种。见
- Calling constructor with braces
- When should we use parenthesis ( ) vs. initializer { } syntax to initialize objects in C++11?
- Why is list initialization (using curly braces) better than the alternatives?
用{}而不是()调用函数有什么区别?
在这种情况下没有区别。两者都只是初始化DocumentReference
对象。
不过最好使用{}
。