
on Fri Apr 06 2012, Sebastian Redl <sebastian.redl-AT-getdesigned.at> wrote:
Hm. Can you describe this concept more fully, e.g. with a requirements table or ConceptGCC syntax?
concept Set<S, V> { bool contains(const S&, const V&); }
template <typename V> concept_map Set<std::set<V>, V> { bool contains(const std::set<V>& s, const V& v) { return s.find(v) != s.end(); } }
template <typename V> concept_map Set<bool, V> { bool contains(bool b, const V&) { return b; } }
// various others, e.g. unordered_set.
template <typename V, Callable<bool (V)> Fn> concept_map Set<Fn, V> { bool contains(Fn fn, const V& v) { return fn(v); } }
template <EqualityComparable V> if no other concept_map matches concept_map Set<V, V> { bool contains(const V& s, const V& v) { return s == v; } }
Specifically, I've used my is_callable to emulate the Callable concept in the enable_if of the contains() overload for functions, and the disable_if in the fallback version.
Thanks, that's very beautiful code. I summarize as: this sort of introspection is still useful for providing concept mappings. That makes sense, thanks. -- Dave Abrahams BoostPro Computing http://www.boostpro.com