Is it safe to change a function pointer (std::function) inside a called function?

前端 未结 2 1606
轻奢々
轻奢々 2021-01-08 01:03

I have a std::function pointing to a function. Inside this function I change the pointer to another function.

std::function fun;

         


        
2条回答
  •  清歌不尽
    2021-01-08 01:41

    It may come back to bite you if you do it without due consideration and in code documentation, but there is no logical reason why it won't work.

    In c++, the address of a function is not needed, either within the function in the return coding.

    If it didn't work in some language the complier probably wouldn't accept it - if it's a half decent compiler.

提交回复
热议问题