小编Pau*_*zak的帖子

为什么Scala中的这个函数调用没有被优化掉?

我正在使用Scala 2.10.3运行此程序:

object Test {
  def main(args: Array[String]) { 
    def factorial(x: BigInt): BigInt = 
      if (x == 0) 1 else x * factorial(x - 1)

    val N = 1000
    val t = new Array[Long](N)
    var r: BigInt = 0

    for (i <- 0 until N) {
      val t0 = System.nanoTime()

      r = r + factorial(300)
      t(i) = System.nanoTime()-t0
    }

    val ts = t.sortWith((x, y) => x < y)

    for (i <- 0 to 10)
      print(ts(i) + "  ")

    println("***  " …
Run Code Online (Sandbox Code Playgroud)

optimization benchmarking scala

3
推荐指数
1
解决办法
254
查看次数

在 Windows 10 上使用 vcpkg 安装 Dear ImGui

我使用以下命令在 Windows 10 上安装 Dear ImGui:

vcpkg install imgui:x64-windows
Run Code Online (Sandbox Code Playgroud)

仅安装:

imgui[core]:x64-windows -> 1.85
Run Code Online (Sandbox Code Playgroud)

我怀疑我需要从此列表中添加一个或多个绑定:

imgui[allegro5-binding]                   Make available Allegro5 binding                                                                          
imgui[docking-experimental]               Build with docking support                                                                               
imgui[dx10-binding]                       Make available DirectX10 binding                                                                         
imgui[dx11-binding]                       Make available DirectX11 binding                                                                         
imgui[dx12-binding]                       Make available DirectX12 binding                                                                         
imgui[dx9-binding]                        Make available DirectX9 binding                                                                          
imgui[freetype]                           Build font atlases using FreeType instead of stb_truetype                                                
imgui[glfw-binding]                       Make available GLFW binding                                                                              
imgui[glut-binding]                       Make available Glut binding                                                                              
imgui[libigl-imgui]                       Install the libigl-imgui headers                                                                         
imgui[marmalade-binding]                  Make available Marmalade binding                                                                         
imgui[metal-binding]                      Make available Metal binding                                                                             
imgui[opengl2-binding]                    Make …
Run Code Online (Sandbox Code Playgroud)

c++ windows imgui

3
推荐指数
1
解决办法
7930
查看次数

在Qt中为QTime和QDateTime添加时间的问题

我无法抽出时间添加功能.我正在使用Qt4.这是代码片段,它产生两个相同的时间而不是100个不同的时间.

void main()  
{  
  QTextStream out (stdout);
  QTime t = QTime::currentTime();

  out << t.toString("hh:mm:ss") << " -> ";
  t.addSecs(100);
  out << t.toString("hh:mm:ss");
}
Run Code Online (Sandbox Code Playgroud)

qt qt4

2
推荐指数
1
解决办法
7811
查看次数

F#:从列表中提取相同长度的重叠连续子列表

在F#中有一个N个元素长列表,我想提取所有可能的M个元素长重叠的连续子列表(M <N),例如:

[1; 2; 3; 4; 5]
Run Code Online (Sandbox Code Playgroud)

产生

[[1; 2; 3]; [2; 3; 4]; [3; 4; 5]]
Run Code Online (Sandbox Code Playgroud)

对于M = 3.

我知道这样做的必要方法,但是有一个简洁的功能诀窍吗?

f# list

2
推荐指数
1
解决办法
127
查看次数

你能解释一下这种重载决议行为吗?

此代码段不能使用VS2013或ICC 16进行编译:

class C2;

class C1
{
public:
  float x, y;

  template<typename T>
  C1 (T x, T y) : x(static_cast<float>(x)), y(static_cast<float>(y)) {};
  C1 (const C2 &a, int i) : x(0), y(0) {};
};

void main()
{
    C1 p(1.5, 2);
}
Run Code Online (Sandbox Code Playgroud)

因为没有C1构造函数的实例匹配参数列表(double, int),但是当我C2PolyLine它替换它时会编译并1.5以某种方式转换为PolyLine.我在一个有很多依赖项的大型项目中测试它,所以我只能在这里放入标题的一个片段:

class PolyLine 
{
protected:
    enum {INIT_LENGTH = 16};

public:
  typedef float (PolyLine::*Fit)(Point2D&, Point2D&, const int, const int, const float) const;

    vector<float> x;  ///< Vector with X …
Run Code Online (Sandbox Code Playgroud)

c++

2
推荐指数
1
解决办法
65
查看次数

这种nullptr的使用是否会产生编译错误?

有没有一个很好的理由为什么这个代码在没有警告的情况下编译(并在运行时崩溃)与Visual C++ 2010:

int a = *((int*)nullptr);
Run Code Online (Sandbox Code Playgroud)

静态分析应该得出结论它会崩溃,对吧?

c++ visual-c++ nullptr c++11

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

此函数中存在奇怪的(?)类型不匹配错误

有人可以解释为什么编译器给我这个错误

类型不匹配.期待'a [] - >字符串,
但给出'a [] - >'a []
类型'字符串'与类型''a []'不匹配

在此代码段上:

let rotate s: string = 
  [|for c in s -> c|] 
  |> Array.permute (function | 0 -> (s.Length-1) | i -> i-1)
Run Code Online (Sandbox Code Playgroud)

而下面的那个编译得很好:

let s = "string"
[|for c in s -> c|] 
|> Array.permute (function | 0 -> (s.Length-1) | i -> i-1)
Run Code Online (Sandbox Code Playgroud)

f#

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

标签 统计

c++ ×3

f# ×2

benchmarking ×1

c++11 ×1

imgui ×1

list ×1

nullptr ×1

optimization ×1

qt ×1

qt4 ×1

scala ×1

visual-c++ ×1

windows ×1