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