What's the best way to force the user of a C++ function to acknowledge the semantic meaning of parameters that are numerical constants?

后端 未结 7 2112
故里飘歌
故里飘歌 2021-02-13 15:27

I\'d like to write function interfaces that force the user to acknowledge the semantic meaning of built-in constants. For example, I\'d like to take

void rotate(         


        
7条回答
  •  一个人的身影
    2021-02-13 15:36

    With the simplest versions (a typedef, a class with one member attribute and inlined accessors) the compiler can make it just as fast the plain float version.

    Also consider using some metaprogramming library like boost.units.

提交回复
热议问题