From e60d1e292eaf78ad2e70f6b16fce3b9c94a0d2fe Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 12 Jan 2017 00:21:06 +0100 Subject: [PATCH] Make better use of C++ rules for implicit generation; allow PointerTo and some mutex impls to be static initialised --- dtool/src/dtoolbase/dtoolbase_cc.h | 21 +++++- dtool/src/dtoolbase/mutexDummyImpl.I | 20 +----- dtool/src/dtoolbase/mutexDummyImpl.h | 14 ++-- dtool/src/dtoolbase/mutexPosixImpl.I | 18 +++-- dtool/src/dtoolbase/mutexPosixImpl.h | 16 ++++- dtool/src/dtoolbase/mutexSpinlockImpl.I | 12 +--- dtool/src/dtoolbase/mutexSpinlockImpl.h | 8 ++- dtool/src/dtoolbase/mutexWin32Impl.h | 5 ++ dtool/src/dtoolbase/pallocator.T | 4 +- dtool/src/dtoolbase/pallocator.h | 8 +-- dtool/src/dtoolbase/pdeque.h | 1 - dtool/src/dtoolbase/plist.h | 1 - dtool/src/dtoolbase/pmap.h | 4 -- dtool/src/dtoolbase/pset.h | 4 -- dtool/src/dtoolbase/pvector.h | 15 ---- dtool/src/dtoolbase/typedObject.I | 21 ------ dtool/src/dtoolbase/typedObject.h | 54 +++++++++----- dtool/src/prc/streamWrapper.h | 3 + panda/src/express/datagramIterator.I | 31 ++------ panda/src/express/datagramIterator.h | 3 - panda/src/express/hashGeneratorBase.I | 7 -- panda/src/express/hashGeneratorBase.h | 1 - panda/src/express/namable.I | 29 -------- panda/src/express/namable.h | 6 -- panda/src/express/nodePointerTo.I | 20 ------ panda/src/express/nodePointerTo.h | 2 - panda/src/express/ordered_vector.I | 70 ------------------ panda/src/express/ordered_vector.h | 7 -- panda/src/express/pointerTo.I | 52 +++++--------- panda/src/express/pointerTo.h | 96 ++++++++++++++----------- panda/src/express/pointerToArray.I | 22 ++++++ panda/src/express/pointerToArray.h | 2 + panda/src/express/pointerToArrayBase.I | 17 ++--- panda/src/express/pointerToArrayBase.h | 3 +- panda/src/express/pointerToBase.h | 2 +- panda/src/express/pointerToVoid.I | 25 +++---- panda/src/express/pointerToVoid.h | 8 +-- panda/src/express/weakPointerToVoid.I | 13 +--- panda/src/express/weakPointerToVoid.h | 1 - panda/src/putil/bitArray.I | 27 ------- panda/src/putil/bitArray.h | 4 -- panda/src/putil/bitMask.I | 28 -------- panda/src/putil/bitMask.h | 4 -- panda/src/putil/buttonHandle.I | 7 -- panda/src/putil/buttonHandle.h | 1 - panda/src/putil/iterator_types.h | 10 ++- panda/src/putil/sparseArray.I | 31 +------- panda/src/putil/sparseArray.h | 4 -- panda/src/putil/writableParam.I | 16 ----- panda/src/putil/writableParam.h | 3 +- 50 files changed, 244 insertions(+), 537 deletions(-) diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index 486eaa00ba..400ed7919a 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -39,6 +39,8 @@ using namespace std; #define OVERRIDE override #define MOVE(x) x #define DEFAULT_CTOR = default +#define DEFAULT_DTOR = default +#define DELETED = delete #define EXPORT_TEMPLATE_CLASS(expcl, exptp, classname) @@ -166,6 +168,10 @@ template typename remove_reference::type &&move(T &&t) { # endif # if __has_extension(cxx_defaulted_functions) # define DEFAULT_CTOR = default +# define DEFAULT_DTOR = default +# endif +# if __has_extension(cxx_deleted_functions) +# define DELETED = delete # endif #elif defined(__GNUC__) && (__cplusplus >= 201103L) // GCC @@ -178,6 +184,8 @@ template typename remove_reference::type &&move(T &&t) { // Starting at GCC 4.4 # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) # define DEFAULT_CTOR = default +# define DEFAULT_DTOR = default +# define DELETED = delete # endif // Starting at GCC 4.6 @@ -200,7 +208,6 @@ template typename remove_reference::type &&move(T &&t) { # define FINAL final # define OVERRIDE override # define MOVE(x) move(x) -# define DEFAULT_CTOR = default #elif defined(_MSC_VER) && _MSC_VER >= 1600 // Visual Studio 2010 # define NOEXCEPT throw() # define OVERRIDE override @@ -209,6 +216,12 @@ template typename remove_reference::type &&move(T &&t) { # define MOVE(x) move(x) #endif +#if defined(_MSC_VER) && _MSC_VER >= 1800 // Visual Studio 2013 +# define DEFAULT_CTOR = default +# define DEFAULT_DTOR = default +# define DELETED = delete +#endif + // Fallbacks if features are not supported #ifndef CONSTEXPR # define CONSTEXPR INLINE @@ -228,6 +241,12 @@ template typename remove_reference::type &&move(T &&t) { #ifndef DEFAULT_CTOR # define DEFAULT_CTOR {} #endif +#ifndef DEFAULT_DTOR +# define DEFAULT_DTOR {} +#endif +#ifndef DELETED +# define DELETED {assert(false);} +#endif #if !defined(LINK_ALL_STATIC) && defined(EXPORT_TEMPLATES) diff --git a/dtool/src/dtoolbase/mutexDummyImpl.I b/dtool/src/dtoolbase/mutexDummyImpl.I index 9c0bbc01d2..94afaa2cc5 100644 --- a/dtool/src/dtoolbase/mutexDummyImpl.I +++ b/dtool/src/dtoolbase/mutexDummyImpl.I @@ -14,28 +14,14 @@ /** * */ -INLINE MutexDummyImpl:: -MutexDummyImpl() { -} - -/** - * - */ -INLINE MutexDummyImpl:: -~MutexDummyImpl() { -} - -/** - * - */ -INLINE void MutexDummyImpl:: +ALWAYS_INLINE void MutexDummyImpl:: acquire() { } /** * */ -INLINE bool MutexDummyImpl:: +ALWAYS_INLINE bool MutexDummyImpl:: try_acquire() { return true; } @@ -43,6 +29,6 @@ try_acquire() { /** * */ -INLINE void MutexDummyImpl:: +ALWAYS_INLINE void MutexDummyImpl:: release() { } diff --git a/dtool/src/dtoolbase/mutexDummyImpl.h b/dtool/src/dtoolbase/mutexDummyImpl.h index 703fb81803..2dc61f0989 100644 --- a/dtool/src/dtoolbase/mutexDummyImpl.h +++ b/dtool/src/dtoolbase/mutexDummyImpl.h @@ -23,12 +23,16 @@ */ class EXPCL_DTOOL MutexDummyImpl { public: - INLINE MutexDummyImpl(); - INLINE ~MutexDummyImpl(); + CONSTEXPR MutexDummyImpl() DEFAULT_CTOR; - INLINE void acquire(); - INLINE bool try_acquire(); - INLINE void release(); +private: + MutexDummyImpl(const MutexDummyImpl ©) DELETED; + MutexDummyImpl &operator = (const MutexDummyImpl ©) DELETED; + +public: + ALWAYS_INLINE void acquire(); + ALWAYS_INLINE bool try_acquire(); + ALWAYS_INLINE void release(); }; #include "mutexDummyImpl.I" diff --git a/dtool/src/dtoolbase/mutexPosixImpl.I b/dtool/src/dtoolbase/mutexPosixImpl.I index 9b86139b41..05acfae1c2 100644 --- a/dtool/src/dtoolbase/mutexPosixImpl.I +++ b/dtool/src/dtoolbase/mutexPosixImpl.I @@ -14,16 +14,8 @@ /** * */ -INLINE MutexPosixImpl:: -MutexPosixImpl() { - TAU_PROFILE("MutexPosixImpl::MutexPosixImpl", " ", TAU_USER); - pthread_mutexattr_t attr; - pthread_mutexattr_init(&attr); - // The symbol PTHREAD_MUTEX_DEFAULT isn't always available? - // pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_DEFAULT); - int result = pthread_mutex_init(&_lock, &attr); - pthread_mutexattr_destroy(&attr); - assert(result == 0); +CONSTEXPR MutexPosixImpl:: +MutexPosixImpl() NOEXCEPT : _lock(PTHREAD_MUTEX_INITIALIZER) { } /** @@ -78,6 +70,11 @@ get_posix_lock() { /** * */ +#ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP +CONSTEXPR ReMutexPosixImpl:: +ReMutexPosixImpl() NOEXCEPT : _lock(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) { +} +#else INLINE ReMutexPosixImpl:: ReMutexPosixImpl() { TAU_PROFILE("ReMutexPosixImpl::ReMutexPosixImpl", " ", TAU_USER); @@ -88,6 +85,7 @@ ReMutexPosixImpl() { pthread_mutexattr_destroy(&attr); assert(result == 0); } +#endif /** * diff --git a/dtool/src/dtoolbase/mutexPosixImpl.h b/dtool/src/dtoolbase/mutexPosixImpl.h index e4f684de52..c8ff5dac8f 100644 --- a/dtool/src/dtoolbase/mutexPosixImpl.h +++ b/dtool/src/dtoolbase/mutexPosixImpl.h @@ -28,9 +28,14 @@ */ class EXPCL_DTOOL MutexPosixImpl { public: - INLINE MutexPosixImpl(); + CONSTEXPR MutexPosixImpl() NOEXCEPT; INLINE ~MutexPosixImpl(); +private: + MutexPosixImpl(const MutexPosixImpl ©) DELETED; + MutexPosixImpl &operator = (const MutexPosixImpl ©) DELETED; + +public: INLINE void acquire(); INLINE bool try_acquire(); INLINE void release(); @@ -47,9 +52,18 @@ private: */ class EXPCL_DTOOL ReMutexPosixImpl { public: +#ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP + CONSTEXPR ReMutexPosixImpl() NOEXCEPT; +#else INLINE ReMutexPosixImpl(); +#endif INLINE ~ReMutexPosixImpl(); +private: + ReMutexPosixImpl(const ReMutexPosixImpl ©) DELETED; + ReMutexPosixImpl &operator = (const ReMutexPosixImpl ©) DELETED; + +public: INLINE void acquire(); INLINE bool try_acquire(); INLINE void release(); diff --git a/dtool/src/dtoolbase/mutexSpinlockImpl.I b/dtool/src/dtoolbase/mutexSpinlockImpl.I index 5b62bf4f55..9fca1e9bf6 100644 --- a/dtool/src/dtoolbase/mutexSpinlockImpl.I +++ b/dtool/src/dtoolbase/mutexSpinlockImpl.I @@ -14,16 +14,8 @@ /** * */ -INLINE MutexSpinlockImpl:: -MutexSpinlockImpl() { - _lock = 0; -} - -/** - * - */ -INLINE MutexSpinlockImpl:: -~MutexSpinlockImpl() { +CONSTEXPR MutexSpinlockImpl:: +MutexSpinlockImpl() : _lock(0) { } /** diff --git a/dtool/src/dtoolbase/mutexSpinlockImpl.h b/dtool/src/dtoolbase/mutexSpinlockImpl.h index 19a8d1802c..75adf85dc1 100644 --- a/dtool/src/dtoolbase/mutexSpinlockImpl.h +++ b/dtool/src/dtoolbase/mutexSpinlockImpl.h @@ -29,9 +29,13 @@ */ class EXPCL_DTOOL MutexSpinlockImpl { public: - INLINE MutexSpinlockImpl(); - INLINE ~MutexSpinlockImpl(); + CONSTEXPR MutexSpinlockImpl(); +private: + MutexSpinlockImpl(const MutexSpinlockImpl ©) DELETED; + MutexSpinlockImpl &operator = (const MutexSpinlockImpl ©) DELETED; + +public: INLINE void acquire(); INLINE bool try_acquire(); INLINE void release(); diff --git a/dtool/src/dtoolbase/mutexWin32Impl.h b/dtool/src/dtoolbase/mutexWin32Impl.h index 0407d5a883..f9c1bf5437 100644 --- a/dtool/src/dtoolbase/mutexWin32Impl.h +++ b/dtool/src/dtoolbase/mutexWin32Impl.h @@ -31,6 +31,11 @@ public: MutexWin32Impl(); INLINE ~MutexWin32Impl(); +private: + MutexWin32Impl(const MutexWin32Impl ©) DELETED; + MutexWin32Impl &operator = (const MutexWin32Impl ©) DELETED; + +public: INLINE void acquire(); INLINE bool try_acquire(); INLINE void release(); diff --git a/dtool/src/dtoolbase/pallocator.T b/dtool/src/dtoolbase/pallocator.T index b8a2fe73be..ebfb8dbafd 100644 --- a/dtool/src/dtoolbase/pallocator.T +++ b/dtool/src/dtoolbase/pallocator.T @@ -14,7 +14,7 @@ template INLINE pallocator_single:: -pallocator_single(TypeHandle type_handle) throw() : +pallocator_single(TypeHandle type_handle) NOEXCEPT : _type_handle(type_handle) { } @@ -37,7 +37,7 @@ deallocate(TYPENAME pallocator_single::pointer p, TYPENAME pallocator_sing template INLINE pallocator_array:: -pallocator_array(TypeHandle type_handle) throw() : +pallocator_array(TypeHandle type_handle) NOEXCEPT : _type_handle(type_handle) { } diff --git a/dtool/src/dtoolbase/pallocator.h b/dtool/src/dtoolbase/pallocator.h index deddc2abfc..b735bb7b3e 100644 --- a/dtool/src/dtoolbase/pallocator.h +++ b/dtool/src/dtoolbase/pallocator.h @@ -52,11 +52,11 @@ public: typedef TYPENAME allocator::const_reference const_reference; typedef TYPENAME allocator::size_type size_type; - INLINE pallocator_single(TypeHandle type_handle) throw(); + INLINE pallocator_single(TypeHandle type_handle) NOEXCEPT; // template member functions in VC++ can only be defined in-class. template - INLINE pallocator_single(const pallocator_single ©) throw() : + INLINE pallocator_single(const pallocator_single ©) NOEXCEPT : _type_handle(copy._type_handle) { } INLINE pointer allocate(size_type n, allocator::const_pointer hint = 0); @@ -80,11 +80,11 @@ public: typedef TYPENAME allocator::const_reference const_reference; typedef TYPENAME allocator::size_type size_type; - INLINE pallocator_array(TypeHandle type_handle = TypeHandle::none()) throw(); + INLINE pallocator_array(TypeHandle type_handle = TypeHandle::none()) NOEXCEPT; // template member functions in VC++ can only be defined in-class. template - INLINE pallocator_array(const pallocator_array ©) throw() : + INLINE pallocator_array(const pallocator_array ©) NOEXCEPT : _type_handle(copy._type_handle) { } INLINE pointer allocate(size_type n, allocator::const_pointer hint = 0); diff --git a/dtool/src/dtoolbase/pdeque.h b/dtool/src/dtoolbase/pdeque.h index 245f7e299a..96cf319e77 100644 --- a/dtool/src/dtoolbase/pdeque.h +++ b/dtool/src/dtoolbase/pdeque.h @@ -37,7 +37,6 @@ public: typedef pallocator_array allocator; typedef TYPENAME deque::size_type size_type; pdeque(TypeHandle type_handle = pdeque_type_handle) : deque >(allocator(type_handle)) { } - pdeque(const pdeque ©) : deque >(copy) { } pdeque(size_type n, TypeHandle type_handle = pdeque_type_handle) : deque >(n, Type(), allocator(type_handle)) { } pdeque(size_type n, const Type &value, TypeHandle type_handle = pdeque_type_handle) : deque >(n, value, allocator(type_handle)) { } }; diff --git a/dtool/src/dtoolbase/plist.h b/dtool/src/dtoolbase/plist.h index 9effd8db6a..bbb9e55089 100644 --- a/dtool/src/dtoolbase/plist.h +++ b/dtool/src/dtoolbase/plist.h @@ -38,7 +38,6 @@ public: typedef list base_class; typedef TYPENAME base_class::size_type size_type; plist(TypeHandle type_handle = plist_type_handle) : base_class(allocator(type_handle)) { } - plist(const plist ©) : base_class(copy) { } plist(size_type n, TypeHandle type_handle = plist_type_handle) : base_class(n, Type(), allocator(type_handle)) { } plist(size_type n, const Type &value, TypeHandle type_handle = plist_type_handle) : base_class(n, value, allocator(type_handle)) { } diff --git a/dtool/src/dtoolbase/pmap.h b/dtool/src/dtoolbase/pmap.h index e9b318c36b..e115191b45 100644 --- a/dtool/src/dtoolbase/pmap.h +++ b/dtool/src/dtoolbase/pmap.h @@ -52,7 +52,6 @@ public: typedef map base_class; pmap(TypeHandle type_handle = pmap_type_handle) : base_class(Compare(), allocator(type_handle)) { } - pmap(const pmap ©) : base_class(copy) { } pmap(const Compare &comp, TypeHandle type_handle = pmap_type_handle) : base_class(comp, allocator(type_handle)) { } #ifdef USE_TAU @@ -118,7 +117,6 @@ class pmultimap : public multimap > allocator; pmultimap(TypeHandle type_handle = pmap_type_handle) : multimap(Compare(), allocator(type_handle)) { } - pmultimap(const pmultimap ©) : multimap(copy) { } pmultimap(const Compare &comp, TypeHandle type_handle = pmap_type_handle) : multimap(comp, allocator(type_handle)) { } }; @@ -132,7 +130,6 @@ template > > class phash_map : public stdext::hash_map > > { public: phash_map() : stdext::hash_map > >() { } - phash_map(const phash_map ©) : stdext::hash_map > >(copy) { } phash_map(const Compare &comp) : stdext::hash_map > >(comp) { } }; @@ -145,7 +142,6 @@ template > > class phash_multimap : public stdext::hash_multimap > > { public: phash_multimap() : stdext::hash_multimap > >() { } - phash_multimap(const phash_multimap ©) : stdext::hash_multimap > >(copy) { } phash_multimap(const Compare &comp) : stdext::hash_multimap > >(comp) { } }; diff --git a/dtool/src/dtoolbase/pset.h b/dtool/src/dtoolbase/pset.h index 4b1ca1617c..b7990ad671 100644 --- a/dtool/src/dtoolbase/pset.h +++ b/dtool/src/dtoolbase/pset.h @@ -51,7 +51,6 @@ public: typedef pallocator_single allocator; typedef set base_class; pset(TypeHandle type_handle = pset_type_handle) : base_class(Compare(), allocator(type_handle)) { } - pset(const pset ©) : base_class(copy) { } pset(const Compare &comp, TypeHandle type_handle = pset_type_handle) : base_class(comp, type_handle) { } #ifdef USE_TAU @@ -110,7 +109,6 @@ class pmultiset : public multiset > { public: typedef pallocator_single allocator; pmultiset(TypeHandle type_handle = pset_type_handle) : multiset(Compare(), allocator(type_handle)) { } - pmultiset(const pmultiset ©) : multiset(copy) { } pmultiset(const Compare &comp, TypeHandle type_handle = pset_type_handle) : multiset(comp, type_handle) { } }; @@ -124,7 +122,6 @@ template > > class phash_set : public stdext::hash_set > { public: phash_set() : stdext::hash_set >() { } - phash_set(const phash_set ©) : stdext::hash_set >(copy) { } phash_set(const Compare &comp) : stdext::hash_set >(comp) { } }; @@ -137,7 +134,6 @@ template > > class phash_multiset : public stdext::hash_multiset > { public: phash_multiset() : stdext::hash_multiset >() { } - phash_multiset(const phash_multiset ©) : stdext::hash_multiset >(copy) { } phash_multiset(const Compare &comp) : stdext::hash_multiset >(comp) { } }; diff --git a/dtool/src/dtoolbase/pvector.h b/dtool/src/dtoolbase/pvector.h index 14bd542f37..b146947543 100644 --- a/dtool/src/dtoolbase/pvector.h +++ b/dtool/src/dtoolbase/pvector.h @@ -46,24 +46,9 @@ public: typedef TYPENAME base_class::size_type size_type; explicit pvector(TypeHandle type_handle = pvector_type_handle) : base_class(allocator(type_handle)) { } - pvector(const pvector ©) : base_class(copy) { } explicit pvector(size_type n, TypeHandle type_handle = pvector_type_handle) : base_class(n, Type(), allocator(type_handle)) { } explicit pvector(size_type n, const Type &value, TypeHandle type_handle = pvector_type_handle) : base_class(n, value, allocator(type_handle)) { } pvector(const Type *begin, const Type *end, TypeHandle type_handle = pvector_type_handle) : base_class(begin, end, allocator(type_handle)) { } - -#ifdef USE_MOVE_SEMANTICS - pvector(pvector &&from) NOEXCEPT : base_class(move(from)) {}; - - pvector &operator =(pvector &&from) NOEXCEPT { - base_class::operator =(move(from)); - return *this; - } -#endif - - pvector &operator =(const pvector ©) { - base_class::operator =(copy); - return *this; - } }; #endif // USE_STL_ALLOCATOR diff --git a/dtool/src/dtoolbase/typedObject.I b/dtool/src/dtoolbase/typedObject.I index 68776b7c13..37bb183781 100644 --- a/dtool/src/dtoolbase/typedObject.I +++ b/dtool/src/dtoolbase/typedObject.I @@ -11,27 +11,6 @@ * @date 2001-05-11 */ -/** - * - */ -INLINE TypedObject:: -TypedObject() { -} - -/** - * - */ -INLINE TypedObject:: -TypedObject(const TypedObject &) { -} - -/** - * - */ -INLINE void TypedObject:: -operator = (const TypedObject &) { -} - /** * Returns the internal index number associated with this object's TypeHandle, * a unique number for each different type. This is equivalent to diff --git a/dtool/src/dtoolbase/typedObject.h b/dtool/src/dtoolbase/typedObject.h index 37b0bd67f4..5fff8e2ff8 100644 --- a/dtool/src/dtoolbase/typedObject.h +++ b/dtool/src/dtoolbase/typedObject.h @@ -47,29 +47,49 @@ * What follows are some examples that can be used in new classes that you * create. * - * @par In the class definition (.h file): @code public: static TypeHandle - * get_class_type() { return _type_handle; } static void init_type() { - * <<>>::init_type(); <<>>::init_type(); - * <<>>::init_type(); register_type(_type_handle, - * "<<>>", <<>>::get_class_type(), - * <<>>::get_class_type(), <<>>::get_class_type()); - * } virtual TypeHandle get_type() const { return get_class_type(); } virtual - * TypeHandle force_init_type() {init_type(); return get_class_type();} + * @par In the class definition (.h file): + * @code + * public: + * static TypeHandle get_class_type() { + * return _type_handle; + * } + * static void init_type() { + * <<>>::init_type(); + * <<>>::init_type(); + * <<>>::init_type(); + * register_type(_type_handle, "<<>>", + * <<>>::get_class_type(), + * <<>>::get_class_type(), + * <<>>::get_class_type()); + * } + * virtual TypeHandle get_type() const { + * return get_class_type(); + * } + * virtual TypeHandle force_init_type() {init_type(); return get_class_type();} * - * private: static TypeHandle _type_handle; @endcode + * private: + * static TypeHandle _type_handle; + * @endcode * - * @par In the class .cxx file: @code TypeHandle - * <<>>::_type_handle; @endcode + * @par In the class .cxx file: + * @code + * TypeHandle <<>>::_type_handle; + * @endcode * - * @par In the class config_<<>>.cxx file: @code - * ConfigureFn(config_<<>>) { <<>>::init_type(); - * <<>>::init_type(); <<>>::init_type(); } @endcode + * @par In the class config_<<>>.cxx file: + * @code + * ConfigureFn(config_<<>>) { + * <<>>::init_type(); + * <<>>::init_type(); + * <<>>::init_type(); + * } + * @endcode */ class EXPCL_DTOOL TypedObject : public MemoryBase { public: - INLINE TypedObject(); - INLINE TypedObject(const TypedObject ©); - INLINE void operator = (const TypedObject ©); + INLINE TypedObject() DEFAULT_CTOR; + INLINE TypedObject(const TypedObject ©) DEFAULT_CTOR; + INLINE TypedObject &operator = (const TypedObject ©) DEFAULT_CTOR; PUBLISHED: // A virtual destructor is just a good idea. diff --git a/dtool/src/prc/streamWrapper.h b/dtool/src/prc/streamWrapper.h index 97d391a894..13a564f226 100644 --- a/dtool/src/prc/streamWrapper.h +++ b/dtool/src/prc/streamWrapper.h @@ -25,6 +25,9 @@ class EXPCL_DTOOLCONFIG StreamWrapperBase { protected: INLINE StreamWrapperBase(); +private: + INLINE StreamWrapperBase(const StreamWrapperBase ©) DELETED; + PUBLISHED: INLINE void acquire(); INLINE void release(); diff --git a/panda/src/express/datagramIterator.I b/panda/src/express/datagramIterator.I index 6f85656b47..cefde399f2 100644 --- a/panda/src/express/datagramIterator.I +++ b/panda/src/express/datagramIterator.I @@ -30,36 +30,13 @@ DatagramIterator(const Datagram &datagram, size_t offset) : nassertv(_current_index <= _datagram->get_length()); } -/** - * - */ -INLINE DatagramIterator:: -DatagramIterator(const DatagramIterator ©) : - _datagram(copy._datagram), - _current_index(copy._current_index) { -} - -/** - * - */ -INLINE void DatagramIterator:: -operator = (const DatagramIterator ©) { - _datagram = copy._datagram; - _current_index = copy._current_index; -} /** * direct Assignment to a Datagram */ -INLINE void DatagramIterator::assign(Datagram &datagram, size_t offset) -{ - _datagram =&datagram; - _current_index = offset; -} -/** - * - */ -INLINE DatagramIterator:: -~DatagramIterator() { +INLINE void DatagramIterator:: +assign(Datagram &datagram, size_t offset) { + _datagram = &datagram; + _current_index = offset; } // Various ways to get data and increment the iterator... Cut-and-paste-orama diff --git a/panda/src/express/datagramIterator.h b/panda/src/express/datagramIterator.h index b3a94c6670..7126901324 100644 --- a/panda/src/express/datagramIterator.h +++ b/panda/src/express/datagramIterator.h @@ -31,9 +31,6 @@ public: PUBLISHED: INLINE DatagramIterator(); INLINE DatagramIterator(const Datagram &datagram, size_t offset = 0); - INLINE DatagramIterator(const DatagramIterator ©); - INLINE void operator = (const DatagramIterator ©); - INLINE ~DatagramIterator(); INLINE bool get_bool(); INLINE int8_t get_int8(); diff --git a/panda/src/express/hashGeneratorBase.I b/panda/src/express/hashGeneratorBase.I index f6a65c756b..58bf0b8344 100644 --- a/panda/src/express/hashGeneratorBase.I +++ b/panda/src/express/hashGeneratorBase.I @@ -19,13 +19,6 @@ HashGeneratorBase() { _hash = 0; } -/** - * - */ -INLINE HashGeneratorBase:: -~HashGeneratorBase() { -} - /** * Returns the hash number generated. */ diff --git a/panda/src/express/hashGeneratorBase.h b/panda/src/express/hashGeneratorBase.h index 97ddb7fe08..86145a74df 100644 --- a/panda/src/express/hashGeneratorBase.h +++ b/panda/src/express/hashGeneratorBase.h @@ -30,7 +30,6 @@ class EXPCL_PANDAEXPRESS HashGeneratorBase { public: INLINE HashGeneratorBase(); - INLINE ~HashGeneratorBase(); INLINE size_t get_hash() const; diff --git a/panda/src/express/namable.I b/panda/src/express/namable.I index e1be80d872..75aa846087 100644 --- a/panda/src/express/namable.I +++ b/panda/src/express/namable.I @@ -20,35 +20,6 @@ Namable(const string &initial_name) : { } -/** - * - */ -INLINE Namable:: -Namable(const Namable ©) : - _name(copy._name) -{ -} - -/** - * - */ -INLINE Namable &Namable:: -operator = (const Namable &other) { - _name = other._name; - return *this; -} - -#ifdef USE_MOVE_SEMANTICS -/** - * - */ -INLINE Namable &Namable:: -operator = (Namable &&other) NOEXCEPT { - _name = MOVE(other._name); - return *this; -} -#endif - /** * */ diff --git a/panda/src/express/namable.h b/panda/src/express/namable.h index 435426fc1b..19a712d9d3 100644 --- a/panda/src/express/namable.h +++ b/panda/src/express/namable.h @@ -26,12 +26,6 @@ class EXPCL_PANDAEXPRESS Namable : public MemoryBase { PUBLISHED: INLINE explicit Namable(const string &initial_name = ""); - INLINE Namable(const Namable ©); - INLINE Namable &operator = (const Namable &other); - -#ifdef USE_MOVE_SEMANTICS - INLINE Namable &operator = (Namable &&other) NOEXCEPT; -#endif INLINE void set_name(const string &name); INLINE void clear_name(); diff --git a/panda/src/express/nodePointerTo.I b/panda/src/express/nodePointerTo.I index e56dd902b6..5485adcaaa 100644 --- a/panda/src/express/nodePointerTo.I +++ b/panda/src/express/nodePointerTo.I @@ -33,16 +33,6 @@ NodePointerTo(const NodePointerTo ©) : } #endif // CPPPARSER -#ifndef CPPPARSER -/** - * - */ -template -INLINE NodePointerTo:: -~NodePointerTo() { -} -#endif // CPPPARSER - #ifdef USE_MOVE_SEMANTICS #ifndef CPPPARSER /** @@ -177,16 +167,6 @@ NodeConstPointerTo(const NodeConstPointerTo ©) : } #endif // CPPPARSER -#ifndef CPPPARSER -/** - * - */ -template -INLINE NodeConstPointerTo:: -~NodeConstPointerTo() { -} -#endif // CPPPARSER - #ifdef USE_MOVE_SEMANTICS #ifndef CPPPARSER /** diff --git a/panda/src/express/nodePointerTo.h b/panda/src/express/nodePointerTo.h index 7fc773852d..ca9832d424 100644 --- a/panda/src/express/nodePointerTo.h +++ b/panda/src/express/nodePointerTo.h @@ -31,7 +31,6 @@ public: typedef TYPENAME NodePointerToBase::To To; INLINE NodePointerTo(To *ptr = (To *)NULL); INLINE NodePointerTo(const NodePointerTo ©); - INLINE ~NodePointerTo(); #ifdef USE_MOVE_SEMANTICS INLINE NodePointerTo(NodePointerTo &&from) NOEXCEPT; @@ -66,7 +65,6 @@ public: INLINE NodeConstPointerTo(const To *ptr = (const To *)NULL); INLINE NodeConstPointerTo(const NodePointerTo ©); INLINE NodeConstPointerTo(const NodeConstPointerTo ©); - INLINE ~NodeConstPointerTo(); #ifdef USE_MOVE_SEMANTICS INLINE NodeConstPointerTo(NodePointerTo &&from) NOEXCEPT; diff --git a/panda/src/express/ordered_vector.I b/panda/src/express/ordered_vector.I index 68a70b39a3..24a74c6a45 100644 --- a/panda/src/express/ordered_vector.I +++ b/panda/src/express/ordered_vector.I @@ -33,36 +33,6 @@ ordered_vector(const Compare &compare, TypeHandle type_handle) : { } -/** - * - */ -template -INLINE ordered_vector:: -ordered_vector(const ordered_vector ©) : - _compare(copy._compare), - _vector(copy._vector) -{ -} - -/** - * - */ -template -INLINE ordered_vector &ordered_vector:: -operator = (const ordered_vector ©) { - _compare = copy._compare; - _vector = copy._vector; - return *this; -} - -/** - * - */ -template -INLINE ordered_vector:: -~ordered_vector() { -} - /** * Returns the iterator that marks the first element in the ordered vector. */ @@ -636,26 +606,6 @@ ov_set(const Compare &compare, TypeHandle type_handle) : { } -/** - * - */ -template -INLINE ov_set:: -ov_set(const ov_set ©) : - ordered_vector(copy) -{ -} - -/** - * - */ -template -INLINE ov_set &ov_set:: -operator = (const ov_set ©) { - ordered_vector::operator = (copy); - return *this; -} - /** * Maps to insert_unique(). */ @@ -713,26 +663,6 @@ ov_multiset(const Compare &compare, TypeHandle type_handle) : { } -/** - * - */ -template -INLINE ov_multiset:: -ov_multiset(const ov_multiset ©) : - ordered_vector(copy) -{ -} - -/** - * - */ -template -INLINE ov_multiset &ov_multiset:: -operator = (const ov_multiset ©) { - ordered_vector::operator = (copy); - return *this; -} - /** * Maps to insert_nonunique(). */ diff --git a/panda/src/express/ordered_vector.h b/panda/src/express/ordered_vector.h index aa84cc4511..7eacfc375e 100644 --- a/panda/src/express/ordered_vector.h +++ b/panda/src/express/ordered_vector.h @@ -135,9 +135,6 @@ public: INLINE ordered_vector(TypeHandle type_handle = ov_set_type_handle); INLINE ordered_vector(const Compare &compare, TypeHandle type_handle = ov_set_type_handle); - INLINE ordered_vector(const ordered_vector ©); - INLINE ordered_vector &operator = (const ordered_vector ©); - INLINE ~ordered_vector(); // Iterator access. INLINE ITERATOR begin(); @@ -265,8 +262,6 @@ public: INLINE ov_set(TypeHandle type_handle = ov_set_type_handle); INLINE ov_set(const Compare &compare, TypeHandle type_handle = ov_set_type_handle); - INLINE ov_set(const ov_set ©); - INLINE ov_set &operator = (const ov_set ©); INLINE ITERATOR insert(ITERATOR position, const VALUE_TYPE &key0); INLINE pair insert(const VALUE_TYPE &key0); @@ -288,8 +283,6 @@ public: INLINE ov_multiset(TypeHandle type_handle = ov_set_type_handle); INLINE ov_multiset(const Compare &compare, TypeHandle type_handle = ov_set_type_handle); - INLINE ov_multiset(const ov_multiset ©); - INLINE ov_multiset &operator = (const ov_multiset ©); INLINE ITERATOR insert(ITERATOR position, const VALUE_TYPE &key); INLINE ITERATOR insert(const VALUE_TYPE &key); diff --git a/panda/src/express/pointerTo.I b/panda/src/express/pointerTo.I index a3d842e374..62962a83e3 100644 --- a/panda/src/express/pointerTo.I +++ b/panda/src/express/pointerTo.I @@ -16,7 +16,7 @@ */ template ALWAYS_INLINE PointerTo:: -PointerTo(To *ptr) : PointerToBase(ptr) { +PointerTo(To *ptr) NOEXCEPT : PointerToBase(ptr) { } /** @@ -55,16 +55,8 @@ operator = (PointerTo &&from) NOEXCEPT { * */ template -INLINE PointerTo:: -~PointerTo() { -} - -/** - * - */ -template -INLINE TYPENAME PointerTo::To &PointerTo:: -operator *() const { +CONSTEXPR TYPENAME PointerTo::To &PointerTo:: +operator *() const NOEXCEPT { return *((To *)(this->_void_ptr)); } @@ -72,8 +64,8 @@ operator *() const { * */ template -INLINE TYPENAME PointerTo::To *PointerTo:: -operator -> () const { +CONSTEXPR TYPENAME PointerTo::To *PointerTo:: +operator -> () const NOEXCEPT { return (To *)(this->_void_ptr); } @@ -84,8 +76,8 @@ operator -> () const { * goes because either will be correct. */ template -INLINE PointerTo:: -operator T * () const { +CONSTEXPR PointerTo:: +operator T * () const NOEXCEPT { return (To *)(this->_void_ptr); } @@ -107,8 +99,8 @@ cheat() { * compiler problems, particularly for implicit upcasts. */ template -INLINE TYPENAME PointerTo::To *PointerTo:: -p() const { +CONSTEXPR TYPENAME PointerTo::To *PointerTo:: +p() const NOEXCEPT { return (To *)(this->_void_ptr); } @@ -137,7 +129,7 @@ operator = (const PointerTo ©) { */ template ALWAYS_INLINE ConstPointerTo:: -ConstPointerTo(const TYPENAME ConstPointerTo::To *ptr) : +ConstPointerTo(const TYPENAME ConstPointerTo::To *ptr) NOEXCEPT : PointerToBase((TYPENAME ConstPointerTo::To *)ptr) { } @@ -152,14 +144,6 @@ ConstPointerTo(const PointerTo ©) : { } -/** - * - */ -template -INLINE ConstPointerTo:: -~ConstPointerTo() { -} - /** * */ @@ -216,8 +200,8 @@ operator = (ConstPointerTo &&from) NOEXCEPT { * */ template -INLINE const TYPENAME ConstPointerTo::To &ConstPointerTo:: -operator *() const { +CONSTEXPR const TYPENAME ConstPointerTo::To &ConstPointerTo:: +operator *() const NOEXCEPT { return *((To *)(this->_void_ptr)); } @@ -225,8 +209,8 @@ operator *() const { * */ template -INLINE const TYPENAME ConstPointerTo::To *ConstPointerTo:: -operator -> () const { +CONSTEXPR const TYPENAME ConstPointerTo::To *ConstPointerTo:: +operator -> () const NOEXCEPT { return (To *)(this->_void_ptr); } @@ -237,8 +221,8 @@ operator -> () const { * don't care which way it goes because either will be correct. */ template -INLINE ConstPointerTo:: -operator const T * () const { +CONSTEXPR ConstPointerTo:: +operator const T * () const NOEXCEPT { return (To *)(this->_void_ptr); } @@ -260,8 +244,8 @@ cheat() { * around compiler problems, particularly for implicit upcasts. */ template -INLINE const TYPENAME ConstPointerTo::To *ConstPointerTo:: -p() const { +CONSTEXPR const TYPENAME ConstPointerTo::To *ConstPointerTo:: +p() const NOEXCEPT { return (To *)(this->_void_ptr); } diff --git a/panda/src/express/pointerTo.h b/panda/src/express/pointerTo.h index 50634f6473..15dbcdefb0 100644 --- a/panda/src/express/pointerTo.h +++ b/panda/src/express/pointerTo.h @@ -14,35 +14,47 @@ #ifndef POINTERTO_H #define POINTERTO_H -/* +/** * This file defines the classes PointerTo and ConstPointerTo (and their * abbreviations, PT and CPT). These should be used in place of traditional - * C-style pointers wherever implicit reference counting is desired. The - * syntax is: instead of: PointerTo p; - * MyClass *p; PT(MyClass) p; ConstPointerTo p; const MyClass - * *p; CPT(MyClass) p; PointerTo and ConstPointerTo will automatically - * increment the object's reference count while the pointer is kept. When the - * PointerTo object is reassigned or goes out of scope, the reference count is - * automatically decremented. If the reference count reaches zero, the object - * is freed. Note that const PointerTo is different from + * C-style pointers wherever implicit reference counting is desired. + * + * The syntax is: instead of: + * + * PointerTo p; MyClass *p; + * PT(MyClass) p; + * + * ConstPointerTo p; const MyClass *p; + * CPT(MyClass) p; + * + * PointerTo and ConstPointerTo will automatically increment the object's + * reference count while the pointer is kept. When the PointerTo object is + * reassigned or goes out of scope, the reference count is automatically + * decremented. If the reference count reaches zero, the object is freed. + * + * Note that const PointerTo is different from * ConstPointerTo. A const PointerTo may not reassign its pointer, * but it may still modify the contents at that address. On the other hand, a * ConstPointerTo may reassign its pointer at will, but may not modify the - * contents. It is like the difference between (MyClass * const) and (const - * MyClass *). In order to use PointerTo, it is necessary that the thing - * pointed to--MyClass in the above example--either inherits from - * ReferenceCount, or is a proxy built with RefCountProxy or RefCountObj (see - * referenceCount.h). However, also see PointerToArray, which does not have - * this restriction. It is crucial that the PointerTo object is only used to - * refer to objects allocated from the free store, for which delete is a - * sensible thing to do. If you assign a PointerTo to an automatic variable - * (allocated from the stack, for instance), bad things will certainly happen - * when the reference count reaches zero and it tries to delete it. It's also - * important to remember that, as always, a virtual destructor is required if - * you plan to support polymorphism. That is, if you define a PointerTo to - * some base type, and assign to it instances of a class derived from that - * base class, the base class must have a virtual destructor in order to - * properly destruct the derived object when it is deleted. + * contents. It is like the difference between (MyClass * const) and + * (const MyClass *). + * + * In order to use PointerTo, it is necessary that the thing pointed to + * --MyClass in the above example--either inherits from ReferenceCount, or is + * a proxy built with RefCountProxy or RefCountObj (see referenceCount.h). + * However, also see PointerToArray, which does not have this restriction. + * + * It is crucial that the PointerTo object is only used to refer to objects + * allocated from the free store, for which delete is a sensible thing to do. + * If you assign a PointerTo to an automatic variable (allocated from the + * stack, for instance), bad things will certainly happen when the reference + * count reaches zero and it tries to delete it. + * + * It's also important to remember that, as always, a virtual destructor is + * required if you plan to support polymorphism. That is, if you define a + * PointerTo to some base type, and assign to it instances of a class derived + * from that base class, the base class must have a virtual destructor in + * order to properly destruct the derived object when it is deleted. */ #include "pandabase.h" @@ -58,10 +70,9 @@ class PointerTo : public PointerToBase { public: typedef TYPENAME PointerToBase::To To; PUBLISHED: - ALWAYS_INLINE PointerTo() DEFAULT_CTOR; - ALWAYS_INLINE PointerTo(To *ptr); + ALWAYS_INLINE CONSTEXPR PointerTo() NOEXCEPT DEFAULT_CTOR; + ALWAYS_INLINE PointerTo(To *ptr) NOEXCEPT; INLINE PointerTo(const PointerTo ©); - INLINE ~PointerTo(); public: #ifdef USE_MOVE_SEMANTICS @@ -69,10 +80,10 @@ public: INLINE PointerTo &operator = (PointerTo &&from) NOEXCEPT; #endif - INLINE To &operator *() const; - INLINE To *operator -> () const; + CONSTEXPR To &operator *() const NOEXCEPT; + CONSTEXPR To *operator -> () const NOEXCEPT; // MSVC.NET 2005 insists that we use T *, and not To *, here. - INLINE operator T *() const; + CONSTEXPR operator T *() const NOEXCEPT; INLINE T *&cheat(); @@ -89,7 +100,7 @@ PUBLISHED: // the DCAST macro defined in typedObject.h instead, e.g. DCAST(MyType, // ptr). This provides a clean downcast that doesn't require .p() or any // double-casting, and it can be run-time checked for correctness. - INLINE To *p() const; + CONSTEXPR To *p() const NOEXCEPT; INLINE PointerTo &operator = (To *ptr); INLINE PointerTo &operator = (const PointerTo ©); @@ -98,8 +109,10 @@ PUBLISHED: // anyway just to help out interrogate (which doesn't seem to want to // automatically export the PointerToBase class). When this works again in // interrogate, we can remove these. - INLINE bool is_null() const { return PointerToBase::is_null(); } - INLINE void clear() { PointerToBase::clear(); } +#ifdef CPPPARSER + INLINE bool is_null() const; + INLINE void clear(); +#endif }; @@ -120,11 +133,10 @@ class ConstPointerTo : public PointerToBase { public: typedef TYPENAME PointerToBase::To To; PUBLISHED: - ALWAYS_INLINE ConstPointerTo() DEFAULT_CTOR; - ALWAYS_INLINE ConstPointerTo(const To *ptr); + ALWAYS_INLINE CONSTEXPR ConstPointerTo() NOEXCEPT DEFAULT_CTOR; + ALWAYS_INLINE ConstPointerTo(const To *ptr) NOEXCEPT; INLINE ConstPointerTo(const PointerTo ©); INLINE ConstPointerTo(const ConstPointerTo ©); - INLINE ~ConstPointerTo(); public: #ifdef USE_MOVE_SEMANTICS @@ -134,14 +146,14 @@ public: INLINE ConstPointerTo &operator = (ConstPointerTo &&from) NOEXCEPT; #endif - INLINE const To &operator *() const; - INLINE const To *operator -> () const; - INLINE operator const T *() const; + CONSTEXPR const To &operator *() const NOEXCEPT; + CONSTEXPR const To *operator -> () const NOEXCEPT; + CONSTEXPR operator const T *() const NOEXCEPT; INLINE const T *&cheat(); PUBLISHED: - INLINE const To *p() const; + CONSTEXPR const To *p() const NOEXCEPT; INLINE ConstPointerTo &operator = (const To *ptr); INLINE ConstPointerTo &operator = (const PointerTo ©); @@ -151,7 +163,9 @@ PUBLISHED: // anyway just to help out interrogate (which doesn't seem to want to // automatically export the PointerToBase class). When this works again in // interrogate, we can remove this. - INLINE void clear() { PointerToBase::clear(); } +#ifdef CPPPARSER + INLINE void clear(); +#endif }; diff --git a/panda/src/express/pointerToArray.I b/panda/src/express/pointerToArray.I index 568b379105..7bf8b89d4e 100644 --- a/panda/src/express/pointerToArray.I +++ b/panda/src/express/pointerToArray.I @@ -68,6 +68,17 @@ PointerToArray(const PointerToArray ©) : { } +/** + * Initializes a PointerToArray by copying existing elements. + */ +template +INLINE PointerToArray:: +PointerToArray(const Element *begin, const Element *end, TypeHandle type_handle) : + PointerToArrayBase(new ReferenceCountedVector(begin, end, type_handle)), + _type_handle(type_handle) +{ +} + #ifdef USE_MOVE_SEMANTICS /** * @@ -627,6 +638,17 @@ ConstPointerToArray(TypeHandle type_handle) : { } +/** + * Initializes a ConstPointerToArray by copying existing elements. + */ +template +INLINE ConstPointerToArray:: +ConstPointerToArray(const Element *begin, const Element *end, TypeHandle type_handle) : + PointerToArrayBase(new ReferenceCountedVector(begin, end, type_handle)), + _type_handle(type_handle) +{ +} + /** * */ diff --git a/panda/src/express/pointerToArray.h b/panda/src/express/pointerToArray.h index 004e15fdea..d486f1b00f 100644 --- a/panda/src/express/pointerToArray.h +++ b/panda/src/express/pointerToArray.h @@ -134,6 +134,7 @@ public: INLINE PointerToArray(TypeHandle type_handle = get_type_handle(Element)); INLINE static PointerToArray empty_array(size_type n, TypeHandle type_handle = get_type_handle(Element)); INLINE PointerToArray(size_type n, const Element &value, TypeHandle type_handle = get_type_handle(Element)); + INLINE PointerToArray(const Element *begin, const Element *end, TypeHandle type_handle = get_type_handle(Element)); INLINE PointerToArray(const PointerToArray ©); #ifdef USE_MOVE_SEMANTICS @@ -289,6 +290,7 @@ PUBLISHED: typedef TYPENAME pvector::size_type size_type; INLINE ConstPointerToArray(TypeHandle type_handle = get_type_handle(Element)); + INLINE ConstPointerToArray(const Element *begin, const Element *end, TypeHandle type_handle = get_type_handle(Element)); INLINE ConstPointerToArray(const PointerToArray ©); INLINE ConstPointerToArray(const ConstPointerToArray ©); diff --git a/panda/src/express/pointerToArrayBase.I b/panda/src/express/pointerToArrayBase.I index 885d759aed..89acba1206 100644 --- a/panda/src/express/pointerToArrayBase.I +++ b/panda/src/express/pointerToArrayBase.I @@ -19,17 +19,6 @@ INLINE ReferenceCountedVector:: ReferenceCountedVector(TypeHandle type_handle) : pvector(type_handle) { } -/** - * - */ -template -INLINE ReferenceCountedVector:: -ReferenceCountedVector(const ReferenceCountedVector ©) : - NodeReferenceCount(copy), - pvector(copy) -{ -} - /** * Creates an array of initial_size elements. */ @@ -41,11 +30,13 @@ ReferenceCountedVector(TYPENAME ReferenceCountedVector::size_type initi } /** - * + * Creates an array with all elements from begin up to but not including end. */ template INLINE ReferenceCountedVector:: -~ReferenceCountedVector() { +ReferenceCountedVector(const Element *begin, const Element *end, TypeHandle type_handle) : + pvector(begin, end, type_handle) +{ } /** diff --git a/panda/src/express/pointerToArrayBase.h b/panda/src/express/pointerToArrayBase.h index 291ffed656..3220ca4c70 100644 --- a/panda/src/express/pointerToArrayBase.h +++ b/panda/src/express/pointerToArrayBase.h @@ -41,9 +41,8 @@ public: typedef TYPENAME pvector::size_type size_type; INLINE ReferenceCountedVector(TypeHandle type_handle); - INLINE ReferenceCountedVector(const ReferenceCountedVector ©); INLINE ReferenceCountedVector(size_type initial_size, TypeHandle type_handle); - INLINE ~ReferenceCountedVector(); + INLINE ReferenceCountedVector(const Element *begin, const Element *end, TypeHandle type_handle); ALLOC_DELETED_CHAIN(ReferenceCountedVector); INLINE size_type size() const; diff --git a/panda/src/express/pointerToBase.h b/panda/src/express/pointerToBase.h index cbafa5587b..6c20aceb6a 100644 --- a/panda/src/express/pointerToBase.h +++ b/panda/src/express/pointerToBase.h @@ -31,7 +31,7 @@ public: typedef T To; protected: - ALWAYS_INLINE PointerToBase() DEFAULT_CTOR; + ALWAYS_INLINE CONSTEXPR PointerToBase() NOEXCEPT DEFAULT_CTOR; INLINE PointerToBase(To *ptr); INLINE PointerToBase(const PointerToBase ©); INLINE ~PointerToBase(); diff --git a/panda/src/express/pointerToVoid.I b/panda/src/express/pointerToVoid.I index 6ae942b645..2f3cad1aba 100644 --- a/panda/src/express/pointerToVoid.I +++ b/panda/src/express/pointerToVoid.I @@ -14,34 +14,25 @@ /** * */ -INLINE PointerToVoid:: -PointerToVoid() { - _void_ptr = (void *)NULL; +INLINE CONSTEXPR PointerToVoid:: +PointerToVoid() NOEXCEPT : _void_ptr(nullptr) { } /** * */ -INLINE PointerToVoid:: -~PointerToVoid() { - nassertv(_void_ptr == (void *)NULL); -} - -/** - * Don't use this constructor. - */ -INLINE PointerToVoid:: -PointerToVoid(const PointerToVoid &) { - nassertv(false); -} +//INLINE PointerToVoid:: +//~PointerToVoid() { +// nassertv(_void_ptr == nullptr); +//} /** * Returns true if the PointerTo is a NULL pointer, false otherwise. (Direct * comparison to a NULL pointer also works.) */ -ALWAYS_INLINE bool PointerToVoid:: +ALWAYS_INLINE CONSTEXPR bool PointerToVoid:: is_null() const { - return (_void_ptr == (void *)NULL); + return _void_ptr == nullptr; } /** diff --git a/panda/src/express/pointerToVoid.h b/panda/src/express/pointerToVoid.h index 25189a4e0a..9503084999 100644 --- a/panda/src/express/pointerToVoid.h +++ b/panda/src/express/pointerToVoid.h @@ -32,14 +32,14 @@ */ class EXPCL_PANDAEXPRESS PointerToVoid : public MemoryBase { protected: - INLINE PointerToVoid(); - INLINE ~PointerToVoid(); + ALWAYS_INLINE CONSTEXPR PointerToVoid() NOEXCEPT; + //INLINE ~PointerToVoid(); private: - INLINE PointerToVoid(const PointerToVoid ©); + PointerToVoid(const PointerToVoid ©) DELETED; PUBLISHED: - ALWAYS_INLINE bool is_null() const; + ALWAYS_INLINE CONSTEXPR bool is_null() const; INLINE size_t get_hash() const; public: diff --git a/panda/src/express/weakPointerToVoid.I b/panda/src/express/weakPointerToVoid.I index f55cf499cc..bc778630b7 100644 --- a/panda/src/express/weakPointerToVoid.I +++ b/panda/src/express/weakPointerToVoid.I @@ -15,16 +15,9 @@ * */ INLINE WeakPointerToVoid:: -WeakPointerToVoid() { - _ptr_was_deleted = false; - _callback = NULL; -} - -/** - * - */ -INLINE WeakPointerToVoid:: -~WeakPointerToVoid() { +WeakPointerToVoid() : + _ptr_was_deleted(false), + _callback(NULL) { } /** diff --git a/panda/src/express/weakPointerToVoid.h b/panda/src/express/weakPointerToVoid.h index e82ec63420..98a481e49e 100644 --- a/panda/src/express/weakPointerToVoid.h +++ b/panda/src/express/weakPointerToVoid.h @@ -25,7 +25,6 @@ class EXPCL_PANDAEXPRESS WeakPointerToVoid : public PointerToVoid { protected: INLINE WeakPointerToVoid(); - INLINE ~WeakPointerToVoid(); public: INLINE void mark_deleted(); diff --git a/panda/src/putil/bitArray.I b/panda/src/putil/bitArray.I index 6c16a549d0..f746a9ba77 100644 --- a/panda/src/putil/bitArray.I +++ b/panda/src/putil/bitArray.I @@ -30,26 +30,6 @@ BitArray(WordType init_value) { _highest_bits = 0; } -/** - * - */ -INLINE BitArray:: -BitArray(const BitArray ©) : - _array(copy._array), - _highest_bits(copy._highest_bits) -{ -} - -/** - * - */ -INLINE BitArray &BitArray:: -operator = (const BitArray ©) { - _array = copy._array; - _highest_bits = copy._highest_bits; - return *this; -} - /** * Returns a BitArray with an infinite array of bits, all on. */ @@ -98,13 +78,6 @@ range(int low_bit, int size) { return result; } -/** - * - */ -INLINE BitArray:: -~BitArray() { -} - /** * Returns true if there is a maximum number of bits that may be stored in * this structure, false otherwise. If this returns true, the number may be diff --git a/panda/src/putil/bitArray.h b/panda/src/putil/bitArray.h index 3a4a4b16d2..72ef1f656d 100644 --- a/panda/src/putil/bitArray.h +++ b/panda/src/putil/bitArray.h @@ -46,8 +46,6 @@ PUBLISHED: INLINE BitArray(); INLINE BitArray(WordType init_value); - INLINE BitArray(const BitArray ©); - INLINE BitArray &operator = (const BitArray ©); BitArray(const SparseArray &from); INLINE static BitArray all_on(); @@ -56,8 +54,6 @@ PUBLISHED: INLINE static BitArray bit(int index); INLINE static BitArray range(int low_bit, int size); - INLINE ~BitArray(); - CONSTEXPR static bool has_max_num_bits(); CONSTEXPR static int get_max_num_bits(); diff --git a/panda/src/putil/bitMask.I b/panda/src/putil/bitMask.I index dca29c5b6a..0411d06042 100644 --- a/panda/src/putil/bitMask.I +++ b/panda/src/putil/bitMask.I @@ -34,26 +34,6 @@ BitMask(WordType init_value) : { } -/** - * - */ -template -INLINE BitMask:: -BitMask(const BitMask ©) : - _word(copy._word) -{ -} - -/** - * - */ -template -INLINE BitMask &BitMask:: -operator = (const BitMask ©) { - _word = copy._word; - return *this; -} - /** * Returns a BitMask whose bits are all on. */ @@ -121,14 +101,6 @@ range(int low_bit, int size) { return result; } -/** - * - */ -template -INLINE BitMask:: -~BitMask() { -} - /** * Returns true if there is a maximum number of bits that may be stored in * this structure, false otherwise. If this returns true, the number may be diff --git a/panda/src/putil/bitMask.h b/panda/src/putil/bitMask.h index 17c1c9f69d..ff9b15db97 100644 --- a/panda/src/putil/bitMask.h +++ b/panda/src/putil/bitMask.h @@ -38,8 +38,6 @@ PUBLISHED: INLINE BitMask(); INLINE BitMask(WordType init_value); - INLINE BitMask(const BitMask ©); - INLINE BitMask &operator = (const BitMask ©); INLINE static BitMask all_on(); INLINE static BitMask all_off(); @@ -47,8 +45,6 @@ PUBLISHED: INLINE static BitMask bit(int index); INLINE static BitMask range(int low_bit, int size); - INLINE ~BitMask(); - CONSTEXPR static bool has_max_num_bits(); CONSTEXPR static int get_max_num_bits(); diff --git a/panda/src/putil/buttonHandle.I b/panda/src/putil/buttonHandle.I index 5701ccb395..2353b01689 100644 --- a/panda/src/putil/buttonHandle.I +++ b/panda/src/putil/buttonHandle.I @@ -19,13 +19,6 @@ CONSTEXPR ButtonHandle:: ButtonHandle(int index) : _index(index) { } -/** - * - */ -INLINE ButtonHandle:: -ButtonHandle(const ButtonHandle ©) : _index(copy._index) { -} - /** * */ diff --git a/panda/src/putil/buttonHandle.h b/panda/src/putil/buttonHandle.h index d2b97be36a..429108249f 100644 --- a/panda/src/putil/buttonHandle.h +++ b/panda/src/putil/buttonHandle.h @@ -31,7 +31,6 @@ PUBLISHED: // previously by another static initializer! INLINE ButtonHandle() DEFAULT_CTOR; CONSTEXPR ButtonHandle(int index); - INLINE ButtonHandle(const ButtonHandle ©); ButtonHandle(const string &name); PUBLISHED: diff --git a/panda/src/putil/iterator_types.h b/panda/src/putil/iterator_types.h index cb405ce18c..2f2966cde7 100644 --- a/panda/src/putil/iterator_types.h +++ b/panda/src/putil/iterator_types.h @@ -14,6 +14,7 @@ #ifndef ITERATOR_TYPES_H #define ITERATOR_TYPES_H +#include "dtoolbase.h" /** * This is an iterator adaptor that converts any iterator that returns a pair @@ -25,9 +26,8 @@ class first_of_pair_iterator : public pair_iterator { public: typedef TYPENAME pair_iterator::value_type::first_type value_type; - first_of_pair_iterator() { } + first_of_pair_iterator() DEFAULT_CTOR; first_of_pair_iterator(const pair_iterator &init) : pair_iterator(init) { } - first_of_pair_iterator(const first_of_pair_iterator ©) : pair_iterator(copy) { } value_type operator *() { return pair_iterator::operator *().first; @@ -44,9 +44,8 @@ class second_of_pair_iterator : public pair_iterator { public: typedef TYPENAME pair_iterator::value_type::second_type value_type; - second_of_pair_iterator() { } + second_of_pair_iterator() DEFAULT_CTOR; second_of_pair_iterator(const pair_iterator &init) : pair_iterator(init) { } - second_of_pair_iterator(const second_of_pair_iterator ©) : pair_iterator(copy) { } value_type operator *() { return pair_iterator::operator *().second; @@ -62,9 +61,8 @@ class typecast_iterator : public base_iterator { public: typedef new_type value_type; - typecast_iterator() { } + typecast_iterator() DEFAULT_CTOR; typecast_iterator(const base_iterator &init) : base_iterator(init) { } - typecast_iterator(const typecast_iterator ©) : base_iterator(copy) { } value_type operator *() { return (new_type)base_iterator::operator *(); diff --git a/panda/src/putil/sparseArray.I b/panda/src/putil/sparseArray.I index fb459806d0..682d5f93be 100644 --- a/panda/src/putil/sparseArray.I +++ b/panda/src/putil/sparseArray.I @@ -18,26 +18,6 @@ INLINE SparseArray:: SparseArray() : _inverse(false) { } -/** - * - */ -INLINE SparseArray:: -SparseArray(const SparseArray ©) : - _subranges(copy._subranges), - _inverse(copy._inverse) -{ -} - -/** - * - */ -INLINE SparseArray &SparseArray:: -operator = (const SparseArray ©) { - _subranges = copy._subranges; - _inverse = copy._inverse; - return *this; -} - /** * Returns a SparseArray with an infinite array of bits, all on. */ @@ -62,7 +42,9 @@ all_off() { INLINE SparseArray SparseArray:: lower_on(int on_bits) { SparseArray result; - result.set_range(0, on_bits); + if (on_bits > 0) { + result._subranges.push_back(Subrange(0, on_bits)); + } return result; } @@ -86,13 +68,6 @@ range(int low_bit, int size) { return result; } -/** - * - */ -INLINE SparseArray:: -~SparseArray() { -} - /** * Returns true if there is a maximum number of bits that may be stored in * this structure, false otherwise. If this returns true, the number may be diff --git a/panda/src/putil/sparseArray.h b/panda/src/putil/sparseArray.h index 9ebd205bac..a372fc240e 100644 --- a/panda/src/putil/sparseArray.h +++ b/panda/src/putil/sparseArray.h @@ -42,8 +42,6 @@ class DatagramIterator; class EXPCL_PANDA_PUTIL SparseArray { PUBLISHED: INLINE SparseArray(); - INLINE SparseArray(const SparseArray ©); - INLINE SparseArray &operator = (const SparseArray ©); SparseArray(const BitArray &from); INLINE static SparseArray all_on(); @@ -52,8 +50,6 @@ PUBLISHED: INLINE static SparseArray bit(int index); INLINE static SparseArray range(int low_bit, int size); - INLINE ~SparseArray(); - INLINE static bool has_max_num_bits(); INLINE static int get_max_num_bits(); diff --git a/panda/src/putil/writableParam.I b/panda/src/putil/writableParam.I index 49b75bf0f9..878820379a 100644 --- a/panda/src/putil/writableParam.I +++ b/panda/src/putil/writableParam.I @@ -30,22 +30,6 @@ WritableParam(const WritableParam ©) : { } -/** - * - */ -INLINE WritableParam:: -~WritableParam() { -} - -/** - * - */ -INLINE void WritableParam:: -operator = (const WritableParam &) { - // The assignment operator cannot be used for this class. - nassertv(false); -} - /** * */ diff --git a/panda/src/putil/writableParam.h b/panda/src/putil/writableParam.h index beefff5b8a..372613fc99 100644 --- a/panda/src/putil/writableParam.h +++ b/panda/src/putil/writableParam.h @@ -36,11 +36,10 @@ private: public: INLINE WritableParam(const Datagram &datagram); INLINE WritableParam(const WritableParam &other); - INLINE ~WritableParam(); private: // The assignment operator cannot be used for this class. - INLINE void operator = (const WritableParam &other); + INLINE void operator = (const WritableParam &other) DELETED; public: virtual TypeHandle get_type() const {