This language bar is your friend. Select your favorite languages!

Idiom #109 Number of bytes of a type

Set n to the number of bytes of a variable t (of type T).

let n = ::std::mem::size_of::<T>();
N : Integer := (T'Size + 7) / 8;
n = sizeof (t);
auto n = T.sizeof;
1
import "reflect"
var t T
tType := reflect.TypeOf(t)
n := tType.Size()
n := SizeOf(T);
import pympler.asizeof
n = pympler.asizeof.asizeof(t)

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

programming-idioms.org