考虑这段代码,它编译成功:
#include <boost/intrusive/unordered_set.hpp>
using namespace boost::intrusive;
typedef unordered_set_member_hook<> Hook;
struct Item
{
Hook hook;
};
typedef unordered_set<Item,
member_hook<Item, Hook, &Item::hook>,
size_type<uint32_t> > Map;
static_assert(4 == sizeof(typename Map::size_type));
static_assert(8 == sizeof(decltype(Map::suggested_upper_bucket_count(1000))));
在文档和代码中,suggested_upper_bucket_count()
都是这样声明的:
static size_type suggested_upper_bucket_count(size_type);
那怎么可能Map::size_type
是 4 个字节 ( uint32_t
) 而结果suggested_upper_bucket_count()
却是 8 个字节呢?