Boost logo

Boost :

From: Gabriel Dos Reis (Gabriel.Dos-Reis_at_[hidden])
Date: 2000-07-21 16:50:28


"Paul A. Bristow" <pbristow_at_[hidden]> writes:

| I am posting to boost files a draft of math constants using templates
| for a few sample constants.
|
| There are several things I am uncertain about:
|
| 1 It seems that, as with numeric_limits, integral constants
| are different. Should I follow the inplmentation of
| limits to create two template classes, perhaps with
| inheritance? Or is this
| an unnecessary complication? - users who instantiate
| math_const<int>::pi will just get a link failure,
| which probably serves them right!

I'll suggest not to care -- constraint is in use.

But if you insist, you might want to split math_const members into
small classes of semantically related entities, i.e.

        template<typename T, bool>
        struct problematic_constants {
                static T e();
                static T pi();
        };

        // this is for integer types.
        template<typename T>
        struct problematic_constants<T, true> {};

        tmeplate<typename T>
        struct math_constants
           : problematic_constants<T, std::numeric_limits<T>::is_integer> {
                // ...
        };

so that any use of math_constants<int>::pi is synonymous of invalid
use of an identifier.

-- Gaby


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