Ariles
boost_pointer.h
Go to the documentation of this file.
1 /**
2  @file
3  @author Alexander Sherikov
4 
5  @copyright 2017-2018 Alexander Sherikov, Licensed under the Apache License, Version 2.0.
6  (see @ref LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
7 
8  @brief
9 */
10 
11 #pragma once
12 
13 #include <boost/smart_ptr/shared_ptr.hpp>
14 #include <boost/smart_ptr/make_shared.hpp>
15 
16 namespace ariles
17 {
18  template <class t_Value>
19  class PointerHandler<boost::shared_ptr<t_Value> >
20  {
21  public:
22  typedef boost::shared_ptr<t_Value> Pointer;
23  typedef t_Value Value;
24 
25 
26  public:
27  static void allocate(Pointer &ptr)
28  {
29  ptr = boost::make_shared<t_Value>();
30  }
31 
32  static void reset(Pointer &ptr)
33  {
34  ptr.reset();
35  }
36 
37  static bool isNull(const Pointer &ptr)
38  {
39  return (NULL == ptr);
40  }
41  };
42 } // namespace ariles
43 #define ARILES_POINTER_TYPE boost::shared_ptr
44 #define ARILES_POINTER_HANDLER BoostSharedPtrHandler
46 
47 
48 // this version is known to work
49 #if BOOST_VERSION >= 105800
50 # include <boost/move/unique_ptr.hpp>
51 # include <boost/move/make_unique.hpp>
52 
53 namespace ariles
54 {
55  template <class t_Value>
56  class PointerHandler<boost::movelib::unique_ptr<t_Value> >
57  {
58  public:
59  typedef boost::movelib::unique_ptr<t_Value> Pointer;
60  typedef t_Value Value;
61 
62 
63  public:
64  static void allocate(Pointer &ptr)
65  {
66  ptr = boost::movelib::make_unique<t_Value>();
67  }
68 
69  static void reset(Pointer &ptr)
70  {
71  ptr.reset();
72  }
73 
74  static bool isNull(const Pointer &ptr)
75  {
76  return (NULL == ptr);
77  }
78  };
79 } // namespace ariles
80 
81 # define ARILES_POINTER_TYPE boost::movelib::unique_ptr
83 #endif
class ARILES_VISIBILITY_ATTRIBUTE PointerHandler
Definition: helpers.h:114
Definition: basic.h:17