Created
May 9, 2018 08:40
-
-
Save fortheday/0fc8c10ee8ac543ecc72585163732404 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <functional> | |
class FScopedExecuter | |
{ | |
private: | |
using T_FUNC = std::function<void(void)>; | |
T_FUNC m_Func; | |
public: | |
FScopedExecuter(T_FUNC &&rvFunc) : m_Func(rvFunc) {} | |
~FScopedExecuter() { m_Func(); } | |
}; | |
void Test() | |
{ | |
{ | |
FScopedExecuter executer([]() { LOG("Execute!"); }); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
std::function<>내부에 힙할당이 있으면서 이동생성자를 구현했다면 rvalue를 사용한 것이 의미가 있을 수 있다. 그렇지 않다면 복사생성자가 호출될 것이다.