kripken/emscripten — Issue #269: compile errors with std::mem_fn
Author: Futumsh
Created: 2012-02-23 07:21:54+00:00
State: open

The following (a.cpp):

#include
#include
#include

struct Foo
{
int m_a;
explicit Foo(int a) : m_a(a) {}
void bar() const { std::cout << m_a << std::endl; }
};

int main(int, char **)
{
std::shared_ptr foo(new Foo(42));
std::mem_fn(&Foo::bar)(foo);
return 0;
}

compiling with:
em++ a.cpp

generates the following errors:

emscripten/system/include/libcxx/__functional_base_03:619:12: error: call to pointer to member function of type
'void ()' drops 'const' qualifier
return ((*__t1).*__f)();
^
emscripten/system/include/libcxx/__functional_03:42:22: note: in instantiation of function template specialization
'std::__1::__invoke >' requested here
return __invoke(__f_, __a0);
^
a.cpp:16:24: note: in instantiation of function template specialization 'std::__1::__mem_fn::operator() >' requested here
std::mem_fn(&Foo::bar)(foo);
^
3 errors generated.