Type_traits *_v variable template utility order fails to compile

帅比萌擦擦* 提交于 2019-12-05 03:26:34

Let's compare the template parameters of the varaible...

template <template <class...> class Template, class... Args>
constexpr bool is_specialization_v = is_specialization<Template<Args...>, Template>::value;

to the arguments

is_specialization_v<std::vector<int>, std::vector>

You declared it to accepts first, a template, but then you pass a type. Then you declared it to accept a type pack, but now you pass a template. The problem is that you got confused and implement the variable as one does a specialization of the primary trait. It doesn't accept parameter to pass as arguments to place in the specialization. It needs to accept the same parameters as the primary, and just forward them:

template <class T, template <class...> class Template>
constexpr bool is_specialization_v = is_specialization<T, Template>::value;

The variable template should have the same template parameters as the original template: <class T, template <class...> class Template>. I'm not sure why you used template parameters from the specialization instead.

It should look like this:

template <class T, template <class...> class Template>
constexpr bool is_specialization_v = is_specialization<T, Template>::value;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!