How to create map in c++ and be able to search for function and call it?

前端 未结 7 958
予麋鹿
予麋鹿 2021-01-01 15:25

I\'m trying to create a map of string and method in C++, but I don\'t know how to do it. I would like to do something like that (pseudocode):

map

        
7条回答
  •  南笙
    南笙 (楼主)
    2021-01-01 16:05

    See this question. The most convenient notation for method is function where function is either included in boost or in under C++0x.

    In your case, the signature would be like this.

    map map; ...
    
    map["sin"](1.0); 
    

提交回复
热议问题