Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2000-09-20 10:48:51


on 9/16/00 1:47 AM, Daryle Walker at darylew_at_[hidden] wrote:

> Should we have a #define for template templates support in boost/config.hpp?
> This could give some flexibility for people who may want to use template
> templates as the best solution, but give alternate solutions if needed. (I
> was think of template templates for getting the standard algorithms to work
> with the range stuff.)

Yikes! I think I should have been more specific in my inspiration for this
request. The stuff the others are talking about, ways to use partial
specialization for template classes as a substitute, is unrelated to my
problem. My concern is for function templates, where the new template has a
different signature than the old one. It relates to the range-stuff being
worked on: I want to make versions of the standard algorithms that work with
the range class instead of separately-entered beginning and ending iterator
arguments. For example:

//==========================================================================
// NOT compiled

template< template<typename T, typename U> U (*F)(T, T, U) >
U
range_apply ( range<T> r, U op )
{
    return F<T,U>(r.begin(), r.end(), op);
}

//...

int main()
{
    //...
    range_apply<std::for_each>( range<int>(5, 7), std::negate<int>() );
    //...
}
//==========================================================================

This would require template templates, and so needs a Boost configuration
#define since not all compilers support it. (It can be provided for other
headers that need template templates, of course.)

-- 

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