As discussed with @kitaisreal 
{
    return filter(NameSet(names.begin(), names.end()));
}
NamesAndTypesList NamesAndTypesList::addTypes(const Names & names) const
{
    
    DenseHashMap<StringRef, const DataTypePtr *, StringRefHash> types;
    types.set_empty_key(StringRef());
    for (const auto & column : *this)
        types[column.name] = &column.type;
    NamesAndTypesList res;
    for (const String & name : names)
    {
        auto it = types.find(name);
        if (it == types.end())
            throw Exception("No column " + name, ErrorCodes::THERE_IS_NO_COLUMN);
        res.emplace_back(name, *it->second);
    }
    return res;
}
bool NamesAndTypesList::contains(const String & name) const