I am trying to practice on void_t usage but following code gives this compilation error.
is_fun is typedef in CompS struct so I think Comps::is_fun should be valid.
Is there anything I missed here?
template <typename T, typename Comp, typename = void_t<>>
class my_set
{
public:
my_set() : mem(5){}
T mem;
};
template <typename T, typename Comp, void_t<typename Comp::is_fun> >
class my_set
{
public:
my_set() : mem(10){}
T mem;
};
struct CompS
{
typedef int is_fun;
};
int main()
{
my_set<int, CompS> a;
std::cout << a.mem << std::endl;
return 0;
}
voidt.cpp:17:38: error: ‘void’ is not a valid type for a template non-type parameter
template <typename T, typename Comp, void_t<typename Comp::is_transparent> >
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
voidt.cpp:9:38: error: template parameter ‘class<template-parameter-1-3>’
template <typename T, typename Comp, typename = void>
^~~~~~~~
voidt.cpp:18:7: error: redeclared here as ‘<typeprefixerror><anonymous>’
class my_set
Aucun commentaire:
Enregistrer un commentaire