Skip to content

Commit f01c0fc

Browse files
committed
Single argument form, specializations
1 parent 3d273eb commit f01c0fc

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,21 @@ nonstd::enable_if_t<some_type_trait<T>::value, void> nonstd_enable_if_t() {}
783783
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
784784
// CHECK-FIXES: {{^}}void nonstd_enable_if_t() requires some_type_trait<T>::value {}{{$}}
785785

786-
// But only if the non-standard enable_if has the same signature as the standard one.
786+
template <>
787+
nonstd::enable_if_t<some_type_trait<int>::value, void> nonstd_enable_if_t<int>() {}
788+
// FIXME - Support non-dependent enable_ifs.
789+
790+
template <typename T>
791+
typename nonstd::enable_if<some_type_trait<T>::value>::type nonstd_enable_if_one_param() {}
792+
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
793+
// CHECK-FIXES: {{^}}void nonstd_enable_if_one_param() requires some_type_trait<T>::value {}{{$}}
794+
795+
template <typename T>
796+
nonstd::enable_if_t<some_type_trait<T>::value> nonstd_enable_if_t_one_param() {}
797+
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
798+
// CHECK-FIXES: {{^}}void nonstd_enable_if_t_one_param() requires some_type_trait<T>::value {}{{$}}
799+
800+
// No fix-its are offered for an enable_if with a different signature from the standard one.
787801
namespace boost {
788802

789803
template <typename Condition, typename T = void>
@@ -799,3 +813,12 @@ typename boost::enable_if<some_type_trait<T>, void>::type boost_enable_if() {}
799813

800814
template <typename T>
801815
boost::enable_if_t<some_type_trait<T>, void> boost_enable_if_t() {}
816+
817+
template <>
818+
boost::enable_if_t<some_type_trait<int>, void> boost_enable_if_t<int>() {}
819+
820+
template <typename T>
821+
typename boost::enable_if<some_type_trait<T>>::type boost_enable_if_one_param() {}
822+
823+
template <typename T>
824+
boost::enable_if_t<some_type_trait<T>> boost_enable_if_t_one_param() {}

0 commit comments

Comments
 (0)