File tree 2 files changed +11
-8
lines changed
2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ const char* strerror_get_message(size_t major, size_t minor)
140
140
}
141
141
142
142
const char ** array = strerror_array_major[major];
143
- size_t size = strerror_array_sizes[major];
143
+ const size_t size = strerror_array_sizes[major];
144
144
145
145
if (minor >= size)
146
146
{
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ written by
44
44
#include < cstdlib>
45
45
#include < cerrno>
46
46
#include < cstring>
47
+ #include < stdexcept>
47
48
48
49
// -------------- UTILITIES ------------------------
49
50
@@ -418,7 +419,8 @@ class FixedArray
418
419
{
419
420
public:
420
421
FixedArray (size_t size)
421
- : m_size(size)
422
+ : m_strIndexErr(" FixedArray: invalid index" )
423
+ , m_size(size)
422
424
, m_entries(new T[size])
423
425
{
424
426
}
@@ -432,31 +434,31 @@ class FixedArray
432
434
const T& operator [](size_t index) const
433
435
{
434
436
if (index >= m_size)
435
- throw std::runtime_error (" Invalid index " );
437
+ throw std::runtime_error (m_strIndexErr );
436
438
437
439
return m_entries[index ];
438
440
}
439
441
440
442
T& operator [](size_t index)
441
443
{
442
444
if (index >= m_size)
443
- throw std::runtime_error (" Invalid index " );
445
+ throw std::runtime_error (m_strIndexErr );
444
446
445
447
return m_entries[index ];
446
448
}
447
449
448
450
const T& operator [](int index) const
449
451
{
450
452
if (index < 0 || static_cast <size_t >(index ) >= m_size)
451
- throw std::runtime_error (" Invalid index " );
453
+ throw std::runtime_error (m_strIndexErr );
452
454
453
455
return m_entries[index ];
454
456
}
455
457
456
458
T& operator [](int index)
457
459
{
458
460
if (index < 0 || static_cast <size_t >(index ) >= m_size)
459
- throw std::runtime_error (" Invalid index " );
461
+ throw std::runtime_error (m_strIndexErr );
460
462
461
463
return m_entries[index ];
462
464
}
@@ -468,8 +470,9 @@ class FixedArray
468
470
FixedArray<T>& operator =(const FixedArray<T>&);
469
471
470
472
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;
473
476
};
474
477
475
478
} // namespace srt
You can’t perform that action at this time.
0 commit comments