Boost logo

Boost Users :

Subject: Re: [Boost-users] [scoped_ptr] How to cast from bast type to decived type
From: Roman Perepelitsa (roman.perepelitsa_at_[hidden])
Date: 2009-11-05 12:24:49


2009/11/5 Mario Klebsch <mkl_at_[hidden]>

> boost::scoped_ptr<base_t> Ptr;
> Ptr.reset(new derived_t());
>
> Prior to using a scoped_ptr, I could write:
>
> ((derived_t*)Ptr)->Method();

  ((derived_t*)Ptr->get())->Method();

or a safer version:
  static_cast<derived_t*>(Ptr->get())->Method();

Roman Perepelitsa.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net