I have a function which returns a shared pointer of type const A
.
std::shared_ptr< const A> getPointer() const;
and I have a function which needs a shared_ptr of type A
.
void foo(std::shared_ptr<A> a);
When I try to call my function I get the following message:
error: no viable conversion from 'shared_ptr< const A>' to 'shared_ptr< A >'
I do not care about performance. This line of code is in a GUI and by all means not part of any hot code. (This means I do not care if I create a copy of A
or not)
What is the easiest solution to fix this?