31class virtual_2d_locator
34 virtual_2d_locator<DerefFn, IsTransposed>,
35 position_iterator<DerefFn, IsTransposed>,
36 position_iterator<DerefFn, 1-IsTransposed>
39 using this_t = virtual_2d_locator<DerefFn, IsTransposed>;
43 virtual_2d_locator<DerefFn, IsTransposed>,
47 using const_t = virtual_2d_locator<typename DerefFn::const_t, IsTransposed>;
48 using deref_fn_t = DerefFn;
49 using point_t =
typename parent_t::point_t;
50 using coord_t =
typename parent_t::coord_t;
51 using x_coord_t =
typename parent_t::x_coord_t;
52 using y_coord_t =
typename parent_t::y_coord_t;
53 using x_iterator =
typename parent_t::x_iterator;
54 using y_iterator =
typename parent_t::y_iterator;
56 template <
typename NewDerefFn>
59 using type = virtual_2d_locator<deref_compose<NewDerefFn, DerefFn>, IsTransposed>;
61 static type make(this_t
const& loc, NewDerefFn
const& new_deref_fn)
63 return type(loc.pos(), loc.step(),
69 point_t
const& p = {0, 0},
70 point_t
const& step = {1, 1},
71 deref_fn_t
const& deref_fn = deref_fn_t())
72 : y_pos_(p, step, deref_fn)
75 template <
typename D,
bool TR>
76 virtual_2d_locator(virtual_2d_locator<D, TR>
const &loc, coord_t y_step)
77 : y_pos_(loc.pos(), point_t(loc.step().x, loc.step().y * y_step), loc.deref_fn())
80 template <
typename D,
bool TR>
81 virtual_2d_locator(virtual_2d_locator<D, TR>
const& loc, coord_t x_step, coord_t y_step,
bool transpose =
false)
84 point_t(loc.step().x * y_step, loc.step().y * x_step) :
85 point_t(loc.step().x * x_step, loc.step().y * y_step)
88 BOOST_ASSERT(transpose == (IsTransposed != TR));
91 template <
typename D,
bool TR>
92 virtual_2d_locator(virtual_2d_locator<D, TR>
const& other) : y_pos_(other.y_pos_) {}
94 virtual_2d_locator(virtual_2d_locator
const& other) : y_pos_(other.y_pos_) {}
95 virtual_2d_locator& operator=(virtual_2d_locator
const& other) =
default;
97 bool operator==(
const this_t& p)
const {
return y_pos_ == p.y_pos_; }
99 auto x() -> x_iterator&
101 return *gil_reinterpret_cast<x_iterator*>(
this);
104 auto x()
const -> x_iterator
const&
106 return *gil_reinterpret_cast_c<x_iterator const*>(
this);
109 auto y() -> y_iterator& {
return y_pos_; }
110 auto y()
const -> y_iterator
const& {
return y_pos_; }
115 return (it2.pos()[1 - IsTransposed] - pos()[1 - IsTransposed])
116 / step()[1 - IsTransposed];
124 auto pos() const -> point_t const& {
return y_pos_.pos(); }
125 auto step() const -> point_t const& {
return y_pos_.step(); }
126 auto deref_fn() const -> deref_fn_t const& {
return y_pos_.deref_fn(); }
129 template <
typename D,
bool TR>
130 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:113