Skip to content

Inheritance from variadic list not expanded well #184

@afigegoznaet

Description

@afigegoznaet

#include
#include <unordered_set>

class Customer{
std::string name;
public:
Customer(const std::string &n) : name(n){}
std::string getName()const{return name;}
};

struct CustomerEq{
bool operator()(const Customer&c0,const Customer&c1)const{
return c0.getName() == c1.getName();
}
};

struct CustomerHash{
std::size_t operator()(const Customer& c) const{
return std::hashstd::string()(c.getName());
}
};

template<typename ... Bases>
struct ManyParentsWithOperator : Bases...{
using Bases::operator()...;//C++17
};

int main()
{
std::unordered_set<Customer, CustomerHash, CustomerEq> set1;
std::unordered_set<Customer, ManyParentsWithOperator<CustomerHash, CustomerEq>, ManyParentsWithOperator<CustomerHash, CustomerEq>> set2;
std::unordered_set<Customer, ManyParentsWithOperator<CustomerEq, CustomerHash>, ManyParentsWithOperator<CustomerEq, CustomerHash>> set3;

set1.emplace("Test");
set2.emplace("Test");
set3.emplace("Test");
return 0;

}

Here: operator() ... expands to:
using ManyParentsWithOperator<CustomerHash, CustomerEq>::operator();
using ManyParentsWithOperator<CustomerHash, CustomerEq>::operator();

I would expect it to expand to
using CustomerHash::operator();
using CustomerEq::operator();

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions