]> granicus.if.org Git - clang/commit
Customize the SFINAE diagnostics for enable_if to provide the failed condition.
authorDouglas Gregor <dgregor@apple.com>
Wed, 5 Jul 2017 20:20:14 +0000 (20:20 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 5 Jul 2017 20:20:14 +0000 (20:20 +0000)
commitd93c41c8dca79a6d02dffdaac23003e7d50cd00a
tree19537fc405a9b9eb27815192c3f190f0aadc9ed3
parent29e21c348d85b4a9b1525b876c669b4229e99930
Customize the SFINAE diagnostics for enable_if to provide the failed condition.

When enable_if disables a particular overload resolution candidate,
rummage through the enable_if condition to find the specific condition
that caused the failure. For example, if we have something like:

    template<
      typename Iter,
      typename = std::enable_if_t<Random_access_iterator<Iter> &&
                                  Comparable<Iterator_value_type<Iter>>>>
    void mysort(Iter first, Iter last) {}

and we call "mysort" with "std::list<int>" iterators, we'll get a
diagnostic saying that the "Random_access_iterator<Iter>" requirement
failed. If we call "mysort" with
"std::vector<something_not_comparable>", we'll get a diagnostic saying
that the "Comparable<...>" requirement failed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307196 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Basic/PartialDiagnostic.h
include/clang/Sema/TemplateDeduction.h
lib/Sema/SemaOverload.cpp
lib/Sema/SemaTemplate.cpp
test/SemaTemplate/constexpr-instantiate.cpp
test/SemaTemplate/overload-candidates.cpp