#include <string>
#include <map>
#include <set>
#include <initializer_list>
using namespace std;
class A
{
public:
struct pair_type // or use std::pair
{
long val;
std::string desc;
};
A(initializer_list<A::pair_type>);
private:
map<long, string> _valueMap;
map<string, long> _descriptionMap;
set<string> _descriptions;
set<long> _values;
};
A::A(initializer_list<A::pair_type> l)
{
for (auto & elem : l)
{
_valueMap.emplace(elem.val, elem.desc);
_descriptionMap.emplace(elem.desc, elem.val);
_descriptions.emplace(elem.desc);
_values.emplace(elem.val);
}
}
class B
{
enum { abbreviation, name, number, numberOfNameOptions };
public:
static A& getType();
};
A& B::getType()
{
static A a =
{
{ abbreviation, "abbreviation" },
{ name, "name" },
{ number, "number" },
{ numberOfNameOptions, "numberOfNameOptions" }
};
return a;
}
int main()
{
B b ;
A a = b.getType() ;
}
I2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPG1hcD4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPGluaXRpYWxpemVyX2xpc3Q+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgQQp7CnB1YmxpYzoKICAgIHN0cnVjdCBwYWlyX3R5cGUgICAgLy8gb3IgdXNlIHN0ZDo6cGFpcgogICAgewogICAgICAgIGxvbmcgdmFsOwogICAgICAgIHN0ZDo6c3RyaW5nIGRlc2M7CiAgICB9OwoKICAgIEEoaW5pdGlhbGl6ZXJfbGlzdDxBOjpwYWlyX3R5cGU+KTsKCnByaXZhdGU6CiAgICBtYXA8bG9uZywgc3RyaW5nPiBfdmFsdWVNYXA7CiAgICBtYXA8c3RyaW5nLCBsb25nPiBfZGVzY3JpcHRpb25NYXA7CiAgICBzZXQ8c3RyaW5nPiBfZGVzY3JpcHRpb25zOwogICAgc2V0PGxvbmc+IF92YWx1ZXM7Cn07CgpBOjpBKGluaXRpYWxpemVyX2xpc3Q8QTo6cGFpcl90eXBlPiBsKQp7CiAgICBmb3IgKGF1dG8gJiBlbGVtIDogbCkKICAgIHsKICAgICAgICBfdmFsdWV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