From 6ddfe89fdf597970201a6016ae8c4fb71fb9c8da Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 11 Aug 2016 16:14:28 +0200 Subject: [PATCH] src: remove VS 2013 compatibility hacks We can remove some Visual Studio 2013-specific workarounds now that support for that compiler has officially been dropped. PR-URL: https://github.com/nodejs/node/pull/8067 Refs: https://github.com/nodejs/node/issues/7484 Refs: https://github.com/nodejs/node/pull/8049 Reviewed-By: James M Snell Reviewed-By: Joao Reis --- src/node_internals.h | 21 --------------------- src/util-inl.h | 24 ++++++++++++------------ src/util.h | 16 +++------------- 3 files changed, 15 insertions(+), 46 deletions(-) diff --git a/src/node_internals.h b/src/node_internals.h index 0170798638922e..b6f5f61c9ccb0a 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -106,29 +106,8 @@ void RegisterSignalHandler(int signal, bool reset_handler = false); #endif -#ifdef _WIN32 -// emulate snprintf() on windows, _snprintf() doesn't zero-terminate the buffer -// on overflow... -// VS 2015 added a standard conform snprintf -#if defined( _MSC_VER ) && (_MSC_VER < 1900) -#include -inline static int snprintf(char *buffer, size_t n, const char *format, ...) { - va_list argp; - va_start(argp, format); - int ret = _vscprintf(format, argp); - vsnprintf_s(buffer, n, _TRUNCATE, format, argp); - va_end(argp); - return ret; -} -#endif -#endif - -#if defined(_MSC_VER) && _MSC_VER < 1900 -#define arraysize(a) (sizeof(a) / sizeof(*a)) // Workaround for VS 2013. -#else template constexpr size_t arraysize(const T(&)[N]) { return N; } -#endif #ifndef ROUND_UP # define ROUND_UP(a, b) ((a) % (b) ? ((a) + (b)) - ((a) % (b)) : (a)) diff --git a/src/util-inl.h b/src/util-inl.h index 31411bb47967e4..9357f675021367 100644 --- a/src/util-inl.h +++ b/src/util-inl.h @@ -28,33 +28,33 @@ bool ListNode::IsEmpty() const { return prev_ == this; } -template +template (T::*M)> ListHead::Iterator::Iterator(ListNode* node) : node_(node) {} -template +template (T::*M)> T* ListHead::Iterator::operator*() const { return ContainerOf(M, node_); } -template +template (T::*M)> const typename ListHead::Iterator& ListHead::Iterator::operator++() { node_ = node_->next_; return *this; } -template +template (T::*M)> bool ListHead::Iterator::operator!=(const Iterator& that) const { return node_ != that.node_; } -template +template (T::*M)> ListHead::~ListHead() { while (IsEmpty() == false) head_.next_->Remove(); } -template +template (T::*M)> void ListHead::MoveBack(ListHead* that) { if (IsEmpty()) return; @@ -67,7 +67,7 @@ void ListHead::MoveBack(ListHead* that) { head_.next_ = &head_; } -template +template (T::*M)> void ListHead::PushBack(T* element) { ListNode* that = &(element->*M); head_.prev_->next_ = that; @@ -76,7 +76,7 @@ void ListHead::PushBack(T* element) { head_.prev_ = that; } -template +template (T::*M)> void ListHead::PushFront(T* element) { ListNode* that = &(element->*M); head_.next_->prev_ = that; @@ -85,12 +85,12 @@ void ListHead::PushFront(T* element) { head_.next_ = that; } -template +template (T::*M)> bool ListHead::IsEmpty() const { return head_.IsEmpty(); } -template +template (T::*M)> T* ListHead::PopFront() { if (IsEmpty()) return nullptr; @@ -99,12 +99,12 @@ T* ListHead::PopFront() { return ContainerOf(M, node); } -template +template (T::*M)> typename ListHead::Iterator ListHead::begin() const { return Iterator(head_.next_); } -template +template (T::*M)> typename ListHead::Iterator ListHead::end() const { return Iterator(const_cast*>(&head_)); } diff --git a/src/util.h b/src/util.h index e74980d72f8e63..9460bb96d5f824 100644 --- a/src/util.h +++ b/src/util.h @@ -135,18 +135,8 @@ template using remove_reference = std::remove_reference; template class ListNode; -template -using ListNodeMember = ListNode T::*; - -// VS 2013 doesn't understand dependent templates. -#ifdef _MSC_VER -#define ListNodeMember(T) ListNodeMember -#else -#define ListNodeMember(T) ListNodeMember -#endif - // TAILQ-style intrusive list head. -template +template (T::*M)> class ListHead; template @@ -158,13 +148,13 @@ class ListNode { inline bool IsEmpty() const; private: - template friend class ListHead; + template (U::*M)> friend class ListHead; ListNode* prev_; ListNode* next_; DISALLOW_COPY_AND_ASSIGN(ListNode); }; -template +template (T::*M)> class ListHead { public: class Iterator {