Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inheritance from variadic list not expanded well #184

Closed
afigegoznaet opened this issue May 13, 2019 · 1 comment · Fixed by #185
Closed

Inheritance from variadic list not expanded well #184

afigegoznaet opened this issue May 13, 2019 · 1 comment · Fixed by #185
Labels
bug Something isn't working

Comments

@afigegoznaet
Copy link

afigegoznaet commented May 13, 2019

#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();

andreasfertig added a commit that referenced this issue May 13, 2019
…a using.

For example:
```
struct X {
  int f(int);
  int f(double);
protected:
  int x;
};

struct Y: X {
  using X::f;
  using X::x;
};
```

Will make the functions `f(int)` and `f(double)` available in `Y` as
well as it moves `X::x` from `protected` to `public` in `Y`. All these
functions or members are shown as comments only.

Fixed #184 which points out the invalid prefix from a using decl.
@andreasfertig
Copy link
Owner

Hello @afigegoznaet,

thanks for discovering that! It was wrong for a long time and I didn't realize it. A fix should be available soon.

Andreas

andreasfertig added a commit that referenced this issue May 13, 2019
…a using.

For example:
```
struct X {
  int f(int);
  int f(double);
protected:
  int x;
};

struct Y: X {
  using X::f;
  using X::x;
};
```

Will make the functions `f(int)` and `f(double)` available in `Y` as
well as it moves `X::x` from `protected` to `public` in `Y`. All these
functions or members are shown as comments only.

Fixed #184 which points out the invalid prefix from a using decl.
@andreasfertig andreasfertig added the bug Something isn't working label Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants