- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
通过以下代码我得到了警告:
warning: specialization of ‘template<class _Iterator> struct std::iterator_traits’ in different namespace [-fpermissive]
template<> class std::iterator_traits<Token_ptr>{
public:
typedef Word difference_type;
typedef Word value_type;
typedef Token_ptr pointer;
typedef Word& reference ;
typedef std::bidirectional_iterator_tag iterator_category ;
};
虽然一切正常,但是否有人知道确切的含义以及发出警告的原因。(g++ 发出警告而 clang++ 不发出警告)。
最佳答案
假设您在 C++11 模式下编译它(因为 clang 没有发出警告)并且这个特化在全局命名空间中,那么您的代码没有任何问题。这是一个 g++ 错误。 §14.7.3 [temp.expl.spec]/p2:
An explicit specialization shall be declared in a namespace enclosing the specialized template. An explicit specialization whose declarator-id is not qualified shall be declared in the nearest enclosing namespace of the template, or, if the namespace is inline (7.3.1), any namespace from its enclosing namespace set. Such a declaration may also be a definition. If the declaration is not a definition, the specialization may be defined later (7.3.1.2).
全局命名空间是一个“包含专用模板的命名空间”,并且您的declarator-id 是用std::
限定的,所以第二句不适用.作为解决方法,您可以执行以下操作 cdhowie的回答表明 - 即打开一个 namespace std
block 并将特化放在那里。
参见 CWG issue 374和 GCC bug 56480 .
关于c++ - 警告 : specialization of template in different namespace,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25594644/
我正在尝试构建模板类 Fod template class Fod { ... }; 它将包含一个带有 static const int value 的内部类 At指示模板参数的索引(S0 为 0,S
我很难理解 Python in a Nutshell 的最后一部分(粗体) Per-Instance Methods An instance can have instance-specific bi
我需要密码字段的正则表达式。 要求是: 密码长度必须在8到20个字符之间 必须包含至少一个字母和一个数字以及来自!@#$%^&*() 的特殊字符_+。 不应以特殊字符开头 我试过了 ^(?=.*[a-
我有一个 C 类型的输入字段。 PARAMETERS lv_sep TYPE c. 字段 lv_sep 应该只接受特殊字符。 你能帮助我如何给出这个约束吗? 最佳答案 您可以在 AT-SELECTIO
我记得 PaulP 展示了一个很酷的技巧来缩写重复的长 @specialized序列,但我找不到原来的帖子了。就像我有 trait Foo[@specialized(Int, Float, Doubl
我有一个特征和一个实现,如下所示: trait Foo[A] { def bar[B >: A: Ordering]: Foo[B] } class FooImpl[A]( val a: A, v
在Sas9中,如何用下划线替换我选择的所有,\ /或空格以及其他特殊字符?无论是在数据步骤中还是在宏函数中的解决方案都可以解决问题,我只是在寻找一种实现方法。 谢谢 最佳答案 您可以使用SAS内置的P
SPECIALIZE 的目的pragma 是创建更具体的函数版本。 我有一个功能 adaptBlocks :: Int -> BlocksField a -> Maybe (BlocksField a
我尝试使用 gcc 10 -std=gnu++20 -fconcepts 构建以下内容: template class MyClass{ T a; }; template class MyClas
已关闭。这个问题是 off-topic 。目前不接受答案。 想要改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 已关闭11 年前。 Improve th
在哪里可以找到文件名中允许的字符列表(取决于操作系统)?(例如,在 Linux 上,文件名中允许使用字符 :,但在 Windows 上则不允许) 最佳答案 您应该从 Wikipedia Filenam
我有下面的powershell功能 Function Test { Param ( [Parameter()] [strin
我有下面的powershell功能 Function Test { Param ( [Parameter()] [strin
我有两个方阵 A 和 B。它们的每一项都有 1 或 0。示例如下所示 A channel id a b c 1 1 1 1 2 1 0 1 3 1 0 0 B id cha
是否可以将基础对象“特化”为派生对象? 例如: class base{... base(...) : ... {}//both have their own constructors virt
我有两个像这样连接在一起的圆圈: 我在形状内部有一个点,我想从该点沿一个方向将光线转换到形状上。为了检索形状边缘的类型转换位置。 我的第一个想法是将 2 段连接到 2 个圆圈进行光线转换。如果没有成功
在我的 Java 项目中,我有以下类/接口(interface)层次结构: public interface ProductSearcher { Set search(String reque
是否可以在不引入与实现完全匹配的签名的情况下定义这个专门的重载? on(eventName: string, cb: Function); on(eventName: "view", cb: (arg
偶然发现 def foo(f: Int => Unit) {} def foo(f: Long => Unit) {} 由于 method foo is defined twice 无法编译.我知道上
在下面的例子中,为什么 foo(f)叫暧昧? 我知道第二个重载也适用于 P == () , 但为什么第一个不被认为更专业, 因此更好的匹配? func foo(_ f: () -> R) { prin
我是一名优秀的程序员,十分优秀!