STIR  6.2.0
is_null_ptr.h
Go to the documentation of this file.
1 //
2 //
3 /*
4  Copyright (C) 2000- 2013, Hammersmith Imanet Ltd
5  Copyright (C) 2016, University College London
6  This file is part of STIR.
7 
8  SPDX-License-Identifier: Apache-2.0
9 
10  See STIR/LICENSE.txt for details
11 */
20 #ifndef __stir_is_null_ptr_H__
21 #define __stir_is_null_ptr_H__
22 
23 #include "stir/shared_ptr.h"
24 #include <memory>
25 #include "stir/unique_ptr.h"
26 START_NAMESPACE_STIR
34 template <typename T>
35 inline bool
36 is_null_ptr(T const* const ptr)
37 {
38 #ifdef BOOST_NO_CXX11_NULLPTR
39  return ptr == 0;
40 #else
41  return ptr == nullptr;
42 #endif
43 }
44 
45 template <typename T>
46 inline bool
47 is_null_ptr(shared_ptr<T> const& sptr)
48 {
49  return is_null_ptr(sptr.get());
50 }
51 
52 template <typename T>
53 inline bool
54 is_null_ptr(unique_ptr<T> const& aptr)
55 {
56  return is_null_ptr(aptr.get());
57 }
58 
59 #ifndef BOOST_NO_CXX11_NULLPTR
60 inline bool
61 is_null_ptr(const std::nullptr_t)
62 {
63  return true;
64 }
65 #endif
66 
68 
69 END_NAMESPACE_STIR
70 
71 #endif
Import of std::shared_ptr, std::dynamic_pointer_cast and std::static_pointer_cast (or corresponding b...
Import of std::unique_ptr into the stir namespace, together with work-arounds for other compilers...