Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Fixed std::runtime_error usage (use C++03 version instead of C++11) #2184

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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