Код: Выделить всё
// template class typelist
template
struct TemplateTypeList {};
// utility types for TemplateTypeList
// type at index of typelist
template
struct TemplateTypeListType;
template
struct TemplateTypeListType {
template
using result = First;
};
template
struct TemplateTypeListType {
template
using result = typename TemplateTypeListType::template result;
};
// index of type in typelist
template
struct TemplateTypeListIndex;
template
struct TemplateTypeListIndex {
static const int result = 0;
};
template
struct TemplateTypeListIndex {
private:
using ResultOfPrior = TemplateTypeListIndex;
public:
static const int result = ResultOfPrior::result == -1 ? -1 : ResultOfPrior::result + 1;
};
template
struct TemplateTypeListIndex {
static const int result = -1;
};
template
struct Class1 {};
template
struct Class2 {};
using Types = TemplateTypeList;
int index = TemplateTypeListIndex::result;
ASSERT_EQ(index, 0); // fails, index == -1
< /code>
Я довольно озадачен, потому что он работает почти в любом другом случае, для которого я использовал его. Есть ли какое -то предположение, которое я делаю со своими неверными специализациями шаблона, вызывая эту проблему?
Подробнее здесь: https://stackoverflow.com/questions/792 ... ont-work-t
Мобильная версия