Line |
Branch |
Exec |
Source |
1 |
|
|
// |
2 |
|
|
// Copyright (c) 2021 INRIA |
3 |
|
|
// |
4 |
|
|
|
5 |
|
|
#ifndef COAL_SERIALIZATION_MEMORY_H |
6 |
|
|
#define COAL_SERIALIZATION_MEMORY_H |
7 |
|
|
|
8 |
|
|
namespace coal { |
9 |
|
|
|
10 |
|
|
namespace internal { |
11 |
|
|
template <typename T> |
12 |
|
|
struct memory_footprint_evaluator { |
13 |
|
1 |
static size_t run(const T &) { return sizeof(T); } |
14 |
|
|
}; |
15 |
|
|
} // namespace internal |
16 |
|
|
|
17 |
|
|
/// \brief Returns the memory footpring of the input object. |
18 |
|
|
/// For POD objects, this function returns the result of sizeof(T) |
19 |
|
|
/// |
20 |
|
|
/// \param[in] object whose memory footprint needs to be evaluated. |
21 |
|
|
/// |
22 |
|
|
/// \return the memory footprint of the input object. |
23 |
|
|
template <typename T> |
24 |
|
4 |
size_t computeMemoryFootprint(const T &object) { |
25 |
|
4 |
return internal::memory_footprint_evaluator<T>::run(object); |
26 |
|
|
} |
27 |
|
|
|
28 |
|
|
} // namespace coal |
29 |
|
|
|
30 |
|
|
#endif // ifndef COAL_SERIALIZATION_MEMORY_H |
31 |
|
|
|