From 709bcb13623731b191df836ee21c59fca1396698 Mon Sep 17 00:00:00 2001 From: q66 Date: Mon, 27 Apr 2015 20:05:33 +0100 Subject: [PATCH] add octa::make_box --- octa/memory.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/octa/memory.h b/octa/memory.h index fbd3f71..31b011d 100644 --- a/octa/memory.h +++ b/octa/memory.h @@ -431,6 +431,31 @@ namespace octa { T *p_ptr; D p_del; }; + + template struct __OctaBoxIf { + typedef Box __OctaBox; + }; + + template struct __OctaBoxIf { + typedef Box __OctaBoxUnknownSize; + }; + + template struct __OctaBoxIf { + typedef void __OctaBoxKnownSize; + }; + + template + typename __OctaBoxIf::__OctaBox make_box(A &&...args) { + return Box(new T(forward(args)...)); + } + + template + typename __OctaBoxIf::__OctaBoxUnknownSize make_box(size_t n) { + return Box(new RemoveExtent[n]()); + } + + template + typename __OctaBoxIf::__OctaBoxKnownSize make_box(A &&...args) = delete; } #endif \ No newline at end of file