Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

Commit

Permalink
#256: compatibility with gcc 4.8
Browse files Browse the repository at this point in the history
  • Loading branch information
caronc authored and hugbug committed Aug 5, 2016
1 parent bcc4478 commit 3e62252
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion daemon/main/Scheduler.cpp
Expand Up @@ -40,7 +40,7 @@ void Scheduler::FirstCheck()
Guard guard(m_taskListMutex);

std::sort(m_taskList.begin(), m_taskList.end(),
[](std::unique_ptr<Task>& task1, std::unique_ptr<Task>& task2)
[](const std::unique_ptr<Task>& task1, const std::unique_ptr<Task>& task2)
{
return (task1->m_hours < task2->m_hours) ||
((task1->m_hours == task2->m_hours) && (task1->m_minutes < task2->m_minutes));
Expand Down
15 changes: 15 additions & 0 deletions daemon/main/nzbget.h
Expand Up @@ -340,4 +340,19 @@ typedef unsigned char uchar;
#define SCANF_SYNTAX(strindex)
#endif

// providing "std::make_unique" for GCC 4.8.x (only 4.8.x)
#if __GNUC__ && __cplusplus < 201402L && __cpp_generic_lambdas < 201304
namespace std {
template<class T> struct _Unique_if { typedef unique_ptr<T> _Single_object; };
template<class T> struct _Unique_if<T[]> { typedef unique_ptr<T[]> _Unknown_bound; };
template<class T, class... Args> typename _Unique_if<T>::_Single_object make_unique(Args&&... args) {
return unique_ptr<T>(new T(std::forward<Args>(args)...));
}
template<class T> typename _Unique_if<T>::_Unknown_bound make_unique(size_t n) {
typedef typename remove_extent<T>::type U;
return unique_ptr<T>(new U[n]());
}
}
#endif

#endif /* NZBGET_H */
6 changes: 3 additions & 3 deletions daemon/queue/QueueEditor.cpp
Expand Up @@ -38,7 +38,7 @@ class GroupSorter
GroupSorter(NzbList* nzbList, QueueEditor::ItemList* sortItemList) :
m_nzbList(nzbList), m_sortItemList(sortItemList) {}
bool Execute(const char* sort);
bool operator()(std::unique_ptr<NzbInfo>& refNzbInfo1, std::unique_ptr<NzbInfo>& refNzbInfo2) const;
bool operator()(const std::unique_ptr<NzbInfo>& refNzbInfo1, const std::unique_ptr<NzbInfo>& refNzbInfo2) const;

private:
enum ESortCriteria
Expand Down Expand Up @@ -129,7 +129,7 @@ bool GroupSorter::Execute(const char* sort)
std::sort(m_nzbList->begin(), m_nzbList->end(), *this);

if (origSortOrder == soAuto &&
std::equal(tempList.begin(), tempList.end(), m_nzbList->begin(), m_nzbList->end(),
std::equal(tempList.begin(), tempList.end(), m_nzbList->begin(),
[](NzbInfo* nzbInfo1, std::unique_ptr<NzbInfo>& nzbInfo2)
{
return nzbInfo1 == nzbInfo2.get();
Expand All @@ -142,7 +142,7 @@ bool GroupSorter::Execute(const char* sort)
return true;
}

bool GroupSorter::operator()(std::unique_ptr<NzbInfo>& refNzbInfo1, std::unique_ptr<NzbInfo>& refNzbInfo2) const
bool GroupSorter::operator()(const std::unique_ptr<NzbInfo>& refNzbInfo1, const std::unique_ptr<NzbInfo>& refNzbInfo2) const
{
NzbInfo* nzbInfo1 = refNzbInfo1.get();
NzbInfo* nzbInfo2 = refNzbInfo2.get();
Expand Down

0 comments on commit 3e62252

Please sign in to comment.