14 struct default_select_many_selector
16 template <
class T1,
class T2>
17 auto operator()(T1&& t1, T2&& t2) const
18 -> decltype(std::forward<T2>(t2))
20 return std::forward<T2>(t2);
27 template <
typename Fn,
typename Arg>
28 struct resolve_select_many_fn_return_type
30 typedef decltype(std::declval<Fn>()(std::declval<Arg>())) value;
33 template <typename TCol>
34 struct value_collection_adapter
36 value_collection_adapter(
const TCol& col)
39 value_collection_adapter(
const value_collection_adapter& src)
40 : _collection(src._collection) {}
42 value_collection_adapter(value_collection_adapter && src)
43 : _collection(std::move(src._collection)) {}
45 const TCol&
get()
const 59 template<
typename TCol>
60 struct collection_store_type
62 typedef typename std::remove_reference<TCol>::type collection_type;
63 typedef std::reference_wrapper<collection_type> reference_store_type;
64 typedef value_collection_adapter<collection_type> value_store_type;
66 typedef typename std::conditional<std::is_reference<TCol>::value, reference_store_type, value_store_type>::type store;
71 template <
class Container1,
class Fn,
class Fn2>
74 template <
class T>
static T instance();
80 typedef typename Container1::cursor Cur1;
81 typedef decltype(
from(instance<Fn>()(instance<Cur1>().
get()))) Container2;
82 typedef typename Container2::cursor Cur2;
84 typedef typename detail::resolve_select_many_fn_return_type<Fn, typename Cur1::element_type>::value inner_collection;
91 typename Cur2::cursor_category,
107 collection_store_ptr store;
110 cursor(Cur1 cur1,
const Fn& fn,
const Fn2& fn2)
111 : cur1(std::move(cur1)), fn(fn), fn2(fn2)
115 store = std::make_shared<collection_store>(fn(cur1.get()));
131 reference_type
get()
const 133 return fn2(cur1.get(), cur2.
get());
140 while (cur2.
empty() && !cur1.empty()) {
145 store = std::make_shared<collection_store>(fn(cur1.get()));
152 : c1(std::move(c1)), fn(std::move(fn)), fn2(std::move(fn2))
158 return cursor(c1.get_cursor(), fn, fn2);
linq_select_many(Container1 c1, Fn fn, Fn2 fn2)
Definition: linq_selectmany.hpp:151
Definition: linq_cursor.hpp:122
Cur2::element_type element_type
Definition: linq_selectmany.hpp:95
void inc()
Definition: linq_cursor.hpp:276
T get() const
Definition: linq_cursor.hpp:277
Definition: linq_selectmany.hpp:72
Definition: linq_selectmany.hpp:87
cursor get_cursor() const
Definition: linq_selectmany.hpp:156
linq_driver< iter_cursor< typename util::container_traits< TContainer >::iterator > > from(TContainer &c)
Definition: linq.hpp:556
Definition: linq_cursor.hpp:64
std::shared_ptr< collection_store > collection_store_ptr
Definition: linq_selectmany.hpp:99
bool empty() const
Definition: linq_selectmany.hpp:120
bool empty() const
Definition: linq_cursor.hpp:275
cursor(Cur1 cur1, const Fn &fn, const Fn2 &fn2)
Definition: linq_selectmany.hpp:110
auto get_cursor(const linq_take< Collection > &take) -> decltype(get_cursor_(take, typename Collection::cursor::cursor_category()))
Definition: linq_take.hpp:87
detail::collection_store_type< inner_collection > collection_store_type
Definition: linq_selectmany.hpp:97
Cur2::reference_type reference_type
Definition: linq_selectmany.hpp:94
util::min_cursor_category< typename Cur1::cursor_category, typename Cur2::cursor_category, forward_cursor_tag >::type cursor_category
Definition: linq_selectmany.hpp:93
collection_store_type::store collection_store
Definition: linq_selectmany.hpp:98
void inc()
Definition: linq_selectmany.hpp:125