Ariles
Loading...
Searching...
No Matches
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
17namespace ariles2
18{
19 template <class t_Value>
20 class PointerHandler<boost::shared_ptr<t_Value>>
21 {
22 public:
23 using Pointer = boost::shared_ptr<t_Value>;
24 using Value = t_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 (nullptr == 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
54namespace ariles2
55{
56 template <class t_Value>
57 class PointerHandler<boost::movelib::unique_ptr<t_Value>>
58 {
59 public:
60 using Pointer = boost::movelib::unique_ptr<t_Value>;
61 using Value = t_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 (nullptr == ptr);
78 }
79 };
80} // namespace ariles2
81
82# define ARILES2_POINTER_TYPE boost::movelib::unique_ptr
84#endif