小编jep*_*jep的帖子

如何在clion中调试下捕获控制台输出?

我正在使用clion来编写控制台应用程序.如果我只是运行程序,我可以看到我的cout调用结果.但是如果我调试它,除了我的exe名称和调试控制台选项卡之外没有输出Process finished with exit code 0.是否有额外的步骤让控制台输出显示在clion的调试下?

或者这甚至不是clion特定的,并且一直使用gdb的人已经知道了吗?

c++ clion

10
推荐指数
1
解决办法
1342
查看次数

为什么将字符串作为"this"传递会导致这种奇怪?

我试图理解为什么javascript正在做一些意想不到的事情(对我而言).这里有一些纯粹的代码.换句话说,我实际上并不想扩展String(我实际上是绑定到函数和东西).所以这是没有库的普通javascript.

var s = 'blah';

String.prototype.foo = function () {
  console.log('this === s:', this === s);
  console.log('this == s:', this == s);
  console.log('typeof this:', typeof this);
  console.log('typeof s:', typeof s);
  console.log('this:', this);
  console.log('s:', s);
};

s.foo()
Run Code Online (Sandbox Code Playgroud)

这是Safari脚本控制台中的输出:

this === s: false
this == s: true
typeof this: object
typeof s: string
this: [object Object]
s: blah
Run Code Online (Sandbox Code Playgroud)

IE,FF,Chrome等的输出相似

我试图绕过为什么这个=== s不是真的.为什么这是一个"对象",但s是一个"字符串".

这里发生了什么?

javascript

7
推荐指数
1
解决办法
95
查看次数

默认的TArray.Sort比较器实际上做了什么以及何时使用它?

在Delphi XE2的帮助下System.Generics.Collections.TArray.Sort,它说

Note: If the Comparer parameter is provided, it is used to compare elements; otherwise the default comparator for the array elements is used. 
Run Code Online (Sandbox Code Playgroud)

我挖回位,发现默认比较TArray.Sort_LookupVtableInfoSystem.Generics.Defaults.这个代码是

function _LookupVtableInfo(intf: TDefaultGenericInterface; info: PTypeInfo; size: Integer): Pointer;
var
  pinfo: PVtableInfo;
begin
  if info <> nil then
  begin
    pinfo := @VtableInfo[intf, info^.Kind];
    Result := pinfo^.Data;
    if ifSelector in pinfo^.Flags then
      Result := TTypeInfoSelector(Result)(info, size);
    if ifVariableSize in pinfo^.Flags then
      Result := MakeInstance(Result, size);
  end
  else
  begin …
Run Code Online (Sandbox Code Playgroud)

delphi delphi-xe2

7
推荐指数
2
解决办法
1293
查看次数

标签 统计

c++ ×1

clion ×1

delphi ×1

delphi-xe2 ×1

javascript ×1