Some langauges contain a construct to express immutable symbols. E.g., in Ruby symbol literals have the form: :symbolName
. Then it is, e.g., possible to use them to efficiently retrieve a value from a map (error_count[:syntax_errors]
) and moreover they can be easily converted into strings (:syntax_error.to_s
). My experience is that this creates very well readable and maintainable code.
Is there something similar available in C++ (I don't want want to use integer constants because I need to declare them and they cannot be easily converted into strings; I don't want to run a script over my source files prior to compilation which does some fancy substitutions)? I am looking for a solution using the C preprocessor or some tricks from meta template programming.