* Release the external pointer (if any) immediately. This will cause * the pointer to be deleted and it's storage to be set to NULL. * After this call the get() method returns NULL and the checked_get() * method throws an exception. * * See the discussion here for the basic logic behind release: * https://stat.ethz.ch/pipermail/r-help/2007-August/137871.html */
| 181 | * https://stat.ethz.ch/pipermail/r-help/2007-August/137871.html |
| 182 | */ |
| 183 | void release() { |
| 184 | |
| 185 | if (get() != NULL) { |
| 186 | // Call the finalizer -- note that this implies that finalizers |
| 187 | // need to be ready for a NULL external pointer value (our |
| 188 | // default C++ finalizer is since delete NULL is a no-op). |
| 189 | // This clears the external pointer just before calling the finalizer, |
| 190 | // to avoid interesting behavior with co-dependent finalizers. |
| 191 | finalizer_wrapper<T,Finalizer>(Storage::get__()); |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | inline operator T*() { |
| 196 | return checked_get(); |
no test coverage detected