Passing a std::shared_ptr<T> to a function that takes a std::shared_ptr<const T>?
template <typename T>
void cfunc(std::shared_ptr<const T> ptr){
// implementation
}
template <typename T>
void func(std::shared_ptr<T> ptr){ return cfunc<T>(std::move(ptr)); }
template <typename T>
void func(std::shared_ptr<const T> ptr){ return cfunc<T>(std::move(ptr)); }
this matches how cbegin
works, and the "overloads" are trivial forwarders with nearly zero cost.