1 #ifndef TERMOX_COMMON_TRANFORM_VIEW_HPP
2 #define TERMOX_COMMON_TRANFORM_VIEW_HPP
7 #include <termox/common/transform_iterator.hpp>
15 template <
typename Container,
typename Map_fn>
19 std::invoke_result_t<Map_fn, typename Container::reference>;
20 using Reference_const =
21 std::invoke_result_t<Map_fn, typename Container::const_reference>;
25 : container_{c}, map_fn_{std::move(map_fn)}
29 [[nodiscard]]
auto size()
const -> std::size_t {
return container_.size(); }
31 [[nodiscard]]
auto is_empty()
const ->
bool {
return container_.empty(); }
33 [[nodiscard]]
auto operator[](std::size_t i)
const -> Reference_const
35 return map_fn_(container_[i]);
38 [[nodiscard]]
auto operator[](std::size_t i) -> Reference
40 return map_fn_(container_[i]);
43 [[nodiscard]]
auto front()
const -> Reference_const
45 return map_fn_(container_.front());
48 [[nodiscard]]
auto front() -> Reference
50 return map_fn_(container_.front());
53 [[nodiscard]]
auto back()
const -> Reference_const
55 return map_fn_(container_.back());
58 [[nodiscard]]
auto back() -> Reference
60 return map_fn_(container_.back());
63 [[nodiscard]]
auto begin()
const
68 [[nodiscard]]
auto begin()
73 [[nodiscard]]
auto end()
const
78 [[nodiscard]]
auto end()
84 Container& container_;