1226584Sdim//===--- Capacity.h - Generic computation of ADT memory use -----*- C++ -*-===// 2226584Sdim// 3226584Sdim// The LLVM Compiler Infrastructure 4226584Sdim// 5226584Sdim// This file is distributed under the University of Illinois Open Source 6226584Sdim// License. See LICENSE.TXT for details. 7226584Sdim// 8226584Sdim//===----------------------------------------------------------------------===// 9226584Sdim// 10226584Sdim// This file defines the capacity function that computes the amount of 11226584Sdim// memory used by an ADT. 12226584Sdim// 13226584Sdim//===----------------------------------------------------------------------===// 14226584Sdim 15226584Sdim#ifndef LLVM_SUPPORT_CAPACITY_H 16226584Sdim#define LLVM_SUPPORT_CAPACITY_H 17226584Sdim 18234353Sdim#include <cstddef> 19234353Sdim 20226584Sdimnamespace llvm { 21226584Sdim 22226584Sdimtemplate <typename T> 23226584Sdimstatic inline size_t capacity_in_bytes(const T &x) { 24226584Sdim // This default definition of capacity should work for things like std::vector 25226584Sdim // and friends. More specialized versions will work for others. 26226584Sdim return x.capacity() * sizeof(typename T::value_type); 27226584Sdim} 28226584Sdim 29226584Sdim} // end namespace llvm 30226584Sdim 31226584Sdim#endif 32226584Sdim 33