diff --git a/dune/common/shared_ptr.hh b/dune/common/shared_ptr.hh index ce4546b64a0284de8bbf610c9f773640ecb0541a..5ca23029fd8675e87b2171e9620d6558277bfde2 100644 --- a/dune/common/shared_ptr.hh +++ b/dune/common/shared_ptr.hh @@ -90,6 +90,11 @@ namespace Dune /** \brief Dereference as const pointer */ inline const element_type* operator->() const; + /** \brief Access to the raw pointer, if you really want it */ + element_type* get() const { + return rep_->rep_; + } + /** \brief Decrease the reference count by one and free the memory if the reference count has reached 0 */ diff --git a/dune/common/test/smartpointertest.cc b/dune/common/test/smartpointertest.cc index 66c091f5904d06d47d97f8bcd0dc2e0713dee718..9871296f446e1d5f559c2e83acf835c174a67e1d 100644 --- a/dune/common/test/smartpointertest.cc +++ b/dune/common/test/smartpointertest.cc @@ -38,6 +38,10 @@ int main(){ assert(bar); assert(bar.use_count()==1); + // test get() + double* barPtr = bar.get(); + assert(barPtr); + // test constructor from a given pointer shared_ptr<double> b(new double(42.0)); {