aboutsummaryrefslogtreecommitdiffstats
path: root/src/math/gfpmath/freestore.h
blob: f83d1e867a60c52953657c3ea2faaa5231230df8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**************************************************
* (C) 2007 Christoph Ludwig                       *
*          ludwig@fh-worms.de                     *
**************************************************/

#ifndef BOTAN_FREESTORE_H__
#define BOTAN_FREESTORE_H__

#if defined(BOTAN_USE_TR1_SHARED_PTR)
  #include <tr1/memory>
#elif defined(BOTAN_USE_BOOST_TR1_SHARED_PTR)
  #include <boost/tr1/memory.hpp>
#else
  #error "Please choose a shared_ptr implementation"
#endif

namespace Botan {

template<typename T>
class BOTAN_DLL SharedPtrConverter
   {
   public:
      typedef std::tr1::shared_ptr<T> SharedPtr;

      SharedPtrConverter() : ptr() {};
      SharedPtrConverter(SharedPtrConverter const& other)
         : ptr(other.ptr) {};

      template<typename Ptr>
      SharedPtrConverter(Ptr p)
         : ptr(p) {};

      SharedPtr const& get_ptr() const { return this->ptr; }
      SharedPtr get_ptr() { return this->ptr; }

      SharedPtr const& get_shared() const { return this->ptr; }
      SharedPtr get_shared() { return this->ptr; }

   private:
      SharedPtr ptr;
   };

}

#endif