Skip to content

Commit

Permalink
Fixed const correctness in static range.
Browse files Browse the repository at this point in the history
  • Loading branch information
5cript committed Jan 22, 2024
1 parent 3835d2f commit 04b8031
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nui/include/nui/frontend/event_system/range.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ namespace Nui
}

template <typename ContainerT>
UnoptimizedRange<IteratorAccessor<ContainerT>> range(ContainerT const& container)
UnoptimizedRange<IteratorAccessor<ContainerT const>> range(ContainerT const& container)
{
return UnoptimizedRange<IteratorAccessor<ContainerT>>{
IteratorAccessor<ContainerT>{container},
return UnoptimizedRange<IteratorAccessor<ContainerT const>>{
IteratorAccessor<ContainerT const>{container},
};
}

Expand Down
8 changes: 8 additions & 0 deletions nui/include/nui/utility/iterator_accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,12 @@ namespace Nui
private:
ContainerT* container_;
};

// Deduction guide for const ContainerT
template <typename ContainerT>
IteratorAccessor(ContainerT const&) -> IteratorAccessor<const ContainerT>;

// Deduction guide for non-const ContainerT
template <typename ContainerT>
IteratorAccessor(ContainerT&) -> IteratorAccessor<ContainerT>;
}

0 comments on commit 04b8031

Please sign in to comment.