libzed 1.9.9
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:
16 virtual ~sizable() noexcept {}
17
23 virtual size_t size() const noexcept = 0;
24};
25
34inline typename std::enable_if<std::is_base_of<z::core::sizable, T>::value>::type size(const T &object, size_t &bytes) noexcept {
35 bytes = object.size();
36}
37
43template <typename T>
44inline typename std::enable_if<!std::is_base_of<z::core::sizable, T>::value>::type size(const T &object, size_t &bytes) noexcept {
45 bytes = sizeof(object);
46}
47} // namespace core
48} // namespace z
A wrapper for std::vector.
Definition array.hpp:72
size_t size() const noexcept override
Get the size of the array.
Definition array.hpp:1000
An interface for getting an object's size.
Definition sizable.hpp:13
virtual ~sizable() noexcept
Virtual destructor.
Definition sizable.hpp:16
virtual size_t size() const noexcept=0
Get the size of the object in memory.