The code at this GitHub file uses a C++ variable "declaration" syntax I'm not familiar with:
std::unique_ptr<CRecentFileList> {m_pRecentFileList} = std::make_unique<CRecentFileList>(...
(m_pRecentFileList
is declarared in a superclass.)
What does it mean when you wrap a variable declaration in braces? (not an initializer list)
I extracted a minimal test case which compiles:
class foo {
int* p;
void f(){
std::unique_ptr<int> {p} = std::make_unique<int>(1);
}
};
Changing int* p
to std::unique_ptr<int> p
creates a compilation error due to unique_ptr(const unique_ptr&) = delete;
This makes me think braced declaration assigns to a outer-scope variable with the same name. I tried creating a test program, but it fails to compile:
int main(){
int x;
int {x} = 1;
}
error: using temporary as lvalue [-fpermissive]
int {x} = 1;
BTW. +1. – Lepidolite