I found an interesting conditional function exception that I got from this site , and when testing, I came across this:
#include<type_traits>
namespace detail
{
enum enabler {};
}
template <int overload, typename Condition>
using EnableIf = std::enable_if_t<Condition::value, detail::enabler>;
template <typename T,
EnableIf<0, std::is_same<T, int>>...>
T twice(T t) { return 2 * t; }
template <typename T,
EnableIf<0, std::is_same<T, float>>...>
T twice(T t) { return 2 * t; }
int main()
{
twice(1);
twice(1.f);
return 0;
}
Should this not cause a compiler error, because the type is the EnableIfsame for both functions? I was going to use a different number for each overload and have a template class that would contain an enumler enum, so that would be a different type, but it doesn't seem to be necessary. Is this a defect or am I missing something?
I tested this on VC ++ (2017) and clang .
Although the VC ++ compiler does not complain, he obviously does not like intellisense:

, , , , , , .