libzed 1.12.3
A general-purpose library for quick and simple data manipulation.
Loading...
Searching...
No Matches
sizable.hpp
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5#include <type_traits>
6
7namespace z {
8namespace core {
13class sizable {
14public:
20 virtual size_t size() const noexcept = 0;
21};
22
30template <typename T>
31inline typename std::enable_if<std::is_base_of<z::core::sizable, T>::value>::type size(const T &object, size_t &bytes) noexcept {
32 bytes = object.size();
33}
34
40template <typename T>
41inline typename std::enable_if<!std::is_base_of<z::core::sizable, T>::value>::type size(const T &object, size_t &bytes) noexcept {
42 bytes = sizeof(object);
43}
44} // namespace core
45} // namespace z
An interface for getting an object's size.
Definition sizable.hpp:13
virtual size_t size() const noexcept=0
Get the size of the object in memory.
Section containing core functions and classes.
std::enable_if< std::is_base_of< z::core::sizable, T >::value >::type size(const T &object, size_t &bytes) noexcept
Get the size of a sizable object.
Definition sizable.hpp:31