1 /* 2 * Copyright 2017 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkVptr_DEFINED 9 #define SkVptr_DEFINED 10 11 #include <string.h> 12 #include <type_traits> 13 14 // Experimentally, see if we can get at the vptr of objects with one. 15 16 template <typename T> SkVptr(const T & object)17static inline void* SkVptr(const T& object) { 18 static_assert(std::has_virtual_destructor<T>::value, ""); 19 void* vptr; 20 memcpy(&vptr, (const void*)&object, sizeof(vptr)); 21 return vptr; 22 } 23 24 #endif//SkVptr_DEFINED 25