sizeof

suggest change

A unary operator that yields the size in bytes of its operand, which may be either an expression or a type. If the operand is an expression, it is not evaluated. The size is a constant expression of type std::size_t.

If the operand is a type, it must be parenthesized.

If expr is an expression, sizeof(expr) is equivalent to sizeof(T) where T is the type of expr.

int a[100];
std::cout << "The number of bytes in `a` is: " << sizeof a;
memset(a, 0, sizeof a); // zeroes out the array

The sizeof... operator yields the number of elements in a parameter pack.

template <class... T>
void f(T&&...) {
    std::cout << "f was called with " << sizeof...(T) << " arguments\n";
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents