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
Showing
- include/clang/Basic/DiagnosticSemaKinds.td 5 additions, 0 deletionsinclude/clang/Basic/DiagnosticSemaKinds.td
- include/clang/Basic/PartialDiagnostic.h 9 additions, 0 deletionsinclude/clang/Basic/PartialDiagnostic.h
- include/clang/Sema/TemplateDeduction.h 6 additions, 0 deletionsinclude/clang/Sema/TemplateDeduction.h
- lib/Sema/SemaOverload.cpp 9 additions, 0 deletionslib/Sema/SemaOverload.cpp
- lib/Sema/SemaTemplate.cpp 131 additions, 7 deletionslib/Sema/SemaTemplate.cpp
- test/SemaTemplate/constexpr-instantiate.cpp 1 addition, 1 deletiontest/SemaTemplate/constexpr-instantiate.cpp
- test/SemaTemplate/overload-candidates.cpp 4 additions, 4 deletionstest/SemaTemplate/overload-candidates.cpp
Loading
Please register or sign in to comment