Does the unary + operator have any practical use?

前端 未结 9 1778
后悔当初
后悔当初 2020-12-03 16:58

Was the unary + operator only included for symmetry with the unary - operator, or does it find some practical use in C++ code?

Searching h

9条回答
  •  囚心锁ツ
    2020-12-03 17:27

    A bit late, but here's a very twisted use that I stumbled across. Apparently the + operator can be useful (if perhaps not strictly necessary) when designing safeguards around the possibility of encountering empty preprocessor tokens. See this post for a more in-depth discussion.

    It's practical, but by no means pleasant.

提交回复
热议问题