小编sma*_*llB的帖子

距离让我的迭代器"冻结"

试试这个:

int main()
{
    std::fstream fin_fout("some.txt");
    std::istream_iterator<std::string> beg(fin_fout),end;
    std::distance(beg,end);//if this line is commented out it works fine but not if is uncommented
    while (beg != end)
    {
      cout << *beg;
      ++beg;
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ iterator

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

红黑树删除算法

从"算法简介第2版"我得到了这个删除算法:

/*
    RB-DELETE(T, z)
    1 if left[z] = nil[T] or right[z] = nil[T]
    2    then y ? z
    3    else y ? TREE-SUCCESSOR(z)
    4 if left[y] ? nil[T]
    5    then x ? left[y]
    6    else x ? right[y]
    7 p[x] ? p[y]
    8 if p[y] = nil[T]
    9    then root[T] ? x
    10    else if y = left[p[y]]
    11            then left[p[y]] ? x
    12            else right[p[y]] ? x
    13 if y != z
    14    then key[z] ? key[y]
    15         copy …
Run Code Online (Sandbox Code Playgroud)

algorithm red-black-tree

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

Rvalue ref和完美转发

我读过很少关于&&的论文,我只是好奇,如果有:

void fnc_1(int&& p)
{
//...
}

void fnc(int&& r)
{
fnc_1(r);//am I suppose to/should I? call it like so:fnc_1(std::forward(r)) 
}
Run Code Online (Sandbox Code Playgroud)

或只是传递'r'就足够了?

c++ rvalue-reference perfect-forwarding c++11

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

LLVM是典型的虚拟机吗?

我想知道LLVM是典型的虚拟机,如Java或.Net,还是简单的运行时环境,就像oridinary C++运行时一样?

c++ llvm

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

从qt中继承表单的最佳方法

从qt设计器中创建的表单继承的最佳方式是什么?

c++ inheritance qt

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

如果 .cpp 文件中有 Q_OBJECT 宏,为什么我的项目无法链接?

此代码按预期编译、链接和工作:

#include <QApplication>
#include <QListView>
#include "File_List_Model.h"

int main(int c,char**v)
{
    QApplication app(c,v);
    QStringList list;

    list << "a" << "b" << "c";

    File_List_Model* model = new File_List_Model;
    model->set_entries(list);

    QListView* view = new QListView;
    view->setModel(model);
    view->show();

    return app.exec();
} 
Run Code Online (Sandbox Code Playgroud)

但是当我将类定义放在.cpp文件而不是头文件中时,我收到链接器错误,指出vtable未正确定义。

#include <QApplication>
#include <QListView>
//#include "File_List_Model.h"
#include "File_List_Proxy.h"
#include <QAbstractItemModel>
#include <QStringList>

class File_List_Model : public QAbstractItemModel
{
    Q_OBJECT
private:
    QStringList data_;
public:
    File_List_Model(QObject *parent = 0) :
        QAbstractItemModel(parent)
    {
    }

    int columnCount(const QModelIndex& parent) const
    { …
Run Code Online (Sandbox Code Playgroud)

qt qmake moc

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

如何通过QFileSystemModel获取所选文件的*full*文件路径?

如何通过QFileSystemModel获取文件路径?通过选择模型选择仅返回文件名或驱动器名称.

请注意,仅文件名是不够的.需要整个文件路径.

c++ qt qfilesystemmodel

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

使用 QT 对 `_Unwind_Resume' 的未定义引用

当尝试在 qt 中切换到 gcc 4.6.2(在工具链中设置)时,我收到以下错误:

c:\ndk_buildrepos\qt-desktop\src\winmain\qtmain_win.cpp:93: error: undefined reference to `_Unwind_Resume'  
Run Code Online (Sandbox Code Playgroud)

知道如何修复它吗?

//.pro
QMAKE_CXXFLAGS += -std=c++0x

SOURCES += \
    main.cpp
Run Code Online (Sandbox Code Playgroud)

c++ qt

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

列出我计算机上安装的物理驱动器

可能重复:
如何列出物理磁盘?

什么是列出我计算机上安装的物理驱动器的"最佳方式"(最快)C++方式?有没有一个升级库可以做到这一点?

c++ windows boost hard-drive

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

constexpr和bizzare错误

我有:

constexpr bool is_concurrency_selected()const
    {
        return ConcurrentGBx->isChecked();//GBx is a groupbox with checkbox
    }
Run Code Online (Sandbox Code Playgroud)

我收到错误:

C:\...\Options_Dialog.hpp:129: error: enclosing class of 'bool Options_Dialog::is_concurrency_selected() const' is not a literal type
Run Code Online (Sandbox Code Playgroud)

有什么想法吗?

c++ constexpr c++11

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