Skip to content

Commit

Permalink
Fix compile error in c++20 (#510)
Browse files Browse the repository at this point in the history
In c++20, more constraints are applied:

* constructor and destructor are not allowed to have template id
* adding two enum value needs explicit convertion
  • Loading branch information
gfphoenix78 authored Jul 10, 2024
1 parent 472db76 commit 1e70fdc
Show file tree
Hide file tree
Showing 21 changed files with 54 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,10 @@ class CStateMachine
}

public:
CStateMachine<TEnumState, tenumstateSentinel, TEnumEvent,
tenumeventSentinel>(
const CStateMachine<TEnumState, tenumstateSentinel, TEnumEvent,
tenumeventSentinel> &) = delete;
CStateMachine(const CStateMachine &) = delete;

// ctor
CStateMachine<TEnumState, tenumstateSentinel, TEnumEvent,
tenumeventSentinel>()
CStateMachine()
: m_tenumstate(TesInitial())
{
GPOS_ASSERT(0 < tenumstateSentinel && 0 < tenumeventSentinel &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ class CJobStateMachine
CJobStateMachine(const CJobStateMachine &) = delete;

// ctor
CJobStateMachine<TEnumState, estSentinel, TEnumEvent, eevSentinel>() =
default;
CJobStateMachine() = default;

// dtor
~CJobStateMachine() = default;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/gporca/libgpopt/include/gpopt/xforms/CXform.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "naucrates/traceflags/traceflags.h"

// Macro for enabling and disabling xforms
#define GPOPT_DISABLE_XFORM_TF(x) EopttraceDisableXformBase + x
#define GPOPT_DISABLE_XFORM_TF(x) EopttraceDisableXformBase + static_cast<int>(x)
#define GPOPT_ENABLE_XFORM(x) GPOS_UNSET_TRACE(GPOPT_DISABLE_XFORM_TF(x))
#define GPOPT_DISABLE_XFORM(x) GPOS_SET_TRACE(GPOPT_DISABLE_XFORM_TF(x))
#define GPOPT_FENABLED_XFORM(x) !GPOS_FTRACE(GPOPT_DISABLE_XFORM_TF(x))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class CXformApply2Join : public CXformExploration
CXformApply2Join(const CXformApply2Join &) = delete;

// ctor for deep pattern
explicit CXformApply2Join<TApply, TJoin>(CMemoryPool *mp, BOOL)
explicit CXformApply2Join(CMemoryPool *mp, BOOL)
: // pattern
CXformExploration(GPOS_NEW(mp) CExpression(
mp, GPOS_NEW(mp) TApply(mp),
Expand All @@ -272,7 +272,7 @@ class CXformApply2Join : public CXformExploration
}

// ctor for shallow pattern
explicit CXformApply2Join<TApply, TJoin>(CMemoryPool *mp)
explicit CXformApply2Join(CMemoryPool *mp)
: // pattern
CXformExploration(GPOS_NEW(mp) CExpression(
mp, GPOS_NEW(mp) TApply(mp),
Expand All @@ -287,14 +287,13 @@ class CXformApply2Join : public CXformExploration
}

// ctor for passed pattern
CXformApply2Join<TApply, TJoin>(CMemoryPool *, // mp
CExpression *pexprPattern)
CXformApply2Join(CMemoryPool * /* mp */, CExpression *pexprPattern)
: CXformExploration(pexprPattern)
{
}

// dtor
~CXformApply2Join<TApply, TJoin>() override = default;
~CXformApply2Join() override = default;

// is transformation an Apply decorrelation (Apply To Join) xform?
BOOL
Expand Down
6 changes: 3 additions & 3 deletions src/backend/gporca/libgpos/include/gpos/common/CAutoP.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ class CAutoP : public CStackObject
T *m_object;

public:
CAutoP<T>(const CAutoP &) = delete;
CAutoP(const CAutoP &) = delete;

// ctor
explicit CAutoP<T>() : m_object(nullptr)
explicit CAutoP() : m_object(nullptr)
{
}

explicit CAutoP<T>(T *object) : m_object(object)
explicit CAutoP(T *object) : m_object(object)
{
}

Expand Down
6 changes: 3 additions & 3 deletions src/backend/gporca/libgpos/include/gpos/common/CAutoRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ class CAutoRef : public CAutoP<T>
{
private:
public:
CAutoRef<T>(const CAutoRef &) = delete;
CAutoRef(const CAutoRef &) = delete;

// ctor
explicit CAutoRef<T>() : CAutoP<T>()
explicit CAutoRef() : CAutoP<T>()
{
}

// ctor
explicit CAutoRef<T>(T *object) : CAutoP<T>(object)
explicit CAutoRef(T *object) : CAutoP<T>(object)
{
}

Expand Down
6 changes: 3 additions & 3 deletions src/backend/gporca/libgpos/include/gpos/common/CAutoRg.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ class CAutoRg : public CStackObject
T *m_object_array;

public:
CAutoRg<T>(const CAutoRg &) = delete;
CAutoRg(const CAutoRg &) = delete;

// ctor
explicit CAutoRg<T>() : m_object_array(nullptr)
explicit CAutoRg() : m_object_array(nullptr)
{
}

// ctor
explicit CAutoRg<T>(T *object_array) : m_object_array(object_array)
explicit CAutoRg(T *object_array) : m_object_array(object_array)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,10 @@ class CDynamicPtrArray : public CRefCount
}

public:
CDynamicPtrArray<T, CleanupFn>(const CDynamicPtrArray<T, CleanupFn> &) =
delete;
CDynamicPtrArray(const CDynamicPtrArray &) = delete;

// ctor
explicit CDynamicPtrArray<T, CleanupFn>(CMemoryPool *mp, ULONG min_size = 4,
explicit CDynamicPtrArray(CMemoryPool *mp, ULONG min_size = 4,
ULONG expansion_factor = 10)
: m_mp(mp),
m_capacity(0),
Expand All @@ -165,7 +164,7 @@ class CDynamicPtrArray : public CRefCount
}

// dtor
~CDynamicPtrArray<T, CleanupFn>() override
~CDynamicPtrArray() override
{
Clear();

Expand Down
10 changes: 5 additions & 5 deletions src/backend/gporca/libgpos/include/gpos/common/CEnumSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ class CEnumSet : public CBitSet
{
private:
public:
CEnumSet<T, sentinel_index>(const CEnumSet<T, sentinel_index> &) = delete;
CEnumSet(const CEnumSet &) = delete;

// ctor
explicit CEnumSet<T, sentinel_index>(CMemoryPool *mp)
explicit CEnumSet(CMemoryPool *mp)
: CBitSet(mp, sentinel_index)
{
}

explicit CEnumSet<T, sentinel_index>(
CMemoryPool *mp, const CEnumSet<T, sentinel_index> &enum_set)
explicit CEnumSet(
CMemoryPool *mp, const CEnumSet &enum_set)
: CBitSet(mp, enum_set)
{
}

// dtor
~CEnumSet<T, sentinel_index>() override = default;
~CEnumSet() override = default;

// determine if bit is set
BOOL
Expand Down
7 changes: 3 additions & 4 deletions src/backend/gporca/libgpos/include/gpos/common/CEnumSetIter.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,17 @@ class CEnumSetIter : public CBitSetIter
{
private:
public:
CEnumSetIter<T, sentinel_index>(const CEnumSetIter<T, sentinel_index> &) =
delete;
CEnumSetIter(const CEnumSetIter &) = delete;

// ctor
explicit CEnumSetIter<T, sentinel_index>(
explicit CEnumSetIter(
const CEnumSet<T, sentinel_index> &enum_set)
: CBitSetIter(enum_set)
{
}

// dtor
~CEnumSetIter<T, sentinel_index>() = default;
~CEnumSetIter() = default;

// current enum
T
Expand Down
8 changes: 3 additions & 5 deletions src/backend/gporca/libgpos/include/gpos/common/CHashMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,10 @@ class CHashMap : public CRefCount
}

public:
CHashMap(const CHashMap<K, T, HashFn, EqFn, DestroyKFn, DestroyTFn> &) =
delete;
CHashMap(const CHashMap &) = delete;

// ctor
CHashMap<K, T, HashFn, EqFn, DestroyKFn, DestroyTFn>(CMemoryPool *mp,
ULONG num_chains = 127)
CHashMap(CMemoryPool *mp, ULONG num_chains = 127)
: m_mp(mp),
m_num_chains(num_chains),
m_size(0),
Expand All @@ -196,7 +194,7 @@ class CHashMap : public CRefCount
}

// dtor
~CHashMap<K, T, HashFn, EqFn, DestroyKFn, DestroyTFn>() override
~CHashMap() override
{
// release all hash chains
Clear();
Expand Down
8 changes: 3 additions & 5 deletions src/backend/gporca/libgpos/include/gpos/common/CHashMapIter.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,17 @@ class CHashMapIter : public CStackObject
}

public:
CHashMapIter(const CHashMapIter<K, T, HashFn, EqFn, DestroyKFn, DestroyTFn>
&) = delete;
CHashMapIter(const CHashMapIter &) = delete;

// ctor
CHashMapIter<K, T, HashFn, EqFn, DestroyKFn, DestroyTFn>(TMap *ptm)
CHashMapIter(TMap *ptm)
: m_map(ptm), m_chain_idx(0), m_key_idx(0)
{
GPOS_ASSERT(nullptr != ptm);
}

// dtor
virtual ~CHashMapIter<K, T, HashFn, EqFn, DestroyKFn, DestroyTFn>() =
default;
virtual ~CHashMapIter() = default;

// advance iterator to next element
BOOL
Expand Down
6 changes: 3 additions & 3 deletions src/backend/gporca/libgpos/include/gpos/common/CHashSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ class CHashSet : public CRefCount
}

public:
CHashSet(const CHashSet<T, HashFn, EqFn, CleanupFn> &) = delete;
CHashSet(const CHashSet &) = delete;

// ctor
CHashSet<T, HashFn, EqFn, CleanupFn>(CMemoryPool *mp, ULONG size = 127)
CHashSet(CMemoryPool *mp, ULONG size = 127)
: m_mp(mp),
m_num_chains(size),
m_size(0),
Expand All @@ -177,7 +177,7 @@ class CHashSet : public CRefCount
}

// dtor
~CHashSet<T, HashFn, EqFn, CleanupFn>() override
~CHashSet() override
{
// release all hash chains
Clear();
Expand Down
6 changes: 3 additions & 3 deletions src/backend/gporca/libgpos/include/gpos/common/CHashSetIter.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ class CHashSetIter : public CStackObject
BOOL m_is_initialized;

public:
CHashSetIter(const CHashSetIter<T, HashFn, EqFn, CleanupFn> &) = delete;
CHashSetIter(const CHashSetIter &) = delete;

// ctor
CHashSetIter<T, HashFn, EqFn, CleanupFn>(TSet *set)
CHashSetIter(TSet *set)
: m_set(set), m_chain_idx(0), m_elem_idx(0)
{
GPOS_ASSERT(nullptr != set);
}

// dtor
virtual ~CHashSetIter<T, HashFn, EqFn, CleanupFn>() = default;
virtual ~CHashSetIter() = default;

// advance iterator to next element
BOOL
Expand Down
2 changes: 1 addition & 1 deletion src/backend/gporca/libgpos/include/gpos/common/CStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CStack
CStack(CStack &) = delete;

// c'tor
CStack<T>(CMemoryPool *mp, ULONG min_size = 4) : m_size(0)
CStack(CMemoryPool *mp, ULONG min_size = 4) : m_size(0)
{
m_dynamic_ptr_array =
GPOS_NEW(mp) CDynamicPtrArray<T, CleanupNULL>(mp, min_size, 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class CSyncHashtable
using DestroyEntryFuncPtr = void (*)(T *);

// ctor
CSyncHashtable<T, K>()
CSyncHashtable()
: m_buckets(nullptr),

m_invalid_key(nullptr)
Expand All @@ -154,7 +154,7 @@ class CSyncHashtable
// dtor
// deallocates hashtable internals, does not destroy
// client objects
~CSyncHashtable<T, K>()
~CSyncHashtable()
{
Cleanup();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ class CSyncHashtableAccessByIter : public CSyncHashtableAccessorBase<T, K>
}

public:
CSyncHashtableAccessByIter<T, K>(const CSyncHashtableAccessByIter<T, K> &) =
delete;
CSyncHashtableAccessByIter(const CSyncHashtableAccessByIter &) = delete;

// ctor
explicit CSyncHashtableAccessByIter<T, K>(CSyncHashtableIter<T, K> &iter)
explicit CSyncHashtableAccessByIter(CSyncHashtableIter<T, K> &iter)
: Base(iter.m_ht, iter.m_bucket_idx), m_iter(iter)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,10 @@ class CSyncHashtableAccessByKey : public CSyncHashtableAccessorBase<T, K>
#endif // GPOS_DEBUG

public:
CSyncHashtableAccessByKey<T, K>(const CSyncHashtableAccessByKey<T, K> &) =
delete;
CSyncHashtableAccessByKey(const CSyncHashtableAccessByKey &) = delete;

// ctor
CSyncHashtableAccessByKey<T, K>(CSyncHashtable<T, K> &ht, const K &key)
CSyncHashtableAccessByKey(CSyncHashtable<T, K> &ht, const K &key)
: Base(ht, ht.GetBucketIndex(key)), m_key(key)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ class CSyncHashtableAccessorBase : public CStackObject

protected:
// ctor - protected to restrict instantiation to children
CSyncHashtableAccessorBase<T, K>(CSyncHashtable<T, K> &ht, ULONG bucket_idx)
CSyncHashtableAccessorBase(CSyncHashtable<T, K> &ht, ULONG bucket_idx)
: m_ht(ht), m_bucket(m_ht.GetBucket(bucket_idx))
{
}

// dtor
virtual ~CSyncHashtableAccessorBase<T, K>() = default;
virtual ~CSyncHashtableAccessorBase() = default;

// accessor to hashtable
CSyncHashtable<T, K> &
Expand Down Expand Up @@ -130,8 +130,7 @@ class CSyncHashtableAccessorBase : public CStackObject
}

public:
CSyncHashtableAccessorBase<T, K>(const CSyncHashtableAccessorBase<T, K> &) =
delete;
CSyncHashtableAccessorBase(const CSyncHashtableAccessorBase &) = delete;

// unlinks element
void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ class CSyncHashtableIter
BOOL m_invalid_elem_inserted;

public:
CSyncHashtableIter<T, K>(const CSyncHashtableIter<T, K> &) = delete;
CSyncHashtableIter(const CSyncHashtableIter &) = delete;

// ctor
explicit CSyncHashtableIter<T, K>(CSyncHashtable<T, K> &ht)
explicit CSyncHashtableIter(CSyncHashtable<T, K> &ht)
: m_ht(ht),
m_bucket_idx(0),
m_invalid_elem(nullptr),
Expand All @@ -133,7 +133,7 @@ class CSyncHashtableIter
}

// dtor
~CSyncHashtableIter<T, K>()
~CSyncHashtableIter()
{
if (m_invalid_elem_inserted)
{
Expand Down
Loading

0 comments on commit 1e70fdc

Please sign in to comment.