diff options
author | 2021-03-03 18:41:52 +0300 | |
---|---|---|
committer | 2021-03-04 14:55:20 +0300 | |
commit | 4049c2fccd33649aabad8e0af51918b212af40cb (patch) | |
tree | c60bfbd44ed2cc91c5fa060031ce1a492aa4bdd3 | |
parent | [dpc++][ranges] + range API for any_of, all_of, none_of, adjacent_find, count (diff) | |
download | llvm-project-4049c2fccd33649aabad8e0af51918b212af40cb.tar.gz llvm-project-4049c2fccd33649aabad8e0af51918b212af40cb.tar.bz2 llvm-project-4049c2fccd33649aabad8e0af51918b212af40cb.zip |
[nanorange] + "generate" factory, "fill" adapter
-rw-r--r-- | include/oneapi/dpl/pstl/ranges/nanorange.hpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/oneapi/dpl/pstl/ranges/nanorange.hpp b/include/oneapi/dpl/pstl/ranges/nanorange.hpp index a698b8096af5..0a4caf154dfd 100644 --- a/include/oneapi/dpl/pstl/ranges/nanorange.hpp +++ b/include/oneapi/dpl/pstl/ranges/nanorange.hpp @@ -19359,12 +19359,44 @@ struct transform_view_fn } }; +struct generate_view_fn +{ + template <typename G, typename Bound = unreachable_sentinel_t> + constexpr auto + operator()(G&& g, Bound size) const + { + return transform_view{iota_view{0, size}, [&g](auto) { return g(); }}; + } +}; + +struct fill_view_fn +{ + template <typename E, typename T> + constexpr auto + operator()(E&& e, T&& value) const + { + return transform_view{::std::forward<E>(e), [&value](auto) { return value; }}; + } + + template <typename T> + constexpr auto + operator()(T&& value) const + { + return detail::rao_proxy{[&value](auto&& r) mutable + { + return transform_view{::std::forward<decltype(r)>(r), [&value](auto) { return value; }}; + }}; + } +}; + } // namespace detail namespace views { NANO_INLINE_VAR(nano::detail::transform_view_fn, transform) +NANO_INLINE_VAR(nano::detail::generate_view_fn, generate) +NANO_INLINE_VAR(nano::detail::fill_view_fn, fill) } NANO_END_NAMESPACE |