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