mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-29 03:29:01 +08:00
Add lazy.h
This commit is contained in:
parent
5ba6f1725d
commit
47b53b9015
26
toolsrc/include/lazy.h
Normal file
26
toolsrc/include/lazy.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
namespace vcpkg
|
||||
{
|
||||
template <typename T>
|
||||
class lazy
|
||||
{
|
||||
public:
|
||||
lazy() : value(T()), initialized(false) {}
|
||||
|
||||
template <class F>
|
||||
T const& get_lazy(F& f) const
|
||||
{
|
||||
if (!initialized)
|
||||
{
|
||||
value = f();
|
||||
initialized = true;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable T value;
|
||||
mutable bool initialized;
|
||||
};
|
||||
}
|
@ -137,6 +137,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\BinaryParagraph.h" />
|
||||
<ClInclude Include="..\include\lazy.h" />
|
||||
<ClInclude Include="..\include\PostBuildLint_BuildInfo.h" />
|
||||
<ClInclude Include="..\include\PostBuildLint_BuildPolicies.h" />
|
||||
<ClInclude Include="..\include\coff_file_reader.h" />
|
||||
|
@ -293,5 +293,8 @@
|
||||
<ClInclude Include="..\include\vcpkg_Chrono.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\lazy.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user