Skip to content

Commit 5f3cd06

Browse files
[core] Fixed std::runtime_error usage (use C++03 version instead of C++11) (#2184)
1 parent e4a1d2b commit 5f3cd06

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

srtcore/strerror_defs.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ const char* strerror_get_message(size_t major, size_t minor)
140140
}
141141

142142
const char** array = strerror_array_major[major];
143-
size_t size = strerror_array_sizes[major];
143+
const size_t size = strerror_array_sizes[major];
144144

145145
if (minor >= size)
146146
{

srtcore/utilities.h

+10-7
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ written by
4444
#include <cstdlib>
4545
#include <cerrno>
4646
#include <cstring>
47+
#include <stdexcept>
4748

4849
// -------------- UTILITIES ------------------------
4950

@@ -418,7 +419,8 @@ class FixedArray
418419
{
419420
public:
420421
FixedArray(size_t size)
421-
: m_size(size)
422+
: m_strIndexErr("FixedArray: invalid index")
423+
, m_size(size)
422424
, m_entries(new T[size])
423425
{
424426
}
@@ -432,31 +434,31 @@ class FixedArray
432434
const T& operator[](size_t index) const
433435
{
434436
if (index >= m_size)
435-
throw std::runtime_error("Invalid index");
437+
throw std::runtime_error(m_strIndexErr);
436438

437439
return m_entries[index];
438440
}
439441

440442
T& operator[](size_t index)
441443
{
442444
if (index >= m_size)
443-
throw std::runtime_error("Invalid index");
445+
throw std::runtime_error(m_strIndexErr);
444446

445447
return m_entries[index];
446448
}
447449

448450
const T& operator[](int index) const
449451
{
450452
if (index < 0 || static_cast<size_t>(index) >= m_size)
451-
throw std::runtime_error("Invalid index");
453+
throw std::runtime_error(m_strIndexErr);
452454

453455
return m_entries[index];
454456
}
455457

456458
T& operator[](int index)
457459
{
458460
if (index < 0 || static_cast<size_t>(index) >= m_size)
459-
throw std::runtime_error("Invalid index");
461+
throw std::runtime_error(m_strIndexErr);
460462

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

470472
private:
471-
size_t m_size;
472-
T* const m_entries;
473+
const char* m_strIndexErr;
474+
size_t m_size;
475+
T* const m_entries;
473476
};
474477

475478
} // namespace srt

0 commit comments

Comments
 (0)