strusBase  0.17
local_ptr.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Patrick P. Frey
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
9 #ifndef _STRUS_BASE_LOCAL_PTR_HPP_INCLUDED
10 #define _STRUS_BASE_LOCAL_PTR_HPP_INCLUDED
11 #include <memory>
12 
13 #if __cplusplus >= 201103L
14 #define STRUS_USE_STD_UNIQUE_PTR
15 #else
16 #undef STRUS_USE_STD_UNIQUE_PTR
17 #endif
18 
19 namespace strus {
20 
21 #if defined STRUS_USE_STD_UNIQUE_PTR
22 template <typename T>
23 class local_ptr : public std::unique_ptr<T>
24 {
25 public:
26  explicit local_ptr( T* p = 0 ) :std::unique_ptr<T>(p) {}
27 };
28 #else //STRUS_USE_STD_UNIQUE_PTR
29 template <typename T>
30 class local_ptr : public std::auto_ptr<T>
31 {
32 public:
33  explicit local_ptr( T* p = 0 ) :std::auto_ptr<T>(p) {}
34 };
35 #endif //STRUS_USE_STD_UNIQUE_PTR
36 
37 } //namespace
38 #endif
39 
40 
Definition: local_ptr.hpp:30
local_ptr(T *p=0)
Definition: local_ptr.hpp:33