STIR 6.4.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*/
19
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"
26START_NAMESPACE_STIR
34template <typename T>
35inline bool
36is_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
45template <typename T>
46inline bool
47is_null_ptr(shared_ptr<T> const& sptr)
48{
49 return is_null_ptr(sptr.get());
50}
51
52template <typename T>
53inline bool
54is_null_ptr(unique_ptr<T> const& aptr)
55{
56 return is_null_ptr(aptr.get());
57}
58
59#ifndef BOOST_NO_CXX11_NULLPTR
60inline bool
61is_null_ptr(const std::nullptr_t)
62{
63 return true;
64}
65#endif
66
68
69END_NAMESPACE_STIR
70
71#endif
Import of std::shared_ptr, std::dynamic_pointer_cast and std::static_pointer_cast into the stir names...
Import of std::unique_ptr into the stir namespace, together with work-arounds for other compilers.