aboutsummaryrefslogtreecommitdiffstats
path: root/common/aloptional.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-07-01 17:25:58 -0700
committerChris Robinson <[email protected]>2019-07-01 17:25:58 -0700
commit6bb0edf0a57bdb95c017db986f76eddbc80857e1 (patch)
treedc2b0677dc338843c585b2499136d16b56e9d1f0 /common/aloptional.h
parent53c13de5ce6467f15cc12c855418ed2589a8508a (diff)
Create and use a make_optional method
Diffstat (limited to 'common/aloptional.h')
-rw-r--r--common/aloptional.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/common/aloptional.h b/common/aloptional.h
index a4b37212..8524a2e2 100644
--- a/common/aloptional.h
+++ b/common/aloptional.h
@@ -139,6 +139,18 @@ private:
};
};
+template<typename T>
+inline optional<typename std::decay<T>::type> make_optional(T&& arg)
+{ return optional<typename std::decay<T>::type>{in_place, std::forward<T>(arg)}; }
+
+template<typename T, typename... Args>
+inline optional<T> make_optional(Args&& ...args)
+{ return optional<T>{in_place, std::forward<Args>(args)...}; }
+
+template<typename T, typename U, typename... Args>
+inline optional<T> make_optional(std::initializer_list<U> il, Args&& ...args)
+{ return optional<T>{in_place, il, std::forward<Args>(args)...}; }
+
#undef REQUIRES
} // namespace al