gpt4 book ai didi

c++ - 如何转发声明以下模板类

转载 作者:搜寻专家 更新时间:2023-10-31 00:48:45 24 4
gpt4 key购买 nike

我尝试转发 declare concurrent_bounded_queue ;

class MyClass {
namespace tbb {
template<typename T> class cache_aligned_allocator;
template<class T, class A = cache_aligned_allocator> class concurrent_bounded_queue;
};

// I wish to maintain this syntax.
tbb::concurrent_bounded_queue<std::string>& concurrentBoundedQueue;
}

我收到以下错误:

error C3203: 'cache_aligned_allocator' : unspecialized class template can't be used as a template argument for template parameter 'A', expected a real type
error C2955: 'tbb::cache_aligned_allocator' : use of class template requires template argument list c:\projects\vitroxreport\src\Executor.h(21) : see declaration of 'tbb::cache_aligned_allocator'

我可以知道如何避免吗?

谢谢。

最佳答案

分配器是一个模板,但队列的第二个参数是具体类。试试这个:

class MyClass {
namespace tbb {
template<typename T> class cache_aligned_allocator;
template<class T, class A = cache_aligned_allocator<T> >
class concurrent_bounded_queue;
};

tbb::concurrent_bounded_queue<std::string>& concurrentBoundedQueue;
};

关于c++ - 如何转发声明以下模板类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2339167/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com