Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
N : Integer := (T'Size + 7) / 8;
n = sizeof (t);
template <typename T>
auto f(T x) { return sizeof x; }
int n;
unsafe
{
n = sizeof(T);
}
int n = sizeof(T);
auto n = T.sizeof;
<T> int bytes(T x) {
return switch (x) {
case Boolean b1 -> 1;
case Byte b2 -> Byte.BYTES;
case Short s -> Short.BYTES;
case Character c -> Character.BYTES;
case Integer i -> Integer.BYTES;
case Float f -> Float.BYTES;
case Long l -> Long.BYTES;
case Double d -> Double.BYTES;
case String s -> s.getBytes().length;
default -> -1;
};
}
int n = bytes(t);
n := SizeOf(T);
use Devel::Size qw(total_size);
my $n = total_size $t;
n = getsizeof(t)
let n = std::mem::size_of::<T>();