mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
Run the `clang-format.bash` script to update all our C and C++ code to a new style defined by `.clang-format`, now with "east const" enforcement. Use `clang-format` version 18. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit. Issue: #26123
43 lines
757 B
C++
43 lines
757 B
C++
#include <cstring>
|
|
|
|
template <size_t N>
|
|
constexpr size_t cmStrLen(char const (& /*str*/)[N])
|
|
{
|
|
return N - 1;
|
|
}
|
|
|
|
namespace ns1 {
|
|
using std::strlen;
|
|
}
|
|
|
|
namespace ns2 {
|
|
std::size_t strlen(char const* str)
|
|
{
|
|
return std::strlen(str);
|
|
}
|
|
}
|
|
|
|
int main()
|
|
{
|
|
// String variable used for calling strlen() on a variable
|
|
auto s0 = "howdy";
|
|
|
|
// Correction needed
|
|
(void)strlen("Hello");
|
|
(void)::strlen("Goodbye");
|
|
(void)std::strlen("Hola");
|
|
(void)ns1::strlen("Bonjour");
|
|
(void)(sizeof("Hallo") - 1);
|
|
(void)(4 + sizeof("Hallo") - 1);
|
|
(void)(sizeof "Hallo" - 1);
|
|
(void)(4 + sizeof "Hallo" - 1);
|
|
|
|
// No correction needed
|
|
(void)ns2::strlen("Salve");
|
|
(void)cmStrLen("Konnichiwa");
|
|
(void)strlen(s0);
|
|
(void)(sizeof("Hallo") - 2);
|
|
|
|
return 0;
|
|
}
|