SlideShare ist ein Scribd-Unternehmen logo
1 von 171
October 28, November 4,  December 2, 2005 Beware of Pointers! Dr. Partha Pratim Das Interra Systems (India) Pvt. Ltd.   Resource Management Series
Resource Management ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Motivation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Raw Pointers A Raw Deal?
What is a Raw Pointer? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Pointered Languages :  Pascal, Ada, C, C++
What is a Raw Pointer? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What is a Raw Pointer? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ownership Issue of Pointers ,[object Object],[object Object],// Create ownership MyClass *p = new MyClass; // Lose ownership p = 0;
Ownership Issue of Pointers ,[object Object],[object Object],// Create ownership   MyClass *p = new MyClass; // Copy ownership – no Copy Constructor!   MyClass *q = p; // Delete Object & Remove ownership  delete q; // Delete Object – where is the ownership?  delete p;
Ownership Issue of Pointers ,[object Object],[object Object],void MyAction() { // Create ownership   MyClass *p = new MyClass; // What if an exception is thrown here?   p->Function(); // Delete Object & Remove ownership  delete p; }
Ownership Issue of Pointers ,[object Object],void MyAction() { MyClass *p = 0; try { MyClass *p = new MyClass; p->Function(); } catch (…) { delete p;  // Repeated code throw; } delete p; }
Ownership Issue of Pointers ,[object Object],void MyDoubleAction() { MyClass *p = 0, *q = 0; try { MyClass *p = new MyClass; p->Function(); MyClass *q = new MyClass; q->Function(); } catch (…) { delete p;  // Repeated code delete q;  // Repeated code throw; } delete p; delete q; }
Pointer Hazards ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pointer Hazards: PREfix Simulation Results
A Pointer-free World Reality or Utopia?
How to deal with an Object? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pointers vis-à-vis Reference ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pointers-free Languages ,[object Object],[object Object],[object Object],[object Object]
Pointers-free Languages ,[object Object],[object Object],[object Object],[object Object]
Pointers-free Languages ,[object Object],[object Object],[object Object],“ Most studies agree that pointers are one of the primary features that enable programmers to put bugs into their code. Given that structures are gone, and arrays and strings are objects, the need for pointers to these constructs goes away . ” –  The Java Language Environment: A White Paper , Sun 1995. ( http://java.sun.com )
Pointers-free Languages ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pointers-free Languages ,[object Object],[object Object],[object Object],[object Object],[object Object],“ Programming languages should be designed not by piling feature on top of feature, but by removing the weaknesses and restrictions that make additional features appear necessary. ” –  Revised Report on Scheme, 1991
Pointers-free Languages ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],“ A language that doesn't affect the way you think about programming, is not worth knowing. ”  – Alan Perlis
Smart Pointers in C++ The Smartness …
What is Smart Pointer? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What is Smart Pointer? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A Simple Smart Pointer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A Smart Pointer mimics a Raw Pointer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Smart Pointer Member Functions ,[object Object],[object Object],SmartPtr<Printer> spRes = ...;  spRes->Acquire();  // acquire the printer ... print a document ...   spRes->Release();  // release the printer  spRes.Release();  // release the pointer to the printer // GetImpl returns the pointer object stored by SmartPtr template <class T> T* GetImpl(SmartPtr<T>& sp);  // GetImplRef returns a reference to the pointer stored by SmartPtr template <class T> T*& GetImplRef(SmartPtr<T>& sp);  // Reset resets the underlying pointer to another value,  // Releases the previous one template <class T> void Reset(SmartPtr<T>& sp, T* source);  // Release releases ownership of the smart pointer template <class T> void Release(SmartPtr<T>& sp, T*& destination);
A Smart Pointer Use-Case ,[object Object],[object Object],[object Object],[object Object],[object Object]
A Smart Pointer Use-Case ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A Smart Pointer Use-Case ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A Smart Pointer Use-Case ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Smartness … ,[object Object],[object Object],[object Object],[object Object],[object Object]
The Smartness … ,[object Object],[object Object],[object Object],[object Object]
Smart Pointers in C++ Storage Policy
3–Way Storage Policy ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Smart Pointers in C++ Ownership Management Policy
Ownership Management Policy ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ownership Policy:  Destructive Copy ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ownership Policy:    Destructive Copy template <class T> class SmartPtr {  public:  SmartPtr(SmartPtr& src) {  // Src ptr is not const pointee_ = src.pointee_;  // Copy src.pointee_ = 0;  // Remove ownership for src ptr }  SmartPtr& operator=(SmartPtr& src) {  // Src ptr is not const if (this != &src) {  // Check & skip self-copy delete pointee_;  // Release destination object pointee_ = src.pointee_;  // Assignment src.pointee_ = 0;  // Remove ownership for src ptr }  return *this;  // Return the assigned Smart Pointer } ...  };
Ownership Policy:    Destructive Copy – The Maelstrom Effect ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],void Display(SmartPtr<Something> sp); ...  SmartPtr<Something> sp(new Something);  Display(sp);  // sinks sp STL Containers need FCO.
Ownership Policy:  Destructive Copy – Advantages  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ownership Policy:  Deep Copy ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ownership Policy:  Deep Copy – Object Slicing ,[object Object],[object Object],[object Object],template <class T>  class SmartPtr {  public:  SmartPtr(const SmartPtr& other):  pointee_(new T(*other.pointee_)) { ... }  ...  };
Ownership Policy:  Deep Copy – Transport Polymorphic Objects ,[object Object],[object Object],// Base class provides a prototype for Clone class AbstractBase { ...  virtual Base* Clone() = 0;  };  // Derived class implements Clone class Concrete : public AbstractBase { ...  virtual Base* Clone() {  return new Concrete(*this);  }  };
Ownership Policy:  Copy-on-Write (COW) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ownership Policy:  Reference Counting ,[object Object],[object Object],[object Object],[object Object],[object Object]
Ownership Policy:  Reference Counting ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ownership Policy:  Reference Counting: Non-Intrusive Counter ,[object Object],[object Object],[object Object]
Ownership Policy:  Reference Counting: Non-Intrusive Counter ,[object Object],[object Object]
Ownership Policy:  Reference Counting: Intrusive Counter ,[object Object],[object Object],[object Object]
Ownership Policy:  Reference Linking ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ownership Policy:  Reference Linking ,[object Object],[object Object],[object Object],[object Object]
Ownership Policy:  Reference Management – Disadvantage  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ownership Policy:  Cyclic Reference – Hack  ,[object Object],[object Object],[object Object],[object Object],[object Object],Smart Pointers “own”; Raw Pointers “disowns”?
Ownership Policy:  Cyclic Reference – Solution  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Smart Pointers in C++ Implicit Conversion
Implicit Conversion ,[object Object],[object Object],[object Object],// For maximum compatibility this should work void Fun(Something* p); ...  SmartPtr<Something> sp(new Something);  Fun(sp);  // OK or error? template <class T> class SmartPtr {  public:  operator T*()  // user-defined conversion to T*  { return pointee_; } ...  };
Implicit Conversion: The Pitfall ,[object Object],[object Object],[object Object],[object Object],// A gross semantic error that goes undetected at compile time  SmartPtr<Something> sp; ...  delete sp;  // Compiler passes this by casting to raw pointer template <class T> class SmartPtr {  public:  operator T*()  // User-defined conversion to T*   { return pointee_; }  operator void*()  // Added conversion to void*   { return pointee_; } ...  }; “ When in doubt, use brute force. ”  – Ken Thompson
Smart Pointers in C++ Null Tests
Null Tests ,[object Object],[object Object],[object Object],[object Object],[object Object],SmartPtr<Something> sp1, sp2;  Something* p; ...  if (sp1)  // Test 1: direct test for non-null pointer ...   if (!sp1)  // Test 2: direct test for null pointer ...  if (sp1 == 0)  // Test 3: explicit test for null pointer ...
Null Tests ,[object Object],template <class T> class SmartPtr {  public:  // Returns true iff pointee is NULL   bool operator!()  { return pointee_ == 0; }  }; if (sp1)  // Rewrite as  if (!!sp1) if (!sp1)  // Works fine if (sp1 == 0)  // Does not work
Smart Pointers in C++ Checking Policy
Checking Policy ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Checking Policy:  Initialization Checking ,[object Object],[object Object],[object Object],[object Object],template <class T> class SmartPtr {  public:    // Prohibit NULL for initialization   SmartPtr(T* p): pointee_(p) {  if (!p) throw NullPointerException();  } ...  };
Checking Policy:  Checking before Dereferencing ,[object Object],[object Object],[object Object],[object Object],template <class T> class SmartPtr {  public:  T& operator*() const {  // Dereferencing   if (!pointee_) throw NullPointerException();  else return *pointee_; }  T* operator->() const {  // Indirection   if (!pointee_) throw NullPointerException();  else return pointee_; }  ...  }; if (p)  {  /* Dereference & use p */  } else  {  /* Handle null pointer condition */  }
Checking Policy:  Error Reporting ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],template <class T> class SmartPtr {  public:  T& operator*() {  // Dereferencing. No Constant   if (!pointee_) pointee_ = new T; return *pointee_; }  T* operator->() {  // Indirection. No Constant   if (!pointee_) pointee_ = new T; return pointee_; }  ...  };
Smart Pointers in C++ Other Design Issues
What is a Smart Pointer? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Other Design Issues ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Smart Pointers in C++ Performance Issues
Space Overhead in Smart Pointers 4 pointer_next *n+4 pointer_prev *n Reference Linking 4 counter RC: Intrusive 4 pointer +4 counter RC: Non-Intrusive (1) 4 pointer *n+4 counter RC: Non-Intrusive (n) <= (n-1)*sizeof(<Object>) COW (n-1)*sizeof(<Object>) Deep Copy Nil Destructive Copy Overhead Ownership
Smart Pointer Timing (GCC, MSVC) ,[object Object],[object Object],[object Object]
Smart Pointers in Practice A Few Examples
Smart Pointers in Practice ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],“ Think of the Standard C++  auto_ptr  as the  Ford Escort  of smart pointers:  A simple general-purpose smart pointer that doesn't have all the gizmos and luxuries of special-purpose or high-performance smart pointers, but that does many common things well and is perfectly suitable for regular daily use. ”  – C/C++ Users Jounral, October 1999.
Smart Pointers in Practice ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Smart Pointers in Practice ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
std::auto_ptr The Smart Pointer in Standard Library
std::auto_ptr ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
std::auto_ptr ,[object Object],“ Think of the Standard C++  auto_ptr  as the  Ford Escort  of smart pointers:  A simple general-purpose smart pointer that doesn't have all the gizmos and luxuries of special-purpose or high-performance smart pointers, but that does many common things well and is perfectly suitable for regular daily use. ”  – C/C++ Users Jounral, October 1999.
std::auto_ptr ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
std::auto_ptr ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
std::auto_ptr Standard Interface Sample Implementation
std::auto_ptr Interface ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
std::auto_ptr Interface ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
std::auto_ptr Interface ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
std::auto_ptr Interface ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
std::auto_ptr Implementation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
std::auto_ptr Implementation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
std::auto_ptr Implementation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
std::auto_ptr Implementation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
std::auto_ptr Implementation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
std::auto_ptr Using Idioms
Using std::auto_ptr – Safety  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using std::auto_ptr – const-ness  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Guard Maelstrom Effect
Using std::auto_ptr –  Common Stuff ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using std::auto_ptr – reset() ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using std::auto_ptr – Ownership  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using std::auto_ptr – Source ,[object Object],[object Object],[object Object],[object Object],[object Object],Resource creator
Using std::auto_ptr – Sink ,[object Object],[object Object],[object Object],[object Object],Resource releaser
std::auto_ptr History
History of auto_ptr ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
History of auto_ptr ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
auto_ptr: Version 1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
auto_ptr: Version 1 – Shortcomings ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
auto_ptr: Version 2 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
auto_ptr: Version 2 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],These methods matter!
auto_ptr: Version 2 – Shortcomings ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
auto_ptr: Version 3 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Colvin-Gibbons Trick
auto_ptr: Version 3 – Advantages  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
auto_ptr: Version 3 – Advantages  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
auto_ptr: Version 3 – Advantages ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
auto_ptr: Version 3 – Advantages ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
auto_ptr: Version 3 – Advantages ,[object Object]
std::auto_ptr Portability
What is your auto_ptr? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
std::auto_ptr Pitfalls
auto_arrays! ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
auto_arrays! Survival ,[object Object],[object Object]
Coping with COAP ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Coping with COAP: Survival ,[object Object]
Smart Pointers in C++ References & Credits
References: Books ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
References: Papers ,[object Object],[object Object]
References: Online Help ,[object Object],[object Object],[object Object]
References: Codes ,[object Object]
References: Code URLs ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
References: Knowledge URLs ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Credits / Acknowledgements ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Thank You Don’t Beware of Pointers –  Just Be Aware of Smart Pointers
std::tr1::shared_ptr   std::tr1::weak_ptr Additional Smart Pointers in TR1 Standard Library of C++ ISO/IEC PDTR 19768. Doc No:  N1745=05-0005.  Date:  2005-01-17
Motivation for a Shared-Ownership Smart Pointer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Motivation for the  shared_ptr  (Shared-Ownership) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Motivation for the  shared_ptr  (Shared-Ownership) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Motivation for the  weak_ptr   (Shared-Ownership-Observer) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Implementation Difficulty of Shared-Ownership Smart Pointer ,[object Object],[object Object],[object Object]
Implementation Difficulty of Shared-Ownership Smart Pointer ,[object Object],[object Object],[object Object]
Implementation Difficulty of Shared-Ownership Smart Pointer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Additional Implementation Difficulty of  weak_ptr ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Impact on the Standard ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Design Decisions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Design Decisions: General Principles ,[object Object],[object Object],[object Object],[object Object],[object Object]
As Close to Raw Pointers as Possible’ but no close ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
As Close to Raw Pointers as Possible’ but no Closer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Just Do the Right Thing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
No Extra Parameter ,[object Object],[object Object],[object Object],[object Object]
“ Shares Ownership With” is an Equivalence Relation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
“ Shares Ownership With” is an Equivalence Relation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The “Empty Pointer” Concept ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The “Empty Pointer” Concept ,[object Object],[object Object],[object Object]
The “Empty Pointer” Concept ,[object Object],[object Object],[object Object],[object Object]
The “Empty Pointer” Concept ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The “Empty Pointer” Concept ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Design Decisions: shared_ptr ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Design Decisions: weak_ptr ,[object Object],[object Object],[object Object]
Design Decisions:  enable_shared_from_this
Design Decisions:  Size & Performance ,[object Object],[object Object],[object Object]
Design Decisions: Alternatives ,[object Object],[object Object]
Incomplete Type ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Smart Pointer Classes in <memory> ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
class bad_weak_ptr ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
class shared_ptr ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
class shared_ptr ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
class shared_ptr ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
class shared_ptr ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
class shared_ptr ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Design Decisions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Weitere ähnliche Inhalte

Was ist angesagt?

Java Script Patterns
Java Script PatternsJava Script Patterns
Java Script PatternsAllan Huang
 
the productive programer: mechanics
the productive programer: mechanicsthe productive programer: mechanics
the productive programer: mechanicselliando dias
 
Effective Scala (SoftShake 2013)
Effective Scala (SoftShake 2013)Effective Scala (SoftShake 2013)
Effective Scala (SoftShake 2013)mircodotta
 
2CPP04 - Objects and Classes
2CPP04 - Objects and Classes2CPP04 - Objects and Classes
2CPP04 - Objects and ClassesMichael Heron
 
Coder sans peur du changement avec la meme pas mal hexagonal architecture
Coder sans peur du changement avec la meme pas mal hexagonal architectureCoder sans peur du changement avec la meme pas mal hexagonal architecture
Coder sans peur du changement avec la meme pas mal hexagonal architectureThomas Pierrain
 
JavaScript - Programming Languages course
JavaScript - Programming Languages course JavaScript - Programming Languages course
JavaScript - Programming Languages course yoavrubin
 
iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)Netcetera
 
More Little Wonders of C#/.NET
More Little Wonders of C#/.NETMore Little Wonders of C#/.NET
More Little Wonders of C#/.NETBlackRabbitCoder
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascriptAyush Sharma
 
Introduction to mobile reversing
Introduction to mobile reversingIntroduction to mobile reversing
Introduction to mobile reversingjduart
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.pptcallroom
 
name name2 n2
name name2 n2name name2 n2
name name2 n2callroom
 

Was ist angesagt? (14)

Java Script Patterns
Java Script PatternsJava Script Patterns
Java Script Patterns
 
the productive programer: mechanics
the productive programer: mechanicsthe productive programer: mechanics
the productive programer: mechanics
 
Effective Scala (SoftShake 2013)
Effective Scala (SoftShake 2013)Effective Scala (SoftShake 2013)
Effective Scala (SoftShake 2013)
 
2CPP04 - Objects and Classes
2CPP04 - Objects and Classes2CPP04 - Objects and Classes
2CPP04 - Objects and Classes
 
Coder sans peur du changement avec la meme pas mal hexagonal architecture
Coder sans peur du changement avec la meme pas mal hexagonal architectureCoder sans peur du changement avec la meme pas mal hexagonal architecture
Coder sans peur du changement avec la meme pas mal hexagonal architecture
 
JavaScript - Programming Languages course
JavaScript - Programming Languages course JavaScript - Programming Languages course
JavaScript - Programming Languages course
 
iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)
 
More Little Wonders of C#/.NET
More Little Wonders of C#/.NETMore Little Wonders of C#/.NET
More Little Wonders of C#/.NET
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascript
 
Introduction to mobile reversing
Introduction to mobile reversingIntroduction to mobile reversing
Introduction to mobile reversing
 
ppt9
ppt9ppt9
ppt9
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.ppt
 
ppt18
ppt18ppt18
ppt18
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
 

Ähnlich wie Beware of Pointers

Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)Ovidiu Farauanu
 
Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2ppd1961
 
cf.Objective() 2017 - Design patterns - Brad Wood
cf.Objective() 2017 - Design patterns - Brad Woodcf.Objective() 2017 - Design patterns - Brad Wood
cf.Objective() 2017 - Design patterns - Brad WoodOrtus Solutions, Corp
 
Introduction To Csharp
Introduction To CsharpIntroduction To Csharp
Introduction To Csharpg_hemanth17
 
Introduction to-csharp-1229579367461426-1
Introduction to-csharp-1229579367461426-1Introduction to-csharp-1229579367461426-1
Introduction to-csharp-1229579367461426-1Sachin Singh
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharpRaga Vahini
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharpSatish Verma
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharpsinghadarsh
 
Introduction to CSharp
Introduction to CSharpIntroduction to CSharp
Introduction to CSharpMody Farouk
 
Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016maiktoepfer
 
An Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAn Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAdam Getchell
 
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management....NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...NETFest
 
DotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETDotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETMaarten Balliauw
 
Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#Talbott Crowell
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...Maarten Balliauw
 

Ähnlich wie Beware of Pointers (20)

Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)
 
Smart pointers
Smart pointersSmart pointers
Smart pointers
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2
 
cf.Objective() 2017 - Design patterns - Brad Wood
cf.Objective() 2017 - Design patterns - Brad Woodcf.Objective() 2017 - Design patterns - Brad Wood
cf.Objective() 2017 - Design patterns - Brad Wood
 
C++ Training
C++ TrainingC++ Training
C++ Training
 
Introduction To Csharp
Introduction To CsharpIntroduction To Csharp
Introduction To Csharp
 
Introduction to-csharp-1229579367461426-1
Introduction to-csharp-1229579367461426-1Introduction to-csharp-1229579367461426-1
Introduction to-csharp-1229579367461426-1
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
 
Introduction to CSharp
Introduction to CSharpIntroduction to CSharp
Introduction to CSharp
 
Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016
 
An Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAn Overview Of Python With Functional Programming
An Overview Of Python With Functional Programming
 
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management....NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
 
DotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETDotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NET
 
Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#
 
Modern C++
Modern C++Modern C++
Modern C++
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
 
All of javascript
All of javascriptAll of javascript
All of javascript
 

Mehr von ppd1961

Land of Pyramids, Petra, and Prayers - Egypt, Jordan, and Israel Tour
Land of Pyramids, Petra, and Prayers - Egypt, Jordan, and Israel TourLand of Pyramids, Petra, and Prayers - Egypt, Jordan, and Israel Tour
Land of Pyramids, Petra, and Prayers - Egypt, Jordan, and Israel Tourppd1961
 
Science & Culture Article with Editorial & Cover
Science & Culture Article with Editorial & CoverScience & Culture Article with Editorial & Cover
Science & Culture Article with Editorial & Coverppd1961
 
NDL @ YOJANA
NDL @ YOJANANDL @ YOJANA
NDL @ YOJANAppd1961
 
Unified Modeling Language (UML)
Unified Modeling Language (UML)Unified Modeling Language (UML)
Unified Modeling Language (UML)ppd1961
 
OOP in C++
OOP in C++OOP in C++
OOP in C++ppd1961
 
Digital geometry - An introduction
Digital geometry  - An introductionDigital geometry  - An introduction
Digital geometry - An introductionppd1961
 
Innovation in technology
Innovation in technologyInnovation in technology
Innovation in technologyppd1961
 
Kinectic vision looking deep into depth
Kinectic vision   looking deep into depthKinectic vision   looking deep into depth
Kinectic vision looking deep into depthppd1961
 
Function Call Optimization
Function Call OptimizationFunction Call Optimization
Function Call Optimizationppd1961
 
How To Define An Integer Constant In C
How To Define An Integer Constant In CHow To Define An Integer Constant In C
How To Define An Integer Constant In Cppd1961
 
Stl Containers
Stl ContainersStl Containers
Stl Containersppd1961
 
Object Lifetime In C C++
Object Lifetime In C C++Object Lifetime In C C++
Object Lifetime In C C++ppd1961
 
Technical Documentation By Techies
Technical Documentation By TechiesTechnical Documentation By Techies
Technical Documentation By Techiesppd1961
 
Vlsi Education In India
Vlsi Education In IndiaVlsi Education In India
Vlsi Education In Indiappd1961
 
Reconfigurable Computing
Reconfigurable ComputingReconfigurable Computing
Reconfigurable Computingppd1961
 
Women In Engineering Panel Discussion
Women In Engineering   Panel DiscussionWomen In Engineering   Panel Discussion
Women In Engineering Panel Discussionppd1961
 
Handling Exceptions In C &amp; C++[Part A]
Handling Exceptions In C &amp; C++[Part A]Handling Exceptions In C &amp; C++[Part A]
Handling Exceptions In C &amp; C++[Part A]ppd1961
 
Dimensions of Offshore Technology Services
Dimensions of Offshore Technology ServicesDimensions of Offshore Technology Services
Dimensions of Offshore Technology Servicesppd1961
 
Concepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming LanguagesConcepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming Languagesppd1961
 

Mehr von ppd1961 (20)

Land of Pyramids, Petra, and Prayers - Egypt, Jordan, and Israel Tour
Land of Pyramids, Petra, and Prayers - Egypt, Jordan, and Israel TourLand of Pyramids, Petra, and Prayers - Egypt, Jordan, and Israel Tour
Land of Pyramids, Petra, and Prayers - Egypt, Jordan, and Israel Tour
 
Science & Culture Article with Editorial & Cover
Science & Culture Article with Editorial & CoverScience & Culture Article with Editorial & Cover
Science & Culture Article with Editorial & Cover
 
NDL @ YOJANA
NDL @ YOJANANDL @ YOJANA
NDL @ YOJANA
 
Unified Modeling Language (UML)
Unified Modeling Language (UML)Unified Modeling Language (UML)
Unified Modeling Language (UML)
 
OOP in C++
OOP in C++OOP in C++
OOP in C++
 
Digital geometry - An introduction
Digital geometry  - An introductionDigital geometry  - An introduction
Digital geometry - An introduction
 
Innovation in technology
Innovation in technologyInnovation in technology
Innovation in technology
 
Kinectic vision looking deep into depth
Kinectic vision   looking deep into depthKinectic vision   looking deep into depth
Kinectic vision looking deep into depth
 
C++11
C++11C++11
C++11
 
Function Call Optimization
Function Call OptimizationFunction Call Optimization
Function Call Optimization
 
How To Define An Integer Constant In C
How To Define An Integer Constant In CHow To Define An Integer Constant In C
How To Define An Integer Constant In C
 
Stl Containers
Stl ContainersStl Containers
Stl Containers
 
Object Lifetime In C C++
Object Lifetime In C C++Object Lifetime In C C++
Object Lifetime In C C++
 
Technical Documentation By Techies
Technical Documentation By TechiesTechnical Documentation By Techies
Technical Documentation By Techies
 
Vlsi Education In India
Vlsi Education In IndiaVlsi Education In India
Vlsi Education In India
 
Reconfigurable Computing
Reconfigurable ComputingReconfigurable Computing
Reconfigurable Computing
 
Women In Engineering Panel Discussion
Women In Engineering   Panel DiscussionWomen In Engineering   Panel Discussion
Women In Engineering Panel Discussion
 
Handling Exceptions In C &amp; C++[Part A]
Handling Exceptions In C &amp; C++[Part A]Handling Exceptions In C &amp; C++[Part A]
Handling Exceptions In C &amp; C++[Part A]
 
Dimensions of Offshore Technology Services
Dimensions of Offshore Technology ServicesDimensions of Offshore Technology Services
Dimensions of Offshore Technology Services
 
Concepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming LanguagesConcepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming Languages
 

Beware of Pointers

  • 1. October 28, November 4, December 2, 2005 Beware of Pointers! Dr. Partha Pratim Das Interra Systems (India) Pvt. Ltd. Resource Management Series
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7. Raw Pointers A Raw Deal?
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17. Pointer Hazards: PREfix Simulation Results
  • 18. A Pointer-free World Reality or Utopia?
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27. Smart Pointers in C++ The Smartness …
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39. Smart Pointers in C++ Storage Policy
  • 40.
  • 41. Smart Pointers in C++ Ownership Management Policy
  • 42.
  • 43.
  • 44. Ownership Policy: Destructive Copy template <class T> class SmartPtr { public: SmartPtr(SmartPtr& src) { // Src ptr is not const pointee_ = src.pointee_; // Copy src.pointee_ = 0; // Remove ownership for src ptr } SmartPtr& operator=(SmartPtr& src) { // Src ptr is not const if (this != &src) { // Check & skip self-copy delete pointee_; // Release destination object pointee_ = src.pointee_; // Assignment src.pointee_ = 0; // Remove ownership for src ptr } return *this; // Return the assigned Smart Pointer } ... };
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61. Smart Pointers in C++ Implicit Conversion
  • 62.
  • 63.
  • 64. Smart Pointers in C++ Null Tests
  • 65.
  • 66.
  • 67. Smart Pointers in C++ Checking Policy
  • 68.
  • 69.
  • 70.
  • 71.
  • 72. Smart Pointers in C++ Other Design Issues
  • 73.
  • 74.
  • 75. Smart Pointers in C++ Performance Issues
  • 76. Space Overhead in Smart Pointers 4 pointer_next *n+4 pointer_prev *n Reference Linking 4 counter RC: Intrusive 4 pointer +4 counter RC: Non-Intrusive (1) 4 pointer *n+4 counter RC: Non-Intrusive (n) <= (n-1)*sizeof(<Object>) COW (n-1)*sizeof(<Object>) Deep Copy Nil Destructive Copy Overhead Ownership
  • 77.
  • 78. Smart Pointers in Practice A Few Examples
  • 79.
  • 80.
  • 81.
  • 82. std::auto_ptr The Smart Pointer in Standard Library
  • 83.
  • 84.
  • 85.
  • 86.
  • 87. std::auto_ptr Standard Interface Sample Implementation
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
  • 106.
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
  • 114.
  • 115.
  • 116.
  • 117.
  • 118.
  • 120.
  • 122.
  • 123.
  • 124.
  • 125.
  • 126. Smart Pointers in C++ References & Credits
  • 127.
  • 128.
  • 129.
  • 130.
  • 131.
  • 132.
  • 133.
  • 134. Thank You Don’t Beware of Pointers – Just Be Aware of Smart Pointers
  • 135. std::tr1::shared_ptr std::tr1::weak_ptr Additional Smart Pointers in TR1 Standard Library of C++ ISO/IEC PDTR 19768. Doc No: N1745=05-0005. Date: 2005-01-17
  • 136.
  • 137.
  • 138.
  • 139.
  • 140.
  • 141.
  • 142.
  • 143.
  • 144.
  • 145.
  • 146.
  • 147.
  • 148.
  • 149.
  • 150.
  • 151.
  • 152.
  • 153.
  • 154.
  • 155.
  • 156.
  • 157.
  • 158.
  • 159.
  • 160. Design Decisions: enable_shared_from_this
  • 161.
  • 162.
  • 163.
  • 164.
  • 165.
  • 166.
  • 167.
  • 168.
  • 169.
  • 170.
  • 171.

Hinweis der Redaktion

  1. An object has ValueSemantics when it can be treated as a single value. In C++ this means implementing a copy constructor and an assignment operator in such a way that when a new or existing instance is set equal to some other instance the new instance will be equivalent to the old one without acting as an alias to it. In computing , a first-class object (also -value , -entity , -citizen ), in the context of a particular programming language , is an entity which can be used in programs without restriction (when compared to other kinds of objects in the same language). Depending on the language, this can imply: being expressible as an anonymous literal value being storable in variables being storable in data structures having an intrinsic identity (independent of any given name) being comparable for equality with other entities being passable as a parameter to a procedure/function being returnable as the result of a procedure/function being constructable at runtime For example, in C , it is not possible to create new functions at runtime (however, see discussion ), whereas other kinds of object can be created at runtime. So functions in C are not first-class objects; sometimes they are called &amp;quot; second-class objects &amp;quot;. Similarly, strings are not first class objects in Fortran as it is not possible to assign them to variables, whereas numbers can be so assigned. Retrieved from &amp;quot; http://en.wikipedia.org/wiki/First-class_object &amp;quot;
  2. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  3. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  4. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  5. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  6. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  7. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  8. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  9. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  10. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  11. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  12. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  13. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  14. Source: cv-qualified type : http://www.embedded.com/showArticle.jhtml?articleID=9900322 A cv-qualified type has the form &amp;quot; cv T &amp;quot; where, cv is a sequence of cv-qualifiers ( const and volatile ) and T is a type (without cv-qualifiers). The sequence cv can be empty, just const by itself, just volatile by itself, or const volatile (in either order). For any two sequences of cv-qualifiers cv1 and cv2 , we say that cv1 has the same or greater cv-qualification than cv2 , and write cv1 &gt;= cv2 , if every cv-qualifier in cv2 also appears in cv1 . If cv1 &gt;= cv2 is false, then we say that cv1 has less cv-qualification than cv2 . “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  15. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  16. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  17. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  18. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  19. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  20. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  21. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  22. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  23. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html “ We have since produced a proof of concept implementation that follows the first model and statisfies the requirement without significant size or performance implications. As a result, this version of the proposal requires use_count() == 0 to hold for all empty pointers, and the code sample will reliably print &amp;quot;std::bad_weak_ptr&amp;quot;.” – What does it mean?
  24. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  25. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  26. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  27. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  28. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html
  29. Source: “ Incomplete Types” (MSDN) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccelng/htm/decla_39.asp “ Incomplete Types” (IBM) http://publib.boulder.ibm.com/infocenter/macxhelp/index.jsp?topic=/com.ibm.vacpp6m.doc/language/ref/clrc03incotyp.htm
  30. Source: “ A Proposal to Add General Purpose Smart Pointers to the Library Technical Report ”, 27-Mar-03. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html