How can I obtain the length of a string at compile time?
C++ constexpr string strlen
Table of contents
Objective
To obtain, at compile time, the length of a compile-time string constant.
☢
Warning
The problem is that the strlen function is not constexpr.
Solution
constexpr len1 = std::string::traits_type::length("Geraldo");
// or
constexpr len2 = std::char_traits<char>::length("Ribeiro");