473,326 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

C++ Template Metaprogramming


Readers of this newsgroup might like to know that Aleksey Gurtovoy and
I have written a book titled _C++ Template Metaprogramming: Concepts,
Tools and Techniques from Boost and Beyond_. The book has recently
entered copyediting, and will be published by Addison Wesley in this
Fall. If you're interested you can peruse some sample chapters at
http://boost-consulting.com/mplbook.

--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
Jul 22 '05 #1
3 1668
David Abrahams (da**@boost-consulting.com) wrote:

: Readers of this newsgroup might like to know that Aleksey Gurtovoy and
: I have written a book titled _C++ Template Metaprogramming: Concepts,
: Tools and Techniques from Boost and Beyond_. The book has recently
: entered copyediting, and will be published by Addison Wesley in this
: Fall. If you're interested you can peruse some sample chapters at
: http://boost-consulting.com/mplbook.

A bit tangential, but I skimmed one of your chapters (I'll read it
properly when I buy the book) and noticed you had an example using
templates to model physical quantities with dimensions. I read a
recent(-ish) article on doing the same thing in CUJ, which raised
a question which wasn't answered there, nor I think in your chapter.
Having not raised it with the CUJ author, I'll raise it here instead.

Basically whilst most mathematical functions (sin for example) are
straightforward, they only apply to dimensionless quantities, and
a few (abs for example) could be applied to any quantity, what about
sqrt? This is meaningful for any quantity with all even dimensions
with return type of those dimensions halved. And there are plenty
of physics formulae of this type. Can sqrt be made to work easily
and properly with compile time failure as should happen?
(Having got sqrt to work, it might be worth adding a cube root as
there are some cases of it - Kepler's third law for one, with
proper factor from Newton. Fourth root occurs, but repeated sqrt
will do that. Anyone ever seen a fifth root?)

Jul 22 '05 #2
Chris Dearlove wrote:
Basically whilst most mathematical functions (sin for example)
are straightforward, they only apply to dimensionless
quantities, and a few (abs for example) could be applied to any
quantity, what about sqrt? This is meaningful for any quantity
with all even dimensions with return type of those dimensions
halved. And there are plenty of physics formulae of this type.
Can sqrt be made to work easily and properly with compile time
failure as should happen?


Should it? What about measuring power in volts/sqrt(hertz)?
The issue might get rather hairy in the general case.
Martin

--
Quidquid latine dictum sit, altum viditur.
Jul 22 '05 #3
In message <10***************@ostenberg.wh.uni-dortmund.de>, Martin
Eisenberg <ma*****************@PAMudo.edu> writes
Chris Dearlove wrote:
Basically whilst most mathematical functions (sin for example)
are straightforward, they only apply to dimensionless
quantities, and a few (abs for example) could be applied to any
quantity, what about sqrt? This is meaningful for any quantity
with all even dimensions with return type of those dimensions
halved. And there are plenty of physics formulae of this type.
Can sqrt be made to work easily and properly with compile time
failure as should happen?
Should it? What about measuring power in volts/sqrt(hertz)?


Speaking as a physicist, yuk. That must be something engineers do. Power
spectral density in volts^2/Hz is just about permissible, with
appropriate assumptions about the impedance.
The issue might get rather hairy in the general case.


True. What do we mean by the principal value of a symbolic square root?

--
Richard Herring
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dave | last post by:
For those who might be so inclined, I was wondering if I might get honest critiques of my first real venture into template metaprogramming. This template metaprogram sorts a list of integers at...
12
by: Dave | last post by:
Would people agree with the statement that to a large degree, using template metaprogramming techniques turns a C++ compiler into a C++ interpreter (but just for the metaprogrammed portions of the...
5
by: Mohammad | last post by:
Hi, Is it possible to disable a method of a template class depending on the typename at compile time? thanks!
21
by: Protoman | last post by:
I've been looking at template metaprogramming. It seems really cool, make the compiler do most of the work. I have very simple program that uses TMP,it calculates the square of a number, but it...
5
by: Mark Stijnman | last post by:
I am trying to teach myself template metaprogramming and I have been trying to create lists of related types. I am however stuck when I want to make a template that gives me the last type in a...
7
by: Joe | last post by:
Hi, I found a concept named template metaprogramming that can be used in C+ + code at compile-time. I am a beginner at C++. But I am a programmer on the .NET platform. Do you know if template...
1
by: Ted | last post by:
I have cross posted this to comp.lang.c++ and to sci.math.num- analysis in the belief that the topic is of interest to some in both groups. I am building my toolkit, in support of my efforts in...
5
by: iapx86 | last post by:
My parser project calls for a computed goto (see code below). The C preprocessor delivers the desired result, but is ugly. Template metaprogramming delivers results I do not understand. Can...
3
by: stdlib99 | last post by:
Hi, I have a simple question regarding templates and meta programming. I am going to try and work my way through the C++ Template Metaprogramming, a book by David Abrahams and Aleksey...
12
by: nooneinparticular314159 | last post by:
Hello. If I declare the following: template<int a, int b, int SomeArray> class DoSomething{ public: .. .. ..
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.