summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2015-12-17 17:36:00 +0100
committer Miodrag Milanovic <mmicko@gmail.com>2015-12-17 17:36:00 +0100
commita111c124c7da653fe5a9818a1bbc66ac9b3d33e7 (patch)
treef32a3f6c8780527ea57e1ee3f2ed35288a33961e /src/lib
parentc0740a42c893f791cb494fa39339c8f00a43341d (diff)
added option to clear with value for arrays (nw)
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/util/coretmpl.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/util/coretmpl.h b/src/lib/util/coretmpl.h
index 6b92b528614..3f2cb5e019a 100644
--- a/src/lib/util/coretmpl.h
+++ b/src/lib/util/coretmpl.h
@@ -37,6 +37,16 @@ inline std::unique_ptr<T> make_unique_clear(std::size_t size)
return ptr;
}
+template<typename T,unsigned char F>
+inline std::unique_ptr<T> make_unique_clear(std::size_t size)
+{
+ auto ptr = std::make_unique<T>(size);
+ static_assert(std::is_array<T>::value, "Type must be array");
+ memset(ptr.get(), F, sizeof(std::remove_extent<T>) * size);
+ return ptr;
+}
+
+
template<typename T>
inline std::unique_ptr<T> make_unique_clear()
{