Skip to content

Commit

Permalink
[Warnings] Fixed Const Reference
Browse files Browse the repository at this point in the history
When a class returns a reference to a dereferenced pointer, if the
pointer does not point to a const object, returning that pointer as a
const has no effect. This was causing warnings.

To fix this, we want a refernece to a const object not a const reference
to an object (silly, I know). So we need to make this more clear in the
class.
  • Loading branch information
AlexandreSinger committed Aug 21, 2024
1 parent 5ee6721 commit ead1091
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libs/EXTERNAL/libtatum/libtatum/tatum/tags/TimingTags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class TimingTags {
using value_type = T;
using pointer = T*;
using reference = T&;
using const_reference = const T&;

Iterator(): p_(nullptr) {}
Iterator(pointer p): p_(p) {}
Expand All @@ -123,7 +124,7 @@ class TimingTags {
friend bool operator!=(Iterator a, Iterator b) { return a.p_ != b.p_; }

reference operator*() { return *p_; }
const reference operator*() const { return *p_; } //Required for MSVC (gcc/clang are fine with only the non-cost version)
const_reference operator*() const { return *p_; } //Required for MSVC (gcc/clang are fine with only the non-cost version)
pointer operator->() { return p_; }
reference operator[](size_t n) { return *(p_ + n); }

Expand Down

0 comments on commit ead1091

Please sign in to comment.