我刚刚开始使用加固多功能指数,迄今为止,有一个集装箱,装配了有序的类型和混合的关键未定的斜体。
我想做的是,如果集装箱是 st的:ctor子或 st子:list子,那么它就能够进入。 通过这一方式,采用<代码>size_t index。
我的守则如下:
// tags
struct linear { };
struct semantic { };
struct semantic_and_index { };
// typedefs for multi_index
typedef boost::multi_index::sequenced<
boost::multi_index::tag<linear>
> LinearIndex;
typedef boost::multi_index::composite_key<
CVertexElement,
boost::multi_index::const_mem_fun<CVertexElement, Buffer::VertexSemantic, &CVertexElement::GetVertexSemantic>,
boost::multi_index::const_mem_fun<CVertexElement, UInt, &CVertexElement::GetSemanticIndex>
> CompositeSemanticIndex;
typedef boost::multi_index::hashed_non_unique<
boost::multi_index::tag<semantic_and_index>,
CompositeSemanticIndex
> SemanticAndIDIndex;
typedef boost::multi_index::hashed_non_unique<
boost::multi_index::tag<semantic>,
boost::multi_index::const_mem_fun<CVertexElement, Buffer::VertexSemantic, &CVertexElement::GetVertexSemantic>
> SemanticIndex;
class CVertexFormat
{
public:
typedef boost::multi_index::multi_index_container <
CVertexElementPtr,
boost::multi_index::indexed_by <
LinearIndex,
SemanticAndIDIndex,
SemanticIndex
> // index_by
> ElementContainer;
// etc...
protected:
ElementContainer m_elements;
};
我指的是:
// this function fails! :(
CVertexElementPtr CVertexFormat::GetElement(size_t index) const
{
//sequenced_index.
typedef ElementContainer::index<linear>::type element_by_linear;
const element_by_linear& index_type = m_elements.get<linear>();
if ( index < index_type.size() )
{
auto itor = index_type.begin();
for (UInt i = 0; i < index_type.size(); ++i)
++itor;
const CVertexElementPtr& pElement = (*itor);
return pElement;
}
else
{
assert(!"Invalid index called for GetElement");
return CVertexElementPtr();
}
}
• 对2010年(右边看望窗):