Re: [boost] [guidelines] why template errors suck

Hi, how about the below. Concept IntOrPair is empty because you do not require it to have any operations. Keyword "explicit" indicates that we do not want it to be an auto-concept: concept map is always required. The second concept_map implements the recursion. Regards, &rzej explicit concept< typename T > IntOrPair { } concept_map IntOrPair<int> { } template< IntOrPair type1, IntOrPair type2 > concept_map IntOrPair< std::pair<type1, type2> > { } template<IntOrPair First, IntOrPair 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<IntOrPair T> int sum_ints( T const & t ) { return sum_ints_impl( t ); }
participants (1)
-
Andrzej Krzemienski