Boost logo

Boost :

From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2002-12-31 23:39:22


----- Original Message -----
From: "David Abrahams" <dave_at_[hidden]>

> Yeah. I have no problem with access protection where it prevents
> unintentional misuse and improves overall code clarity. However, this
> seems like it doesn't fit that bill.

Oh, it does IMHO. Once it is defined it can be reused in all such contexts.
However, whether it actually matters enough is another question altogether.
Anyway, my main point is that you can prohibit overriding of a default
template argument by preceding it with another default parameter that cannot
be specified because the type itself is inaccessible everywhere but inside
the template itself. Consider it another tool to throw in the toolbox.
Here was my problem with this:

template<class T, class U> struct is_same {
    enum { value = false };
};

template<class T> struct is_same<T, T> {
    enum { value = true };
};

template<class T> struct function_type;
template<class R, class P1, class P2> struct function_type<R (P1, P2)> {
    typedef R type(P1, P2);
};

template<class T> struct identity {
    typedef T type;
};

int main() {
    typedef identity< int (int, int) throw(int) >::type ft;
    std::cout << is_same<ft, function_type<ft>::type>::value << &std::endl;
    return 0;
}

! I.e. the function type is un-reconstitutable without the original type
because it loses the exception specification:

template<class T, class U = T> struct function_type;

template<class R, class P1, class P2, class T>
struct function_type<R (P1, P2), T> {
    typedef T type;
};

I guess that's what happens when you descend into the ethertype dimension of
exception specifications.

Paul Mensonides


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