Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2004-09-16 20:30:26

Cromwell Enage writes:
> Once Tropical Storm Jeanne passes away, I should be
> through with hurricanes for a while.
> The latest-and-greatest MPL looks great! The new
> ability to plug in custom numeric metatypes so that
> they work with existing numeric ops makes it a
> definite keeper.
> The part of my sub-library that I've updated to work
> with the new MPL is at
> <>,
> and has been tested with MinGW 3.2 and MSVC 7.1 (2003
> Toolkit).

I'll surely take a look at it once we are done with release.

> Renaming issues aren't too bad; I just have
> to remember (for one thing) that reverse_copy is
> defined at copy.hpp and not reverse_copy.hpp as I
> originally thought.

That's to keep the number of headers manageable.

> I also noticed that
> BOOST_MPL_AUX_TYPEOF is no longer there,

Yep; it was an internal facility in the first place.

> but I've managed to eliminate the need for it.

That's what I'd expect; it shouldn't be needed anymore.

> A major issue I have is how to properly use
> numeric_cast in order to make something like the
> following statement work correctly:
> typedef plus<int_<1>,fraction_c<long,4,3> >::type
> fraction_7_over_3;
> Right now I've made N^2 specializations of plus_impl,
> where N here means the total number of built-in and
> custom numeric metatypes. For my sub-library, N==4,
> which means I've made 16 specializations of plus_impl
> alone!

Hmm, this doesn't sound right. You've seen the complex numbers
test/example referred from the changelog --

Something like this should be enough:

    struct fraction_c_tag : int_<20> {};

    template<> struct numeric_cast< integral_c_tag,fraction_c_tag >
        template< typename N > struct apply
            : fraction_c< typename N::value_type,N::value,1 >

> Factor in the comparison ops as well the
> arithmetic ops, and my code is starting to look
> bloated. I've supplied a couple of convenience macros
> to reduce the copy-and-pasting, but I still think I'm
> missing something crucial here, and I think that
> something is how to use (or specialize) numeric_cast.

Let me know if the above doesn't cover it.

Aleksey Gurtovoy
MetaCommunications Engineering

Boost list run by bdawes at, gregod at, cpdaniel at, john at