clang-tidy - readability-container-data-pointer — Extra Clang Tools 18.1.8 documentation

# Extra Clang Tools 18.1.8 documentation

## clang-tidy - readability-container-data-pointer

# readability-container-data-pointer

Finds cases where code could use `data()` rather than the address of the element at index 0 in a container. This pattern is commonly used to materialize a pointer to the backing data of a container. `std::vector` and `std::string` provide a `data()` accessor to retrieve the data pointer which should be preferred.

This also ensures that in the case that the container is empty, the data pointer access does not perform an errant memory access.

## Options

IgnoredContainers

  Semicolon-separated list of containers regexp for which this check won’t be enforced. Default is empty.