27 #ifndef MLN_UTIL_OBJECT_ID_HH
28 # define MLN_UTIL_OBJECT_ID_HH
35 # include <mln/core/concept/object.hh>
36 # include <mln/value/concept/integer.hh>
37 # include <mln/metal/abort.hh>
43 namespace util {
template <
typename Tag,
typename V>
class object_id; }
52 template <
typename Tag,
typename V>
53 void from_to_(
const util::object_id<Tag,V>& from, V& to_);
66 template <
typename Tag,
typename V>
72 typedef unsigned equiv;
79 template <
typename V2>
82 template <
typename Tag2,
typename V2>
86 template <
typename V2>
89 const V& value()
const;
92 operator unsigned()
const;
94 bool is_valid()
const;
97 unsigned to_equiv()
const;
104 template <
typename Tag,
typename V>
108 template <
typename Tag,
typename V,
typename V2>
114 # ifndef MLN_INCLUDE_ONLY
119 template <
typename Tag,
typename V>
126 template <
typename Tag,
typename V>
127 template <
typename V2>
132 mlc_converts_to(V2,V)::check();
135 template <
typename Tag,
typename V>
136 template <
typename Tag2,
typename V2>
141 typedef object_id<Tag2,V2> id_t;
142 mlc_abort(id_t)::check();
145 template <
typename Tag,
typename V>
146 template <
typename V2>
149 object_id<Tag,V>::operator=(
const V2& v)
151 mlc_converts_to(V2,V)::check();
157 template <
typename Tag,
typename V>
160 object_id<Tag,V>::value()
165 template <
typename Tag,
typename V>
168 object_id<Tag,V>::value()
const
173 template <
typename Tag,
typename V>
175 object_id<Tag,V>::operator unsigned()
const
181 template <
typename Tag,
typename V>
184 object_id<Tag,V>::is_valid()
const
186 return id_ != mln_max(V);
189 template <
typename Tag,
typename V>
192 object_id<Tag,V>::invalidate()
197 template <
typename Tag,
typename V>
200 object_id<Tag,V>::to_equiv()
const
207 template <
typename Tag,
typename V,
typename V2>
210 operator==(
const object_id<Tag,V>& lhs,
const Value<V2>& rhs)
212 return lhs.value() == exact(rhs).to_equiv();
215 template <
typename Tag,
typename V>
218 operator==(
const object_id<Tag,V>& lhs,
const object_id<Tag,V>& rhs)
220 return lhs.value() == rhs.value();
223 template <
typename Tag,
typename V>
226 operator<(const object_id<Tag,V>& lhs,
const object_id<Tag,V>& rhs)
228 return lhs.value() < rhs.value();
240 template <
typename Tag,
typename V>
241 void from_to_(
const util::object_id<Tag,V>& from, V& to_)
250 # endif // ! MLN_INCLUDE_ONLY
254 #endif // ! MLN_UTIL_OBJECT_ID_HH