
14 Sep
2004
14 Sep
'04
1:12 p.m.
Terje Slettebø <tslettebo@broadpark.no> writes:
However, the invention of enable_if [HJW03] [JWL03] (now part of Boost) opened the door to overloading based on arbitrary properties of types. Now, what we needed was techniques for detecting type properties, which could be used to create "concept type traits". Using this, we could have done, e.g. for std::sort:
template<class Iterator> typename enable_if<is_random_access_iterator<Iterator> >::type sort(Iterator begin, Iterator end) { // ... }
I should have pointed to this example more specifically in my previous message. If you had a sort overload for bidirectional iterators using this technique, you'd have an ambiguity. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com