15[[nodiscard]]
inline size_t heapBytes(
const std::vector<T> & vec )
17 constexpr bool hasHeapBytes =
requires(
const T& t ) { t.heapBytes(); };
18 if constexpr ( hasHeapBytes )
20 size_t res = vec.capacity() *
sizeof( T );
21 for (
const T & t : vec )
27 return vec.capacity() *
sizeof( T );
31template<
typename T,
typename U>
34 constexpr bool hasHeapBytes =
requires(
const T & t ) { t.heapBytes(); };
35 if constexpr ( hasHeapBytes )
37 size_t res = vec.
size() *
sizeof( T );
38 for (
const T & t : vec )
44 return vec.
size() *
sizeof( T );
50[[nodiscard]]
inline size_t heapBytes(
const std::unique_ptr<T> & ptr )
54 return sizeof( T ) + ptr->heapBytes();
59[[nodiscard]]
inline size_t heapBytes(
const std::shared_ptr<T> & ptr )
63 return sizeof( T ) + ptr->heapBytes();
68[[nodiscard]]
inline size_t heapBytes(
const std::function<T> & )
std::vector<T>-like container that requires specific indexing type,
Definition MRMesh/MRVector.h:20
std::size_t size() const
Definition MRMesh/MRVector.h:42
size_t heapBytes(const std::vector< T > &vec)
returns the amount of memory given vector occupies on heap
Definition MRHeapBytes.h:15
Definition MRCameraOrientationPlugin.h:8