Greetings qpid-dev,

I work with Anandeep at Microsoft and have started looking at some of
the C++ related Jiras.

The build error in QPID-1424 results from the debug implementation of
lower_bound() in VC++, which is fussy in nature, and insists that the
comp() function meet the exact definition of a "strict weak ordering".
In particular, it requires that the first and second arguments have
the same type while it tries to "helpfully" perform a sanity check.
When not building a debug version, the check is omitted and the code
compiles just fine.

I have attached a patch that avoids the use of std::lower_bound() and
uses a simpler but slower linear search when compiling on Windows in
debug mode.  That seems to be the easiest way to solve the problem
without intrusive code changes after the M4 code freeze.

The patch is attached.  Let me know if it requires reworking in any
way.

Thanks.

Cliff
--- SessionManager.cpp.trunk    2008-07-08 15:58:37.383158000 -0700
+++ SessionManager.cpp.new      2008-11-18 15:41:57.125791738 -0800
@@ -86,9 +86,18 @@ void SessionManager::forget(const Sessio
 void SessionManager::eraseExpired() {
     // Called with lock held.
     if (!detached.empty()) {
+#if (!defined(_WIN32) || !defined(_DEBUG))
         Detached::iterator keep = std::lower_bound(
             detached.begin(), detached.end(), now(),
             boost::bind(std::less<AbsTime>(), 
boost::bind(&SessionState::expiry, _1), _2));
+#else
+        // VC++ _DEBUG version of lower_bound is fussy and requires a "strict 
weak ordering".
+        // Substitute a simplified linear search (only used in debug mode)
+        AbsTime now = AbsTime::now();
+        Detached::iterator keep = detached.begin();
+        while ((keep != detached.end()) && ((*keep).expiry < now))
+            keep++;
+#endif
         if (detached.begin() != keep) {
             QPID_LOG(debug, "Expiring sessions: " << 
log::formatList(detached.begin(), keep));
             detached.erase(detached.begin(), keep);

Reply via email to