如何在编译时解析静态const std :: string?

Mau*_*uiz 4 c++ string parsing compilation-time

我的C++代码中有一些带有绑定的SQL查询,这些查询是static const std::string,因为这些查询很复杂,所以很容易出错.我想在编译时做一些非常基本的检查,例如计算逗号或:字符的数量.

Seb*_*edl 5

你不能.A static const std::string在编译时不存在.

字符串文字可以使用constexpr函数,但不能使用std::string对象.