Skip to content

Commit 248ae5f

Browse files
committed
Safer memeory access in debug
1 parent f51bac0 commit 248ae5f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/dsm/headers/Agent.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "../utility/Logger.hpp"
1717
#include "../utility/Typedef.hpp"
1818

19+
#include <cassert>
1920
#include <concepts>
2021
#include <limits>
2122
#include <optional>
@@ -103,7 +104,7 @@ namespace dsm {
103104
Id id() const { return m_id; }
104105
/// @brief Get the agent's itinerary
105106
/// @return The agent's itinerary
106-
Id itineraryId() const { return m_trip[m_itineraryIdx]; }
107+
Id itineraryId() const;
107108
/// @brief Get the agent's trip
108109
/// @return The agent's trip
109110
std::vector<Id> const& trip() const { return m_trip; }
@@ -155,6 +156,13 @@ namespace dsm {
155156
m_time{0},
156157
m_itineraryIdx{0} {}
157158

159+
template <typename delay_t>
160+
requires(is_numeric_v<delay_t>)
161+
Id Agent<delay_t>::itineraryId() const {
162+
assert(m_itineraryIdx < m_trip.size());
163+
return m_trip[m_itineraryIdx];
164+
}
165+
158166
template <typename delay_t>
159167
requires(is_numeric_v<delay_t>)
160168
void Agent<delay_t>::setSpeed(double speed) {

0 commit comments

Comments
 (0)