| delorie.com/archives/browse.cgi | search | 
| Date: | Sat, 27 Feb 1999 18:05:14 -0500 | 
| Message-Id: | <199902272305.SAA02761@envy.delorie.com> | 
| X-Authentication-Warning: | envy.delorie.com: dj set sender to dj AT envy DOT delorie DOT com using -f | 
| From: | DJ Delorie <dj AT delorie DOT com> | 
| To: | djgpp AT delorie DOT com | 
| In-reply-to: | <3.0.6.32.19990227021519.0088c6f0@pop.globalserve.net> (message | 
| from Paul Derbyshire on Sat, 27 Feb 1999 02:15:19 -0500) | |
| Subject: | Re: sin, cos ?? | 
| References: | <36d2f284 DOT 0 AT news DOT sbbs DOT se> | 
| <199902231842 DOT NAA15055 AT envy DOT delorie DOT com> | |
| <7b26kt$g5n AT chronicle DOT concentric DOT net> <3 DOT 0 DOT 6 DOT 32 DOT 19990227021519 DOT 0088c6f0 AT pop DOT globalserve DOT net> | |
| Reply-To: | djgpp AT delorie DOT com | 
Too bad this example won't compile if the user is using C.  Replacing
those templates with a simple "double" would have been just as useful,
yet would have worked for both C and C++.
> const long double pi = 3.141592653589793
> 
> template <class F> // 'F' as in 'Floating point'
> inline F deg2rad (F deg) { return deg*pi/180.0; }
> 
> template <class F>
> inline F rad2deg (F rad) { return 180.0*rad/pi; }
> 
> There. Nice and type-safe and free of bogons with arguments that have side
> effects. More readable too, just as inlined and quick, and moreover, if you
> have egcs you can stick these in your own namespace and keep them from
> cluttering the global one.
| webmaster | delorie software privacy | 
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |