c语言watch窗口怎么出来,如何在VS2015的监视窗口中查看C ++模板参数(How to view C++ template argument in watch window in VS2015...

本文介绍如何在Visual Studio 2015的监视窗口中查看复杂的C++模板参数类型。通过将_First或_Last添加到监视窗口,可以显示已解析的_Iter类型。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

如何在VS2015的监视窗口中查看C ++模板参数(How to view C++ template argument in watch window in VS2015)

我正在调试一些C ++代码,其中包含一些C模板,其中T作为模板参数。 我想看看(或鼠标悬停)是什么类型的T.

当我添加T来观看时,它不显示类型。 有没有办法解决调试器中的T参数?

我可以在调用堆栈上看到模板参数类型。 由于类型非常复杂,他调用堆栈中的行很长,不适合我的显示。 而且很难阅读。

有没有办法在调试器监视中解决T参数?

我使用Visual Studio 2015 Update 3。

JdFUG.png

I am debugging some C++ code which contains some C++ templates with T as an template argument. I would like to see in watch (or on mouse over) what type is T.

When I add T to watch, it does not show the type. Is there a way to resolve T argument in debugger?

I can see the template arguments types on call stack. As the types are quite complex, the lines in the he call stack is so long, that cannot fit my display. And very hard to read.

Is there a way to resolve T argument in debugger watch?

I use Visual Studio 2015 Update 3.

JdFUG.png

原文:https://stackoverflow.com/questions/39433928

更新时间:2020-01-03 15:18

最满意答案

将_First或_Last添加到监视_Last ,它们的类型为_Iter ,将显示已解析的类型。 我认为没有任何其他方式:在编译时_Iter被替换为使用的任何类型,因此一旦构建应用程序,就不再注意名称_Iter了。

Add _First or _Last to the watch widow, they are of type _Iter, and the resolved type will be displayed. I don't think there is any other way: at compile time _Iter is replaced by whatever type is used, so once the application is built there's no notice of the name _Iter anymore.

2016-09-11

相关问答

这是因为std::vector不是单参数模板。 标准规定了std::vector的元素类型和分配器类型参数。 如果您不使用旧版C ++并且可以使用可变参数模板,则可以像这样声明您的函数: template class C>

void print2(C& c);

This is because std::vector is not a single-argument template. Standard mandates a

...

这里的页面说明它适用于Visual Studio 2017,因此如果它与Visual Studio 2015一起使用,我会感到惊讶,因此,不幸的是,您找不到下载的原因。 The page here says it works with Visual Studio 2017, therefore I would be surprised if it worked with Visual Studio 2015, hence the reason you do not find the downloa

...

我已将您的代码修改为工作示例(未经过100%测试) template

bool is_any_test_impl(T t) {

return false;

}

template

bool is_any_test_impl(T1 t1, T2 t2, Args&&... args) {

return t1 == t2 || is_any_test_impl(std::forward(t1)

...

为此,我实际上在创建项目后改变了VS2015的语言。 恢复到以前的语言使它再次工作。 Fount it, I actually changed the language of VS2015 after creating the projects. Reverting back to previous language makes it work again.

如果调试器可以看到同步对象的内部状态,那么程序也可以。 允许它绕过API并以线程不安全的方式使用对象。 这是为了您自己的利益,但当然在尝试调试线程问题时是一个巨大的皮塔饼。 祝你好运。 If a debugger could see the internal state of a synchronization object then a program could as well. Allowing it to circumvent the API and use the object in a

...

要使用VS 2015,参数应该是/p:VisualStudioVersion=14.0 。 First thing first. I was using VS2015 to edit TfvcTemplate.12.xaml build template which cased issues. For some reason, when using VS2015 - it was modifying the xaml document incorrectly. To make any type o

...

将_First或_Last添加到监视_Last ,它们的类型为_Iter ,将显示已解析的类型。 我认为没有任何其他方式:在编译时_Iter被替换为使用的任何类型,因此一旦构建应用程序,就不再注意名称_Iter了。 Add _First or _Last to the watch widow, they are of type _Iter, and the resolved type will be displayed. I don't think there is any other way:

...

这是一个最令人烦恼的解决问题。 规范案例将是: T t( U(x) );

其中T和U以前称为类型名称。 这可以通过两种有效的方式解析: 声明t作为T类型的对象,初始化器是表达式U(x) ,变量x的函数样式转换为临时U 声明t作为返回T的函数,带有1个类型为U且名称为x参数; x周围有多余的括号。 (声明者可以用括号括起来)。 消除歧义标准中的文字在[dcl.ambig.res] / 1中。 它说的是解析这段代码取决于U(x)是一个声明还是一个表达式,然后引用[stmt.ambig]。 在[stm

...

类型A (*)(B)是指向一个函数的指针的类型,该函数接受一个B类型的参数并返回A类型的值。 这只是另一种类型。 您的代码是类模板replace_type_impl的部分特化实例。 The type A (*)(B) is the type of a pointer to a function taking one argument of type B and returning a value of type A. It's just another type. Your code is an

...

我发现了一些事情。 我注意到在我发布的示例项目中实际上它在VS2013中无法正确呈现。 Generic.xaml的关键是:

如果我将其更改为:

它在VS2013中呈现良好(但仍未在VS2015中)。 理论上(来自MSDN)这不应该

...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值