Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
1.6 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. autoptr.hxx
  6. Abstract:
  7. Auto pointer inline implmentation.
  8. Author:
  9. Steve Kiraly (SteveKi) 5/15/96
  10. Revision History:
  11. --*/
  12. // Constructor
  13. template< class T >
  14. _INLINE
  15. auto_ptr<T>::
  16. auto_ptr(
  17. T *p
  18. ) : pointee(p)
  19. {
  20. };
  21. // Destructor
  22. template< class T >
  23. _INLINE
  24. auto_ptr<T>::
  25. ~auto_ptr(
  26. VOID
  27. )
  28. {
  29. delete pointee;
  30. };
  31. // Dereference
  32. template< class T >
  33. _INLINE
  34. T&
  35. auto_ptr<T>::
  36. operator*(
  37. VOID
  38. ) const
  39. {
  40. return *pointee;
  41. }
  42. // Dereference
  43. template< class T >
  44. _INLINE
  45. T*
  46. auto_ptr<T>::
  47. operator->(
  48. VOID
  49. ) const
  50. {
  51. return pointee;
  52. }
  53. // Return value of current dumb pointer
  54. template< class T >
  55. _INLINE
  56. T*
  57. auto_ptr<T>::
  58. get(
  59. VOID
  60. ) const
  61. {
  62. return pointee;
  63. }
  64. // Relinquish ownership of current dumb pointer
  65. template< class T >
  66. _INLINE
  67. T *
  68. auto_ptr<T>::
  69. release(
  70. VOID
  71. )
  72. {
  73. T *oldPointee = pointee;
  74. pointee = 0;
  75. return oldPointee;
  76. }
  77. // Delete owned dumb pointer
  78. template< class T >
  79. _INLINE
  80. VOID
  81. auto_ptr<T>::
  82. reset(
  83. T *p
  84. )
  85. {
  86. delete pointee;
  87. pointee = p;
  88. }
  89. // Copying an auto pointer
  90. template< class T >
  91. _INLINE
  92. auto_ptr<T>::
  93. auto_ptr(
  94. const auto_ptr<T>& rhs
  95. ) : pointee( rhs.release() )
  96. {
  97. }
  98. // Assign one auto pointer to another
  99. template< class T >
  100. _INLINE
  101. const auto_ptr<T>&
  102. auto_ptr<T>::
  103. operator=(
  104. const auto_ptr<T>& rhs
  105. )
  106. {
  107. if( this != &rhs )
  108. {
  109. reset( rhs.release() );
  110. }
  111. return *this;
  112. }