decorated_tuple::cow_ptr decorated_tuple::make(cow_ptr d, vector_type v) { auto ptr = dynamic_cast<const decorated_tuple*>(d.get()); if (ptr) { d = ptr->decorated(); auto& pmap = ptr->mapping(); for (size_t i = 0; i < v.size(); ++i) { v[i] = pmap[v[i]]; } } return make_counted<decorated_tuple>(std::move(d), std::move(v)); }
inline bool operator==(const cow_ptr<X>& lhs, const cow_ptr<Y>& rhs) { return lhs.get() == rhs.get(); }
cow_ptr(cow_ptr<Y> const& other) : m_ptr(const_cast<Y*>(other.get())) { }
cow_ptr(cow_ptr<Y> other) : m_ptr(other.get()) { static_assert(std::is_convertible<Y*, T*>::value, "Y* is not assignable to T*"); }