27 #ifndef MLN_VALUE_LABEL_HH
28 # define MLN_VALUE_LABEL_HH
34 # include <mln/debug/format.hh>
35 # include <mln/metal/math/pow.hh>
36 # include <mln/trait/value_.hh>
37 # include <mln/value/concept/symbolic.hh>
38 # include <mln/value/internal/value_like.hh>
39 # include <mln/value/internal/convert.hh>
40 # include <mln/value/internal/encoding.hh>
42 # include <mln/value/internal/make_generic_name.hh>
49 template <
unsigned n>
struct label;
50 template <
unsigned n>
struct int_u;
62 struct value_< mln::value::label<n> >
72 card = mln_value_card_from_(n)
75 typedef trait::value::nature::symbolic
nature;
76 typedef trait::value::kind::label
kind;
77 typedef mln_value_quant_from_(card) quant;
79 static const self_
min() {
return 0; }
80 static const self_
max() {
return mlc_pow_int(2, n) - 1; }
82 static const char* name()
89 typedef unsigned comp;
105 template <
unsigned n>
109 typename internal::encoding_unsigned_<n>::ret,
152 template <>
struct label<0>;
153 template <>
struct label<1>;
162 template <
unsigned n>
163 std::ostream& operator<<(std::ostream& ostr, const label<n>& l);
167 template <
unsigned n>
171 template <
unsigned n>
176 template <
unsigned n,
unsigned m>
180 template <
unsigned n>
184 template <
unsigned n>
191 # ifndef MLN_INCLUDE_ONLY
197 template <
unsigned n>
203 template <
unsigned n>
210 template <
unsigned n>
217 template <
unsigned n>
224 template <
unsigned n>
229 mln_precondition(i <= mln_max(
enc));
234 template <
unsigned n>
243 template <
unsigned n>
248 mln_precondition(this->v_ < mln_max(
enc));
253 template <
unsigned n>
258 mln_precondition(this->v_ != 0);
263 template <
unsigned n>
268 return label<n>(this->v_ + 1);
271 template <
unsigned n>
276 return label<n>(this->v_ - 1);
279 template <
unsigned n>
281 std::ostream& operator<<(std::ostream& ostr, const label<n>& i)
286 template <
unsigned n>
289 from_to_(
const value::int_u<n>& from, value::label<n>& to_)
294 template <
unsigned n>
296 from_to_(
const value::label<n>& from, value::int_u<n>& to_)
301 template <
unsigned n,
unsigned m>
304 from_to_(
const value::int_u<n>& from, value::label<m>& to_)
306 enum { valid = n < m };
307 metal::bool_<valid>::check();
311 template <
unsigned n>
314 from_to_(
const value::label<n>& from,
bool& to_)
319 template <
unsigned n>
322 from_to_(
const value::label<n>& from,
unsigned& to_)
330 # endif // ! MLN_INCLUDE_ONLY
335 #endif // ! MLN_VALUE_LABEL_HH