#ifndef FIND_OR_THROW_H #define FIND_OR_THROW_H #include namespace G13 { class NotFoundException : public std::exception { public: const char *what() throw(); }; template inline const V_T &find_or_throw(const std::map &m, const K_T &target) { auto i = m.find(target); if (i == m.end()) { throw NotFoundException(); } return i->second; }; template inline V_T &find_or_throw(std::map &m, const K_T &target) { auto i = m.find(target); if (i == m.end()) { throw NotFoundException(); } return i->second; }; } // namespace G13 #endif // FIND_OR_THROW_H