From 87383d735cb6de4d179e0933e538775db6bda4e5 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Thu, 5 Jan 2017 17:14:07 -0800 Subject: [PATCH] C++14: Decommission my own make_unique. --- firmware/baseband/baseband_thread.cpp | 2 ++ firmware/common/utility.hpp | 42 --------------------------- 2 files changed, 2 insertions(+), 42 deletions(-) diff --git a/firmware/baseband/baseband_thread.cpp b/firmware/baseband/baseband_thread.cpp index 8901f528..7083e9f4 100644 --- a/firmware/baseband/baseband_thread.cpp +++ b/firmware/baseband/baseband_thread.cpp @@ -33,6 +33,8 @@ using namespace lpc43xx; #include "portapack_shared_memory.hpp" +#include "utility.hpp" + #include static baseband::SGPIO baseband_sgpio; diff --git a/firmware/common/utility.hpp b/firmware/common/utility.hpp index c6cfab94..feab67ec 100644 --- a/firmware/common/utility.hpp +++ b/firmware/common/utility.hpp @@ -113,46 +113,4 @@ struct range_t { } }; -namespace std { - -/*! Stephan T Lavavej (STL!) implementation of make_unique, which has been accepted into the C++14 standard. - * It includes handling for arrays. - * Paper here: http://isocpp.org/files/papers/N3656.txt - */ -template struct _Unique_if { - typedef unique_ptr _Single_object; -}; - -//! Specialization for unbound array -template struct _Unique_if { - typedef unique_ptr _Unknown_bound; -}; - -//! Specialization for array of known size -template struct _Unique_if { - typedef void _Known_bound; -}; - -//! Specialization for normal object type -template -typename _Unique_if::_Single_object -make_unique(Args&& ... args) { - return unique_ptr(new T(std::forward(args)...)); -} - -//! Specialization for unknown bound -template -typename _Unique_if::_Unknown_bound -make_unique(size_t n) { - typedef typename remove_extent::type U; - return unique_ptr(new U[n]()); -} - -//! Deleted specialization -template -typename _Unique_if::_Known_bound -make_unique(Args&& ...) = delete; - -} /* namespace std */ - #endif/*__UTILITY_H__*/