Posts
[C++]C++ Simple Lazy class
template<class T> class Lazy { #pragma region Var private: std::function<T (void)> _func; T _result; bool _bIsValueCreated; #pragma endregion
#pragma region Private Property private: __declspec(property(get=Get_func,put=Set_func)) std::function<T (void)> m_func; #pragma endregion
#pragma region Public Property public: __declspec(property(get=Get_result)) T m_result;
__declspec(property(get=Get_bIsValueCreated,put=Set_bIsValueCreated)) bool m_bIsValueCreated; #pragma endregion
#pragma region Constructor & DeConstructor public: Lazy(std::function<T (void)> func) { Reset(); m_func = func; }
~Lazy(void) { Reset(); } #pragma endregion
#pragma region Property Process Method private: inline std::function<T (void)> Get_func() { return _func; }
read more