error: no match for call to ‘(std::_Mem_fn<void (CNC::CGUI::*)(float, char)>) (float, char&)’
void CGUI::null(float numP, char dir){}
void CGUI::Function()
{
auto function_X_axis = std::mem_fn(&CGUI::null);
}
void Move_X_axis(float numP, char dir){}
void CGUI::Function2()
{
function_X_axis = std::mem_fn(&CGUI::Move_X_axis);
char sign = 'e';
function_X_axis(1.0f, sign);
}
dir and sign, are both char, not char reference.
Where did the char reference come from?
I am not using templates.
i have searched for different parts of the error, but nothing close.
CodePudding user response:
Probably because the argument could be passed as lvalue reference to char. Passing by value would be as good.
It doesn't really matter as your problem is lack of the CGUI
object:
#include <functional>
struct CGUI
{
void null(float, char);
};
void CGUI::null(float numP, char dir){}
int main()
{
CGUI gui;
auto function_X_axis = std::mem_fn(&CGUI::null);
char sign = 'e';
function_X_axis(gui, 1.0f, sign);
}
Haven't you confused mem_fn
with bind
or lambda of some sort?