diff --git a/src/node_internals.h b/src/node_internals.h index de5d3a798e1019..8af4adb053a4f7 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -99,29 +99,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 e035143dea0130..eb99bb74e5d0de 100644 --- a/src/util.h +++ b/src/util.h @@ -122,18 +122,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 @@ -145,13 +135,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 {