From 16289f7313db42bce3f538efc6b29320e1f8f63d Mon Sep 17 00:00:00 2001 From: Sacha Arbonel Date: Wed, 6 Nov 2024 15:11:17 +0100 Subject: [PATCH] cpp 11 --- examples/server/server.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/examples/server/server.cpp b/examples/server/server.cpp index ac2ad5e6e80..22c17b0708f 100644 --- a/examples/server/server.cpp +++ b/examples/server/server.cpp @@ -54,9 +54,19 @@ namespace { namespace whisper_server { - template - std::unique_ptr make_unique(Args&&... args) { - return std::unique_ptr(new T(std::forward(args)...)); + // Specialization for arrays with known size + template + typename std::enable_if::value && std::extent::value != 0, + std::unique_ptr>::type + make_unique(std::size_t) = delete; + + // Specialization for arrays with unknown size + template + typename std::enable_if::value && std::extent::value == 0, + std::unique_ptr>::type + make_unique(std::size_t n) { + typedef typename std::remove_extent::type U; + return std::unique_ptr(new U[n]()); } const int PROCESSING_TIMEOUT_MS = 30000; // Max time for processing audio