Skip to content

Commit

Permalink
Internals: constexpr for VlUnpacked data access (verilator#5725) (v…
Browse files Browse the repository at this point in the history
…erilator#5770)

Add `constexpr` to data access functions of `VlUnpacked` whose `std::array` equivalent in C++14 is `constexpr`.
  • Loading branch information
trungnt2910 authored Feb 10, 2025
1 parent cc1133c commit aa3942a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ Todd Strader
Tomasz Gorochowik
Topa Topino
Toru Niina
Trung Nguyen
Tudor Timi
Tymoteusz Blazejczyk
Udi Finkelstein
Expand Down
4 changes: 2 additions & 2 deletions include/verilated_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ class VlUnpacked final {
WData* data() { return &m_storage[0]; }
const WData* data() const { return &m_storage[0]; }

std::size_t size() const { return N_Depth; }
constexpr std::size_t size() const { return N_Depth; }
// To fit C++14
template <std::size_t N_CurrentDimension = 0, typename U = T_Value>
int find_length(int dimension, std::false_type) const {
Expand Down Expand Up @@ -1357,7 +1357,7 @@ class VlUnpacked final {
}

T_Value& operator[](size_t index) { return m_storage[index]; }
const T_Value& operator[](size_t index) const { return m_storage[index]; }
constexpr const T_Value& operator[](size_t index) const { return m_storage[index]; }

// *this != that, which might be used for change detection/trigger computation, but avoid
// operator overloading in VlUnpacked for safety in other contexts.
Expand Down

0 comments on commit aa3942a

Please sign in to comment.