diff --git a/src/node_internals.h b/src/node_internals.h index e908da37b1f565..7304d625b8dfe6 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 a167a57c5ab67d..a72094724ecd05 100644 --- a/src/util-inl.h +++ b/src/util-inl.h @@ -28,33 +28,33 @@ bool ListNode::IsEmpty() const { return prev_ == this; } -template +template M> ListHead::Iterator::Iterator(ListNode* node) : node_(node) {} -template +template M> T* ListHead::Iterator::operator*() const { return ContainerOf(M, node_); } -template +template M> const typename ListHead::Iterator& ListHead::Iterator::operator++() { node_ = node_->next_; return *this; } -template +template M> bool ListHead::Iterator::operator!=(const Iterator& that) const { return node_ != that.node_; } -template +template M> ListHead::~ListHead() { while (IsEmpty() == false) head_.next_->Remove(); } -template +template M> void ListHead::MoveBack(ListHead* that) { if (IsEmpty()) return; @@ -67,7 +67,7 @@ void ListHead::MoveBack(ListHead* that) { head_.next_ = &head_; } -template +template 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 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 M> bool ListHead::IsEmpty() const { return head_.IsEmpty(); } -template +template M> T* ListHead::PopFront() { if (IsEmpty()) return nullptr; @@ -99,12 +99,12 @@ T* ListHead::PopFront() { return ContainerOf(M, node); } -template +template M> typename ListHead::Iterator ListHead::begin() const { return Iterator(head_.next_); } -template +template M> typename ListHead::Iterator ListHead::end() const { return Iterator(const_cast*>(&head_)); } diff --git a/src/util.h b/src/util.h index 08fb01e5ac89cf..004ed7fe019c03 100644 --- a/src/util.h +++ b/src/util.h @@ -127,15 +127,8 @@ 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 M> class ListHead; template @@ -147,13 +140,13 @@ class ListNode { inline bool IsEmpty() const; private: - template friend class ListHead; + template M> friend class ListHead; ListNode* prev_; ListNode* next_; DISALLOW_COPY_AND_ASSIGN(ListNode); }; -template +template M> class ListHead { public: class Iterator {