- typeDescriptions.push_back(TypeDescription(typeDescriptions.size(), name));
- return typeDescriptions.back();
+ if (typeName2ID.count(name)) {
+ std::stringstream msg;
+ msg << "duplicate type name " << name
+ << " (have " << GetTypeId(name) << ", got " << id << ")";
+ throw std::invalid_argument(msg.str());
+ }
+ typeName2ID[name] = id;
+ return typeDescriptions.insert(make_pair(id, TypeDescription(id, name))).first->second;