我有一個類模板,它看起來像這樣選擇性地定義一個類型:是否有可能在派生類中
template <Base>
struct foo : Base
{
typedef int some_type;
};
,我有一個底座,看起來像這樣:
struct some_base
{
typedef float some_type;
};
現在foo<some_base>::some_type
將爲int
,因爲衍生foo
將隱藏Base::some_type
。我想要做的是,如果Base::some_type
已定義,請使用其他方法,在foo
本地將some_type
定義爲'int
- 所以問題是,這可能嗎?
我可以顛倒的關係,並拯救自己有些頭痛,但它不是在實際應用中非常合乎邏輯......
這正是我正在尋找的!非常感謝。 – Nim 2011-02-11 09:15:38