How to get printf style compile-time warnings or errors

后端 未结 5 1682
小蘑菇
小蘑菇 2020-12-14 10:39

I would like to write a routine like printf, not functionally-wise, but rather I\'d like the routine to have the same time compile check characteristics as printf.

F

5条回答
  •  無奈伤痛
    2020-12-14 11:22

    A while back someone posted an mpl::string to the boost groups. I think it may actually have gotten into the library. If that is the case you could implement something like this by providing your template string as a template parameter (an mpl::string) and then using some pretty profound meta-programming skills to parse the formatting bits in it. Then you'd use this information to chose an implementation that has the appropriate argument count and types.

    No, I'm not going to do it for you :P It would be quite difficult. However, I do believe it would be possible.

提交回复
热议问题