• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//  (C) Copyright John Maddock 2001.
2//  Use, modification and distribution are subject to the
3//  Boost Software License, Version 1.0. (See accompanying file
4//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6//  See http://www.boost.org/libs/config for most recent version.
7
8//  MACRO:         BOOST_NO_AUTO_PTR
9//  TITLE:         std::auto_ptr
10//  DESCRIPTION:   If the compiler / library supplies non-standard or broken
11//                 std::auto_ptr.
12
13#include <memory>
14
15namespace boost_no_auto_ptr{
16
17template <class T>
18class my_ptr
19{
20   T* p;
21public:
22   my_ptr(std::auto_ptr<T>& r)
23   {
24      p = r.release();
25   }
26   my_ptr& operator=(std::auto_ptr<T>& r)
27   {
28      delete p;
29      p = r.release();
30      return *this;
31   }
32   ~my_ptr()
33   {
34      delete p;
35   }
36};
37
38
39int test()
40{
41   std::auto_ptr<int> ap1(new int);
42   my_ptr<int> mp(ap1);
43   std::auto_ptr<int> ap2(new int);
44   mp = ap2;
45
46   return 0;
47}
48
49}
50
51
52
53
54