4

我有这个结构:

struct MyStruct
{
    MyStruct(const Wrapper &wrapper, /*...*/) :
        wrapper(std::cref(wrapper)), /*...*/ {}

    std::reference_wrapper<Wrapper const> wrapper;
    /*...*/
};

但是,现在我想使用 a tbb::concurrent_bounded_queue<MyStruct>,这是不可能的,因为MyStruct没有默认构造函数。但我不知道如何定义它,因为wrapper必须以某种方式初始化。有没有解决方案(除了使用原始指针)?

tbb错误(在哪里FindAffineShapeArgsMyStruct

/usr/include/tbb/concurrent_queue.h(453): error: no default constructor exists for class "FindAffineShapeArgs"
          T value;
            ^
          detected during:
            instantiation of "void tbb::concurrent_bounded_queue<T, A>::clear() [with T=FindAffineShapeArgs, A=tbb::cache_aligned_allocator<FindAffineShapeArgs>]" at line 446
            instantiation of "tbb::concurrent_bounded_queue<T, A>::~concurrent_bounded_queue() [with T=FindAffineShapeArgs, A=tbb::cache_aligned_allocator<FindAffineShapeArgs>]" at line 272 of "/home/luca/Dropbox/HKUST/CloudCache/cloudcache/CloudCache/Descriptors/hesaff/pyramid.cpp"
4

0 回答 0