2 * Copyright (C) 2006 Apple Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
26 template <typename T> inline T* getPtr(T* p) { return p; }
28 template <typename T> struct IsSmartPtr {
29 static const bool value = false;
32 template <typename T, bool isSmartPtr>
36 struct GetPtrHelper<T, false /* isSmartPtr */> {
38 static T* getPtr(T& p) { return &p; }
42 struct GetPtrHelper<T, true /* isSmartPtr */> {
43 typedef typename T::PtrType PtrType;
44 static PtrType getPtr(const T& p) { return p.get(); }
48 inline typename GetPtrHelper<T, IsSmartPtr<T>::value>::PtrType getPtr(T& p)
50 return GetPtrHelper<T, IsSmartPtr<T>::value>::getPtr(p);
54 inline typename GetPtrHelper<T, IsSmartPtr<T>::value>::PtrType getPtr(const T& p)
56 return GetPtrHelper<T, IsSmartPtr<T>::value>::getPtr(p);
61 #endif // WTF_GetPtr_h