I making a custom map class (kc::map
) that extends std::map
, and I want to add at_index()
, and I need to return map<K, V>::iterator
. But when I return map<K, V>
, this error occurs: error: invalid use of incomplete type ‘class kc::map<K, V>’
:
namespace kc
{
template<typename K, typename V> class map : public std::map<K, V>
{
public:
using std::map<K, V>::map;
map<K, V> get_value()
{
return *this;
}
map<K, V>::iterator at_index(int index)
{
map<K, V> m = get_value();
for (int i = 0; i < index; i++)
{
m.erase(m.begin());
}
return m.begin();
}
};
};