In my code I’ve been rewriting static_cast<int *> about a million times, is there a way to redefine a keyword so that whenever I call this it does the same thing?
example
cast would do the same thing as static_cast<int *>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
static_casthas the benefit that C++ programmers will recognize exactly what it is without needing to go find your#defineor other statement. I would highly recommend you continue to usestatic_cast.However, my assumption is that your problem is the number of keystrokes required, and so the best solution would be to use a text editor which supports macros. This way, the code that ends up saved does use the standard
static_cast<T>(x)syntax, but you may only need to type something such as [sc]tabTtabxtab.Information on how to do such will be found in documentation of such editors. I’m not a big fan of highly-customizable editors, so specifics are beyond my knowledge.