From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/WTF/wtf/GetPtr.h | 59 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 5 deletions(-) (limited to 'Source/WTF/wtf/GetPtr.h') diff --git a/Source/WTF/wtf/GetPtr.h b/Source/WTF/wtf/GetPtr.h index 25a0e6d9b..78107cbe5 100644 --- a/Source/WTF/wtf/GetPtr.h +++ b/Source/WTF/wtf/GetPtr.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006 Apple Computer, Inc. + * Copyright (C) 2006 Apple Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -21,12 +21,61 @@ #ifndef WTF_GetPtr_h #define WTF_GetPtr_h +#include + namespace WTF { - template inline T* getPtr(T* p) - { - return p; - } +enum HashTableDeletedValueType { HashTableDeletedValue }; +enum HashTableEmptyValueType { HashTableEmptyValue }; + +template inline T* getPtr(T* p) { return p; } + +template struct IsSmartPtr { + static const bool value = false; +}; + +template +struct GetPtrHelperBase; + +template +struct GetPtrHelperBase { + typedef T* PtrType; + static T* getPtr(T& p) { return std::addressof(p); } +}; + +template +struct GetPtrHelperBase { + typedef typename T::PtrType PtrType; + static PtrType getPtr(const T& p) { return p.get(); } +}; + +template +struct GetPtrHelper : GetPtrHelperBase::value> { +}; + +template +inline typename GetPtrHelper::PtrType getPtr(T& p) +{ + return GetPtrHelper::getPtr(p); +} + +template +inline typename GetPtrHelper::PtrType getPtr(const T& p) +{ + return GetPtrHelper::getPtr(p); +} + +// Explicit specialization for C++ standard library types. + +template struct IsSmartPtr> { + static const bool value = true; +}; + +template +struct GetPtrHelper> { + typedef T* PtrType; + static T* getPtr(const std::unique_ptr& p) { return p.get(); } +}; } // namespace WTF -- cgit v1.2.1