我完全无法解决以下编译错误:
#include <iostream>
#include <boost/lockfree/queue.hpp>
class C
{
public:
static int size;
};
int C::size = 10;
template <class temp>
class B: public temp
{
class A
{
public:
static A pool[temp::size];
static boost::lockfree::queue<A*> mpool;
static bool firstTime;
};
public:
void show() { std::cout << "Called Show" << std::endl; }
};
template <class temp>
bool B<temp>::A::firstTime = true;
template <class temp>
typename B<temp>::A B<temp>::A::pool[temp::size];
template <class temp>
boost::lockfree::queue<B<temp>::A*> B<temp>::A::mpool(temp::size);
int main()
{
B<C> d;
d.show();
}
它说明了以下错误 - 我努力但却无法解决问题 - 需要帮助:
test11.cpp:37:39: error: type/value mismatch at argument 1 in template parameter list for 'template<class T, class A0, class A1, class A2> class boost::lockfree::queue'
boost::lockfree::queue<B<temp>::A*> B<temp>::A::mpool(temp::size);
^
test11.cpp:37:39: error: expected a type, got '(B<temp>::A * <expression error>)'
test11.cpp:37:58: error: invalid type in declaration before '(' token
boost::lockfree::queue<B<temp>::A*> B<temp>::A::mpool(temp::size);
^
test11.cpp:37:58: error: conflicting declaration 'int B<temp>::A::mpool'
test11.cpp:21:40: note: previous declaration as 'boost::lockfree::queue<B<temp>::A*> B<temp>::A::mpool'
static boost::lockfree::queue<A*> mpool;
^
test11.cpp:37:58: error: declaration of 'boost::lockfree::queue<B<temp>::A*> B<temp>::A::mpool' outside of class is not definition [-fpermissive]
boost::lockfree::queue<B<temp>::A*> B<temp>::A::mpool(temp::size);
答案 0 :(得分:0)
您在这里错过了一个typename声明。
template<class T> boost::lockfree::queue<typename B<T>::A*> B<T>::A::mpool(T::size);
B<T>::A
是一个类型名称并不明显。