A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ptr.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005,2006 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8
9#ifndef PTR_H
10#define PTR_H
11
12#include "assert.h"
13
14#include <iostream>
15#include <stdint.h>
16#include <type_traits>
17
18/**
19 * @file
20 * @ingroup ptr
21 * ns3::Ptr smart pointer declaration and implementation.
22 */
23
24namespace ns3
25{
26
27/**
28 * @ingroup core
29 * @defgroup ptr Smart Pointer
30 * @brief Heap memory management.
31 *
32 * See \ref ns3::Ptr for implementation details.
33 *
34 * See \ref main-ptr.cc for example usage.
35 */
36/**
37 * @ingroup ptr
38 *
39 * @brief Smart pointer class similar to \c boost::intrusive_ptr.
40 *
41 * This smart-pointer class assumes that the underlying
42 * type provides a pair of \c Ref() and \c Unref() methods which are
43 * expected to increment and decrement the internal reference count
44 * of the object instance. You can add \c Ref() and \c Unref()
45 * to a class simply by inheriting from ns3::SimpleRefCount<>
46 * using the CRTP (`class Foo : public SimpleRefCount<Foo>`)
47 *
48 * This implementation allows you to manipulate the smart pointer
49 * as if it was a normal pointer: you can test if it is non-null,
50 * compare it to other pointers of the same type, etc.
51 *
52 * It is possible to extract the raw pointer from this
53 * smart pointer with the GetPointer() and PeekPointer() methods.
54 *
55 * If you want to store a `new Object()` into a smart pointer,
56 * we recommend you to use the CreateObject<>() template function
57 * to create the Object and store it in a smart pointer to avoid
58 * memory leaks. These functions are really small convenience
59 * functions and their goal is just is save you a small
60 * bit of typing. If the Object does not inherit from Object
61 * (or ObjectBase) there is also a convenience wrapper Create<>()
62 *
63 * @tparam T \explicit The type of the underlying object.
64 *
65 * Inheritance graph was not generated because of its size.
66 * @hideinheritancegraph
67 */
68template <typename T>
69class Ptr
70{
71 private:
72 /** The pointer. */
74
75 /** Interoperate with const instances. */
76 friend class Ptr<const T>;
77
78 /**
79 * Get a permanent pointer to the underlying object.
80 *
81 * The underlying refcount is incremented prior
82 * to returning to the caller so the caller is
83 * responsible for calling Unref himself.
84 *
85 * @tparam U \deduced The actual type of the argument and return pointer.
86 * @param [in] p Smart pointer
87 * @return The pointer managed by this smart pointer.
88 */
89 template <typename U>
90 friend U* GetPointer(const Ptr<U>& p);
91 /**
92 * Get a temporary pointer to the underlying object.
93 *
94 * The underlying refcount is not incremented prior
95 * to returning to the caller so the caller is not
96 * responsible for calling Unref himself.
97 *
98 * @tparam U \deduced The actual type of the argument and return pointer.
99 * @param [in] p Smart pointer
100 * @return The pointer managed by this smart pointer.
101 * @hidecaller
102 * @hideref
103 */
104 template <typename U>
105 friend U* PeekPointer(const Ptr<U>& p);
106
107 /** Mark this as a a reference by incrementing the reference count. */
108 inline void Acquire() const;
109
110 public:
111 /** Create an empty smart pointer */
113 /**
114 * Create a smart pointer which points to the object pointed to by
115 * the input raw pointer ptr. This method creates its own reference
116 * to the pointed object. The caller is responsible for Unref()'ing
117 * its own reference, and the smart pointer will eventually do the
118 * same, so that object is deleted if no more references to it
119 * remain.
120 *
121 * @param [in] ptr Raw pointer to manage
122 */
123 Ptr(T* ptr);
124 /**
125 * Create a smart pointer which points to the object pointed to by
126 * the input raw pointer ptr.
127 *
128 * @param [in] ptr Raw pointer to manage
129 * @param [in] ref if set to true, this method calls Ref, otherwise,
130 * it does not call Ref.
131 */
132 Ptr(T* ptr, bool ref);
133 /**
134 * Copy by referencing the same underlying object.
135 *
136 * @param [in] o The other Ptr instance.
137 */
138 Ptr(const Ptr& o);
139 /**
140 * Copy, removing \c const qualifier.
141 *
142 * @tparam U \deduced The type underlying the Ptr being copied.
143 * @param [in] o The Ptr to copy.
144 */
145 template <typename U>
146 Ptr(const Ptr<U>& o);
147 /** Destructor. */
149 /**
150 * Assignment operator by referencing the same underlying object.
151 *
152 * @param [in] o The other Ptr instance.
153 * @return A reference to self.
154 */
155 Ptr<T>& operator=(const Ptr& o);
156 /**
157 * An rvalue member access.
158 * @returns A pointer to the underlying object.
159 */
160 T* operator->() const;
161 /**
162 * An lvalue member access.
163 * @returns A pointer to the underlying object.
164 */
166 /**
167 * A \c const dereference.
168 * @returns A pointer to the underlying object.
169 */
170 T& operator*() const;
171 /**
172 * A dereference.
173 * @returns A pointer to the underlying object.
174 */
176
177 /**
178 * Test for non-NULL pointer.
179 *
180 * This enables simple pointer checks like
181 * @code
182 * Ptr<...> p = ...;
183 * if (p) ...
184 * if (!p) ...
185 * @endcode
186 *
187 * The same construct works in the NS_ASSERT... and NS_ABORT... macros.
188 *
189 * @note Explicit tests against `0`, `NULL` or `nullptr` are not supported.
190 * All these cases will fail to compile:
191 * @code
192 * if (p != nullptr {...} // Should be `if (p)`
193 * if (p != NULL) {...}
194 * if (p != 0) {...}
195 *
196 * if (p == nullptr {...} // Should be `if (!p)`
197 * if (p == NULL) {...}
198 * if (p == 0) {...}
199 * @endcode
200 * Just use `if (p)` or `if (!p)` as indicated.
201 *
202 * @note NS_TEST... invocations should be written as follows:
203 * @code
204 * // p should be non-NULL
205 * NS_TEST...NE... (p, nullptr, ...);
206 * // p should be NULL
207 * NS_TEST...EQ... (p, nullptr, ...);
208 * @endcode
209 *
210 * @note Unfortunately return values are not
211 * "contextual conversion expression" contexts,
212 * so you need to explicitly cast return values to bool:
213 * @code
214 * bool f (...)
215 * {
216 * Ptr<...> p = ...;
217 * return (bool)(p);
218 * }
219 * @endcode
220 *
221 * @returns \c true if the underlying pointer is non-NULL.
222 */
223 explicit operator bool() const;
224};
225
226/**
227 * @ingroup ptr
228 * Create class instances by constructors with varying numbers
229 * of arguments and return them by Ptr.
230 *
231 * This template work for any class \c T derived from ns3::SimpleRefCount
232 *
233 * @see CreateObject for methods to create derivatives of ns3::Object
234 */
235/** @{ */
236/**
237 * @tparam T \explicit The type of class object to create.
238 * @tparam Ts \deduced Types of the constructor arguments.
239 * @param [in] args Constructor arguments.
240 * @return A Ptr to the newly created \c T.
241 * @hidecaller
242 * @hiderefby
243 */
244template <typename T, typename... Ts>
245Ptr<T> Create(Ts&&... args);
246
247/** @}*/
248
249/**
250 * @ingroup ptr
251 * Output streamer.
252 * @tparam T \deduced The type of the underlying Object.
253 * @param [in,out] os The output stream.
254 * @param [in] p The Ptr.
255 * @returns The stream.
256 */
257template <typename T>
258std::ostream& operator<<(std::ostream& os, const Ptr<T>& p);
259
260/**
261 * @ingroup ptr
262 * Equality operator.
263 *
264 * This enables code such as
265 * @code
266 * Ptr<...> p = ...;
267 * Ptr<...> q = ...;
268 * if (p == q) ...
269 * @endcode
270 *
271 * Note that either \c p or \c q could also be ordinary pointers
272 * to the underlying object.
273 *
274 * @tparam T1 \deduced Type of the object on the lhs.
275 * @tparam T2 \deduced Type of the object on the rhs.
276 * @param [in] lhs The left operand.
277 * @param [in] rhs The right operand.
278 * @return \c true if the operands point to the same underlying object.
279 */
280/** @{ */
281template <typename T1, typename T2>
282bool operator==(const Ptr<T1>& lhs, T2 const* rhs);
283
284template <typename T1, typename T2>
285bool operator==(T1 const* lhs, Ptr<T2>& rhs);
286
287template <typename T1, typename T2>
288bool operator==(const Ptr<T1>& lhs, const Ptr<T2>& rhs);
289/**@}*/
290
291/**
292 * @ingroup ptr
293 * Specialization for comparison to \c nullptr
294 * @copydoc operator==(Ptr<T1>const&,Ptr<T2>const&)
295 */
296template <typename T1, typename T2>
297std::enable_if_t<std::is_same_v<T2, std::nullptr_t>, bool> operator==(const Ptr<T1>& lhs, T2 rhs);
298
299/**
300 * @ingroup ptr
301 * Inequality operator.
302 *
303 * This enables code such as
304 * @code
305 * Ptr<...> p = ...;
306 * Ptr<...> q = ...;
307 * if (p != q) ...
308 * @endcode
309 *
310 * Note that either \c p or \c q could also be ordinary pointers
311 * to the underlying object.
312 *
313 * @tparam T1 \deduced Type of the object on the lhs.
314 * @tparam T2 \deduced Type of the object on the rhs.
315 * @param [in] lhs The left operand.
316 * @param [in] rhs The right operand.
317 * @return \c true if the operands point to the same underlying object.
318 */
319/** @{ */
320template <typename T1, typename T2>
321bool operator!=(const Ptr<T1>& lhs, T2 const* rhs);
322
323template <typename T1, typename T2>
324bool operator!=(T1 const* lhs, Ptr<T2>& rhs);
325
326template <typename T1, typename T2>
327bool operator!=(const Ptr<T1>& lhs, const Ptr<T2>& rhs);
328/**@}*/
329
330/**
331 * @ingroup ptr
332 * Specialization for comparison to \c nullptr
333 * @copydoc operator==(Ptr<T1>const&,Ptr<T2>const&)
334 */
335template <typename T1, typename T2>
336std::enable_if_t<std::is_same_v<T2, std::nullptr_t>, bool> operator!=(const Ptr<T1>& lhs, T2 rhs);
337
338/**
339 * @ingroup ptr
340 * Comparison operator applied to the underlying pointers.
341 *
342 * @tparam T \deduced The type of the operands.
343 * @param [in] lhs The left operand.
344 * @param [in] rhs The right operand.
345 * @return The comparison on the underlying pointers.
346 */
347/** @{ */
348template <typename T>
349bool operator<(const Ptr<T>& lhs, const Ptr<T>& rhs);
350template <typename T>
351bool operator<(const Ptr<T>& lhs, const Ptr<const T>& rhs);
352template <typename T>
353bool operator<(const Ptr<const T>& lhs, const Ptr<T>& rhs);
354template <typename T>
355bool operator<=(const Ptr<T>& lhs, const Ptr<T>& rhs);
356template <typename T>
357bool operator>(const Ptr<T>& lhs, const Ptr<T>& rhs);
358template <typename T>
359bool operator>=(const Ptr<T>& lhs, const Ptr<T>& rhs);
360/** @} */
361
362/**
363 * Return a copy of \c p with its stored pointer const casted from
364 * \c T2 to \c T1.
365 *
366 * @tparam T1 \deduced The type to return in a Ptr.
367 * @tparam T2 \deduced The type of the underlying object.
368 * @param [in] p The original \c const Ptr.
369 * @return A non-const Ptr.
370 */
371template <typename T1, typename T2>
373
374// Duplicate of struct CallbackTraits<T> as defined in callback.h
375template <typename T>
377
378/**
379 * @ingroup callbackimpl
380 *
381 * Trait class to convert a pointer into a reference,
382 * used by MemPtrCallBackImpl.
383 *
384 * This is the specialization for Ptr types.
385 *
386 * @tparam T \deduced The type of the underlying object.
387 */
388template <typename T>
390{
391 /**
392 * @param [in] p Object pointer
393 * @return A reference to the object pointed to by p
394 */
395 static T& GetReference(const Ptr<T> p)
396 {
397 return *PeekPointer(p);
398 }
399};
400
401namespace internal
402{
403
404// Duplicate of struct EventMemberImplObjTraits<T> as defined in make-event.h
405// We repeat it here to declare a specialization on Ptr<T>
406// without making this header dependent on make-event.h
407template <typename T>
408struct EventMemberImplObjTraits;
409
410/**
411 * @ingroup events
412 * @defgroup makeeventmemptr MakeEvent from class methods.
413 *
414 * Create EventImpl instances from class member methods which take
415 * varying numbers of arguments.
416 */
417
418/**
419 * @ingroup makeeventmemptr
420 * Helper for the MakeEvent functions which take a class method.
421 *
422 * This is the specialization for Ptr types.
423 *
424 * @tparam T \deduced The type of the underlying object.
425 */
426template <typename T>
428{
429 /**
430 * @param [in] p Object pointer
431 * @return A reference to the object pointed to by p
432 */
433 static T& GetReference(Ptr<T> p)
434 {
435 return *PeekPointer(p);
436 }
437};
438
439} // namespace internal
440
441} // namespace ns3
442
443namespace ns3
444{
445
446class Object;
447
448/*************************************************
449 * friend non-member function implementations
450 ************************************************/
451
452template <typename T, typename... Ts>
453Ptr<T>
454Create(Ts&&... args)
455{
456 static_assert(!std::is_base_of_v<Object, T>,
457 "Use CreateObject() instead of Create() for Object subclasses");
458 return Ptr<T>(new T(std::forward<Ts>(args)...), false);
459}
460
461template <typename U>
462U*
464{
465 return p.m_ptr;
466}
467
468template <typename U>
469U*
471{
472 p.Acquire();
473 return p.m_ptr;
474}
475
476template <typename T>
477std::ostream&
478operator<<(std::ostream& os, const Ptr<T>& p)
479{
480 os << PeekPointer(p);
481 return os;
482}
483
484template <typename T1, typename T2>
485bool
486operator==(const Ptr<T1>& lhs, T2 const* rhs)
487{
488 return PeekPointer(lhs) == rhs;
489}
490
491template <typename T1, typename T2>
492bool
493operator==(T1 const* lhs, Ptr<T2>& rhs)
494{
495 return lhs == PeekPointer(rhs);
496}
497
498template <typename T1, typename T2>
499bool
500operator!=(const Ptr<T1>& lhs, T2 const* rhs)
501{
502 return PeekPointer(lhs) != rhs;
503}
504
505template <typename T1, typename T2>
506bool
507operator!=(T1 const* lhs, Ptr<T2>& rhs)
508{
509 return lhs != PeekPointer(rhs);
510}
511
512template <typename T1, typename T2>
513bool
514operator==(const Ptr<T1>& lhs, const Ptr<T2>& rhs)
515{
516 return PeekPointer(lhs) == PeekPointer(rhs);
517}
518
519template <typename T1, typename T2>
520bool
521operator!=(const Ptr<T1>& lhs, const Ptr<T2>& rhs)
522{
523 return PeekPointer(lhs) != PeekPointer(rhs);
524}
525
526template <typename T1, typename T2>
527std::enable_if_t<std::is_same_v<T2, std::nullptr_t>, bool>
528operator==(const Ptr<T1>& lhs, T2 rhs)
529{
530 return PeekPointer(lhs) == nullptr;
531}
532
533template <typename T1, typename T2>
534std::enable_if_t<std::is_same_v<T2, std::nullptr_t>, bool>
535operator!=(const Ptr<T1>& lhs, T2 rhs)
536{
537 return PeekPointer(lhs) != nullptr;
538}
539
540template <typename T>
541bool
542operator<(const Ptr<T>& lhs, const Ptr<T>& rhs)
543{
544 return PeekPointer<T>(lhs) < PeekPointer<T>(rhs);
545}
546
547template <typename T>
548bool
549operator<(const Ptr<T>& lhs, const Ptr<const T>& rhs)
550{
551 return PeekPointer<T>(lhs) < PeekPointer<const T>(rhs);
552}
553
554template <typename T>
555bool
556operator<(const Ptr<const T>& lhs, const Ptr<T>& rhs)
557{
558 return PeekPointer<const T>(lhs) < PeekPointer<T>(rhs);
559}
560
561template <typename T>
562bool
563operator<=(const Ptr<T>& lhs, const Ptr<T>& rhs)
564{
565 return PeekPointer<T>(lhs) <= PeekPointer<T>(rhs);
566}
567
568template <typename T>
569bool
570operator>(const Ptr<T>& lhs, const Ptr<T>& rhs)
571{
572 return PeekPointer<T>(lhs) > PeekPointer<T>(rhs);
573}
574
575template <typename T>
576bool
577operator>=(const Ptr<T>& lhs, const Ptr<T>& rhs)
578{
579 return PeekPointer<T>(lhs) >= PeekPointer<T>(rhs);
580}
581
582/**
583 * Cast a Ptr.
584 *
585 * @tparam T1 \deduced The desired type to cast to.
586 * @tparam T2 \deduced The type of the original Ptr.
587 * @param [in] p The original Ptr.
588 * @return The result of the cast.
589 */
590/** @{ */
591template <typename T1, typename T2>
592Ptr<T1>
594{
595 return Ptr<T1>(const_cast<T1*>(PeekPointer(p)));
596}
597
598/**
599 * @copydoc ConstCast()
600 * @hidecaller
601 * @hiderefby
602 */
603template <typename T1, typename T2>
604Ptr<T1>
606{
607 return Ptr<T1>(dynamic_cast<T1*>(PeekPointer(p)));
608}
609
610template <typename T1, typename T2>
611Ptr<T1>
613{
614 return Ptr<T1>(static_cast<T1*>(PeekPointer(p)));
615}
616
617/** @} */
618
619/**
620 * Return a deep copy of a Ptr.
621 *
622 * @tparam T \deduced The type of the underlying object.
623 * @param [in] object The object Ptr to copy.
624 * @returns The copy.
625 */
626/** @{ */
627template <typename T>
628Ptr<T>
630{
631 Ptr<T> p = Ptr<T>(new T(*PeekPointer(object)), false);
632 return p;
633}
634
635template <typename T>
636Ptr<T>
638{
639 Ptr<T> p = Ptr<T>(new T(*PeekPointer(object)), false);
640 return p;
641}
642
643/** @} */
644
645/****************************************************
646 * Member method implementations.
647 ***************************************************/
648
649template <typename T>
650void
652{
653 if (m_ptr != nullptr)
654 {
655 m_ptr->Ref();
656 }
657}
658
659template <typename T>
661 : m_ptr(nullptr)
662{
663}
664
665template <typename T>
667 : m_ptr(ptr)
668{
669 Acquire();
670}
671
672template <typename T>
673Ptr<T>::Ptr(T* ptr, bool ref)
674 : m_ptr(ptr)
675{
676 if (ref)
677 {
678 Acquire();
679 }
680}
681
682template <typename T>
684 : m_ptr(nullptr)
685{
686 T* ptr = PeekPointer(o);
687 if (ptr != nullptr)
688 {
689 m_ptr = ptr;
690 Acquire();
691 }
692}
693
694template <typename T>
695template <typename U>
697 : m_ptr(PeekPointer(o))
698{
699 Acquire();
700}
701
702template <typename T>
704{
705 if (m_ptr != nullptr)
706 {
707 m_ptr->Unref();
708 }
709}
710
711template <typename T>
712Ptr<T>&
714{
715 if (&o == this)
716 {
717 return *this;
718 }
719 if (m_ptr != nullptr)
720 {
721 m_ptr->Unref();
722 }
723 m_ptr = o.m_ptr;
724 Acquire();
725 return *this;
726}
727
728template <typename T>
729T*
731{
732 NS_ASSERT_MSG(m_ptr, "Attempted to dereference zero pointer");
733 return m_ptr;
734}
735
736template <typename T>
737T*
739{
740 NS_ASSERT_MSG(m_ptr, "Attempted to dereference zero pointer");
741 return m_ptr;
742}
743
744template <typename T>
745T&
747{
748 NS_ASSERT_MSG(m_ptr, "Attempted to dereference zero pointer");
749 return *m_ptr;
750}
751
752template <typename T>
753T&
755{
756 NS_ASSERT_MSG(m_ptr, "Attempted to dereference zero pointer");
757 return *m_ptr;
758}
759
760template <typename T>
762{
763 return m_ptr != nullptr;
764}
765
766} // namespace ns3
767
768/****************************************************
769 * Global Functions (outside namespace ns3)
770 ***************************************************/
771
772/**
773 * @ingroup ptr
774 * Hashing functor taking a `Ptr` and returning a @c std::size_t.
775 * For use with `unordered_map` and `unordered_set`.
776 *
777 * @note When a `Ptr` is used in a container the lifetime of the underlying
778 * object is at least as long as the container. In other words,
779 * you need to remove the object from the container when you are done with
780 * it, otherwise the object will persist until the container itself is
781 * deleted.
782 *
783 * @tparam T \deduced The type held by the `Ptr`
784 */
785template <class T>
786struct std::hash<ns3::Ptr<T>>
787{
788 /**
789 * The functor.
790 * @param p The `Ptr` value to hash.
791 * @return the hash
792 */
793 std::size_t operator()(ns3::Ptr<T> p) const
794 {
795 return std::hash<const T*>()(ns3::PeekPointer(p));
796 }
797};
798
799#endif /* PTR_H */
NS_ASSERT() and NS_ASSERT_MSG() macro definitions.
A base class which provides memory management and object aggregation.
Definition object.h:81
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
Ptr(T *ptr)
Create a smart pointer which points to the object pointed to by the input raw pointer ptr.
Definition ptr.h:666
Ptr(const Ptr &o)
Copy by referencing the same underlying object.
Definition ptr.h:683
T & operator*()
A dereference.
Definition ptr.h:754
Ptr()
Create an empty smart pointer.
Definition ptr.h:660
void Acquire() const
Mark this as a a reference by incrementing the reference count.
Definition ptr.h:651
friend U * PeekPointer(const Ptr< U > &p)
Get a temporary pointer to the underlying object.
Definition ptr.h:463
Ptr(const Ptr< U > &o)
Copy, removing const qualifier.
Definition ptr.h:696
T * operator->()
An lvalue member access.
Definition ptr.h:730
T & operator*() const
A const dereference.
Definition ptr.h:746
friend U * GetPointer(const Ptr< U > &p)
Get a permanent pointer to the underlying object.
Definition ptr.h:470
Ptr< T > & operator=(const Ptr &o)
Assignment operator by referencing the same underlying object.
Definition ptr.h:713
Ptr(T *ptr, bool ref)
Create a smart pointer which points to the object pointed to by the input raw pointer ptr.
Definition ptr.h:673
~Ptr()
Destructor.
Definition ptr.h:703
A * m_ptr
Definition ptr.h:73
T * operator->() const
An rvalue member access.
Definition ptr.h:738
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
bool operator>=(const int64x64_t &lhs, const int64x64_t &rhs)
Greater or equal operator.
Definition int64x64.h:162
bool operator<=(const int64x64_t &lhs, const int64x64_t &rhs)
Less or equal operator.
Definition int64x64.h:149
bool operator>(const Length &left, const Length &right)
Check if left has a value greater than right.
Definition length.cc:406
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:454
Every class exported by the ns3 library is enclosed in the ns3 namespace.
U * PeekPointer(const Ptr< U > &p)
Definition ptr.h:463
bool operator!=(Callback< R, Args... > a, Callback< R, Args... > b)
Inequality test.
Definition callback.h:664
bool operator==(const EventId &a, const EventId &b)
Definition event-id.h:146
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition angles.cc:148
Ptr< T1 > const_pointer_cast(const Ptr< T2 > &p)
Return a copy of p with its stored pointer const casted from T2 to T1.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:605
bool operator<(const EventId &a, const EventId &b)
Definition event-id.h:159
Ptr< T > Copy(Ptr< T > object)
Return a deep copy of a Ptr.
Definition ptr.h:629
Ptr< T1 > StaticCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:612
U * GetPointer(const Ptr< U > &p)
Definition ptr.h:470
Ptr< T1 > ConstCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:593
static T & GetReference(const Ptr< T > p)
Definition ptr.h:395
Helper for the MakeEvent functions which take a class method.
Definition make-event.h:104
std::size_t operator()(ns3::Ptr< T > p) const
The functor.
Definition ptr.h:793