Boost logo

Boost :

From: Matthias Schabel (boost_at_[hidden])
Date: 2007-02-09 12:21:55


> If exponents of 4 are the highest you've seen, shouldn't you
> consider the size of (2*3*5*7*11*13*17)^4, which requires 76 bits?
> Also, I may want to extend the list - some people have requested a
> "money" unit, for example, which would be assigned the value 19 in
> your system. Then I can't even represent all powers of 3. I suspect
> this idea, while clever, does not cover the problem domain
> sufficiently well to be superior to lists.

I agree that this is a clever idea; I imagine that implementing it
would not be too difficult, just to see how much it speeds
compilation relative to the optimized list-based code that Steven put
together. Essentially, as James points out above, we would be trading
generality for performance. I would certainly happy to test out a
replacement for dimension.hpp based on this approach. One concern I
have is how to ensure that each fundamental unit has a unique prime
number associated with it. I guess the current system has the same
problem, though counting integers is clearly easier than counting
primes. That actually raises a question I had a while ago:

Is there some method to count specializations of a template class?
That is, if I have

template<long N> struct ordinal { typedef typename
boost::mpl::int_<N> value; };

I want to be able to do something like this (warning not C++):

struct tag1 : public next_ordinal::type { };
struct tag2 : public next_ordinal::type { };
struct tag3 : public next_ordinal::type { };

etc... where next_ordinal::type resolves to ordinal<1>, ordinal<2>,
and ordinal<3> on sequential calls. Anyone have any ideas? This would
simplify and make safer the process of defining user-defined unit
systems.

Matthias

----------------------------------------------------------------
Matthias Schabel, Ph.D.
Assistant Professor, Department of Radiology
Utah Center for Advanced Imaging Research
729 Arapeen Drive
Salt Lake City, UT 84108
801-587-9413 (work)
801-585-3592 (fax)
801-706-5760 (cell)
801-484-0811 (home)
matthias dot schabel at hsc dot utah dot edu
----------------------------------------------------------------


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk