小编rai*_*ndi的帖子

奇怪的C++性能(VC 2010)

我有用C++编写的这个循环,用MSVC2010编译需要很长时间才能运行.(300毫秒)

    for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
        if (buf[i*w+j] > 0) {
            const int sy = max(0, i - hr);
            const int ey = min(h, i + hr + 1);
            const int sx = max(0, j - hr);
            const int ex = min(w, j + hr + 1);
            float val = 0;
            for (int k=sy; k < ey; k++) {
                for (int m=sx; m < ex; m++) {
                    val += original[k*w + m] * …
Run Code Online (Sandbox Code Playgroud)

c++ performance assembly

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

例如,C++ 0x auto关键字的含义是什么?

auto a = (Foo<T>*)malloc(sizeof(Foo<T>));
auto *b = (Foo<T>*)malloc(sizeof(Foo<T>));
Run Code Online (Sandbox Code Playgroud)

我不认为模板是存在的,但问题是它的重要的:是a和b相同类型的?

g++ -std=c++0x -Wall (4.4)没有给出任何错误或警告,但我没有运行程序,所以我不知道它是否做同样的事情.

这是否意味着a,auto是Foo<T>*,但是b,auto是Foo<T>吗?

c++ gcc c++11

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

标签 统计

c++ ×2

assembly ×1

c++11 ×1

gcc ×1

performance ×1