也许我的Google fu不够强大。
使用GCC4.4.3,我得到了一组这样的类:
template <typename storage_t, typename index_t = std::size_t, typename
leaf_payload_t = std::size_t>
struct btree_node {
public:
typedef btree_node<storage_t, index_t, leaf_payload_t> this_t;
typedef boost::shared_ptr<this_t> handle_t;
// [...]
};
template <typename storage_t, typename index_t = std::size_t, typename
leaf_payload_t = std::size_t>
class btree {
public:
class caching_storage_t;
typedef btree_node<caching_storage_t, index_t, leaf_payload_t> node_t;
typedef typename node_t::handle_t nodehandle_t;
// [...]
class caching_storage_t {
public:
//typedef typename btree::nodehandle_t nodehandle_t; // Fails -- why?
typedef typename boost::shared_ptr<node_t> nodehandle_t;
// [...]
};
};
nodehandle_t
在里面
caching_storage_t
,因为如果我尝试使用注释掉的typedef行(我更喜欢这样),就会得到一个错误“struct btree node<…>”中没有名为handle的类型,这显然是不正确的,而且编译器知道它,因为typedef在
btree
. 我也试过
using typename btree::nodehandle_t;
,我能想到的每一个变化,都是徒劳的。
这是语言/语法问题(如果是,正确的语法是什么)还是编译器错误?
here
,但似乎并不适用,因为
typedef
本身不是模板。我所能找到的其他东西似乎都不太接近。)