Boost logo

Boost :

Subject: Re: [boost] [guidelines] why template errors suck
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-09-27 21:22:41


On 9/27/2010 6:06 PM, Eric Niebler wrote:
> I think so far I have failed to make my use case sufficiently clear, so
> I'll simplify and try to follow the Process. Take the following simple
> algorithm sum_ints:
> template<class First, class Second>
> int sum_ints_impl( std::pair<First, Second> const& p )
> {
> return sum_ints_impl(p.first) + sum_ints_impl(p.second);
> }
> int sum_ints_impl( int i )
> {
> return i;
> }
> template<class T>
> int sum_ints( T const& t )
> {
> return sum_ints_impl( t );
> }
> <snip>
> Can you show me how you would approach this problem?

The only solution I know is to make sum_ints_impl
a concept itself with concept maps for int and std::pair.
Frankly, I think that moving the metaprogramming into
concepts like this is a terrible idea. The current situation
with template error messages may be bad, but I strongly
suspect that the errors coming from such a concept
metaprogramming system would be far worse, because
of the "silently fail to match" behavior of concepts.

In Christ,
Steven Watanabe

Boost list run by bdawes at, gregod at, cpdaniel at, john at