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