Skip to content

Commit

Permalink
support C++17
Browse files Browse the repository at this point in the history
  • Loading branch information
willamowius committed Nov 22, 2023
1 parent cda1d9f commit 8772876
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
12 changes: 11 additions & 1 deletion include/ptlib/pprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,23 @@ class PTimerList : public PObject
PAtomicInteger::IntegerType m_serialNumber;
};

// TODO the use of binary_function needs a patch for C++17
#if (__cplusplus >= 201703L)

This comment has been minimized.

Copy link
@Lastique

Lastique Mar 8, 2024

Contributor

This #if should not be necessary. You can just unconditionally use the C++17 version everywhere.

struct TimerExpiryInfo_compare
{
typedef TimerExpiryInfo first_argument_type;
typedef TimerExpiryInfo second_argument_type;
typedef bool result_type;
bool operator()(const TimerExpiryInfo & _Left, const TimerExpiryInfo & _Right) const
{ return (_Left.m_expireTime < _Right.m_expireTime); }
};
#else
struct TimerExpiryInfo_compare
: public binary_function<TimerExpiryInfo, TimerExpiryInfo, bool>
{
bool operator()(const TimerExpiryInfo & _Left, const TimerExpiryInfo & _Right) const
{ return (_Left.m_expireTime < _Right.m_expireTime); }
};
#endif

typedef std::multiset<TimerExpiryInfo, TimerExpiryInfo_compare> TimerExpiryInfoList;
TimerExpiryInfoList m_expiryList;
Expand Down
6 changes: 5 additions & 1 deletion include/ptlib/psharedptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,13 @@ class PSharedPtr : public PContainer
: PContainer(c)
{ CopyContents(c); }

#if (__cplusplus >= 201703L)
PSharedPtr(std::unique_ptr<element_type> & v)
{ ptr = v.release(); }
#else
PSharedPtr(std::auto_ptr<element_type> & v)
{ ptr = v.release(); }

#endif
PSharedPtr & operator=(const PSharedPtr & c)
{ AssignContents(c); return *this; }

Expand Down
1 change: 0 additions & 1 deletion make/unix.mak
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ ifeq ($(USE_GCC),yes)
# avoid warning from clang
ifeq ($(USE_CLANG),"1")
STDCCFLAGS += -Wno-deprecated-declarations -Wno-unused-result -Wno-unused-variable -Wno-unknown-pragmas -Wno-unused-private-field -Wno-overloaded-virtual
CXX += -std=c++14
else
# avoid warnings from gcc >= 5 / gcc >= 10
ifeq "$(GCCMAJORGTEQ5)" "1"
Expand Down
6 changes: 2 additions & 4 deletions src/ptlib/common/object.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -949,10 +949,8 @@ void PMemoryHeap::SetAllocationBreakpoint(DWORD objectNumber)

#if !defined(P_VXWORKS) && !defined(_WIN32_WCE)

#if (__cplusplus >= 201703L)
// C++17
//_GLIBCXX_NODISCARD void* operator new[](std::size_t nSize) _GLIBCXX_THROW (std::bad_alloc)
void* operator new[](std::size_t nSize) _GLIBCXX_THROW (std::bad_alloc)
#if (__cplusplus >= 201703L) // C++17
void* operator new[](std::size_t nSize, std::align_val_t al) noexcept(false)
#else
#if (__GNUC__ >= 3) || ((__GNUC__ == 2)&&(__GNUC_MINOR__ >= 95)) //2.95.X & 3.X
void * operator new[](size_t nSize) throw ()
Expand Down

0 comments on commit 8772876

Please sign in to comment.