Discussion:
problem with bind
(too old to reply)
Leigh Johnston
2010-03-06 11:38:32 UTC
Permalink
The following doesn't compile in VS2008:

#include <functional>

struct foo
{
void operator()() { }
};

int main()
{
foo o;
std::tr1::bind(o)();
}

Has this been fixed in VS2010?

/Leigh
Jeff Flinn
2010-03-08 13:07:34 UTC
Permalink
What's the error message? Do either of the inline changes below help?
Post by Leigh Johnston
#include <functional>
struct foo
{
typedef void result_type;
Post by Leigh Johnston
void operator()() { }
};
int main() {
foo o;
std::tr1::bind(o)();
std::tr1::bind<void>(o)();
Post by Leigh Johnston
}
Has this been fixed in VS2010?
Jeff
Leigh Johnston
2010-03-08 15:19:13 UTC
Permalink
Post by Jeff Flinn
What's the error message? Do either of the inline changes below help?
Post by Leigh Johnston
#include <functional>
struct foo
{
typedef void result_type;
Post by Leigh Johnston
void operator()() { }
};
int main() {
foo o;
std::tr1::bind(o)();
std::tr1::bind<void>(o)();
Post by Leigh Johnston
}
Has this been fixed in VS2010?
Jeff
Doesn't help, the problem is the operator()() is not const and for some
reason VS2008 will only consider the const version and error otherwise:

1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\xxcallobj(7)
: error C3848: expression having type 'const foo' would lose some
const-volatile qualifiers in order to call 'void foo::operator ()(void)'
David Lowndes
2010-03-08 16:30:14 UTC
Permalink
Post by Leigh Johnston
#include <functional>
struct foo
{
void operator()() { }
};
int main()
{
foo o;
std::tr1::bind(o)();
}
Has this been fixed in VS2010?
It's the same with the VC2010 RC compiler.

Dave
Leigh Johnston
2010-03-08 17:20:16 UTC
Permalink
Post by David Lowndes
Post by Leigh Johnston
#include <functional>
struct foo
{
void operator()() { }
};
int main()
{
foo o;
std::tr1::bind(o)();
}
Has this been fixed in VS2010?
It's the same with the VC2010 RC compiler.
Dave
I will raise a defect on MS Connect.

/Leigh
Leigh Johnston
2010-03-08 17:26:47 UTC
Permalink
Post by David Lowndes
Post by Leigh Johnston
#include <functional>
struct foo
{
void operator()() { }
};
int main()
{
foo o;
std::tr1::bind(o)();
}
Has this been fixed in VS2010?
It's the same with the VC2010 RC compiler.
Dave
Raised as
https://connect.microsoft.com/VisualStudio/feedback/details/540098/problem-with-non-const-operator-and-bind#

Please vote.

/Leigh

Loading...