How to parse a static const std::string in compilation time?

  • A+
Category:Languages

I have some SQL queries with binds in my C++ code, those queries are static const std::string, because those queries are complex it is very easy to be wrong with some details. I would like to do some very basic checks in compilation time, for example counting the number of commas or : character.

 


You can't. A static const std::string doesn't exist at compile time.

String literals are possible with constexpr functions, but not std::string objects.

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: