Skip to content

Commit

Permalink
cpp 11
Browse files Browse the repository at this point in the history
  • Loading branch information
sachaarbonel committed Nov 6, 2024
1 parent 3f71fe8 commit 16289f7
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions examples/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,19 @@ namespace {

namespace whisper_server {

template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
// Specialization for arrays with known size
template<typename T>
typename std::enable_if<std::is_array<T>::value && std::extent<T>::value != 0,
std::unique_ptr<T>>::type
make_unique(std::size_t) = delete;

// Specialization for arrays with unknown size
template<typename T>
typename std::enable_if<std::is_array<T>::value && std::extent<T>::value == 0,
std::unique_ptr<T>>::type
make_unique(std::size_t n) {
typedef typename std::remove_extent<T>::type U;
return std::unique_ptr<T>(new U[n]());
}

const int PROCESSING_TIMEOUT_MS = 30000; // Max time for processing audio
Expand Down

0 comments on commit 16289f7

Please sign in to comment.