简体   繁体   English

重新定义类的默认参数<template-parameter-1-2>

[英]redefinition of default argument for class<template-parameter-1-2>

I'm having some issue with the compiler on this SFINAE. 我在此SFINAE上的编译器遇到问题。 Looks like it doesn't resolve the template before raising this error. 在引发此错误之前,它似乎无法解析模板。 Here is the code: 这是代码:

template<typename Sig, typename = typename std::enable_if<!std::is_pointer<Sig>::value>::type>
class   GLFunction { /* class def... */ };

template<typename FP, typename = typename std::enable_if<std::is_pointer<FP>::value>::type>
class   GLFunction { /* class def... */ };

Do you know how I can achieve this? 你知道我怎么能做到吗?

Thx. 谢谢。

Read the error, it tells you what's wrong: you can't redefine a default argument, you must only provide it once. 读取错误,它告诉您出了什么问题:您无法重新定义默认参数,只需提供一次即可。

What are you trying to do? 你想做什么? Why have you defined the same template twice? 为什么要定义两次相同的模板? Is one of them meant to be a partial specialization? 其中之一是否意味着要成为部分专业化人员?

Why can't you just do it the simple way, like this? 您为什么不能像这样简单地做呢?

// Primary template, with default argument:
template <typename Sig, bool = std::is_pointer<Sig>::value>
class   GLFunction { /* class def... */ };

// Partial specialization used for pointers:
template <typename FP>
class   GLFunction<FP, true> { /* class def... */ };

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM