小编the*_*cky的帖子

如何从 boost::geometry::model::point 继承?

我想从bg::model::point继承以使用自己的功能扩展它。*point*s 应存储在rtree 中

以下最小示例无法编译我的派生点(boost 1.54,gcc 4.7.2)的用法:

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/index/rtree.hpp>
#include <iostream>
#include <boost/shared_ptr.hpp>

namespace bg = boost::geometry;
namespace bgi = boost::geometry::index;

namespace boost { namespace geometry { namespace index {

// apparently necessary:
template <typename Box>
struct indexable< boost::shared_ptr<Box> >
{
    typedef boost::shared_ptr<Box> V;

    typedef Box const& result_type;
    result_type operator()(V const& v) const { return *v; }
};

}}} // namespace boost::geometry::index


namespace { // anonymous namespace

// myPoint
template<typename CoordinateType, …
Run Code Online (Sandbox Code Playgroud)

c++ inheritance boost boost-geometry

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

OpenMP:并发写入std :: map

我有一个std::map密钥与thread_num相同.每个线程都写入值,std::vector这里.因此可以保证每个线程只在"他的"上运行std::vector.

例:

#include <iostream>
#include <omp.h>
#include <map>
#include <vector>


int main(void) {

    std::map<unsigned int, std::vector<unsigned int> > M;

// initialize map using first touch policy:
#pragma omp parallel for schedule(static,1)
    for (int i=0; i<omp_get_num_procs(); ++i) {
#pragma omp critical
        M[omp_get_thread_num()] = std::vector<unsigned int>();
    }

// do some parallel operations:
#pragma omp parallel for schedule(static)
    for (int i=0; i<100; ++i) {
        M[omp_get_thread_num()].push_back(i);
    }

// disp the content:
    for (auto it_key : M) {
        std::cout …
Run Code Online (Sandbox Code Playgroud)

c++ openmp c++11

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

标签 统计

c++ ×2

boost ×1

boost-geometry ×1

c++11 ×1

inheritance ×1

openmp ×1