One Unified Global Perspective
Communications with a Global Perspective
Home
Intro
Contact Us
Voice over IP
PBX Solutions
Services
Support
Glossary
Open Source
Blog
Forum

WebMail





2008 Mar 17 - Mon

Don't Use Defined Macros, Use Templated Inline Functions Instead

In the olden C days, one would use #define MACRO .... to build an inline macro for computationally quick evaluation of some calculation. When using that method of programming, one needed to remember to parenthesize extensively in order to prevent wierd things from happening when calling the function with an expression.

The modern approach is to use a template for an inline function, which yields all the efficiency of a macro, plus all the predictable behavior and type safety of a regular function (item #2 in the book Effective C++). An example declaration follows:

template<typename T>
  inline void DoWithMax( const T& a, const T& b ) {
    f( a > b ? a : b );
  }



Blog Content ©2012
Ray Burkholder
All Rights Reserved
ray@oneunified.net
(441) 500-7292
Available for Contract Work
Resume

RSS: Click to see the XML version of this web page.

twitter
View Ray 
Burkholder's profile on LinkedIn
technorati
Add to Technorati Favorites



March
Su Mo Tu We Th Fr Sa
           
16
         


Main Links:
Monitoring Server
SSH Tools
QuantDeveloper Code

Special Links:
Frink

Blog Links:
Sergey Solyanik
Marc Andreessen
HotGigs
Micro Persuasion
... Reasonable ...
Chris Donnan
BeyondVC
lifehacker
Trader Mike
Ticker Sense
HeadRush
TraderFeed
Stock Bandit
The Daily WTF
Guy Kawaski
J. Brant Arseneau
Steve Pavlina
Matt Cutts
Kevin Scaldeferri
Joel On Software
Quant Recruiter
Blosxom User Group
Wesner Moise
Julian Dunn
Steve Yegge
Max Dama

2008
Months
Mar




Mason HQ

Disclaimer: This site may include market analysis. All ideas, opinions, and/or forecasts, expressed or implied herein, are for informational purposes only and should not be construed as a recommendation to invest, trade, and/or speculate in the markets. Any investments, trades, and/or speculations made in light of the ideas, opinions, and/or forecasts, expressed or implied herein, are committed at your own risk, financial or otherwise.