I am deriving a class from std::map as I wish to create my own methods for this data structure. I am having issues with "mySelect", which should return nullptr if the element is not there and unique_ptr otherwise.
I have tried specifying the typename keyword before declaration of the iterator to no avail.
template <class KeyType, class ValueType>
class Container : public std::map<KeyType, ValueType> {
public:
std::unique_ptr<ValueType> mySelect(KeyType key) {
typename map<KeyType, ValueType>::iterator value;
if ((value = this->find(key)) == this->end())
return nullptr;
return std::make_unique<ValueType>(value);
}
}
I'm getting this error:
Error C2664 'std::vector<std::shared_ptr<Transaction>,std::allocator<_Ty>>::vector(const std::vector<_Ty,std::allocator<_Ty>> &)': cannot convert argument 1 from 'std::_Tree_iterator<std::_Tree_val<std::_Tree_simple_types<_Ty>>>' to 'const _Alloc &'