Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <class First, class Second>
- struct compressed_pair : First, Second
- {
- compressed_pair() {}
- compressed_pair(const First& x, const Second & y)
- : First(x), Second(y)
- {}
- First& first() { return *this; }
- Second& second() { return *this; }
- };
- struct a
- {};
- struct b : a
- {};
- int main()
- {
- compressed_pair<a, b> p;
- auto x = p.first();
- }
- compressed_pair.cpp:8:30: error: ambiguous conversion from derived class 'compressed_pair<a, b>' to base class 'a':
- struct compressed_pair<struct a, struct b> -> struct a
- struct compressed_pair<struct a, struct b> -> struct b -> struct a
- First& first() { return *this; }
- ^~~~~
- compressed_pair.cpp:21:16: note: in instantiation of member function 'compressed_pair<a, b>::first' requested here
- auto x = p.first();
- ^
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement