libzed 1.11.4
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
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
A wrapper for std::vector.
Definition array.hpp:38
size_t size() const noexcept override
Get the size of the array.
Definition array.hpp:1030
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.