Boost logo

Boost Users :

From: MOSS Sebastian (Sebastian.MOSS_at_[hidden])
Date: 2007-11-08 18:20:50


Hi,

 

I'm having trouble with the following design with vs 7.1 and wondering
if anyone could offer a workaround.

 

Particularly it seems that the ".template operator" syntax isn't liked.
(This works on gcc 4.0.3). Removing the 'template' keyword from the bind
arguments gives an error novel.

 

Any ideas would be warmly welcomed!

 

s

 

 

#include <boost/bind.hpp>

#include <boost/function.hpp>

#include <iostream>

 

class tmpl_operator

{

public:

    template <typename T> void operator&( const T& rhs ) const

    {

        // do stuff

        std::cout << rhs;

    }

};

 

template <class T, class bound>

class command

{

public:

    command( T& obj, bound& instance ) : _instance(instance)

    {

        // works with gcc (4.0.3) but not cl (7.1):

        apply = boost::bind(&bound::template operator&<T>,

                            instance,

                            obj);

        // doesn't compile in vs:

        //_instance.template operator&<T>(obj);

 

        // this compiles in vs though:

        // _instance.operator&<T>(obj);

    }

    void execute() { apply(); }

private:

    bound _instance;

    boost::function<void (void)> apply;

};

 

 

int main()

{

    double dbl = 2.71;

    tmpl_operator instance;

 

    command<double,tmpl_operator> test(dbl,instance);

    test.execute();

 

}
 
*******************************
This e-mail contains information for the intended recipient only. It may contain proprietary material or confidential information. If you are not the intended recipient you are not authorised to distribute, copy or use this e-mail or any attachment to it. Murex cannot guarantee that it is virus free and accepts no responsibility for any loss or damage arising from its use. If you have received this e-mail in error please notify immediately the sender and delete the original email received, any attachments and all copies from your system.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net