Passing operator as a parameter

后端 未结 4 1549
我在风中等你
我在风中等你 2021-02-05 03:25

I want to have a function that evaluates 2 bool vars (like a truth table)

for example:

since

T | F : T

then

myfunc(\'t\', \'f         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-05 03:33

    Declare:

    template bool myfunc(char lv, char rv, Func func);
    

    Or if you need to link it separately:

    bool myfunc(char lv, char rv, std::function func);
    

    Then you can call:

    myfunc('t', 'f', std::logical_or());
    

提交回复
热议问题