I get an error regarding Call of nonfunction on line 526 in Functor.h (loki-0.1.4\loki-0.1.4\include\noncc\Borland)
anyone who know why? Or someone who knows a proper way to implement functors to const member functions.
And to clearify, it works if the get function isn't overloaded but neither by using initialization or by static_cast. (i looked at the examples in the book about overloading)
/t
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I get an error regarding Call of nonfunction on line 526 in Functor.h (loki-0.1.4\loki-0.1.4\include\noncc\Borland)
anyone who know why? Or someone who knows a proper way to implement functors to const member functions.
struct SomeClass
{
std::string value;
void set(std::string const & p)
{
value = p;
}
std::string get() const
{
return value;
}
std::string get()
{
return value;
}
};
void TestFunction(int, double)
{
int i = 4;
}
void TestFunction(int)
{
int i = 5;
}
typedef std::string (SomeClass::* const_getter)() const;
typedef void (*ptTestFunction)(int);
typedef Loki::Functor<void, TYPELIST_1(std::string const &)> setter;
typedef Loki::Functor<std::string> getter;
#pragma argsused
int main(int argc, char* argv[])
{
SomeClass * object = new SomeClass();
SomeClass const * cobject = new SomeClass();
const_getter tmp = &SomeClass::get;
setter f1(&(*object), &SomeClass::set);
std::string test = "HelloWorld";
ptTestFunction t = &TestFunction;
Loki::Functor<void, TYPELIST_1(int)> get (t);
Loki::Functor<std::string> t2(tmp);
f1(test);
return 0;
}
/t
And to clearify, it works if the get function isn't overloaded but neither by using initialization or by static_cast. (i looked at the examples in the book about overloading)
/t
To construct a Functor with a member function you also need a object on which the member function could be called:
Loki::Functor<std::string> t2(object, tmp);
Thanks, I thought I had tried that. But evidently not.
/t