FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
C++
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
March 01, 2003

C++ Expression Templates

(Page 15 of 18)
March 2003/C++ Expression Templates

Listing 8: Definition and usage of expression templates

template <class ExprT> struct exprTraits 
{ typedef ExprT expr_type; };

template <> struct exprTraits<double> 
{ typedef Literal expr_type; };

template <> struct exprTraits<int> 
{ typedef Literal expr_type; };

...

double sigma=2.0, mean=5.0;
const double Pi = 3.141593;
cout << integrate(
  1.0/(sqrt(2*Pi)*sigma) * exp(sqr(x-mean)/(-2*sigma*sigma)),
  2.0,10.0,100) << endl;

— End of Listing —
Previous Page | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 Next Page
RELATED ARTICLES
No Related Articles
TOP 5 ARTICLES
No Top Articles.



MICROSITES
FEATURED TOPIC

ADDITIONAL TOPICS

INFO-LINK