[C++-sig] Can boost.python and PyQt be used together?

David Abrahams dave at boost-consulting.com
Mon Dec 9 22:01:50 CET 2002


"Paul F. Kunz" <Paul_Kunz at SLAC.Stanford.EDU> writes:

>>>>>> On Mon, 09 Dec 2002 14:38:45 -0500, David Abrahams <dave at boost-consulting.com> said:
>
>>> class_ <WindowController> ( "WindowController" ) .def (
>>> "newCanvas", ( CanvasWindow * ( WindowController::* ) // function
>>> pointer (void) ) // arguments
>
>> You may remember that I warned you that the previous line could be
>> unsafe...
>
>> Avoid casts if possible, especially C-style casts.
>
>    I have to, there's another method with the same name that takes a
> const std::string & as argument.

You don't have to. You can declare a variable of that type and assign
to that first, or you can use the following function template, soon to
be in Boost:

   template <class U> implicit_cast(U x) { return x; }

as:

   implicit_cast<CanvasWindow * ( WindowController::* )()>(
        &WindowController::newCanvas )

>> How would anyone know? We can't see CanvasWindow.
>
>
> class CanvasWindow : public CanvasWindowBase
> {
> private:
>
> /* members not shown */
>
> public:
>  CanvasWindow ();
>
>   CanvasWindow ( const CanvasWindow & );
>
>   virtual ~CanvasWindow();
>
> /*other members not shown*/
> };

There's nothing obviously amiss here.

-- 
                       David Abrahams
   dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution





More information about the Cplusplus-sig mailing list