32class virtual_2d_locator
35 virtual_2d_locator<DerefFn, IsTransposed>,
36 position_iterator<DerefFn, IsTransposed>,
37 position_iterator<DerefFn, 1-IsTransposed>
40 using this_t = virtual_2d_locator<DerefFn, IsTransposed>;
44 virtual_2d_locator<DerefFn, IsTransposed>,
48 using const_t = virtual_2d_locator<typename DerefFn::const_t, IsTransposed>;
49 using deref_fn_t = DerefFn;
50 using point_t =
typename parent_t::point_t;
51 using coord_t =
typename parent_t::coord_t;
52 using x_coord_t =
typename parent_t::x_coord_t;
53 using y_coord_t =
typename parent_t::y_coord_t;
54 using x_iterator =
typename parent_t::x_iterator;
55 using y_iterator =
typename parent_t::y_iterator;
57 template <
typename NewDerefFn>
60 using type = virtual_2d_locator<deref_compose<NewDerefFn, DerefFn>, IsTransposed>;
62 static type make(this_t
const& loc, NewDerefFn
const& new_deref_fn)
64 return type(loc.pos(), loc.step(),
70 point_t
const& p = {0, 0},
71 point_t
const& step = {1, 1},
72 deref_fn_t
const& deref_fn = deref_fn_t())
73 : y_pos_(p, step, deref_fn)
76 template <
typename D,
bool TR>
77 virtual_2d_locator(virtual_2d_locator<D, TR>
const &loc, coord_t y_step)
78 : y_pos_(loc.pos(), point_t(loc.step().x, loc.step().y * y_step), loc.deref_fn())
81 template <
typename D,
bool TR>
82 virtual_2d_locator(virtual_2d_locator<D, TR>
const& loc, coord_t x_step, coord_t y_step,
bool transpose =
false)
85 point_t(loc.step().x * y_step, loc.step().y * x_step) :
86 point_t(loc.step().x * x_step, loc.step().y * y_step)
89 BOOST_ASSERT(transpose == (IsTransposed != TR));
92 template <
typename D,
bool TR>
93 virtual_2d_locator(virtual_2d_locator<D, TR>
const& other) : y_pos_(other.y_pos_) {}
95 virtual_2d_locator(virtual_2d_locator
const& other) : y_pos_(other.y_pos_) {}
96 virtual_2d_locator& operator=(virtual_2d_locator
const& other) =
default;
98 bool operator==(
const this_t& p)
const {
return y_pos_ == p.y_pos_; }
100 auto x() -> x_iterator&
102 return *gil_reinterpret_cast<x_iterator*>(
this);
105 auto x()
const -> x_iterator
const&
107 return *gil_reinterpret_cast_c<x_iterator const*>(
this);
110 auto y() -> y_iterator& {
return y_pos_; }
111 auto y()
const -> y_iterator
const& {
return y_pos_; }
116 return (it2.pos()[1 - IsTransposed] - pos()[1 - IsTransposed])
117 / step()[1 - IsTransposed];
125 auto pos() const -> point_t const& {
return y_pos_.pos(); }
126 auto step() const -> point_t const& {
return y_pos_.step(); }
127 auto deref_fn() const -> deref_fn_t const& {
return y_pos_.deref_fn(); }
130 template <
typename D,
bool TR>
131 friend class virtual_2d_locator;
auto y_distance_to(this_t const &it2, x_coord_t) const -> y_coord_t
Returns the y distance between two x_iterators given the difference of their x positions.
Definition virtual_locator.hpp:114