2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
15 \brief pimpl_ptr inline template implementation */
17 //#include "pimpl_ptr.ih"
20 #include "IgnoreValue.hh"
22 #define prefix_ inline
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
26 // senf::pimpl_ptr<T,CloneAllocator>
28 template <typename T, class CloneAllocator>
29 prefix_ senf::pimpl_ptr<T,CloneAllocator>::pimpl_ptr(T* pointee)
32 // Is it fair to assume pointer assignment to be atomic on multi-threaded platforms ?
34 doDelete_ = &myDeleteFn;
37 template <typename T, class CloneAllocator>
38 prefix_ senf::pimpl_ptr<T,CloneAllocator>::pimpl_ptr(const pimpl_ptr & rhs)
42 template <typename T, class CloneAllocator>
43 prefix_ senf::pimpl_ptr<T,CloneAllocator>::~pimpl_ptr()
49 template <typename T, class CloneAllocator>
50 prefix_ const T* senf::pimpl_ptr<T,CloneAllocator>::get()
56 template <typename T, class CloneAllocator>
57 prefix_ T* senf::pimpl_ptr<T,CloneAllocator>::get()
63 template <typename T, class CloneAllocator>
64 prefix_ const T* senf::pimpl_ptr<T,CloneAllocator>::operator->()
70 template <typename T, class CloneAllocator>
71 prefix_ T* senf::pimpl_ptr<T,CloneAllocator>::operator->()
77 template <typename T, class CloneAllocator>
78 prefix_ const T& senf::pimpl_ptr<T,CloneAllocator>::operator*()
84 template <typename T, class CloneAllocator>
85 prefix_ T& senf::pimpl_ptr<T,CloneAllocator>::operator*()
91 template <typename T, class CloneAllocator>
92 prefix_ void senf::pimpl_ptr<T,CloneAllocator>::swap(pimpl_ptr & with)
98 template <typename T, class CloneAllocator>
99 prefix_ senf::pimpl_ptr<T,CloneAllocator> &
100 senf::pimpl_ptr<T,CloneAllocator>::operator=(const pimpl_ptr & rhs)
102 T* pp = doCopy_(rhs.p);
108 template <typename T, class CloneAllocator>
109 prefix_ void senf::pimpl_ptr<T,CloneAllocator>::myDeleteFn(T* p)
111 return CloneAllocator::deallocate_clone(p);
114 template <typename T, class CloneAllocator>
115 prefix_ T* senf::pimpl_ptr<T,CloneAllocator>::myCopyFn(const T* p)
117 return CloneAllocator::allocate_clone(*p);
120 //-/////////////////////////////////////////////////////////////////////////////////////////////////
122 template <class T, class CloneAllocator>
123 prefix_ void std::swap(senf::pimpl_ptr<T,CloneAllocator> & lhs,
124 senf::pimpl_ptr<T,CloneAllocator> & rhs)
130 template <class T, class CloneAllocator>
131 typename senf::pimpl_ptr<T,CloneAllocator>::Copier
132 senf::pimpl_ptr<T,CloneAllocator>::doCopy_ (0);
134 template <class T, class CloneAllocator>
135 typename senf::pimpl_ptr<T,CloneAllocator>::Deleter
136 senf::pimpl_ptr<T,CloneAllocator>::doDelete_ (0);
138 //-/////////////////////////////////////////////////////////////////////////////////////////////////
145 // comment-column: 40
146 // c-file-style: "senf"
147 // indent-tabs-mode: nil
148 // ispell-local-dictionary: "american"
149 // compile-command: "scons -u test"