4
下面的类不会编译:decltype(some_vector):: SIZE_TYPE不作为模板参数工作
template<class Key, class Compare = std::less<Key>, class Allocator = std::allocator<Key>>
class MyContainer
{
public:
std::vector<Key, Allocator> data;
std::vector<std::pair<std::size_t, decltype(data)::size_type>> order;
};
我得到以下编译器错误:
error: type/value mismatch at argument 2 in template parameter list for ‘template struct std::pair’
为什么说无法编译,而下面的代码工作正常?
template<class Key, class Compare = std::less<Key>, class Allocator = std::allocator<Key>>
class MyContainer
{
public:
std::vector<Key, Allocator> data;
std::vector<std::pair<std::size_t, std::size_t>> order;
};
只是完全丑陋! (但它有效......:/) –
“而不是一个对象”,这碰到了头部的指甲。 – Surt