- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试为部分专用类型创建 Visual Studio 调试可视化工具。例如,假设我有这样的东西:
template <typename T>
struct Foo
{
T bar;
};
template <typename T>
struct Foo<T*>
{
T baz;
};
如果没有偏特化,这会很容易:
<Type Name="Foo<*>"> ... </Type>
有了完全特化,这也很容易:
<Type Name="Foo<int>"> ... </Type>
但是我如何涵盖部分特化?这甚至受支持吗?如果没有,是否有解决方法?
最佳答案
简短回答 - 不可以。您不能在 natvis 类型名称中指定类型限定符、引用等 <Type Name="Foo<*>">
.
但是:
您可以将模板的 typename 参数用作字符串并与类型进行比较。例如,在节点的 Condition
属性:
<Type Name="Foo<*>">
<DisplayString Condition="strcmp("$T1","short")==0">specialization short</DisplayString>
<DisplayString Condition="strcmp("$T1","int &")==0">specialization int &</DisplayString>
<DisplayString>unspecified specialization</DisplayString>
</Type>
对于 Foo<short>
你会看到specialization short
和 unspecified specialization
对于其他。
例子:
template <typename T, typename U>
struct Foo
{
T bar;
};
template <typename U>
struct Foo<int &, U>
{
U baz;
};
int main()
{
int gg = 0;
Foo<short, int> a;
Foo<int, int> b;
Foo<int &, int> c;
纳维斯:
<Type Name="Foo<*,*>" >
<DisplayString Condition="strcmp("$T1","short")==0">specialization short</DisplayString>
<DisplayString>unspecified specialization</DisplayString>
</Type>
<Type Name="Foo<int&,*>">
<DisplayString>partial specialization int&</DisplayString>
</Type>
结果:
或者你,如果你在你的偏特化类型中有一些独特的成员,可以使用 Priority
选项。
例子:
template <typename T>
struct Foo
{
T bar;
};
template <typename U>
struct Foo<U &>
{
U baz;
};
int main()
{
int g = 0;
Foo<short> a;
Foo<int> b;
Foo<int &> c{g};
纳维斯:
<Type Name="Foo<*>">
<DisplayString>partial specialization {baz}</DisplayString>
</Type>
<Type Name="Foo<*>" Priority="Low">
<DisplayString>other specialization</DisplayString>
</Type>
结果:
关于C++ 部分模板特化和 Natvis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58477187/
我从这里实现了元组:https://voidnish.wordpress.com/2013/07/13/tuple-implementation-via-variadic-templates/ 是否可
我们经常为枚举使用前缀。 在 NatVis 中显示全名非常冗长。 是否可以删除枚举名称的前缀(又名返回枚举名称的子字符串)? enum FooFormat { FooFormat_Foo, F
我正在尝试为部分专用类型创建 Visual Studio 调试可视化工具。例如,假设我有这样的东西: template struct Foo { T bar; }; template st
我正在尝试创建一个 .natvis Visual Studio 的文件。根据这个page我可以使用 $T1, $T2 引用模板参数等等。所以在 MyClass 的情况下$T1将引用类型 A .这行得通
natvis 中有没有一种方法可以将类型重新解释为已经由 natvis 定义的类型?还是别名? 例如,我想做这种“技巧”(在我的上下文中确实是必要的,即使这对您来说听起来很奇怪,这是 JIT 符号生成
我正在尝试为 uint32_t 类型定义一个 .natvis ,以显示为一个包含四个字符的数组,在调试期间,在 Watch 窗口中,它会被表示为一点像这样:(char*)&fourcc,4。 不幸的是
我刚刚了解了 Visual Studio 中的 .natvis 文件,并且一直在为我的 Ruby C++ 扩展项目设置一些文件。 http://msdn.microsoft.com/en-us/lib
昨天我发现MSVC's "Natvis" tool ,它允许您调整调试器以智能方式呈现您的类型。我很快开始美化我的数学库。 这是我的 3*3 矩阵类的外观(未初始化的数据): 很漂亮,对吧?我的下午没
我目前正在为 natvis 中的日期类型编写可视化工具。日期类型以通常的 unix 方式存储自 1970 年以来的秒数,但如果不使用临时变量,从中导出年、月和月的日期会非常冗长。我希望能够存储工作变量
假设我必须遵循结构: template struct TSH2SizedArray { inline void Add(const Type & Value); inline Type
我有一个类型定义为: typedef unsigned short StringChecksum; 我最终打算使用 NatVis 在我们加载到内存中的全局字符串表中显示相应的值。 所以我定义了一个新的
VS2013 中 shared_ptr 的默认可视化工具有这个(很多很多东西被删除了!): _Ptr 这意味着在调试器中,您必须展开 shared_ptr,然后展开 [ptr]
我无法在调试时对 VS2015 中的基本 std:string 有一个像样的 View 。我按照此地址给出的说明进行操作:https://msdn.microsoft.com/fr-fr/librar
我正在尝试使用在 natvis.xsd(natvis 模式文件)中定义的标签来编写 C# 或 C++ 代码来可视化类型。我找不到任何关于此的文档,所以我不确定它是如何工作的。特别是我需要为 Custo
我正在使用 Visual Studio 2017 为某些类编写可视化工具,但遇到了 .natvis 代码可读性方面的问题。我有一个自定义数组类型,我想在 Watch 窗口的 Value 字段中直接显示
我正在使用 VS Ultimate 2012 Update 5: Microsoft Visual Studio Ultimate 2012 版本 11.0.61219.00 更新 5 微软 .NET
我有一个自定义数据结构,其中包含一个 char* 缓冲区,该缓冲区具有两个关联的长度:最大长度和实际长度: struct MyData { char* data; int length;
我正在 Microsoft Visual Studio 2015 中使用 .natvis 文件编写调试器可视化工具。如果可能的话,我想在我的类(class)中获得一条信息。我想知道获取该变量的语法是什
我正在为 visual studio 2012 编写一个 natvis 文件,以帮助自定义调试时显示的内容。我正在尝试将 void* 转换为模板类,但我看到以下错误: Fatal error: Ele
我正在尝试在 Visual Studio 2013 调试器中显示一个矩阵类。该类(class)的相关部分是这样的: class mat { private: size_t rowdim, co
我是一名优秀的程序员,十分优秀!