c++ - Handling an error in a template method -


i having problem finding solution handling error in template function.

template<typename k, typename v> const v& directhashmap<k, v>::lookup(k key) const {     int pos = position(key);      return _values.get(pos)->value; } 

i can't return error code because don't know type returning. prefer not use exceptions because never used exceptions in project before , not consistent if method exception.

if has solution please let me know! feedback appreciated.

you should instead return const_iterator collection.

the end user can test see if it's equivalent .end() collection. how containers in stl typically work. (refer map::find, unordered_map::find, , unordered_set::find)


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -