26 #ifndef MLN_VALUE_INTERNAL_CONVERT_HH
27 # define MLN_VALUE_INTERNAL_CONVERT_HH
33 # include <mln/core/contract.hh>
34 # include <mln/trait/value_.hh>
51 static T value_at_index(
unsigned i);
52 static unsigned index_of_value(
const T& v);
59 static bool value_at_index(
unsigned i);
60 static unsigned index_of_value(
bool v);
64 # ifndef MLN_INCLUDE_ONLY
69 convert_<T>::value_at_index(
unsigned i)
71 return T(
int(mln_min(T)) +
int(i) );
77 convert_<T>::index_of_value(
const T& v)
79 return unsigned(
int(v) -
int(mln_min(T)) );
86 convert_<bool>::value_at_index(
unsigned i)
88 mln_precondition(i < 2);
89 return i == 1 ?
true :
false;
94 convert_<bool>::index_of_value(
bool v)
99 # endif // ! MLN_INCLUDE_ONLY
108 #endif // ! MLN_VALUE_INTERNAL_CONVERT_HH