boost::mpl::vector - getting to a type's base-offset

拈花ヽ惹草 提交于 2019-12-01 06:43:12

If what you're looking for is a kind of indexOf feature, I guess the example from Boost.MPL doc concerning find will do the trick:

typedef vector<char,int,unsigned,long,unsigned long> types;
typedef find<types,unsigned>::type iter;

BOOST_MPL_ASSERT(( is_same< deref<iter>::type, unsigned > ));
BOOST_MPL_ASSERT_RELATION( iter::pos::value, ==, 2 );

Their is a metafunction in the itterator category to do just this, it is called distance.

p.s., apologies for answering my own question so quickly. I just stumbled on the solution.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!