我有这个结构:
struct MyStruct
{
MyStruct(const Wrapper &wrapper, /*...*/) :
wrapper(std::cref(wrapper)), /*...*/ {}
std::reference_wrapper<Wrapper const> wrapper;
/*...*/
};
但是,现在我想使用tbb::concurrent_bounded_queue<MyStruct>
,这是不可能的,因为MyStruct
没有默认构造函数。但我不知道如何定义它,因为必须以某种方式初始化wrapper
。有没有解决方案(除了使用原始指针)?
tbb
错误(此处FindAffineShapeArgs
为MyStruct
):
/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"