I am reading the following C++17 code:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <fstream>
#include <tuple>
using namespace std;
enum class Relationship { parent, child, sibling };
struct Person { string name; };
struct Relationships
{
vector<tuple<Person, Relationship, Person>> relations;
void add_parent_and_child(const Person& parent, const Person& child)
{
relations.push_back({parent, Relationship::parent, child});
relations.push_back({child, Relationship::child, parent});
}
};
struct Research
{
Research (Relationships& relationships)
{
auto& relations = relationships.relations;
for(auto&& [first, rel, second] : relations)
{
if(first.name == "John" && rel == Relationship::parent)
{
cout << "John has a child called " << second.name << endl;
}
}
}
};
int main()
{
Person parent {"John"};
Person child1 {"Chris"}, child2 {"Matt"};
Relationships relationships;
relationships.add_parent_and_child(parent, child1);
relationships.add_parent_and_child(parent, child2);
Research _(relationships);
return 0;
}
That code compiles and works fine. What I do not get is the line:
Research _(relationships);
Why is there an underscore? Is this a new feature of C++17? What is it called?