Mercurial > hg > piper-cpp
diff bits/PreservingPluginOutputIdMapper.h @ 65:2d866edd79d5
Merge from noexcept branch
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Fri, 23 Sep 2016 14:23:10 +0100 |
parents | 8a4bcb3dc3a6 |
children |
line wrap: on
line diff
--- a/bits/PreservingPluginOutputIdMapper.h Fri Sep 23 14:20:29 2016 +0100 +++ b/bits/PreservingPluginOutputIdMapper.h Fri Sep 23 14:23:10 2016 +0100 @@ -49,7 +49,7 @@ public: PreservingPluginOutputIdMapper() { } - virtual int idToIndex(std::string outputId) const { + virtual int idToIndex(std::string outputId) const noexcept { int n = int(m_ids.size()); int i = 0; while (i < n) { @@ -62,8 +62,8 @@ return i; } - virtual std::string indexToId(int index) const { - //!!! todo: this should in fact throw, or otherwise return an error + virtual std::string indexToId(int index) const noexcept { + if (index < 0 || size_t(index) >= m_ids.size()) return ""; return m_ids[index]; }