C++ Logo

std-discussion

Advanced search

Re: explicit object parameter + private/protected inheritance + `using Base::` doesn't work, is this a bug in the compiler or a standard defect?

From: Yongwei Wu <wuyongwei_at_[hidden]>
Date: Tue, 18 Aug 2026 16:01:18 +0800
The "issue" is irrelevant.

If it does not work in your case, why use it? Just avoid it.

Deducing this is a special feature for special cases: you are not
required to change your code to use it.

Actually its usefulness is quite limited, at least narrower than I
originally thought. One of the gotchas is that it is not very useful
for containers, because a const pointer does not make a pointee const.

On Sat, 15 Aug 2026 at 21:28, sidneycogdil via Std-Discussion
<std-discussion_at_[hidden]> wrote:
>
> to elaborate more on the issue: previously `using A::get;` alone is enough to
> export a member function from a private base. with explicit object parameters,
> to export a member function from private base, `using A::get;` isn't enough
> anymore, and instead you have to either write a forwarder function matching
> the exact signatures for every overload, or write this in the derived class:
>
> ```cpp
> decltype(auto) get(this auto &&self, auto &&...args)
> noexcept(noexcept((std::forward<decltype(self)>(self)).A3::get(std::forward<decltype(args)>(args)...)))
> requires (requires {
> (std::forward<decltype(self)>(self)).A3::get(std::forward<decltype(args)>(args)...);
> })
> {
> return
> (std::forward<decltype(self)>(self)).A3::get(std::forward<decltype(args)>(args)...);
> }
> ```
>
> which adds unnecessary template instantiations and hinders IDE auto-completion
> signature hinting, and also hurts readability. `using A::get;` is much
> cleaner.
>
> you can use protected members in the base class and use protected inheritance,
> however that pollutes the derived class with all the names from the base class
> which should have been private.
>
>
>
>
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion



-- 
Yongwei Wu
URL: http://wyw.dcweb.cn/

Received on 2026-08-18 08:01:38