MCPcopy Create free account
hub / github.com/cztomczak/cefpython / scoped_ptr

Class scoped_ptr

src/include/base/cef_scoped_ptr.h:353–486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351// types.
352template <class T, class D = base::DefaultDeleter<T>>
353class scoped_ptr {
354 MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue)
355
356 COMPILE_ASSERT(base::cef_internal::IsNotRefCounted<T>::value,
357 T_is_refcounted_type_and_needs_scoped_refptr);
358
359 public:
360 // The element and deleter types.
361 typedef T element_type;
362 typedef D deleter_type;
363
364 // Constructor. Defaults to initializing with NULL.
365 scoped_ptr() : impl_(NULL) {}
366
367 // Constructor. Takes ownership of p.
368 explicit scoped_ptr(element_type* p) : impl_(p) {}
369
370 // Constructor. Allows initialization of a stateful deleter.
371 scoped_ptr(element_type* p, const D& d) : impl_(p, d) {}
372
373 // Constructor. Allows construction from a scoped_ptr rvalue for a
374 // convertible type and deleter.
375 //
376 // IMPLEMENTATION NOTE: C++11 unique_ptr<> keeps this constructor distinct
377 // from the normal move constructor. By C++11 20.7.1.2.1.21, this constructor
378 // has different post-conditions if D is a reference type. Since this
379 // implementation does not support deleters with reference type,
380 // we do not need a separate move constructor allowing us to avoid one
381 // use of SFINAE. You only need to care about this if you modify the
382 // implementation of scoped_ptr.
383 template <typename U, typename V>
384 scoped_ptr(scoped_ptr<U, V> other) : impl_(&other.impl_) {
385 COMPILE_ASSERT(!base::is_array<U>::value, U_cannot_be_an_array);
386 }
387
388 // Constructor. Move constructor for C++03 move emulation of this type.
389 scoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) {}
390
391 // operator=. Allows assignment from a scoped_ptr rvalue for a convertible
392 // type and deleter.
393 //
394 // IMPLEMENTATION NOTE: C++11 unique_ptr<> keeps this operator= distinct from
395 // the normal move assignment operator. By C++11 20.7.1.2.3.4, this templated
396 // form has different requirements on for move-only Deleters. Since this
397 // implementation does not support move-only Deleters, we do not need a
398 // separate move assignment operator allowing us to avoid one use of SFINAE.
399 // You only need to care about this if you modify the implementation of
400 // scoped_ptr.
401 template <typename U, typename V>
402 scoped_ptr& operator=(scoped_ptr<U, V> rhs) {
403 COMPILE_ASSERT(!base::is_array<U>::value, U_cannot_be_an_array);
404 impl_.TakeState(&rhs.impl_);
405 return *this;
406 }
407
408 // Reset. Deletes the currently owned object, if any.
409 // Then takes ownership of a new object, if given.
410 void reset(element_type* p = NULL) { impl_.reset(p); }

Callers

nothing calls this directly

Calls 3

TakeStateMethod · 0.80
releaseMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected