xref: /llvm-project/clang-tools-extra/docs/clang-tidy/checks/readability/container-data-pointer.rst (revision 90bbe97036a156156759f1555d760890321d50fc)
1.. title:: clang-tidy - readability-container-data-pointer
2
3readability-container-data-pointer
4==================================
5
6Finds cases where code could use ``data()`` rather than the address of the
7element at index 0 in a container. This pattern is commonly used to materialize
8a pointer to the backing data of a container. ``std::vector`` and
9``std::string`` provide a ``data()`` accessor to retrieve the data pointer which
10should be preferred.
11
12This also ensures that in the case that the container is empty, the data pointer
13access does not perform an errant memory access.
14
15Options
16-------
17
18.. option:: IgnoredContainers
19
20   Semicolon-separated list of containers regexp for which this check won't be
21   enforced. Default is `empty`.
22