Date: Fri, 14 Aug 2026 13:37:33 +0000
https://godbolt.org/z/MxacGPbGo
```cpp
struct A1 {
A1(int a)
: a(a)
{
}
auto get(this A1 const &self)
{
return self.a;
}
private:
int a;
};
struct B1 : private A1 {
using A1::get;
};
auto f(B1 &b)
{
auto n = b.get(); // doesn't work. bad
(void)n;
}
struct A2 {
A2(int a)
: a(a)
{
}
auto get() const
{
return this->a;
}
private:
int a;
};
struct B2 : private A2 {
using A2::get;
};
auto f(B2 &b)
{
auto n = b.get(); // works. good
(void)n;
}
```
The only difference is that explicit object parameter is used in A1::get but
not in A2::get.
```cpp
struct A1 {
A1(int a)
: a(a)
{
}
auto get(this A1 const &self)
{
return self.a;
}
private:
int a;
};
struct B1 : private A1 {
using A1::get;
};
auto f(B1 &b)
{
auto n = b.get(); // doesn't work. bad
(void)n;
}
struct A2 {
A2(int a)
: a(a)
{
}
auto get() const
{
return this->a;
}
private:
int a;
};
struct B2 : private A2 {
using A2::get;
};
auto f(B2 &b)
{
auto n = b.get(); // works. good
(void)n;
}
```
The only difference is that explicit object parameter is used in A1::get but
not in A2::get.
Received on 2026-08-14 13:37:48
