Skip to content

Commit

Permalink
fix 5248
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Aug 2, 2018
1 parent 87d41b6 commit b4ae95e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
4 changes: 4 additions & 0 deletions far/changelog
@@ -1,3 +1,7 @@
drkns 03.08.2018 00:28:15 +0100 - build 5252

1. Уточнение 5248.

drkns 02.08.2018 19:06:57 +0100 - build 5251

1. Уточнение 5250.2.
Expand Down
45 changes: 41 additions & 4 deletions far/common/range.hpp
Expand Up @@ -270,15 +270,52 @@ namespace detail
{
return select_iterator<T, accessor>(Iterator, Accessor);
}

template<typename container, typename container_ref, typename accessor, typename accessor_ref, typename T>
class selector
{
public:
selector(container_ref Container, accessor_ref Accessor):
m_Container(FWD(Container)),
m_Accessor(FWD(Accessor))
{
}

auto begin() { return make(this); }
auto end() { return make(this); }
auto begin() const { return make(this); }
auto end() const { return make(this); }
auto cbegin() const { return make(this); }
auto cend() const { return make(this); }

private:
template<typename self>
static auto make(self Self)
{
return make_select_iterator(std::cend(Self->m_Container), Self->m_Accessor);
}

container m_Container;
accessor m_Accessor;
};

template<typename arg_type>
using stored_type = std::conditional_t<
std::is_rvalue_reference_v<arg_type>,
std::remove_reference_t<arg_type>,
std::add_lvalue_reference_t<std::remove_reference_t<arg_type>>
>;
}

template<typename container, typename accessor>
[[nodiscard]]
auto select(container&& Container, const accessor& Selector)
auto select(container&& Container, accessor&& Accessor)
{
return make_range(
detail::make_select_iterator(std::begin(Container), Selector),
detail::make_select_iterator(std::end(Container), Selector));
return detail::selector<
detail::stored_type<decltype(Container)>, decltype(Container),
detail::stored_type<decltype(Accessor)>, decltype(Accessor),
decltype(std::begin(Container))
>(FWD(Container), FWD(Accessor));
}

#endif // RANGE_HPP_3B87674F_96D1_487D_B83E_43E43EFBA4D3
2 changes: 1 addition & 1 deletion far/vbuild.m4
@@ -1 +1 @@
m4_define(BUILD,5251)m4_dnl
m4_define(BUILD,5252)m4_dnl

0 comments on commit b4ae95e

Please sign in to comment.