0
我在59行获得error: expected unqualified-id before 'typename'
内提升multi_index当我尝试编译此:使用模板结构
#include <cstdlib>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/identity.hpp>
#include <boost/multi_index/member.hpp>
template <typename ValueT, typename SizeT = size_t>
struct Test {
typedef SizeT SizeType;
typedef ValueT ValueType;
struct ValueTag {};
struct ProbabilityTag {};
struct TotalProbabilityTag {};
struct NodeType {
SizeType value;
ValueType probability;
ValueType totalProbability;
typedef boost::multi_index_container<
NodeType,
boost::multi_index::indexed_by<
boost::multi_index::ordered_unique<
boost::multi_index::tag<ValueTag>,
BOOST_MULTI_INDEX_MEMBER(NodeType, SizeType, value)
>,
boost::multi_index::ordered_non_unique<
boost::multi_index::tag<ProbabilityTag>,
BOOST_MULTI_INDEX_MEMBER(NodeType, ValueType, probability)
>,
boost::multi_index::ordered_non_unique<
boost::multi_index::tag<TotalProbabilityTag>,
BOOST_MULTI_INDEX_MEMBER(NodeType, ValueType, totalProbability)
>
>
> NodeIndexType;
NodeIndexType * node;
NodeType(const NodeType & o):
value(o.value),
probability(o.probability),
totalProbability(o.totalProbability)
{
if (o.node != NULL) {
this->node = new NodeIndexType(*(o.node));
}
}
~NodeType() {
delete this->node;
}
bool operator< (const NodeType & b) const {
return this->value < b.value;
}
};
typedef typename NodeType::NodeIndexType NodeIndexType;
typedef NodeIndexType::typename index<typename ValueTag>::type ViewNodeByValue; /* this does not work */
};
int main() {
Test<int> a;
return EXIT_SUCCESS;
}
这一切工作正常,如果我删除注释行。我已经看到template parameter to boost multi index container,但我找不到在模板结构或类中使用此方法的方法。
任何人谁可以告诉我如何解决这个问题?
有关错误消息,请参阅http://codepad.org/UPMapaXI。
我有同样的问题和海湾合作委员会4.8.5给我的建议: CollectionManager.hpp:50:32:注意:使用CollectionManager :: CollectionContainer ::模板索引来表明它是一个模板 –
sfanjoy