|
Boost : |
From: Beman Dawes (beman_at_[hidden])
Date: 1999-11-23 21:31:37
At 07:08 AM 11/23/99 -0500, John Maddock wrote:
>The paremeter traits idea would indeed be a very useful addition.
I fooled around with it a bit more this evening, and it really does
look worth developing further, IMO.
> ...
>
>I was also playing with this idea and wondered whether a version for
const
>arguments would be useful, using your code as a basis it would look
>something like:
>
> ...
I'm not sure a separate class is needed. If parameter_traits is
specialized for both <T*> and <const T*>, and for <T&> and <const T&>
per your example, is there really a need for a separate class.
I also tried specializing on <T[sz]> and <const T[sz]> like this:
template< typename T, int sz >
struct parameter_traits< const T[sz] >
{
typedef const T * decayed_type;
typedef const T * parameter_type;
static const char * which() { return "const T[sz]
specialization"; }
};
This actually works, at least with GCC 2.95.2! Many other compilers
decay the template argument, which they shouldn't, according to
Dietmar Kuehl.
By the way, Dietmar was the one who taught me how to write the above
specialization - I couldn't have figured it out myself in a million
years.
You can use that specialization so the arguments like "abc" work
correctly.
Beyond parameter_type, what other typedefs should be included? I
change template_type to decayed_type for now, and removed raw_type.
Need to figure out which would be actually useful and which are just
overspecification.
--Beman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk