|
Boost : |
From: Ed Brey (edbrey_at_[hidden])
Date: 2001-10-24 13:24:03
From: "Greg Colvin" <gcolvin_at_[hidden]>
>
> However, I'm still not sure why we need the various namespaces. Why not
> just:
>
> template< typename Tag >
> struct constant {
> constant() {}
> operator float() const; // fully specialized for each Tag
> operator double() const; // fully specialized for each Tag
> };
>
> struct pi_tag {};
> template<> inline constant< pi_tag >::operator float() const {
> return 3.14159265358979323846F;
> }
> template<> inline constant< pi_tag >::operator double() const {
> return 3.141592653589793238462643383279502884197;
> }
It would certainly be nice to find a better alternative to the namespaces. I like the thought behind the overloading suggestion. However, it can lead to too much ambiguity, e.g.:
double floor(double);
float floor(float);
double three = floor(pi);
double two_pi_from_int = pi * 2;
double two_pi_from_double = pi * 2.0;
According to my compiler, all three statements result in ambiguity.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk