
On Oct 6, 2011, at 11:05 AM, lcaminiti wrote:
Dave Abrahams wrote:
somebody write the description of the algorithm, including the concept requirements. With option 2, we know that == has to be an equivalence relation. The semantics in option 1 are a lot fuzzier.
Good point! I'll try to start :)
template< typename Iter, typename Val > requires InputIterator<Iter>, EqualityComparable<iterator_traits<Iter>::value_type, Val> bool none_of_equal ( Iter first, Iter last, Val const& val ) ; // option 1a
That seems right to me.
template< typename Iter > requires InputIterator<Iter>, EqualityComparable<iterator_traits<Iter>::value_type> bool none_of_equal ( Iter first, Iter last, iterator_traits<Iter>::value_type const& value ) ; // option 2
I think you're missing the requirement is that the value passed in be convertible to "iterator_traits<Iter>::value_type", since that is what will happen at the call site. Given: std::vector<int> v ; none_of_equal ( v.begin (), v.end (), 3.2 ); you need to capture the fact that the floating point number 3.2 has to be convertible to 'int'. [ But maybe that's "external" to the function definition ]
Essentially, I'd think option 1 requires operator== that satisfies has_equal_to<iterator_traits<Iter>::value_type, Val>
Yes.
while option 2 requires operator== that satisfies has_equal_to<iterator_traits<Iter>::value_type>.
Ok - but that's not sufficient. -- Marshall Marshall Clow Idio Software <mailto:mclow.lists@gmail.com> A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait). -- Yu Suzuki