小编vbo*_*vbo的帖子

在Visual C++和clang中使用C++ 11 unordered_set

我试图在跨平台的C++应用程序中使用std :: unordered_set.它在Windows下编译和工作就像Visual C++中的魅力,但在Mac OS X下的clang上产生致命的编译错误.

我想知道它为什么会发生,以及正确的方法是什么.

示例代码:

// 
// Clang build cmdline:
// $ clang++ ./set.cpp -Wall -Werror -Wfatal-errors -std=c++11 -stdlib=libc++ -o set.out
// 

#include <iostream>
#include <unordered_set>

struct Point {
    int x, y;
    Point(int x = 0, int y = 0) {
        this->x = x;
        this->y = y;
    }
    bool operator==(Point const& p) const {
        return this->x == p.x && this->y == p.y;
    }
    operator std::size_t () const {
        return std::hash<int>()(x) ^ std::hash<int>()(y);
    }
};

typedef std::unordered_set<Point> points_set_t; …
Run Code Online (Sandbox Code Playgroud)

c++ clang unordered-set visual-c++ c++11

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

标签 统计

c++ ×1

c++11 ×1

clang ×1

unordered-set ×1

visual-c++ ×1