我有一个关于享元选项的问题,给出下面的定义,基于http://www.boost.org/doc/libs/1_40_0/libs/flyweight/test/test_basic.cpp
typedef boost::flyweights::flyweight<
std::string,
boost::flyweights::tag<int>,
boost::flyweights::static_holder_class<boost::mpl::_1>,
boost::flyweights::hashed_factory_class<
boost::mpl::_1,
boost::mpl::_2,
boost::hash<boost::mpl::_2>,
std::equal_to<boost::mpl::_2>,
std::allocator<boost::mpl::_1>
>,
boost::flyweights::simple_locking,
boost::flyweights::refcounted
> StringFlyweight;
StringFlyweight test1("Hello World");
boost::mpl::_1
和有什么价值boost::mpl::_2
?什么时候分配?
boost::mpl::_1
很可能是std::string
。boost::mpl::_2
应该是size_t
?如果属实,如何扣除?我不明白 key_type 是如何选择的。
我已阅读http://www.boost.org/doc/libs/1_41_0/libs/flyweight/doc/tutorial/lambda_expressions.html但这是我第一次接触 Boost.MPL 并且还不够:)