c++ - Is it possible to generate constant value during compilation? -
I want to identify my classes to identify each type with a unique hash code. But I do not want it to produce a method all the time, like it. int GetHashCode ()
is applied during the runtime. I want to use the constraint already generated and I was hoping that the compiler comes with some computing and set these constants. Can this be done using templates? If you could possibly give me some examples
Update:
Thanks for the comment '' I realized that my question should be: Kiss with minimum runtime cost Is it possible to check type?
I want to check an object against the pointer against class type. Just the classes that apply to my libs, I was thinking about some custom hashing, thus the original question. I had considered using the typeid
, but I am unaware of the runtime price to run it. I have made a assumption because Typid produces a type_info
class Which will consume more than the simple comparison of the unique difference values.
You can do it together.
Comments
Post a Comment