decltype((void)T{}) in template Partial Specialization not deduce?


decltype((void)T{}) in template Partial Specialization not deduce?


template<typename T,typename U = void>
struct Test
{
static const int value = 0;
};
template<typename T>
struct Test<T, decltype((void)T{})>
{
static const int value = 2;
};

template<typename T>
struct Test<T*, decltype((void)T{})>
{
static const int value = 1;
};

int main(){
cout<<Test<int*>::value<<endl;
return 0;
}



code on gcc/clang both get error:ambiguous ,but decltype change to void_t is ok.why?





Could this be related? stackoverflow.com/questions/4031228/…
– alter igel
Jun 30 at 1:07





@alterigel I don't think so.change to decltype(T{},void()) error again
– fe263
Jun 30 at 1:13





What are you trying to do here?
– Nicol Bolas
Jun 30 at 1:18





@NicolBolas I think use decltype is deduced context,but compiler don't think so. I want to know why?
– fe263
Jun 30 at 1:38









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Opening a url is failing in Swift

Export result set on Dbeaver to CSV