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 #include "../internal/helpers.h"
16 
17 namespace ariles2
18 {
19  template <class t_Value>
20  class PointerHandler<boost::shared_ptr<t_Value> >
21  {
22  public:
23  typedef boost::shared_ptr<t_Value> Pointer;
24  typedef t_Value Value;
25 
26 
27  public:
28  static void allocate(Pointer &ptr)
29  {
30  ptr = boost::make_shared<t_Value>();
31  }
32 
33  static void reset(Pointer &ptr)
34  {
35  ptr.reset();
36  }
37 
38  static bool isNull(const Pointer &ptr)
39  {
40  return (NULL == ptr);
41  }
42  };
43 } // namespace ariles2
44 #define ARILES2_POINTER_TYPE boost::shared_ptr
45 #define ARILES2_POINTER_HANDLER BoostSharedPtrHandler
47 
48 
49 // this version is known to work
50 #if BOOST_VERSION >= 105800
51 # include <boost/move/unique_ptr.hpp>
52 # include <boost/move/make_unique.hpp>
53 
54 namespace ariles2
55 {
56  template <class t_Value>
57  class PointerHandler<boost::movelib::unique_ptr<t_Value> >
58  {
59  public:
60  typedef boost::movelib::unique_ptr<t_Value> Pointer;
61  typedef t_Value Value;
62 
63 
64  public:
65  static void allocate(Pointer &ptr)
66  {
67  ptr = boost::movelib::make_unique<t_Value>();
68  }
69 
70  static void reset(Pointer &ptr)
71  {
72  ptr.reset();
73  }
74 
75  static bool isNull(const Pointer &ptr)
76  {
77  return (NULL == ptr);
78  }
79  };
80 } // namespace ariles2
81 
82 # define ARILES2_POINTER_TYPE boost::movelib::unique_ptr
84 #endif
ariles2
Definition: basic.h:16
ariles2::PointerHandler< boost::shared_ptr< t_Value > >::allocate
static void allocate(Pointer &ptr)
Definition: boost_pointer.h:28
ariles2::PointerHandler< boost::shared_ptr< t_Value > >::reset
static void reset(Pointer &ptr)
Definition: boost_pointer.h:33
ariles2::PointerHandler
class ARILES2_VISIBILITY_ATTRIBUTE PointerHandler
Definition: helpers.h:150
ariles2::PointerHandler< boost::shared_ptr< t_Value > >::Pointer
boost::shared_ptr< t_Value > Pointer
Definition: boost_pointer.h:23
ariles2::PointerHandler< boost::shared_ptr< t_Value > >::Value
t_Value Value
Definition: boost_pointer.h:24
ariles2::PointerHandler< boost::shared_ptr< t_Value > >::isNull
static bool isNull(const Pointer &ptr)
Definition: boost_pointer.h:38
generic_pointer.h