1.. title:: clang-tidy - bugprone-sizeof-container 2 3bugprone-sizeof-container 4========================= 5 6The check finds usages of ``sizeof`` on expressions of STL container types. Most 7likely the user wanted to use ``.size()`` instead. 8 9All class/struct types declared in namespace ``std::`` having a const ``size()`` 10method are considered containers, with the exception of ``std::bitset`` and 11``std::array``. 12 13Examples: 14 15.. code-block:: c++ 16 17 std::string s; 18 int a = 47 + sizeof(s); // warning: sizeof() doesn't return the size of the container. Did you mean .size()? 19 20 int b = sizeof(std::string); // no warning, probably intended. 21 22 std::string array_of_strings[10]; 23 int c = sizeof(array_of_strings) / sizeof(array_of_strings[0]); // no warning, definitely intended. 24 25 std::array<int, 3> std_array; 26 int d = sizeof(std_array); // no warning, probably intended. 27