|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2004-05-15 21:07:56
Cromwell Enage <sponage_at_[hidden]> writes:
> Hi, all!
>
> I spent a bit of time reading Pete Isenesee's article,
> "Fast Math Using Template Metaprogramming", which can
> be found in Game Programming Gems, Section 1.2, and it
> inspired me to implement compile-time versions of some
> of the standard math functions. Two of the
> metafunctions even work for complex numbers, using the
> components as input instead of any particular complex
> number class. My work so far can be found here:
>
> <http://groups.yahoo.com/group/boost/files/mpl_math.zip>
>
> Yes, it also provides the math constant PI. Perhaps a
> constants library can be built on top of this one?
>
> I'm holding off on putting this mini-library in the
> Sandbox until the file hierarchy is reasonably stable;
> I'm not even sure if the classes are well-structured
> at this point. For this reason, I'm also holding off
> on writing documentation; I'm hoping the example
> program would be simple enough to understand.
>
> Please send feedback!
Did you compile it? If so, on what compilers?
I can't see how it could possibly work.
#include <boost/config.hpp>
template <typename RealNum>
struct sample_t
{
BOOST_STATIC_CONSTANT(RealNum, base = 5.0);
BOOST_STATIC_CONSTANT(RealNum, power = 1.0);
BOOST_STATIC_CONSTANT(RealNum, angle = 1.234);
};
is an illegal program (try comeau online to see some reasons why).
Also, it's not very mpl-ish. Nothing seems to follow the
metafunction protocol of operating on and returning types.
I hate to be discouraging; it's probably a really interesting idea. I
am only looking as far as some details of the implementation, here.
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk