小编Naz*_*554的帖子

如何在SQL Server中为多列数据提供排名?

我有输入表,如下所示 -

ID  Name q1     q2      q3      q4
1   a    2621   2036    1890    2300
2   b    18000  13000   14000   15000
3   c    100    200     300     400
Run Code Online (Sandbox Code Playgroud)

我想要q1, q2, q3 and q4每行的列()数据排名.例如,如果我考虑上面输入的最后一行,那么q4列包含的400值高于其他列,因此排名q4将是1,q3排名将是2,q2排名将是3q1排名将是4.

我正在寻找像 - 的输出

id  name  q1  q2  q3  q4
1   a     1   3   4   2
2   b     1   4   3   2
3   c     4   3   2   1 …
Run Code Online (Sandbox Code Playgroud)

sql-server sql-server-2012

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

为什么此代码与MSVC无效对齐?

我已经在ideone.com上测试了这个代码并且16它应该输出.但是,当我在Visual Studio 2013中尝试它时,它显示8.它是编译器的错误还是缺少C++ 11支持?

#include <iostream>
#include <type_traits>
using namespace std;
using float_pack = aligned_storage<4 * sizeof(float), 16>::type;
int main() {

    cout << alignment_of<float_pack>::value << endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我使用了alignment_of,因为MSVC不支持alignof.

编辑:我看到我无法16与之对齐aligned_storage.但为什么这个片段没问题呢?

#include <iostream>
#include <type_traits>
#include <xmmintrin.h>
using namespace std;

__declspec(align(16)) struct float_pack {
    float x[4];
};

int main()
{
    cout << alignment_of<float_pack>::value << endl;
}
Run Code Online (Sandbox Code Playgroud)

输出是16.这是否意味着编译器在使用扩展时可以提供更大的对齐?为什么我不能达到同样的效果aligned_storage?只是因为MSVC没有提供那个aligned_storage

c++ memory-alignment visual-c++ c++11

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

添加符号时出错:命令行中缺少DSO

试图在Qt项目中使用Ogre.食人魔成功建立.运行项目它给我三个错误:

/usr/lib/x86_64-linux-gnu/libboost_system.so.1.54.0:-1: error: error adding symbols: DSO missing from command line
-1: error: main.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv'
Run Code Online (Sandbox Code Playgroud)

当我搜索错误时,它说要编辑makefile并添加:LIBS = -lpthread

但它已经存在了.

如何解决此错误?

c++ qt ogre

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

尝试将std :: aligned_storage与SSE和new一起使用

我想尝试使用C++中的SSE instrincs来获取一些浮点数的平方根.但是当我尝试存储结果时,我得到一个例外.我可以像这样使用std :: aligned_storage吗?

#include <iostream>
#include <type_traits>
#include <xmmintrin.h>
using namespace std;

using float_storage = aligned_storage<4 * sizeof(float), 16>;

int main()
{
    int N;
    cin >> N;

    float_storage * values = new float_storage[ N / 4 ]; // 4 floats in pack

    for(int i = 0; i < N / 4; i++)
    {
        void *vptr = static_cast<void*>(&values[i]);
        float *fptr = static_cast<float*>(vptr);

        for(int i = 0; i < 4; i++)
            cin >> fptr[i];
    }

    for(int i = 0; i < …
Run Code Online (Sandbox Code Playgroud)

c++ memory-management sse memory-alignment c++11

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

移植到Qt5后,OpenGL应用程序看起来很奇怪

我最近将我的引擎移植QGLWidget到了QWindow.一切都很好,除了纹理.它们出现了很多洞,黑暗而且非常奇怪.

显示我的意思的例子:(破碎的构建(QWindow)) 破碎的构造(QWindow)

第二个例子:(工作构建QGLWidget): 正在构建QGLWidget

设置我使用的纹理QOpenGLTexture.它显示glTextureView无法解决的警告,但仍然有效.在我使用的QGLWidget版本QGLWidget::convertToGLFormat和一些原始的OpenGL调用中.

QGLWidget版本代码:

if(!mProgram.isLinked())
{
    qCritical() << tr("Error: the shader program is not linked, object name: %1").arg(mName);
    return false;
}

if(mTextureID != 0)
{
    qCritical() << tr("Error: texture already set, object name: %1").arg(mName);
    return false;
}

QImage tex;
bool loadok = tex.load(path);
if(!loadok)
{
    qCritical() << tr("Error: failed to load the image, object name: %1").arg(mName);
    return false;
}

tex = QGLWidget::convertToGLFormat(tex);



glGenTextures(1, &mTextureID);
if(mTextureID == 0)
{
    qCritical() …
Run Code Online (Sandbox Code Playgroud)

c++ opengl qt qglwidget qt5

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