Closed breznak closed 7 years ago
this is currently failing
$ g++ -std=c++11 -o vect VectorKeyTest.cpp
In file included from VectorKeyTest.cpp:5:0:
LRUCache11.hpp: In instantiation of ‘void lru11::Cache<Key, Value, Lock, Map>::insert(const Key&, const Value&) [with Key = std::vector<int>; Value = std::vector<unsigned int>; Lock = std::mutex; Map = std::map<std::vector<int>, std::vector<unsigned int> >]’:
VectorKeyTest.cpp:21:26: required from here
LRUCache11.hpp:135:7: error: base operand of ‘->’ has non-pointer type ‘std::vector<unsigned int>’
iter->second->value = v;
^
LRUCache11.hpp:136:7: error: no matching function for call to ‘std::__cxx11::list<lru11::KeyValuePair<std::vector<int>, std::vector<unsigned int> >, std::allocator<lru11::KeyValuePair<std::vector<int>, std::vector<unsigned int> > > >::splice(std::__cxx11::list<lru11::KeyValuePair<std::vector<int>, std::vector<unsigned int> >, std::allocator<lru11::KeyValuePair<std::vector<int>, std::vector<unsigned int> > > >::iterator, lru11::Cache<std::vector<int>, std::vector<unsigned int>, std::mutex, std::map<std::vector<int>, std::vector<unsigned int> > >::list_type&, std::vector<unsigned int>&)’
keys_.splice(keys_.begin(), keys_, iter->second);
^
In file included from /usr/include/c++/5/list:63:0,
from LRUCache11.hpp:34,
from VectorKeyTest.cpp:5:
/usr/include/c++/5/bits/stl_list.h:1386:7: note: candidate: void std::__cxx11::list<_Tp, _Alloc>::splice(std::__cxx11::list<_Tp, _Alloc>::const_iterator, std::__cxx11::list<_Tp, _Alloc>&&) [with _Tp = lru11::KeyValuePair<std::vector<int>, std::vector<unsigned int> >; _Alloc = std::allocator<lru11::KeyValuePair<std::vector<int>, std::vector<unsigned int> > >; std::__cxx11::list<_Tp, _Alloc>::const_iterator = std::_List_const_iterator<lru11::KeyValuePair<std::vector<int>, std::vector<unsigned int> > >]
splice(const_iterator __position, list&& __x) noexcept
^
/usr/include/c++/5/bits/stl_list.h:1386:7: note: candidate expects 2 arguments, 3 provided
/usr/include/c++/5/bits/stl_list.h:1405:7: note: candidate: void std::__cxx11::list<_Tp, _Alloc>::splice(std::__cxx11::list<_Tp, _Alloc>::const_iterator, std::__cxx11::list<_Tp, _Alloc>&) [with _Tp = lru11::KeyValuePair<std::vector<int>, std::vector<unsigned int> >; _Alloc = std::allocator<lru11::KeyValuePair<std::vector<int>, std::vector<unsigned int> > >; std::__cxx11::list<_Tp, _Alloc>::const_iterator = std::_List_const_iterator<lru11::KeyValuePair<std::vector<int>, std::vector<unsigned int> > >]
splice(const_iterator __position, list& __x) noexcept
^
Based on the conversation in #8 , can you please show me how to get this done @mohaps ? Currently I work-around it by computing the hash myself and storing the {hash, result vector}, but this would be a cleaner and faster solution.
Ping @mohaps , are you still here?
Fixes #8
An example of using the cache for storing/retrieving vectors.