Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using declarations and const overloads

Suppose I have two versions of operator-> (overloaded on const) in a base class. If I say

using Base::operator->;

in a derived class, will I get access to both versions or just the non-const one?

like image 557
fredoverflow Avatar asked Jan 19 '23 00:01

fredoverflow


1 Answers

Same business as name hiding. It's all or nothing. Using declarations (7.3.3) bring a name, not a member.

ISO/IEC 14882 (2003), 7.3.3. 1/ A using-declaration introduces a name into the declarative region in which the using-declaration appears. That name is a synonym for the name of some entity declared elsewhere.

I encourage you to read 7.3.3, there are subtle things inside. You cannot using-declare a template, all the members refered by the name you using-declare must be accessible, the names are considerd for overload resolution alongside the names in the block the using declaration is found (ie. they don't hide anything), etc, etc.

like image 116
Alexandre C. Avatar answered Jan 28 '23 06:01

Alexandre C.