
2005-04-05 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr> Conform to mlc. * ntg/core/math.hh: Delete cause redundant with mlc/arith.hh. * ntg/real/int_s.hh: Update. * ntg/real/int_u.hh: Likewise. * ntg/real/behavior.hh: Likewise. * ntg/core/macros.hh: Likewise. * ntg/core/pred_succ.hh: Likewise. * ntg/core/internal/global_ops_traits.hh: Likewise. Index: ntg/real/int_s.hh =================================================================== --- ntg/real/int_s.hh (revision 111) +++ ntg/real/int_s.hh (working copy) @@ -35,7 +35,7 @@ # include <ntg/real/int_u.hh> # include <mlc/bool.hh> -# include <mlc/cmp.hh> +# include <mlc/arith.hh> # include <mlc/is_a.hh> # include <string> @@ -356,8 +356,8 @@ struct operator_traits<operator_plus, int_s<nbits, B1>, int_s<mbits, B2> > { enum { commutative = true, - need_check = ((unsigned) mlc::max<nbits, mbits>::ret >= 32) }; - typedef int_s<(unsigned)mlc::maxN<nbits + 1,mbits + 1, 32>::ret, + need_check = (mlc::on<unsigned>::max<nbits, mbits>::ret >= 32) }; + typedef int_s<mlc::on<unsigned>::maxN<nbits + 1,mbits + 1, 32>::ret, typename deduce_op_behavior<B1, B2>::ret> ret; typedef int_s<nbits, typename ret_behavior_if<need_check, ret>::ret> impl; @@ -371,7 +371,7 @@ { enum { commutative = true, need_check = ((mbits >= 31) || (nbits >= 32)) }; - typedef int_s<(unsigned)mlc::maxN<nbits + 1,mbits + 2, 32>::ret, + typedef int_s<mlc::on<unsigned>::maxN<nbits + 1,mbits + 2, 32>::ret, typename deduce_op_behavior<B1, B2>::ret> ret; typedef int_s<nbits, typename ret_behavior_if<need_check, ret>::ret> impl; @@ -389,7 +389,7 @@ { enum { commutative = true, need_check = ((mbits >= 31) || (nbits >= 31)) }; - typedef int_s<(unsigned)mlc::maxN<nbits + 1, mbits + 1, 32>::ret, + typedef int_s<mlc::on<unsigned>::maxN<nbits + 1, mbits + 1, 32>::ret, typename deduce_op_behavior<B1, B2>::ret> ret; typedef int_s<nbits, typename ret_behavior_if<need_check, ret>::ret> impl; @@ -402,7 +402,7 @@ { enum { commutative = true, need_check = ((mbits >= 31) || (nbits >= 32)) }; - typedef int_s<(unsigned)mlc::maxN<nbits + 1, mbits + 2, 32>::ret, + typedef int_s<mlc::on<unsigned>::maxN<nbits + 1, mbits + 2, 32>::ret, typename deduce_op_behavior<B1, B2>::ret> ret; typedef int_s<nbits, typename ret_behavior_if<need_check, ret>::ret> impl; @@ -420,7 +420,7 @@ { enum { commutative = true, need_check = (mbits + nbits > 32) }; - typedef int_s<(unsigned)mlc::saturateN<nbits + mbits, 32>::ret, + typedef int_s<mlc::on<unsigned>::saturateN<nbits + mbits, 32>::ret, typename deduce_op_behavior<B1, B2>::ret> ret; typedef int_s<nbits, typename ret_behavior_if<need_check, ret>::ret> impl; @@ -434,7 +434,7 @@ { enum { commutative = true, need_check = (nbits + mbits + 1 > 32)}; - typedef int_s<(unsigned)mlc::saturateN<nbits + mbits+1, 32>::ret, + typedef int_s<mlc::on<unsigned>::saturateN<nbits + mbits+1, 32>::ret, typename deduce_op_behavior<B1, B2>::ret> ret; typedef int_s<nbits, typename ret_behavior_if<need_check, ret>::ret> impl; @@ -471,7 +471,7 @@ { enum { commutative = false, need_check = (mbits >= 32) }; - typedef int_s<mlc::saturateN<mbits + 1, 32>::ret, + typedef int_s<mlc::on<unsigned>::saturateN<mbits + 1, 32>::ret, typename deduce_op_behavior<B1, B2>::ret> ret; typedef int_s<nbits, typename ret_behavior_if<need_check, ret>::ret> impl; @@ -498,7 +498,7 @@ { enum { commutative = false, need_check = (mbits >= 32) }; - typedef int_s<(unsigned)mlc::saturateN<mbits + 1, 32>::ret, + typedef int_s<mlc::on<unsigned>::saturateN<mbits + 1, 32>::ret, typename deduce_op_behavior<B1, B2>::ret> ret; typedef int_s<nbits, typename ret_behavior_if<need_check, ret>::ret> impl; @@ -528,7 +528,7 @@ struct operator_traits<operator_min, int_s<nbits, B1>, int_s<mbits, B2> > { enum { commutative = true }; - typedef int_s<(unsigned) mlc::min<nbits, mbits>::ret, + typedef int_s<mlc::on<unsigned>::min<nbits, mbits>::ret, typename deduce_op_behavior<B1, B2>::ret> ret; typedef int_s<nbits, force> impl; }; @@ -543,7 +543,7 @@ struct operator_traits<operator_max, int_s<nbits, B1>, int_s<mbits, B2> > { enum { commutative = true }; - typedef int_s<(unsigned) mlc::max<nbits, mbits>::ret, + typedef int_s<mlc::on<unsigned>::max<nbits, mbits>::ret, typename deduce_op_behavior<B1, B2>::ret> ret; typedef int_s<nbits, force> impl; }; @@ -558,7 +558,7 @@ struct operator_traits<operator_cmp, int_s<nbits, B1>, int_s<mbits, B2> > { enum { commutative = true }; - typedef int_s<(unsigned)mlc::maxN<nbits,mbits,32>::ret, unsafe> ret; + typedef int_s<mlc::on<unsigned>::maxN<nbits,mbits,32>::ret, unsafe> ret; typedef int_s<nbits, force> impl; }; @@ -569,7 +569,7 @@ struct operator_traits<operator_cmp, int_s<nbits, B1>, int_u<mbits, B2> > { enum { commutative = true }; - typedef int_s<(unsigned)mlc::maxN<nbits,mbits+1, 32>::ret, unsafe> ret; + typedef int_s<mlc::on<unsigned>::maxN<nbits,mbits+1, 32>::ret, unsafe> ret; typedef int_s<nbits, force> impl; }; Index: ntg/real/int_u.hh =================================================================== --- ntg/real/int_u.hh (revision 111) +++ ntg/real/int_u.hh (working copy) @@ -34,7 +34,7 @@ # include <ntg/bin.hh> # include <mlc/bool.hh> -# include <mlc/cmp.hh> +# include <mlc/arith.hh> # include <mlc/is_a.hh> # include <string> @@ -97,7 +97,7 @@ typedef self base_type; typedef typename C_for_int_u<nbits>::type storage_type; - typedef int_s<mlc::saturateN<nbits+1, 32>::ret, + typedef int_s<mlc::on<unsigned>::saturateN<nbits+1, 32>::ret, behavior> signed_type; typedef self unsigned_type; // FIXME: calculate it more precisely @@ -279,8 +279,8 @@ struct operator_traits<operator_plus, int_u<nbits, B1>, int_u<mbits, B2> > { enum { commutative = true, - need_check = ((unsigned) mlc::max<nbits, mbits>::ret >= 32) }; - typedef int_u<(unsigned) mlc::maxN<nbits + 1, mbits + 1, 32>::ret, + need_check = (mlc::on<unsigned>::max<nbits, mbits>::ret >= 32) }; + typedef int_u<mlc::on<unsigned>::maxN<nbits + 1, mbits + 1, 32>::ret, typename deduce_op_behavior<B1, B2>::ret> ret; typedef int_u<nbits, typename ret_behavior_if<need_check, ret>::ret> impl; @@ -296,8 +296,8 @@ struct operator_traits<operator_minus, int_u<nbits, B1>, int_u<mbits, B2> > { enum { commutative = true, - need_check = ((unsigned) mlc::max<nbits, mbits>::ret >= 32) }; - typedef int_s<(unsigned) mlc::maxN<nbits+1, mbits+1, 32>::ret, + need_check = (mlc::on<unsigned>::max<nbits, mbits>::ret >= 32) }; + typedef int_s<mlc::on<unsigned>::maxN<nbits+1, mbits+1, 32>::ret, typename deduce_op_behavior<B1, B2>::ret> ret; typedef int_u<nbits, typename ret_behavior_if<need_check, ret>::ret> impl; @@ -324,7 +324,7 @@ struct operator_traits<operator_times, int_u<nbits, B1>, int_u<mbits, B2> > { enum { commutative = true, need_check = (nbits + mbits > 32) }; - typedef int_u<(unsigned) mlc::saturateN<nbits + mbits, 32>::ret, + typedef int_u<mlc::on<unsigned>::saturateN<nbits + mbits, 32>::ret, typename deduce_op_behavior<B1, B2>::ret> ret; typedef int_u<nbits, typename ret_behavior_if<need_check, ret>::ret> impl; @@ -368,7 +368,7 @@ struct operator_traits<operator_min, int_u<nbits, B1>, int_u<mbits, B2> > { enum { commutative = true }; - typedef int_u<(unsigned) mlc::min<nbits, mbits>::ret, + typedef int_u<mlc::on<unsigned>::min<nbits, mbits>::ret, typename deduce_op_behavior<B1, B2>::ret> ret; typedef int_u<nbits, force> impl; }; @@ -384,7 +384,7 @@ struct operator_traits<operator_max, int_u<nbits, B1>, int_u<mbits, B2> > { enum { commutative = true }; - typedef int_u<(unsigned) mlc::max<nbits, mbits>::ret, + typedef int_u<mlc::on<unsigned>::max<nbits, mbits>::ret, typename deduce_op_behavior<B1, B2>::ret> ret; typedef int_u<nbits, force> impl; }; @@ -401,7 +401,7 @@ { enum { commutative = true }; // FIXME: why unsafe? I think there is a reason. - typedef int_u<(unsigned) mlc::maxN<nbits, mbits, 32>::ret, unsafe> ret; + typedef int_u<mlc::on<unsigned>::maxN<nbits, mbits, 32>::ret, unsafe> ret; typedef int_u<nbits, force> impl; }; Index: ntg/real/behavior.hh =================================================================== --- ntg/real/behavior.hh (revision 111) +++ ntg/real/behavior.hh (working copy) @@ -386,7 +386,7 @@ static storage_type check (const P& rhs) { - typedef typename mlc::if_<ntg_is_a(P, decimal)::ret, + typedef typename mlc::if_< mlc::value<bool, ntg_is_a(P, decimal)::ret>, cycle_fmod, cycle_mod>::ret cycle_op; Index: ntg/core/macros.hh =================================================================== --- ntg/core/macros.hh (revision 111) +++ ntg/core/macros.hh (working copy) @@ -28,6 +28,11 @@ #ifndef NTG_CORE_MACROS_HH # define NTG_CORE_MACROS_HH +# include <mlc/if.hh> +# include <mlc/cmp.hh> +# include <mlc/arith.hh> + + /*------. | casts | `------*/ @@ -169,18 +174,18 @@ ** ** If T is non vectorial, the value returned should not be considered. */ -#define ntg_if_vectorial_nb_comp(T) \ - ntg::type_traits<typename mlc::if_<ntg_is_a(T, ntg::vectorial)::ret, \ - T, \ +#define ntg_if_vectorial_nb_comp(T) \ + ntg::type_traits<typename mlc::if_< mlc::value<bool, ntg_is_a(T, ntg::vectorial)::ret>, \ + T, \ ntg::vec<42, bool> >::ret>::nb_comp /*! Same as \a ntg_if_vectorial_nb_comp but without 'typename' ** ** \see ntg_if_vectorial_nb_comp -*/ -#define ntg_if_vectorial_nb_comp_(T) \ - ntg::type_traits<mlc::if_<ntg_is_a_(T, ntg::vectorial)::ret, \ - T, \ +*/ \ +#define ntg_if_vectorial_nb_comp_(T) \ + ntg::type_traits<mlc::if_< mlc::value<bool, ntg_is_a_(T, ntg::vectorial)::ret>, \ + T, \ ntg::vec<42, bool> >::ret>::nb_comp /*! Compare the number of components. @@ -193,9 +198,9 @@ */ #define ntg_compare_nb_comp(A, B) \ mlc::if_< \ - ntg_is_a(A, ntg::non_vectorial)::ret, \ + mlc::value<bool, ntg_is_a(A, ntg::non_vectorial)::ret>, \ ntg_is_a(B, ntg::non_vectorial), \ - mlc::eq<ntg_if_vectorial_nb_comp(A), \ + mlc::on<unsigned>::eq<ntg_if_vectorial_nb_comp(A), \ ntg_if_vectorial_nb_comp(B) > >::ret /*! Same as \a ntg_compare_nb_comp but without 'typename' @@ -204,9 +209,9 @@ */ #define ntg_compare_nb_comp_(A, B) \ mlc::if_< \ - ntg_is_a_(A, ntg::non_vectorial)::ret, \ + mlc::value<bool, ntg_is_a_(A, ntg::non_vectorial)::ret>, \ ntg_is_a_(B, ntg::non_vectorial), \ - mlc::eq<ntg_if_vectorial_nb_comp_(A), \ + mlc::on<unsigned>::eq<ntg_if_vectorial_nb_comp_(A), \ ntg_if_vectorial_nb_comp_(B) > >::ret #endif // !NTG_CORE_MACROS_HH Index: ntg/core/pred_succ.hh =================================================================== --- ntg/core/pred_succ.hh (revision 111) +++ ntg/core/pred_succ.hh (working copy) @@ -29,7 +29,9 @@ # define NTG_CORE_PRED_SUCC_HH +#include <mlc/if.hh> #include <mlc/is_a.hh> + #include <ntg/real/int_u.hh> #include <ntg/core/macros.hh> @@ -45,9 +47,9 @@ typedef int_u<1> bool_with_arith; typedef T non_vectorial_with_arith; - typedef typename mlc::if_<ntg_is_a(T, ntg::binary)::ret, - id_<bool_with_arith>, - id_<non_vectorial_with_arith> >::ret::ret ret; + typedef typename mlc::if_< mlc::value<bool,ntg_is_a(T, ntg::binary)::ret>, + id_<bool_with_arith>, + id_<non_vectorial_with_arith> >::ret ret; }; } Index: ntg/core/math.hh =================================================================== --- ntg/core/math.hh (revision 111) +++ ntg/core/math.hh (working copy) @@ -1,82 +0,0 @@ -// Copyright (C) 2001, 2002, 2003, 2005 EPITA Research and Development Laboratory -// -// This file is part of the Olena Library. This library is free -// software; you can redistribute it and/or modify it under the terms -// of the GNU General Public License version 2 as published by the -// Free Software Foundation. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; see the file COPYING. If not, write to -// the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -// MA 02111-1307, USA. -// -// As a special exception, you may use this file as part of a free -// software library without restriction. Specifically, if other files -// instantiate templates or use macros or inline functions from this -// file, or you compile this file and link it with other files to -// produce an executable, this file does not by itself cause the -// resulting executable to be covered by the GNU General Public -// License. This exception does not however invalidate any other -// reasons why the executable file might be covered by the GNU General -// Public License. - -#ifndef NTG_CORE_MATH_HH -# define NTG_CORE_MATH_HH - -# include <mlc/bool.hh> - -namespace mlc -{ - - namespace internal - { - - // Helper structs for pow2sup below. - - template<unsigned N> struct is_pow2 { typedef false_type ret; }; - template<> struct is_pow2<8> { typedef true_type ret; }; - template<> struct is_pow2<16> { typedef true_type ret; }; - template<> struct is_pow2<32> { typedef true_type ret; }; - template<> struct is_pow2<64> { typedef true_type ret; }; - - template<unsigned N, class> struct find_pow2sup; - template<unsigned N> struct find_pow2sup<N,true_type> { - enum { value = N }; - }; - template<unsigned N> struct find_pow2sup<N,false_type> { - enum { value = find_pow2sup< N+1, - typename is_pow2<N+1>::ret >::value }; - }; - - } // end of internal - - // Smaller power of 2 greater than N. - - template<unsigned N> - struct pow2sup { - enum { - value = - internal::find_pow2sup< N, - typename internal::is_pow2<N>::ret >::value - }; - private: - typedef typename is_true<N < 32>::ensure_type precondition_type; - }; - - // Various tests on N (actually, we tests only oddness.) - - template<unsigned N> - class utest { - public: - typedef typename is_true<N/2 == (N+1)/2>::ensure_type is_odd_type; - static void ensure_odd() { is_odd_type::is_true(); } - }; - -} // end of namespace mlc - -#endif // METALIC_MATH_HH Index: ntg/core/internal/global_ops_traits.hh =================================================================== --- ntg/core/internal/global_ops_traits.hh (revision 111) +++ ntg/core/internal/global_ops_traits.hh (working copy) @@ -38,8 +38,9 @@ # include <ntg/core/macros.hh> # include <ntg/core/type_traits.hh> -# include <mlc/bool.hh> +# include <mlc/if.hh> + namespace ntg { namespace internal { @@ -183,14 +184,15 @@ enum { can_invert = (operator_traits<Op, T2, T1>::commutative && is_defined<rev_traits>::ret) }; - typedef typename - mlc::if_<is_defined<traits>::ret, - get_order<T1, T2>, typename - mlc::if_<can_invert, - get_order_inv<T1, T2>, - meta_undefined_traits<undefined_traits> - >::ret - >::ret deduced_type; + typedef + typename mlc::if_< mlc::value<bool, (is_defined<traits>::ret)>, + get_order<T1, T2>, + typename mlc::if_< mlc::value<bool, can_invert>, + get_order_inv<T1, T2>, + meta_undefined_traits<undefined_traits> + >::ret + >::ret + deduced_type; typedef typename deduced_type::traits_lhs_type traits_lhs_type; typedef typename deduced_type::traits_rhs_type traits_rhs_type;