diff --git a/Source/Core/Common/Common.vcxproj b/Source/Core/Common/Common.vcxproj
index 4c8d2f1b61..4ec7689777 100644
--- a/Source/Core/Common/Common.vcxproj
+++ b/Source/Core/Common/Common.vcxproj
@@ -125,6 +125,7 @@
+
diff --git a/Source/Core/Common/Common.vcxproj.filters b/Source/Core/Common/Common.vcxproj.filters
index 10aa2c9d36..ffbed04915 100644
--- a/Source/Core/Common/Common.vcxproj.filters
+++ b/Source/Core/Common/Common.vcxproj.filters
@@ -253,6 +253,7 @@
GL\GLExtensions
+
diff --git a/Source/Core/Common/Lazy.h b/Source/Core/Common/Lazy.h
new file mode 100644
index 0000000000..322d4bfeac
--- /dev/null
+++ b/Source/Core/Common/Lazy.h
@@ -0,0 +1,38 @@
+// Copyright 2017 Dolphin Emulator Project
+// Licensed under GPLv2+
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include
+#include
+#include
+
+namespace Common
+{
+// A Lazy object holds a value. If a Lazy object is constructed using
+// a function as an argument, that function will be called to compute
+// the value the first time any code tries to access the value.
+
+template
+class Lazy
+{
+public:
+ Lazy() : m_value(T()) {}
+ Lazy(const std::variant>& value) : m_value(value) {}
+ Lazy(std::variant>&& value) : m_value(std::move(value)) {}
+ const T& operator*() const { return *ComputeValue(); }
+ const T* operator->() const { return ComputeValue(); }
+ T& operator*() { return *ComputeValue(); }
+ T* operator->() { return ComputeValue(); }
+private:
+ T* ComputeValue() const
+ {
+ if (!std::holds_alternative(m_value))
+ m_value = std::get>(m_value)();
+ return &std::get(m_value);
+ }
+
+ mutable std::variant> m_value;
+};
+}