NASaCJ

Programmer, Photography, Guitar

  • ABOUT

Recent Posts

  • A very fast low latency async Logger for C++
  • 亚丁的央迈勇
  • 亚丁一瞥
  • Linear Regression, Gradient Descent Implementation in C++
  • Weak_ptr solves Cyclic Reference Problem of shared_ptr when designing Interfaces in Object Models

Recent Comments

  • Weak_ptr solves Cyclic Reference Problem of shared_ptr when designing Interfaces in Object Models | NASaCJ on Use shared_ptr inheritance rightly when design and use interfaces
  • nasacj on Use shared_ptr inheritance rightly when design and use interfaces

Archives

  • September 2019
  • October 2018
  • September 2018
  • March 2016
  • September 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015
  • December 2014

Categories

  • Notes
  • Photo
  • Programming
    • C++
      • Boost
    • Leetcode
    • Machine Learning
    • Network
      • TCP
  • Travelling
  • Uncategorized

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Category: Boost

Smart Pointer Programming Techniques

February 2, 2015 by nasacj·0 Comments

Smart Pointer Programming Techniques

Using incomplete classes for implementation hiding
The “Pimpl” idiom
Using abstract classes for implementation hiding
Preventing delete px.get()
Using a shared_ptr to hold a pointer to an array
Encapsulating allocation details, wrapping factory functions
Using a shared_ptr to hold a pointer to a statically allocated object
Using a shared_ptr to hold a pointer to a COM object
Using a shared_ptr to hold a pointer to an object with an embedded reference count
Using a shared_ptr to hold another shared ownership smart pointer
Obtaining a shared_ptr from a raw pointer
Obtaining a shared_ptr (weak_ptr) to this in a constructor
Obtaining a shared_ptr to this
Using shared_ptr as a smart counted handle
Using shared_ptr to execute code on block exit
Using shared_ptr<void> to hold an arbitrary object
Associating arbitrary data with heterogeneous shared_ptr instances
Using shared_ptr as a CopyConstructible mutex lock
Using shared_ptr to wrap member function calls
Delayed deallocation
Weak pointers to objects not managed by a shared_ptr

Proudly powered by WordPress. Theme: Flat 1.7.11 by Themeisle.