types/description: rename the size query for description to 'bytes'

This tends to cause less confusion for consumers about the exact meaning
of 'size'. It gets confused with arity quite often.
This commit is contained in:
Danny Robson 2019-05-20 12:30:04 +10:00
parent 7805153e17
commit 34a69f5656

View File

@ -73,6 +73,10 @@ namespace cruft::types {
/// A description of the type that makes up a scalar or vector type.
///
/// A vector3f would be { REAL, sizeof(float), 3 };
///
/// DO NOT add a 'size' member function as it tends to be used in a way
/// that confuses total byte size, element byte size, and arity.
/// Instead: use the bytes member function, or the arity member variable.
struct description {
/// The signed, realness, or voidness of the type.
enum category category;
@ -86,7 +90,11 @@ namespace cruft::types {
std::size_t alignment;
/// Returns the number of bytes required to store this type.
constexpr std::size_t size (void) const noexcept { return width * arity; }
constexpr std::size_t
bytes (void) const noexcept
{
return width * arity;
}
};