A Node is a fixed‐size container of as many objects of type T as would fit in a region of memory of size NS. The last NS % sizeof(T) bytes are ignored and uninitialized.

Synopsis

Declared in <folly/Padded.h>

template<
    class T,
    size_t NS>
class Node;

Description

Node only works for trivial types, which is usually not a concern. This is intentional: Node itself is trivial, which means that it can be serialized / deserialized using a simple memcpy.

Type Aliases

Name

Description

value_type

The underlying element type.

Member Functions

Name

Description

data

data overloads

operator==

Compares two nodes for element‐wise equality.

operator!=

Compares two nodes for inequality.

Static Member Functions

Name

Description

nodeCount

Return the number of nodes needed to represent n values. Rounds up.

paddedByteSize

Return the total byte size needed to represent n values, rounded up to the nearest full node.

paddingBytes

Return the number of bytes used for padding n values. Note that, even if n is a multiple of kElementCount, this may return non‐zero if kPaddingBytes != 0, as the padding at the end of the last node is not included in the result.

unpaddedByteSize

Return the minimum byte size needed to represent n values. Does not round up. Even if n is a multiple of kElementCount, this may be different from paddedByteSize() if kPaddingBytes != 0, as the padding at the end of the last node is not included in the result. Note that the calculation below works for n=0 correctly (returns 0).

Static Data Members

Name

Description

kElementCount

The number of elements stored in one node.

kNodeSize

The size of one node in bytes.

kPaddingBytes

The number of trailing padding bytes in one node.

Created with MrDocs