lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] patch fixing ::Connect() compilation with MSVC


From: Vadim Zeitlin
Subject: [lmi] patch fixing ::Connect() compilation with MSVC
Date: Sun, 22 Jun 2008 15:55:26 +0200

 Hello again,

 Here is another small patch which I made to fix MSVC compilation but
which, I think, can stand on its own:

--- wx_utility.hpp      2008-06-02 04:00:35 +0000
+++ wx_utility.hpp      2008-06-22 13:45:36 +0000
@@ -81,7 +81,7 @@
 {
     // Double parentheses: don't parse comma as a macro parameter separator.
     BOOST_STATIC_ASSERT((boost::is_same<void,Return>::value));
-    BOOST_STATIC_ASSERT((boost::is_base_and_derived<wxObject,Class>::value));
+    
BOOST_STATIC_ASSERT((boost::is_base_and_derived<wxEvtHandler,Class>::value));
     typedef typename boost::remove_reference<Argument>::type argument_type;
     BOOST_STATIC_ASSERT
         ((
@@ -94,7 +94,8 @@
         throw std::runtime_error("Connect(): null pointer.");
         }

-    object->Connect(id, event, c_cast<wxObjectEventFunction>(handler));
+    object->Connect(id, event, c_cast<wxObjectEventFunction>(
+            static_cast<void (wxEvtHandler::*)(Argument)>(handler)));
 }

 calendar_date ConvertDateFromWx(wxDateTime const&);


The first change is not necessary to fix anything at all, it just tightens
up a check: an event handling class should derive from wxEvtHandler, not
just wxObject.

 The second change is the important one: without the intervening
static_cast MSVC refuses to cast between pointers with an error message
saying that they have different representations (this is correct for the
reasons related to multiple/virtual inheritance discussed previously but
it's irrelevant here, I'll discuss them separately later but the good news
is that we found a way to fix this problem). The static_cast casts from
pointer to derived class member to pointer to base class member and so is
safe and almost useless except that it allows the subsequent c_cast to
work.

 If you agree with this patch but prefer to apply it together with the rest
of the patches necessary for MSVC compilation, I can understand this but I
just thought that this patch wasn't necessarily MSVC-specific. OTOH if you
disagree with it, please let me know.

 Thanks,
VZ





reply via email to

[Prev in Thread] Current Thread [Next in Thread]