3081: Fix minor bugs for 4 extra tests to pass.

https://svn.lrde.epita.fr/svn/oln/trunk/milena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Fix minor bugs for 4 extra tests to pass. * mln/core/site_set/operators.hh (include): Remove dependency to set::card; it was cycling. Remove temporary util::yes. * mln/metal/ref.hh: Fix guard. * mln/io/abort.hh: Add std::. * mln/io/pnm/load_header.hh: Add std::. core/site_set/operators.hh | 52 ++++++++++++++++++++++++++++++++++----------- io/abort.hh | 18 +++++++-------- io/pnm/load_header.hh | 19 +++++++--------- metal/ref.hh | 2 - 4 files changed, 59 insertions(+), 32 deletions(-) Index: mln/core/site_set/operators.hh --- mln/core/site_set/operators.hh (revision 3080) +++ mln/core/site_set/operators.hh (working copy) @@ -33,14 +33,11 @@ /// /// Definition of operators on mln::Site_Set. /// -/// \todo Re-vamp this file now! +/// \todo Fix code for multi-sets. # include <algorithm> # include <mln/core/concept/site_set.hh> -# include <mln/set/card.hh> - -# include <mln/util/yes.hh> // Temporary include. @@ -159,6 +156,37 @@ util::ord<P>()); } + + // card. + + template <typename S> + inline + unsigned set_card_dispatch_(mln::trait::site_set::nsites::any, + const S& s) + { + unsigned n = 0; + mln_piter(S) p(s); + for_all(p) + ++n; + return n; + } + + template <typename S> + inline + unsigned set_card_dispatch_(mln::trait::site_set::nsites::known, + const S& s) + { + return s.nsites(); + } + + template <typename S> + inline + unsigned set_card(const Site_Set<S>& s) + { + return set_card_dispatch_(mln_trait_site_set_nsites(S)(), + exact(s)); + } + } // end of namespace mln::internal @@ -187,7 +215,7 @@ operator_equal_uniques(const Site_Set<Sl>& lhs, const Site_Set<Sr>& rhs) { - if (set::card(lhs) != set::card(rhs)) + if (internal::set_card(lhs) != internal::set_card(rhs)) return false; return mln::internal::sym_diff_std_set(lhs, rhs).empty(); } @@ -198,7 +226,7 @@ operator_equal_unique_multiple(const Site_Set<Sl>& lhs, const Site_Set<Sr>& rhs) { - if (set::card(lhs) != set::card(rhs)) + if (internal::set_card(lhs) != internal::set_card(rhs)) return false; return mln::internal::to_std_set(lhs) == mln::internal::to_std_set(rhs); } @@ -210,7 +238,7 @@ const Site_Set<Sr>& rhs) { // FIXME: Approximate code... - if (set::card(lhs) != set::card(rhs)) + if (internal::set_card(lhs) != internal::set_card(rhs)) return false; return mln::internal::to_std_set(lhs) == mln::internal::to_std_set(rhs); } @@ -231,7 +259,7 @@ if (lhs.is_empty()) return true; // We have "empty set < a non empty set". // From here, both lhs and rhs are not empty. - if (set::card(lhs) >= set::card(rhs)) + if (internal::set_card(lhs) >= internal::set_card(rhs)) return false; return lhs.crop_wrt(rhs) == lhs; } @@ -242,7 +270,7 @@ operator_less_uniques(const Site_Set<Sl>& lhs, const Site_Set<Sr>& rhs) { - if (set::card(lhs) >= set::card(rhs)) + if (internal::set_card(lhs) >= internal::set_card(rhs)) return false; return mln::internal::leq_std_set(lhs, rhs); } @@ -253,7 +281,7 @@ operator_less_unique_multiple(const Site_Set<Sl>& lhs, const Site_Set<Sr>& rhs) { - if (set::card(lhs) >= set::card(rhs)) + if (internal::set_card(lhs) >= internal::set_card(rhs)) return false; return mln::internal::leq_std_set(lhs, rhs); } @@ -265,7 +293,7 @@ const Site_Set<Sr>& rhs) { // FIXME: Approximate code... - if (set::card(lhs) >= set::card(rhs)) + if (internal::set_card(lhs) >= internal::set_card(rhs)) return false; return mln::internal::leq_std_set(lhs, rhs); } @@ -464,7 +492,7 @@ operator<=(const Site_Set<Sl>& lhs, const Site_Set<Sr>& rhs) { mlc_equal(mln_site(Sl), mln_site(Sr))::check(); - if (set::card(lhs) > set::card(rhs)) + if (internal::set_card(lhs) > internal::set_card(rhs)) return false; return lhs < rhs || lhs == rhs; } Index: mln/metal/ref.hh --- mln/metal/ref.hh (revision 3080) +++ mln/metal/ref.hh (working copy) @@ -27,7 +27,7 @@ // Public License. #ifndef MLN_METAL_REF_HH -# define MLN_METAL_RFE_HH +# define MLN_METAL_REF_HH /// \file mln/metal/ref.hh /// Index: mln/io/abort.hh --- mln/io/abort.hh (revision 3080) +++ mln/io/abort.hh (working copy) @@ -1,5 +1,5 @@ -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 EPITA -// Research and Development Laboratory +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 EPITA +// Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -29,14 +29,13 @@ #ifndef MLN_IO_ABORT_HH # define MLN_IO_ABORT_HH -/*! - * \file mln/io/abort.hh - * - * \brief Define a function which aborts a process in io module. - * - */ +/// \file mln/io/abort.hh +/// +/// Define a function which aborts a process in io module. # include <iostream> +# include <cstdlib> + namespace mln { @@ -49,13 +48,14 @@ /// The way to abort when an error occur in io processing. void abort(); + # ifndef MLN_INCLUDE_ONLY inline void abort() { std::cerr << "I/O error, aborting." << std::endl; - exit(0); + std::exit(0); } # endif // ! MLN_INCLUDE_ONLY Index: mln/io/pnm/load_header.hh --- mln/io/pnm/load_header.hh (revision 3080) +++ mln/io/pnm/load_header.hh (working copy) @@ -1,5 +1,5 @@ -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 EPITA -// Research and Development Laboratory +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 EPITA +// Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -29,17 +29,16 @@ #ifndef MLN_IO_PNM_LOAD_HEADER_HH # define MLN_IO_PNM_LOAD_HEADER_HH -/*! - * \file mln/io/pnm/load_header.hh - * - * \brief Define a function which loads header for PNM image. - * - */ +/// \file mln/io/pnm/load_header.hh +/// +/// Define a function which loads header for PNM image. +# include <cstdlib> # include <iostream> # include <fstream> # include <string> + namespace mln { @@ -95,7 +94,7 @@ if (! test) { std::cerr << "error: badly formed header!"; - abort(); + std::abort(); } return false; } @@ -114,7 +113,7 @@ << "expected P" << ascii << " or P" << raw << ", get P" << type << "!"; - abort(); + std::abort(); } }
participants (1)
-
Thierry Geraud