3192: Introduce literal::min and literal::max.

* milena/headers.mk: add new headers to distribution. * milena/mln/literal/all.hh: include new headers. * milena/mln/literal/max.hh, * milena/mln/literal/min.hh: New literals. They use mln_{max,min} internaly. * milena/tests/unit_test/Makefile.am, * milena/tests/unit_test/mln_literal_max.cc, * milena/tests/unit_test/mln_literal_min.cc: new unit tests. --- milena/ChangeLog | 16 ++++++++ milena/headers.mk | 2 + milena/mln/literal/all.hh | 7 ++- milena/mln/literal/{all.hh => max.hh} | 61 ++++++++++++++++------------- milena/mln/literal/{all.hh => min.hh} | 61 ++++++++++++++++------------- milena/tests/unit_test/Makefile.am | 4 ++ milena/tests/unit_test/mln_literal_max.cc | 11 +++++ milena/tests/unit_test/mln_literal_min.cc | 11 +++++ 8 files changed, 117 insertions(+), 56 deletions(-) copy milena/mln/literal/{all.hh => max.hh} (56%) copy milena/mln/literal/{all.hh => min.hh} (56%) create mode 100644 milena/tests/unit_test/mln_literal_max.cc create mode 100644 milena/tests/unit_test/mln_literal_min.cc diff --git a/milena/ChangeLog b/milena/ChangeLog index 85efec7..fdfc0ea 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,21 @@ 2009-01-23 Guillaume Lazzara <z@lrde.epita.fr> + Introduce literal::min and literal::max. + + * milena/headers.mk: add new headers to distribution. + + * milena/mln/literal/all.hh: include new headers. + + * milena/mln/literal/max.hh, + * milena/mln/literal/min.hh: New literals. They use mln_{max,min} + internaly. + + * milena/tests/unit_test/Makefile.am, + * milena/tests/unit_test/mln_literal_max.cc, + * milena/tests/unit_test/mln_literal_min.cc: new unit tests. + +2009-01-23 Guillaume Lazzara <z@lrde.epita.fr> + Fix various operator issues with value::shell. * mln/value/shell.hh: make it inherit from Proxy. diff --git a/milena/headers.mk b/milena/headers.mk index 7263811..65d98e5 100644 --- a/milena/headers.mk +++ b/milena/headers.mk @@ -44,6 +44,7 @@ mln/pw/cst.hh \ mln/pw/var.hh \ mln/pw/essential.hh \ mln/literal/zero.hh \ +mln/literal/max.hh \ mln/literal/ops.hh \ mln/literal/origin.hh \ mln/literal/grays.hh \ @@ -51,6 +52,7 @@ mln/literal/all.hh \ mln/literal/colors.hh \ mln/literal/black.hh \ mln/literal/one.hh \ +mln/literal/min.hh \ mln/literal/white.hh \ mln/literal/essential.hh \ mln/registration/get_rtransf.hh \ diff --git a/milena/mln/literal/all.hh b/milena/mln/literal/all.hh index 781c507..22b6603 100644 --- a/milena/mln/literal/all.hh +++ b/milena/mln/literal/all.hh @@ -1,5 +1,5 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2007, 2008, 2009 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 @@ -64,6 +64,9 @@ namespace mln # include <mln/literal/grays.hh> # include <mln/literal/colors.hh> +# include <mln/literal/max.hh> +# include <mln/literal/min.hh> + # include <mln/literal/ops.hh> diff --git a/milena/mln/literal/all.hh b/milena/mln/literal/max.hh similarity index 56% copy from milena/mln/literal/all.hh copy to milena/mln/literal/max.hh index 781c507..117cc66 100644 --- a/milena/mln/literal/all.hh +++ b/milena/mln/literal/max.hh @@ -1,5 +1,4 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2009 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 @@ -26,45 +25,53 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_LITERAL_ALL_HH -# define MLN_LITERAL_ALL_HH +#ifndef MLN_LITERAL_MAX_HH +# define MLN_LITERAL_MAX_HH -/// \file mln/literal/all.hh +/// \file mln/literal/max.hh /// -/// File that includes all literals. +/// Definition of the literal of mln::max. -// Technical note: -// -// With some recent g++ versions, we have a warning due to literal -// conversions (namely: "type qualifiers ignored on function return -// type"). This warning comes from the "operator T()" method -// instantiated with T being a const type, for instance, when -// literal::zero is given to a procedure expecting a "const int&" -// object. This warning will be avoided in very recent versions -// of C++ thanks to the new compiling option -Wignore_qualifiers. +# include <mln/core/concept/literal.hh> +# include <mln/trait/value_.hh> namespace mln { - /// Namespace of literals. - namespace literal {} + namespace literal + { + + /// Type of literal max. + struct max_t : public Literal<max_t> + { + + template <typename T> + operator T () const; + }; + + + /// Literal max. + extern const max_t& max; + -} +# ifndef MLN_INCLUDE_ONLY + template <typename T> + inline + max_t::operator T () const + { + return mln_max(T); + } -# include <mln/literal/zero.hh> -# include <mln/literal/one.hh> -# include <mln/literal/origin.hh> + const max_t& max = max_t(); -# include <mln/literal/white.hh> -# include <mln/literal/black.hh> +# endif // ! MLN_INCLUDE_ONLY -# include <mln/literal/grays.hh> -# include <mln/literal/colors.hh> + } // end of namespace mln::literal -# include <mln/literal/ops.hh> +} // end of namespace mln -#endif // ! MLN_LITERAL_ALL_HH +#endif // ! MLN_LITERAL_MAX_HH diff --git a/milena/mln/literal/all.hh b/milena/mln/literal/min.hh similarity index 56% copy from milena/mln/literal/all.hh copy to milena/mln/literal/min.hh index 781c507..74cfbd2 100644 --- a/milena/mln/literal/all.hh +++ b/milena/mln/literal/min.hh @@ -1,5 +1,4 @@ -// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory -// (LRDE) +// Copyright (C) 2009 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 @@ -26,45 +25,53 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_LITERAL_ALL_HH -# define MLN_LITERAL_ALL_HH +#ifndef MLN_LITERAL_MIN_HH +# define MLN_LITERAL_MIN_HH -/// \file mln/literal/all.hh +/// \file mln/literal/min.hh /// -/// File that includes all literals. +/// Definition of the literal of mln::min. -// Technical note: -// -// With some recent g++ versions, we have a warning due to literal -// conversions (namely: "type qualifiers ignored on function return -// type"). This warning comes from the "operator T()" method -// instantiated with T being a const type, for instance, when -// literal::zero is given to a procedure expecting a "const int&" -// object. This warning will be avoided in very recent versions -// of C++ thanks to the new compiling option -Wignore_qualifiers. +# include <mln/core/concept/literal.hh> +# include <mln/trait/value_.hh> namespace mln { - /// Namespace of literals. - namespace literal {} + namespace literal + { + + /// Type of literal min. + struct min_t : public Literal<min_t> + { + + template <typename T> + operator T () const; + }; + + + /// Literal min. + extern const min_t& min; + -} +# ifndef MLN_INCLUDE_ONLY + template <typename T> + inline + min_t::operator T () const + { + return mln_min(T); + } -# include <mln/literal/zero.hh> -# include <mln/literal/one.hh> -# include <mln/literal/origin.hh> + const min_t& min = min_t(); -# include <mln/literal/white.hh> -# include <mln/literal/black.hh> +# endif // ! MLN_INCLUDE_ONLY -# include <mln/literal/grays.hh> -# include <mln/literal/colors.hh> + } // end of namespace mln::literal -# include <mln/literal/ops.hh> +} // end of namespace mln -#endif // ! MLN_LITERAL_ALL_HH +#endif // ! MLN_LITERAL_MIN_HH diff --git a/milena/tests/unit_test/Makefile.am b/milena/tests/unit_test/Makefile.am index 3b4444a..315f1b3 100644 --- a/milena/tests/unit_test/Makefile.am +++ b/milena/tests/unit_test/Makefile.am @@ -44,6 +44,7 @@ mln_pw_cst \ mln_pw_var \ mln_pw_essential \ mln_literal_zero \ +mln_literal_max \ mln_literal_ops \ mln_literal_origin \ mln_literal_grays \ @@ -51,6 +52,7 @@ mln_literal_all \ mln_literal_colors \ mln_literal_black \ mln_literal_one \ +mln_literal_min \ mln_literal_white \ mln_literal_essential \ mln_registration_get_rtransf \ @@ -1065,6 +1067,7 @@ mln_pw_cst_SOURCES = mln_pw_cst.cc mln_pw_var_SOURCES = mln_pw_var.cc mln_pw_essential_SOURCES = mln_pw_essential.cc mln_literal_zero_SOURCES = mln_literal_zero.cc +mln_literal_max_SOURCES = mln_literal_max.cc mln_literal_ops_SOURCES = mln_literal_ops.cc mln_literal_origin_SOURCES = mln_literal_origin.cc mln_literal_grays_SOURCES = mln_literal_grays.cc @@ -1072,6 +1075,7 @@ mln_literal_all_SOURCES = mln_literal_all.cc mln_literal_colors_SOURCES = mln_literal_colors.cc mln_literal_black_SOURCES = mln_literal_black.cc mln_literal_one_SOURCES = mln_literal_one.cc +mln_literal_min_SOURCES = mln_literal_min.cc mln_literal_white_SOURCES = mln_literal_white.cc mln_literal_essential_SOURCES = mln_literal_essential.cc mln_registration_get_rtransf_SOURCES = mln_registration_get_rtransf.cc diff --git a/milena/tests/unit_test/mln_literal_max.cc b/milena/tests/unit_test/mln_literal_max.cc new file mode 100644 index 0000000..1bf00c4 --- /dev/null +++ b/milena/tests/unit_test/mln_literal_max.cc @@ -0,0 +1,11 @@ +// Unit test for mln/literal/max.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/literal/max.hh> +#include <mln/literal/max.hh> + +int main() +{ + // Nothing. +} diff --git a/milena/tests/unit_test/mln_literal_min.cc b/milena/tests/unit_test/mln_literal_min.cc new file mode 100644 index 0000000..f29827c --- /dev/null +++ b/milena/tests/unit_test/mln_literal_min.cc @@ -0,0 +1,11 @@ +// Unit test for mln/literal/min.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/literal/min.hh> +#include <mln/literal/min.hh> + +int main() +{ + // Nothing. +} -- 1.5.6.5
participants (1)
-
Guillaume Lazzara