#include <iostream>
struct A
{
void foo() { std::cout << "A::foo()\n" ; }
void foo() const { std::cout << "A::foo() const\n" ; }
};
template < typename T > struct B
{
private: typename std::remove_const<T>::type private_data ;
public: T& public_data = private_data ;
};
int main()
{
B<A> x ; x.public_data.foo() ; // A::foo()
B<const A> y ; y.public_data.foo() ; // A::foo() const
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IEEKewogICAgdm9pZCBmb28oKSB7IHN0ZDo6Y291dCA8PCAiQTo6Zm9vKClcbiIgOyB9CiAgICB2b2lkIGZvbygpIGNvbnN0IHsgc3RkOjpjb3V0IDw8ICJBOjpmb28oKSBjb25zdFxuIiA7IH0KfTsKCnRlbXBsYXRlIDwgdHlwZW5hbWUgVCA+IHN0cnVjdCBCCnsKICAgIHByaXZhdGU6IHR5cGVuYW1lIHN0ZDo6cmVtb3ZlX2NvbnN0PFQ+Ojp0eXBlIHByaXZhdGVfZGF0YSA7CiAgICBwdWJsaWM6IFQmIHB1YmxpY19kYXRhID0gcHJpdmF0ZV9kYXRhIDsKfTsKCmludCBtYWluKCkKewogICAgQjxBPiB4IDsgeC5wdWJsaWNfZGF0YS5mb28oKSA7IC8vIEE6OmZvbygpCgogICAgQjxjb25zdCBBPiB5IDsgeS5wdWJsaWNfZGF0YS5mb28oKSA7IC8vIEE6OmZvbygpIGNvbnN0Cn0K