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
148 /**
149 * Move by transferring the managed reference from another Ptr.
150 *
151 * The moved-from Ptr is left empty. The underlying reference count is not changed.
152 *
153 * @param [in,out] o The Ptr to move from.
154 */
155 Ptr(Ptr&& o) noexcept
156 : m_ptr(o.m_ptr)
157 {
158 o.m_ptr = nullptr;
159 }
160
161 /**
162 * Move assignment operator.
163 *
164 * Releases any object currently referenced by this Ptr, then transfers the managed
165 * reference from another Ptr. The moved-from Ptr is left empty. The underlying
166 * reference count for the moved object is not changed.
167 *
168 * @param [in,out] o The Ptr to move from.
169 * @return A reference to self.
170 */
171 Ptr& operator=(Ptr&& o) noexcept
172 {
173 if (this != &o)
174 {
175 if (m_ptr)
176 {
177 m_ptr->Unref();
178 }
179 m_ptr = o.m_ptr;
180 o.m_ptr = nullptr;
181 }
182 return *this;
183 }
184
185 /** Destructor. */
187 /**
188 * Assignment operator by referencing the same underlying object.
189 *
190 * @param [in] o The other Ptr instance.
191 * @return A reference to self.
192 */
193 Ptr<T>& operator=(const Ptr& o);
194 /**
195 * An rvalue member access.
196 * @returns A pointer to the underlying object.
197 */
198 T* operator->() const;
199 /**
200 * An lvalue member access.
201 * @returns A pointer to the underlying object.
202 */
204 /**
205 * A \c const dereference.
206 * @returns A pointer to the underlying object.
207 */
208 T& operator*() const;
209 /**
210 * A dereference.
211 * @returns A pointer to the underlying object.
212 */
214
215 /**
216 * Test for non-NULL pointer.
217 *
218 * This enables simple pointer checks like
219 * @code
220 * Ptr<...> p = ...;
221 * if (p) ...
222 * if (!p) ...
223 * @endcode
224 *
225 * The same construct works in the NS_ASSERT... and NS_ABORT... macros.
226 *
227 * @note Explicit tests against `0`, `NULL` or `nullptr` are not supported.
228 * All these cases will fail to compile:
229 * @code
230 * if (p != nullptr {...} // Should be `if (p)`
231 * if (p != NULL) {...}
232 * if (p != 0) {...}
233 *
234 * if (p == nullptr {...} // Should be `if (!p)`
235 * if (p == NULL) {...}
236 * if (p == 0) {...}
237 * @endcode
238 * Just use `if (p)` or `if (!p)` as indicated.
239 *
240 * @note NS_TEST... invocations should be written as follows:
241 * @code
242 * // p should be non-NULL
243 * NS_TEST...NE... (p, nullptr, ...);
244 * // p should be NULL
245 * NS_TEST...EQ... (p, nullptr, ...);
246 * @endcode
247 *
248 * @note Unfortunately return values are not
249 * "contextual conversion expression" contexts,
250 * so you need to explicitly cast return values to bool:
251 * @code
252 * bool f (...)
253 * {
254 * Ptr<...> p = ...;
255 * return (bool)(p);
256 * }
257 * @endcode
258 *
259 * @returns \c true if the underlying pointer is non-NULL.
260 */
261 explicit operator bool() const;
262};
263
264/**
265 * @ingroup ptr
266 * Create class instances by constructors with varying numbers
267 * of arguments and return them by Ptr.
268 *
269 * This template work for any class \c T derived from ns3::SimpleRefCount
270 *
271 * @see CreateObject for methods to create derivatives of ns3::Object
272 */
273/** @{ */
274/**
275 * @tparam T \explicit The type of class object to create.
276 * @tparam Ts \deduced Types of the constructor arguments.
277 * @param [in] args Constructor arguments.
278 * @return A Ptr to the newly created \c T.
279 * @hidecaller
280 * @hiderefby
281 */
282template <typename T, typename... Ts>
283Ptr<T> Create(Ts&&... args);
284
285/** @}*/
286
287/**
288 * @ingroup ptr
289 * Output streamer.
290 * @tparam T \deduced The type of the underlying Object.
291 * @param [in,out] os The output stream.
292 * @param [in] p The Ptr.
293 * @returns The stream.
294 */
295template <typename T>
296std::ostream& operator<<(std::ostream& os, const Ptr<T>& p);
297
298/**
299 * @ingroup ptr
300 * Equality operator.
301 *
302 * This enables code such as
303 * @code
304 * Ptr<...> p = ...;
305 * Ptr<...> q = ...;
306 * if (p == q) ...
307 * @endcode
308 *
309 * Note that either \c p or \c q could also be ordinary pointers
310 * to the underlying object.
311 *
312 * @tparam T1 \deduced Type of the object on the lhs.
313 * @tparam T2 \deduced Type of the object on the rhs.
314 * @param [in] lhs The left operand.
315 * @param [in] rhs The right operand.
316 * @return \c true if the operands point to the same underlying object.
317 */
318/** @{ */
319template <typename T1, typename T2>
320bool operator==(const Ptr<T1>& lhs, T2 const* rhs);
321
322template <typename T1, typename T2>
323bool operator==(T1 const* lhs, Ptr<T2>& rhs);
324
325template <typename T1, typename T2>
326bool operator==(const Ptr<T1>& lhs, const Ptr<T2>& rhs);
327/**@}*/
328
329/**
330 * @ingroup ptr
331 * Specialization for comparison to \c nullptr
332 * @copydoc operator==(Ptr<T1>const&,Ptr<T2>const&)
333 */
334template <typename T1, typename T2>
335std::enable_if_t<std::is_same_v<T2, std::nullptr_t>, bool> operator==(const Ptr<T1>& lhs, T2 rhs);
336
337/**
338 * @ingroup ptr
339 * Inequality operator.
340 *
341 * This enables code such as
342 * @code
343 * Ptr<...> p = ...;
344 * Ptr<...> q = ...;
345 * if (p != q) ...
346 * @endcode
347 *
348 * Note that either \c p or \c q could also be ordinary pointers
349 * to the underlying object.
350 *
351 * @tparam T1 \deduced Type of the object on the lhs.
352 * @tparam T2 \deduced Type of the object on the rhs.
353 * @param [in] lhs The left operand.
354 * @param [in] rhs The right operand.
355 * @return \c true if the operands point to the same underlying object.
356 */
357/** @{ */
358template <typename T1, typename T2>
359bool operator!=(const Ptr<T1>& lhs, T2 const* rhs);
360
361template <typename T1, typename T2>
362bool operator!=(T1 const* lhs, Ptr<T2>& rhs);
363
364template <typename T1, typename T2>
365bool operator!=(const Ptr<T1>& lhs, const Ptr<T2>& rhs);
366/**@}*/
367
368/**
369 * @ingroup ptr
370 * Specialization for comparison to \c nullptr
371 * @copydoc operator==(Ptr<T1>const&,Ptr<T2>const&)
372 */
373template <typename T1, typename T2>
374std::enable_if_t<std::is_same_v<T2, std::nullptr_t>, bool> operator!=(const Ptr<T1>& lhs, T2 rhs);
375
376/**
377 * @ingroup ptr
378 * Comparison operator applied to the underlying pointers.
379 *
380 * @tparam T \deduced The type of the operands.
381 * @param [in] lhs The left operand.
382 * @param [in] rhs The right operand.
383 * @return The comparison on the underlying pointers.
384 */
385/** @{ */
386template <typename T>
387bool operator<(const Ptr<T>& lhs, const Ptr<T>& rhs);
388template <typename T>
389bool operator<(const Ptr<T>& lhs, const Ptr<const T>& rhs);
390template <typename T>
391bool operator<(const Ptr<const T>& lhs, const Ptr<T>& rhs);
392template <typename T>
393bool operator<=(const Ptr<T>& lhs, const Ptr<T>& rhs);
394template <typename T>
395bool operator>(const Ptr<T>& lhs, const Ptr<T>& rhs);
396template <typename T>
397bool operator>=(const Ptr<T>& lhs, const Ptr<T>& rhs);
398/** @} */
399
400/**
401 * Return a copy of \c p with its stored pointer const casted from
402 * \c T2 to \c T1.
403 *
404 * @tparam T1 \deduced The type to return in a Ptr.
405 * @tparam T2 \deduced The type of the underlying object.
406 * @param [in] p The original \c const Ptr.
407 * @return A non-const Ptr.
408 */
409template <typename T1, typename T2>
411
412// Duplicate of struct CallbackTraits<T> as defined in callback.h
413template <typename T>
415
416/**
417 * @ingroup callbackimpl
418 *
419 * Trait class to convert a pointer into a reference,
420 * used by MemPtrCallBackImpl.
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(const Ptr<T> p)
434 {
435 return *PeekPointer(p);
436 }
437};
438
439namespace internal
440{
441
442// Duplicate of struct EventMemberImplObjTraits<T> as defined in make-event.h
443// We repeat it here to declare a specialization on Ptr<T>
444// without making this header dependent on make-event.h
445template <typename T>
446struct EventMemberImplObjTraits;
447
448/**
449 * @ingroup events
450 * @defgroup makeeventmemptr MakeEvent from class methods.
451 *
452 * Create EventImpl instances from class member methods which take
453 * varying numbers of arguments.
454 */
455
456/**
457 * @ingroup makeeventmemptr
458 * Helper for the MakeEvent functions which take a class method.
459 *
460 * This is the specialization for Ptr types.
461 *
462 * @tparam T \deduced The type of the underlying object.
463 */
464template <typename T>
466{
467 /**
468 * @param [in] p Object pointer
469 * @return A reference to the object pointed to by p
470 */
471 static T& GetReference(Ptr<T> p)
472 {
473 return *PeekPointer(p);
474 }
475};
476
477} // namespace internal
478
479} // namespace ns3
480
481namespace ns3
482{
483
484class Object;
485
486/*************************************************
487 * friend non-member function implementations
488 ************************************************/
489
490template <typename T, typename... Ts>
491Ptr<T>
492Create(Ts&&... args)
493{
494 static_assert(!std::is_base_of_v<Object, T>,
495 "Use CreateObject() instead of Create() for Object subclasses");
496 return Ptr<T>(new T(std::forward<Ts>(args)...), false);
497}
498
499template <typename U>
500U*
502{
503 return p.m_ptr;
504}
505
506template <typename U>
507U*
509{
510 p.Acquire();
511 return p.m_ptr;
512}
513
514template <typename T>
515std::ostream&
516operator<<(std::ostream& os, const Ptr<T>& p)
517{
518 os << PeekPointer(p);
519 return os;
520}
521
522template <typename T1, typename T2>
523bool
524operator==(const Ptr<T1>& lhs, T2 const* rhs)
525{
526 return PeekPointer(lhs) == rhs;
527}
528
529template <typename T1, typename T2>
530bool
531operator==(T1 const* lhs, Ptr<T2>& rhs)
532{
533 return lhs == PeekPointer(rhs);
534}
535
536template <typename T1, typename T2>
537bool
538operator!=(const Ptr<T1>& lhs, T2 const* rhs)
539{
540 return PeekPointer(lhs) != rhs;
541}
542
543template <typename T1, typename T2>
544bool
545operator!=(T1 const* lhs, Ptr<T2>& rhs)
546{
547 return lhs != PeekPointer(rhs);
548}
549
550template <typename T1, typename T2>
551bool
552operator==(const Ptr<T1>& lhs, const Ptr<T2>& rhs)
553{
554 return PeekPointer(lhs) == PeekPointer(rhs);
555}
556
557template <typename T1, typename T2>
558bool
559operator!=(const Ptr<T1>& lhs, const Ptr<T2>& rhs)
560{
561 return PeekPointer(lhs) != PeekPointer(rhs);
562}
563
564template <typename T1, typename T2>
565std::enable_if_t<std::is_same_v<T2, std::nullptr_t>, bool>
566operator==(const Ptr<T1>& lhs, T2 rhs)
567{
568 return PeekPointer(lhs) == nullptr;
569}
570
571template <typename T1, typename T2>
572std::enable_if_t<std::is_same_v<T2, std::nullptr_t>, bool>
573operator!=(const Ptr<T1>& lhs, T2 rhs)
574{
575 return PeekPointer(lhs) != nullptr;
576}
577
578template <typename T>
579bool
580operator<(const Ptr<T>& lhs, const Ptr<T>& rhs)
581{
582 return PeekPointer<T>(lhs) < PeekPointer<T>(rhs);
583}
584
585template <typename T>
586bool
587operator<(const Ptr<T>& lhs, const Ptr<const T>& rhs)
588{
589 return PeekPointer<T>(lhs) < PeekPointer<const T>(rhs);
590}
591
592template <typename T>
593bool
594operator<(const Ptr<const T>& lhs, const Ptr<T>& rhs)
595{
596 return PeekPointer<const T>(lhs) < PeekPointer<T>(rhs);
597}
598
599template <typename T>
600bool
601operator<=(const Ptr<T>& lhs, const Ptr<T>& rhs)
602{
603 return PeekPointer<T>(lhs) <= PeekPointer<T>(rhs);
604}
605
606template <typename T>
607bool
608operator>(const Ptr<T>& lhs, const Ptr<T>& rhs)
609{
610 return PeekPointer<T>(lhs) > PeekPointer<T>(rhs);
611}
612
613template <typename T>
614bool
615operator>=(const Ptr<T>& lhs, const Ptr<T>& rhs)
616{
617 return PeekPointer<T>(lhs) >= PeekPointer<T>(rhs);
618}
619
620/**
621 * Cast a Ptr.
622 *
623 * @tparam T1 \deduced The desired type to cast to.
624 * @tparam T2 \deduced The type of the original Ptr.
625 * @param [in] p The original Ptr.
626 * @return The result of the cast.
627 */
628/** @{ */
629template <typename T1, typename T2>
630Ptr<T1>
632{
633 return Ptr<T1>(const_cast<T1*>(PeekPointer(p)));
634}
635
636/**
637 * @copydoc ConstCast()
638 * @hidecaller
639 * @hiderefby
640 */
641template <typename T1, typename T2>
642Ptr<T1>
644{
645 return Ptr<T1>(dynamic_cast<T1*>(PeekPointer(p)));
646}
647
648template <typename T1, typename T2>
649Ptr<T1>
651{
652 return Ptr<T1>(static_cast<T1*>(PeekPointer(p)));
653}
654
655/** @} */
656
657/**
658 * Return a deep copy of a Ptr.
659 *
660 * @tparam T \deduced The type of the underlying object.
661 * @param [in] object The object Ptr to copy.
662 * @returns The copy.
663 */
664/** @{ */
665template <typename T>
666Ptr<T>
668{
669 Ptr<T> p = Ptr<T>(new T(*PeekPointer(object)), false);
670 return p;
671}
672
673template <typename T>
674Ptr<T>
676{
677 Ptr<T> p = Ptr<T>(new T(*PeekPointer(object)), false);
678 return p;
679}
680
681/** @} */
682
683/****************************************************
684 * Member method implementations.
685 ***************************************************/
686
687template <typename T>
688void
690{
691 if (m_ptr != nullptr)
692 {
693 m_ptr->Ref();
694 }
695}
696
697template <typename T>
699 : m_ptr(nullptr)
700{
701}
702
703template <typename T>
705 : m_ptr(ptr)
706{
707 Acquire();
708}
709
710template <typename T>
711Ptr<T>::Ptr(T* ptr, bool ref)
712 : m_ptr(ptr)
713{
714 if (ref)
715 {
716 Acquire();
717 }
718}
719
720template <typename T>
722 : m_ptr(nullptr)
723{
724 T* ptr = PeekPointer(o);
725 if (ptr != nullptr)
726 {
727 m_ptr = ptr;
728 Acquire();
729 }
730}
731
732template <typename T>
733template <typename U>
735 : m_ptr(PeekPointer(o))
736{
737 Acquire();
738}
739
740template <typename T>
742{
743 if (m_ptr != nullptr)
744 {
745 m_ptr->Unref();
746 }
747}
748
749template <typename T>
750Ptr<T>&
752{
753 if (&o == this)
754 {
755 return *this;
756 }
757 if (m_ptr != nullptr)
758 {
759 m_ptr->Unref();
760 }
761 m_ptr = o.m_ptr;
762 Acquire();
763 return *this;
764}
765
766template <typename T>
767T*
769{
770 NS_ASSERT_MSG(m_ptr, "Attempted to dereference zero pointer");
771 return m_ptr;
772}
773
774template <typename T>
775T*
777{
778 NS_ASSERT_MSG(m_ptr, "Attempted to dereference zero pointer");
779 return m_ptr;
780}
781
782template <typename T>
783T&
785{
786 NS_ASSERT_MSG(m_ptr, "Attempted to dereference zero pointer");
787 return *m_ptr;
788}
789
790template <typename T>
791T&
793{
794 NS_ASSERT_MSG(m_ptr, "Attempted to dereference zero pointer");
795 return *m_ptr;
796}
797
798template <typename T>
800{
801 return m_ptr != nullptr;
802}
803
804} // namespace ns3
805
806/****************************************************
807 * Global Functions (outside namespace ns3)
808 ***************************************************/
809
810/**
811 * @ingroup ptr
812 * Hashing functor taking a `Ptr` and returning a @c std::size_t.
813 * For use with `unordered_map` and `unordered_set`.
814 *
815 * @note When a `Ptr` is used in a container the lifetime of the underlying
816 * object is at least as long as the container. In other words,
817 * you need to remove the object from the container when you are done with
818 * it, otherwise the object will persist until the container itself is
819 * deleted.
820 *
821 * @tparam T \deduced The type held by the `Ptr`
822 */
823template <class T>
824struct std::hash<ns3::Ptr<T>>
825{
826 /**
827 * The functor.
828 * @param p The `Ptr` value to hash.
829 * @return the hash
830 */
831 std::size_t operator()(ns3::Ptr<T> p) const
832 {
833 return std::hash<const T*>()(ns3::PeekPointer(p));
834 }
835};
836
837#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:704
Ptr & operator=(Ptr &&o) noexcept
Move assignment operator.
Definition ptr.h:171
Ptr(const Ptr &o)
Copy by referencing the same underlying object.
Definition ptr.h:721
T & operator*()
A dereference.
Definition ptr.h:792
Ptr()
Create an empty smart pointer.
Definition ptr.h:698
void Acquire() const
Mark this as a a reference by incrementing the reference count.
Definition ptr.h:689
friend U * PeekPointer(const Ptr< U > &p)
Get a temporary pointer to the underlying object.
Definition ptr.h:501
Ptr(const Ptr< U > &o)
Copy, removing const qualifier.
Definition ptr.h:734
T * operator->()
An lvalue member access.
Definition ptr.h:768
T & operator*() const
A const dereference.
Definition ptr.h:784
friend U * GetPointer(const Ptr< U > &p)
Get a permanent pointer to the underlying object.
Definition ptr.h:508
Ptr< T > & operator=(const Ptr &o)
Assignment operator by referencing the same underlying object.
Definition ptr.h:751
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:711
Ptr(Ptr &&o) noexcept
Move by transferring the managed reference from another Ptr.
Definition ptr.h:155
~Ptr()
Destructor.
Definition ptr.h:741
A * m_ptr
Definition ptr.h:73
T * operator->() const
An rvalue member access.
Definition ptr.h:776
#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:492
Every class exported by the ns3 library is enclosed in the ns3 namespace.
U * PeekPointer(const Ptr< U > &p)
Definition ptr.h:501
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:167
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:643
bool operator<(const EventId &a, const EventId &b)
Definition event-id.h:174
Ptr< T > Copy(Ptr< T > object)
Return a deep copy of a Ptr.
Definition ptr.h:667
Ptr< T1 > StaticCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:650
U * GetPointer(const Ptr< U > &p)
Definition ptr.h:508
Ptr< T1 > ConstCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:631
static T & GetReference(const Ptr< T > p)
Definition ptr.h:433
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:831