From 34a69f56567090286d195f3ce07beffaa6c13364 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 20 May 2019 12:30:04 +1000 Subject: [PATCH] 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. --- types/description.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/types/description.hpp b/types/description.hpp index 7292332d..874cd1b7 100644 --- a/types/description.hpp +++ b/types/description.hpp @@ -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; + } };