16[[nodiscard]]
inline size_t heapBytes(
const std::vector<T> & vec )
18 constexpr bool hasHeapBytes =
requires(
const T& t ) { t.heapBytes(); };
19 if constexpr ( hasHeapBytes )
21 size_t res = vec.capacity() *
sizeof( T );
22 for (
const T & t : vec )
28 return vec.capacity() *
sizeof( T );
32template<
typename T,
typename U>
35 constexpr bool hasHeapBytes =
requires(
const T & t ) { t.heapBytes(); };
36 if constexpr ( hasHeapBytes )
38 size_t res = vec.
size() *
sizeof( T );
39 for (
const T & t : vec )
45 return vec.
size() *
sizeof( T );
51[[nodiscard]]
inline size_t heapBytes(
const std::unique_ptr<T> & ptr )
55 return sizeof( T ) + ptr->heapBytes();
60[[nodiscard]]
inline size_t heapBytes(
const std::shared_ptr<T> & ptr )
64 return sizeof( T ) + ptr->heapBytes();
70[[nodiscard]]
inline size_t heapBytes(
const std::function<T> & )
76template<
typename ...Ts>
77[[nodiscard]]
inline size_t heapBytes(
const phmap::flat_hash_map<Ts...>& hashMap )
84 const auto cap = hashMap.capacity();
85 constexpr size_t kWidth = 16;
86 return cap + kWidth + cap *
sizeof(
typename phmap::flat_hash_map<Ts...>::slot_type );
#define MR_REQUIRES_IF_SUPPORTED(...)
Definition MRMacros.h:31
std::vector<T>-like container that requires specific indexing type,
Definition MRMesh/MRVector.h:19
std::size_t size() const
Definition MRMesh/MRVector.h:51
size_t heapBytes(const BitSet &bs)
returns the amount of memory given BitSet occupies on heap
Definition MRMesh/MRBitSet.h:226
Definition MRCameraOrientationPlugin.h:8