Evaluating strlen at compilation time?

前端 未结 3 2053
面向向阳花
面向向阳花 2020-12-11 04:22

If my code has this constexpr string

constexpr char my_str[] = \"hello\";

the type of my_str contains information

3条回答
  •  暖寄归人
    2020-12-11 05:22

    In C++17 you can use std::char_traits::length, which is constexpr, instead of strlen.

提交回复
热议问题