Skip to content

Commit

Permalink
[core] Fixed std::runtime_error usage (use C++03 version instead of C…
Browse files Browse the repository at this point in the history
…++11) (#2184)
  • Loading branch information
maxsharabayko authored Nov 12, 2021
1 parent e4a1d2b commit 5f3cd06
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion srtcore/strerror_defs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const char* strerror_get_message(size_t major, size_t minor)
}

const char** array = strerror_array_major[major];
size_t size = strerror_array_sizes[major];
const size_t size = strerror_array_sizes[major];

if (minor >= size)
{
Expand Down
17 changes: 10 additions & 7 deletions srtcore/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ written by
#include <cstdlib>
#include <cerrno>
#include <cstring>
#include <stdexcept>

// -------------- UTILITIES ------------------------

Expand Down Expand Up @@ -418,7 +419,8 @@ class FixedArray
{
public:
FixedArray(size_t size)
: m_size(size)
: m_strIndexErr("FixedArray: invalid index")
, m_size(size)
, m_entries(new T[size])
{
}
Expand All @@ -432,31 +434,31 @@ class FixedArray
const T& operator[](size_t index) const
{
if (index >= m_size)
throw std::runtime_error("Invalid index");
throw std::runtime_error(m_strIndexErr);

return m_entries[index];
}

T& operator[](size_t index)
{
if (index >= m_size)
throw std::runtime_error("Invalid index");
throw std::runtime_error(m_strIndexErr);

return m_entries[index];
}

const T& operator[](int index) const
{
if (index < 0 || static_cast<size_t>(index) >= m_size)
throw std::runtime_error("Invalid index");
throw std::runtime_error(m_strIndexErr);

return m_entries[index];
}

T& operator[](int index)
{
if (index < 0 || static_cast<size_t>(index) >= m_size)
throw std::runtime_error("Invalid index");
throw std::runtime_error(m_strIndexErr);

return m_entries[index];
}
Expand All @@ -468,8 +470,9 @@ class FixedArray
FixedArray<T>& operator=(const FixedArray<T>&);

private:
size_t m_size;
T* const m_entries;
const char* m_strIndexErr;
size_t m_size;
T* const m_entries;
};

} // namespace srt
Expand Down

0 comments on commit 5f3cd06

Please sign in to comment.