It is the following example
#include <iostream>
#include <memory>
class B{
public:
void foo() const{
std::cout << "foo const" << std::endl;
}
void foo() {
std::cout << "foo non-const" << std::endl;
}
};
class A{
public:
void bar() const{
std::cout << "bar const" << std::endl;
b_->foo();
}
void bar() {
std::cout << "bar non-const" << std::endl;
b_->foo();
}
std::shared_ptr<B> b_{std::make_shared<B>()};
};
int main(){
A const a;
a.bar();
}
Based on standard correctly the const is not propagated and foo non-const is called. My question how to implement propagation_const in version before C++17?