How can I use the compile time constant __LINE__ in a string?

后端 未结 8 2049
旧巷少年郎
旧巷少年郎 2021-01-31 10:41

I can use __LINE__ as a method parameter just fine, but I would like an easy way to use it in a function that uses strings.

For instance say I have this:

8条回答
  •  隐瞒了意图╮
    2021-01-31 11:28

    The usual options for formatting a number into a string apply: Boost lexical_cast, ostringstream, sprintf or snprintf, etc.

    Here is one of my favorite links on the topic: http://www.gotw.ca/publications/mill19.htm

提交回复
热议问题