Commit 684efc9e authored by Thierry Geraud's avatar Thierry Geraud
Browse files

2006-09-15 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>

	Add operator- to n-dimensional dpoint types.
	
	* oln/core/traits_id.hh (op_uminus_dpointnd): New.
	* oln/core/abstract/dpoint_nd.hh (operator-): New.
	(impl_less): New.
	(case_): New case for operator-.
	* oln/core/2d/dpoint2d.hh (dpoint2d_): New ctor.



git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@544 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 9a61ee62
2006-09-15 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>
Add operator- to n-dimensional dpoint types.
* oln/core/traits_id.hh (op_uminus_dpointnd): New.
* oln/core/abstract/dpoint_nd.hh (operator-): New.
(impl_less): New.
(case_): New case for operator-.
* oln/core/2d/dpoint2d.hh (dpoint2d_): New ctor.
2006-09-15 Roland Levillain <roland@lrde.epita.fr>
Add a missing file to the distribution.
......
......@@ -79,6 +79,12 @@ namespace oln
{
}
/// Ctor.
dpoint2d_(coord_t row, coord_t col)
: super_t(xtd::mk_vec(row, col))
{
}
coord_t row() const { return v_[0]; }
coord_t& row() { return v_[0]; }
......
......@@ -31,6 +31,7 @@
# include <mlc/value.hh>
# include <xtd/vec.hh>
# include <stc/exact.hh>
# include <oln/core/abstract/dpoint.hh>
......@@ -55,6 +56,7 @@ namespace oln
template <typename E>
class dpoint_nd : public abstract::dpoint<E>
{
typedef E exact_t;
typedef dpoint_nd<E> self_t;
typedef oln_type_of(E, dim) dim;
typedef oln_type_of(E, coord) coord_t;
......@@ -85,6 +87,17 @@ namespace oln
return v_;
}
exact_t operator-() const
{
exact_t tmp(-v_);
return tmp;
}
bool impl_less(const self_t& rhs) const
{
return xtd::lexi_less(v_, rhs.vec());
}
protected:
/// Ctor.
......@@ -102,6 +115,18 @@ namespace oln
} // end of namespace oln::abstract
/// - abstract::dpoint_nd
template <typename D>
struct case_ < xtd::op_uminus, D,
oln::id::op_uminus_dpointnd >
: where_< mlc_is_a(D, abstract::dpoint_nd) >
{
typedef stc_to_exact(D) ret;
};
} // end of namespace oln
......
......@@ -39,7 +39,7 @@ namespace oln
/// \{
/// Identifiers for oln operators +.
/// Identifiers for oln binary operators +.
enum {
op_plus_pointnd_dpointnd = 1
......@@ -50,7 +50,7 @@ namespace oln
/// \{
/// Identifiers for oln operators -.
/// Identifiers for oln binary operators -.
enum {
op_minus_pointnd_pointnd = 1,
......@@ -60,6 +60,17 @@ namespace oln
/// \}
/// \{
/// Identifiers for oln unary operators -.
enum {
op_uminus_dpointnd = 1
};
/// \}
} // end of namespace oln::id
} // end of namespace oln
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment