I'm rather a beginner in C++ and yesterday I came across a constructor I don't understand.
struct Person
{
explicit Person(std::vector<std::function<void (float)>> &update_loop)
{
update_loop.emplace_back([this](float dt) { update(dt); });
}
void update(float dt);
};
int main()
{
std::vector<std::function<void (float)>> update_loop;
Person person { update_loop };
}
I know it's possible to initialize aggregate objects in this way, but Person
doesn't have data members, just a constructor and a function, so what exactly Person person { update_loop }
does? If it uses the explicit constructor shouldn't it use round parentheses, like Person person(update_loop)
?