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?
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?
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.
You get access to all versions of a method/operator with the same name in that parent.
both. did you try it? (damn this answer is short: ah well, here is example:
#include <iostream>
#include <string>
struct bar
{
void foo() { std::cout << "non_c:foo()" << std::endl; }
void foo() const { std::cout << "c:foo()" << std::endl; }
};
class base
{
public:
bar* operator->() { return &b; }
bar const* operator->() const { return &b; }
private:
bar b;
};
class derived : public base
{
public:
using base::operator->;
};
int main(void)
{
const derived d = derived();
derived e;
d->foo();
e->foo();
}