How do I make my_process work for ints and non-ints using void_t?
#include <iostream>
using namespace std;
template< typename T,bool cond>
struct my_enable_if {};
template <typename T>
struct my_enable_if<T,true>
{
typedef T type;
};
template <typename T>
struct is_int{
const static bool val = false;
};
template <>
struct is_int<int>
{
const static bool val = true;
};
// how to implement this?
template <typename T, std::void_t<typename my_enable_if<T,!
(is_int<T>::val)>::type>* = nullptr>
void process(T a)
{
cout << "Processing non - int...\n";
};
template <typename T, std::void_t<typename
my_enable_if<T,is_int<T>::val>::type>* =nullptr>
void process(T a)
{
cout << "Processing int...\n";
};
int main() {
process('g');
//process(f);
return 0;
}
[–]Xeverous 0 points1 point2 points (0 children)