3 #if !defined(CPPLINQ_LINQ_TAKE_HPP) 4 #define CPPLINQ_LINQ_TAKE_HPP 11 template <
class InnerCursor>
21 bool empty()
const {
return cur.empty() || rem == 0; }
22 void inc() { cur.inc(); --rem; }
23 reference_type
get()
const {
return cur.get(); }
25 bool atbegin()
const {
return cur.atbegin(); }
26 void dec() { cur.dec(); --rem; }
28 void skip(std::size_t n) { cur.skip(n); rem -= n; }
29 std::size_t
position()
const {
return cur.position(); }
30 std::size_t
size()
const {
return cur.size(); }
38 template <
class Collection>
49 template <
class Collection>
50 typename Collection::cursor
57 auto cur = c.get_cursor();
65 template <
class Collection>
68 typedef typename std::conditional<
71 typename Collection::cursor::cursor_category>::value,
72 typename Collection::cursor,
76 linq_take(
const Collection& c, std::size_t n) : c(c), n(n) {}
79 return detail::take_get_cursor_(c, n,
typename Collection::cursor::cursor_category());
86 template <
class Collection>
90 -> decltype(get_cursor_(
take,
typename Collection::cursor::cursor_category()))
92 return get_cursor_(
take,
typename Collection::cursor::cursor_category());
97 #endif // !defined(CPPLINQ_LINQ_TAKE_HPP) std::conditional< util::less_or_equal_cursor_category< random_access_cursor_tag, typename Collection::cursor::cursor_category >::value, typename Collection::cursor, linq_take_cursor< typename Collection::cursor > >::type cursor
Definition: linq_take.hpp:74
cursor get_cursor() const
Definition: linq_take.hpp:78
std::size_t position() const
Definition: linq_take.hpp:29
Definition: linq_cursor.hpp:63
InnerCursor::cursor_category cursor_category
Definition: linq_take.hpp:16
InnerCursor::reference_type reference_type
Definition: linq_take.hpp:15
Definition: linq_cursor.hpp:66
Definition: linq_take.hpp:66
Definition: linq_take.hpp:12
Collection c
Definition: linq_take.hpp:82
void inc()
Definition: linq_take.hpp:22
void skip(std::size_t n)
Definition: linq_take.hpp:28
linq_take(const Collection &c, std::size_t n)
Definition: linq_take.hpp:76
bool atbegin() const
Definition: linq_take.hpp:25
std::size_t n
Definition: linq_take.hpp:83
Definition: linq_cursor.hpp:107
auto take(AN &&...an) -> operator_factory< take_tag, AN... >
For the first count items from this observable emit them from the new observable that is returned...
Definition: rx-take.hpp:133
auto get_cursor(const linq_take< Collection > &take) -> decltype(get_cursor_(take, typename Collection::cursor::cursor_category()))
Definition: linq_take.hpp:87
std::size_t size() const
Definition: linq_take.hpp:30
void forget()
Definition: linq_take.hpp:20
InnerCursor::element_type element_type
Definition: linq_take.hpp:14
linq_take_cursor(const InnerCursor &cur, std::size_t rem)
Definition: linq_take.hpp:18
bool empty() const
Definition: linq_take.hpp:21
void dec()
Definition: linq_take.hpp:26