From 660776f03a0daffc691f77eb14ccaeaacf1d1ae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 8 Nov 2012 19:28:31 +0100 Subject: [PATCH] GCC 4.4 compatibility: no lambda functions. --- src/Profiler.cpp | 12 +++++++++++- src/Profiler.h | 14 ++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Profiler.cpp b/src/Profiler.cpp index dcede5b73..0afb8779f 100644 --- a/src/Profiler.cpp +++ b/src/Profiler.cpp @@ -101,11 +101,21 @@ void Profiler::printStatistics() { vector totalSorted(sections.size()); iota(totalSorted.begin(), totalSorted.end(), 0); + #ifndef CORRADE_GCC44_COMPATIBILITY sort(totalSorted.begin(), totalSorted.end(), [this](size_t i, size_t j){return totalData[i] > totalData[j];}); + #else + sort(totalSorted.begin(), totalSorted.end(), Compare(this)); + #endif Corrade::Utility::Debug() << "Statistics for last" << measureDuration << "frames:"; for(size_t i = 0; i != sections.size(); ++i) - Corrade::Utility::Debug() << ' ' << sections[totalSorted[i]] << chrono::microseconds(totalData[totalSorted[i]]).count()/frameCount << u8"µs"; + Corrade::Utility::Debug() << ' ' << sections[totalSorted[i]] + << chrono::microseconds(totalData[totalSorted[i]]).count()/frameCount + #ifndef CORRADE_GCC44_COMPATIBILITY + << u8"µs"; + #else + << "µs"; + #endif } } diff --git a/src/Profiler.h b/src/Profiler.h index 3be943bd6..f0a09fb05 100644 --- a/src/Profiler.h +++ b/src/Profiler.h @@ -24,6 +24,7 @@ #include #include +#include "magnumCompatibility.h" #include "magnumVisibility.h" namespace Magnum { @@ -190,6 +191,19 @@ class MAGNUM_EXPORT Profiler { void printStatistics(); private: + #if !defined(DOXYGEN_GENERATING_OUTPUT) && defined(CORRADE_GCC44_COMPATIBILITY) + struct Compare { + public: + inline Compare(const Profiler* p): p(p) {} + inline bool operator()(size_t i, size_t j) const { + return p->totalData[i] > p->totalData[j]; + } + + private: + const Profiler* p; + }; + #endif + void save(); bool enabled;