Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

To be honest, I don't know if there is a way to speed it up. I do know that a lot of C++ programmers would look at this and cringe because macros really aren't used so much in C++ any more, also you're using old style C casts rather than C++

    static_cast<TYPE>(VALUE).

A macro isn't a function, it is replaced by the C/C++ pre-processor prior to the actual compilation of the code.

One of the reasons macros are not common in C++ any more is because they aren't type safe.

There are a couple of other ways to achieve what macros do for you in C++, one is to use template functions, and the other is to inline the function. Template functions accept various types and perform the same function, inline functions replace the function call with the actual generated code in the calling code. You may want to look at this stackoverflowstackoverflow question and this onethis one as well.

Static casts evaluate the cast at compile time to see if the cast can actually be performed, dynamic casts do the type checking at run time. You may want to look at this stackoverflowstackoverflow question.

To be honest, I don't know if there is a way to speed it up. I do know that a lot of C++ programmers would look at this and cringe because macros really aren't used so much in C++ any more, also you're using old style C casts rather than C++

    static_cast<TYPE>(VALUE).

A macro isn't a function, it is replaced by the C/C++ pre-processor prior to the actual compilation of the code.

One of the reasons macros are not common in C++ any more is because they aren't type safe.

There are a couple of other ways to achieve what macros do for you in C++, one is to use template functions, and the other is to inline the function. Template functions accept various types and perform the same function, inline functions replace the function call with the actual generated code in the calling code. You may want to look at this stackoverflow question and this one as well.

Static casts evaluate the cast at compile time to see if the cast can actually be performed, dynamic casts do the type checking at run time. You may want to look at this stackoverflow question.

To be honest, I don't know if there is a way to speed it up. I do know that a lot of C++ programmers would look at this and cringe because macros really aren't used so much in C++ any more, also you're using old style C casts rather than C++

    static_cast<TYPE>(VALUE).

A macro isn't a function, it is replaced by the C/C++ pre-processor prior to the actual compilation of the code.

One of the reasons macros are not common in C++ any more is because they aren't type safe.

There are a couple of other ways to achieve what macros do for you in C++, one is to use template functions, and the other is to inline the function. Template functions accept various types and perform the same function, inline functions replace the function call with the actual generated code in the calling code. You may want to look at this stackoverflow question and this one as well.

Static casts evaluate the cast at compile time to see if the cast can actually be performed, dynamic casts do the type checking at run time. You may want to look at this stackoverflow question.

Source Link
pacmaninbw
  • 24.9k
  • 11
  • 46
  • 109

To be honest, I don't know if there is a way to speed it up. I do know that a lot of C++ programmers would look at this and cringe because macros really aren't used so much in C++ any more, also you're using old style C casts rather than C++

    static_cast<TYPE>(VALUE).

A macro isn't a function, it is replaced by the C/C++ pre-processor prior to the actual compilation of the code.

One of the reasons macros are not common in C++ any more is because they aren't type safe.

There are a couple of other ways to achieve what macros do for you in C++, one is to use template functions, and the other is to inline the function. Template functions accept various types and perform the same function, inline functions replace the function call with the actual generated code in the calling code. You may want to look at this stackoverflow question and this one as well.

Static casts evaluate the cast at compile time to see if the cast can actually be performed, dynamic casts do the type checking at run time. You may want to look at this stackoverflow question.