Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
April 2006
- 3 participants
- 35 discussions
https://svn.lrde.epita.fr/svn/oln/trunk/extended
Index: ChangeLog
from Thierry Geraud <theo(a)lrde.epita.fr>
Add some math functions and clean up file deps.
* xtd/math.hh: Add includes.
* xtd/math/log.hh: New.
* xtd/math/floor.hh: New.
* xtd/math/log10.hh: New.
* xtd/math/tan.hh: New.
* xtd/math/atan.hh: New.
* xtd/math/cos.hh: New.
* xtd/math/trigo.hh: Remove; dispatch contents into several files.
* xtd/math/acos.hh: New.
* xtd/math/sin.hh: New.
* xtd/math/sqrt.hh: New.
* xtd/math/asin.hh: New.
* xtd/math/tanh.hh: New.
* xtd/math/exp.hh: New.
* xtd/math/cosh.hh: New.
* xtd/math/id.hh: Update includes.
* xtd/math/sinh.hh: New.
* xtd/math/atan2.hh: New.
* xtd/math/abs.hh: New.
* xtd/math/pow.hh: New.
* xtd/math/includes.hh: New.
* xtd/math/constraints.hh: New.
* xtd/math/ceil.hh: New.
* xtd/ops_expr.hh: Remove; dispatch contents into...
* xtd/internal/opmacros.hh: ...this new file and the following three
files.
* xtd/math/arith.hh: Update.
* xtd/math/cmp.hh: New.
* xtd/math/logic.hh: New.
* xtd/traits.hh: Rename as...
* xtd/optraits.hh: ...this; update.
* xtd/builtin/traits.hh: Update.
* tests/cos.cc: Update.
* tests/Makefile.am: Update.
* tests/math.cc: New.
* tests/cast.cc: Update.
tests/Makefile.am | 4 +
tests/cast.cc | 2
tests/cos.cc | 16 +++---
tests/math.cc | 14 +++++
xtd/builtin/traits.hh | 2
xtd/internal/opmacros.hh | 124 +++++++++++++++++++++++++++--------------------
xtd/math.hh | 60 +++++++++++++++++++---
xtd/math/abs.hh | 115 +++++++++++++++++++++++++++++++++++++++++++
xtd/math/acos.hh | 93 +++++++++++++++++++++++++++++++++++
xtd/math/arith.hh | 104 ++-------------------------------------
xtd/math/asin.hh | 93 +++++++++++++++++++++++++++++++++++
xtd/math/atan.hh | 93 +++++++++++++++++++++++++++++++++++
xtd/math/atan2.hh | 94 +++++++++++++++++++++++++++++++++++
xtd/math/ceil.hh | 93 +++++++++++++++++++++++++++++++++++
xtd/math/cmp.hh | 49 ++++++++++++++++++
xtd/math/constraints.hh | 63 +++++++++++++++++++++++
xtd/math/cos.hh | 93 +++++++++++++++++++++++++++++++++++
xtd/math/cosh.hh | 93 +++++++++++++++++++++++++++++++++++
xtd/math/exp.hh | 93 +++++++++++++++++++++++++++++++++++
xtd/math/floor.hh | 93 +++++++++++++++++++++++++++++++++++
xtd/math/id.hh | 3 -
xtd/math/includes.hh | 40 +++++++++++++++
xtd/math/log.hh | 93 +++++++++++++++++++++++++++++++++++
xtd/math/log10.hh | 93 +++++++++++++++++++++++++++++++++++
xtd/math/logic.hh | 48 ++++++++++++++++++
xtd/math/pow.hh | 109 +++++++++++++++++++++++++++++++++++++++++
xtd/math/sin.hh | 93 +++++++++++++++++++++++++++++++++++
xtd/math/sinh.hh | 93 +++++++++++++++++++++++++++++++++++
xtd/math/sqrt.hh | 93 +++++++++++++++++++++++++++++++++++
xtd/math/tan.hh | 93 +++++++++++++++++++++++++++++++++++
xtd/math/tanh.hh | 93 +++++++++++++++++++++++++++++++++++
xtd/optraits.hh | 6 +-
32 files changed, 2076 insertions(+), 172 deletions(-)
Index: xtd/math.hh
--- xtd/math.hh (revision 449)
+++ xtd/math.hh (working copy)
@@ -28,17 +28,61 @@
#ifndef EXTENDED_MATH_HH
# define EXTENDED_MATH_HH
-# include <cmath>
-# include <xtd/abstract/plain_fun.hh>
-# include <xtd/mfun.hh>
-# include <xtd/arg.hh>
-# include <xtd/ops_expr.hh>
-# include <xtd/math/id.hh>
-# include <xtd/math/trigo.hh>
+// FIXME: preconditions are not handled in code included below...
+
+
+
+/// \{
+/// Definition of xtd cmath-like functions.
+
+# include <xtd/math/abs.hh>
+# include <xtd/math/acos.hh>
+# include <xtd/math/asin.hh>
+# include <xtd/math/atan.hh>
+# include <xtd/math/atan2.hh>
+# include <xtd/math/ceil.hh>
+# include <xtd/math/cos.hh>
+# include <xtd/math/cosh.hh>
+# include <xtd/math/exp.hh>
+// 'fabs' is obsolete
+# include <xtd/math/floor.hh>
+// fmod
+// frexp
+// ldexp
+# include <xtd/math/log.hh>
+# include <xtd/math/log10.hh>
+// modf
+# include <xtd/math/pow.hh>
+# include <xtd/math/sin.hh>
+# include <xtd/math/sinh.hh>
+# include <xtd/math/sqrt.hh>
+# include <xtd/math/tan.hh>
+# include <xtd/math/tanh.hh>
+
+/// \}
+
+
+
+/// \{
+/// Definition of xtd operators and related functions.
+
# include <xtd/math/arith.hh>
-// # include <xtd/math/logic.hh>
+# include <xtd/math/logic.hh>
+# include <xtd/math/cmp.hh>
+
+/// \}
+
+
+
+/// \{
+/// Misc functions.
+
+# include <xtd/math/id.hh>
+
+/// \}
+
Index: xtd/math/log.hh
--- xtd/math/log.hh (revision 0)
+++ xtd/math/log.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_LOG_HH
+# define EXTENDED_MATH_LOG_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+ /// \{
+ /// Definition of xtd (base-2) logarithm functions.
+
+
+ template <typename T> struct log_;
+
+ template <> struct constraints_< log_, float > {};
+ template <> struct constraints_< log_, double > {};
+ template <> struct constraints_< log_, long double > {};
+
+ template <typename T>
+ struct fun_traits_< log_<T> >
+ {
+ typedef T arg_type;
+ typedef T res_type;
+ };
+
+
+ template <typename T>
+ struct log_
+
+ : public abstract::plain_nary_fun_< 1, log_<T> >,
+
+ private constraints_< log_, T >
+ {
+ xtd_res(log_<T>) impl_op(const T& arg) const
+ {
+ return std::log(arg);
+ }
+ };
+
+
+ typedef m1fun_<log_> log_type;
+
+
+ /// \}
+
+
+
+ /// \brief Plain function object xtd::log_f : float -> float.
+ const log_<float> log_f;
+
+ /// \brief Plain function object xtd::log_d : double -> double.
+ const log_<double> log_d;
+
+ /// \brief Plain function object xtd::log_ld : long double -> long double.
+ const log_<long double> log_ld;
+
+ /// \brief Meta function object xtd::log.
+ const log_type log;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_LOG_HH
Index: xtd/math/floor.hh
--- xtd/math/floor.hh (revision 0)
+++ xtd/math/floor.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_FLOOR_HH
+# define EXTENDED_MATH_FLOOR_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+ /// \{
+ /// Definition of xtd floor functions.
+
+
+ template <typename T> struct floor_;
+
+ template <> struct constraints_< floor_, float > {};
+ template <> struct constraints_< floor_, double > {};
+ template <> struct constraints_< floor_, long double > {};
+
+ template <typename T>
+ struct fun_traits_< floor_<T> >
+ {
+ typedef T arg_type;
+ typedef T res_type;
+ };
+
+
+ template <typename T>
+ struct floor_
+
+ : public abstract::plain_nary_fun_< 1, floor_<T> >,
+
+ private constraints_< floor_, T >
+ {
+ xtd_res(floor_<T>) impl_op(const T& arg) const
+ {
+ return std::floor(arg);
+ }
+ };
+
+
+ typedef m1fun_<floor_> floor_type;
+
+
+ /// \}
+
+
+
+ /// \brief Plain function object xtd::floor_f : float -> float.
+ const floor_<float> floor_f;
+
+ /// \brief Plain function object xtd::floor_d : double -> double.
+ const floor_<double> floor_d;
+
+ /// \brief Plain function object xtd::floor_ld : long double -> long double.
+ const floor_<long double> floor_ld;
+
+ /// \brief Meta function object xtd::floor.
+ const floor_type floor;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_FLOOR_HH
Index: xtd/math/log10.hh
--- xtd/math/log10.hh (revision 0)
+++ xtd/math/log10.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_LOG10_HH
+# define EXTENDED_MATH_LOG10_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+ /// \{
+ /// Definition of xtd base-10 logarithm functions.
+
+
+ template <typename T> struct log10_;
+
+ template <> struct constraints_< log10_, float > {};
+ template <> struct constraints_< log10_, double > {};
+ template <> struct constraints_< log10_, long double > {};
+
+ template <typename T>
+ struct fun_traits_< log10_<T> >
+ {
+ typedef T arg_type;
+ typedef T res_type;
+ };
+
+
+ template <typename T>
+ struct log10_
+
+ : public abstract::plain_nary_fun_< 1, log10_<T> >,
+
+ private constraints_< log10_, T >
+ {
+ xtd_res(log10_<T>) impl_op(const T& arg) const
+ {
+ return std::log10(arg);
+ }
+ };
+
+
+ typedef m1fun_<log10_> log10_type;
+
+
+ /// \}
+
+
+
+ /// \brief Plain function object xtd::log10_f : float -> float.
+ const log10_<float> log10_f;
+
+ /// \brief Plain function object xtd::log10_d : double -> double.
+ const log10_<double> log10_d;
+
+ /// \brief Plain function object xtd::log10_ld : long double -> long double.
+ const log10_<long double> log10_ld;
+
+ /// \brief Meta function object xtd::log10.
+ const log10_type log10;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_LOG10_HH
Index: xtd/math/tan.hh
--- xtd/math/tan.hh (revision 0)
+++ xtd/math/tan.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_TAN_HH
+# define EXTENDED_MATH_TAN_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+ /// \{
+ /// Definition of xtd tangent functions.
+
+
+ template <typename T> struct tan_;
+
+ template <> struct constraints_< tan_, float > {};
+ template <> struct constraints_< tan_, double > {};
+ template <> struct constraints_< tan_, long double > {};
+
+ template <typename T>
+ struct fun_traits_< tan_<T> >
+ {
+ typedef T arg_type;
+ typedef T res_type;
+ };
+
+
+ template <typename T>
+ struct tan_
+
+ : public abstract::plain_nary_fun_< 1, tan_<T> >,
+
+ private constraints_< tan_, T >
+ {
+ xtd_res(tan_<T>) impl_op(const T& arg) const
+ {
+ return std::tan(arg);
+ }
+ };
+
+
+ typedef m1fun_<tan_> tan_type;
+
+
+ /// \}
+
+
+
+ /// \brief Plain function object xtd::tan_f : float -> float.
+ const tan_<float> tan_f;
+
+ /// \brief Plain function object xtd::tan_d : double -> double.
+ const tan_<double> tan_d;
+
+ /// \brief Plain function object xtd::tan_ld : long double -> long double.
+ const tan_<long double> tan_ld;
+
+ /// \brief Meta function object xtd::tan.
+ const tan_type tan;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_TAN_HH
Index: xtd/math/atan.hh
--- xtd/math/atan.hh (revision 0)
+++ xtd/math/atan.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_ATAN_HH
+# define EXTENDED_MATH_ATAN_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+ /// \{
+ /// Definition of xtd arc tangent functions.
+
+
+ template <typename T> struct atan_;
+
+ template <> struct constraints_< atan_, float > {};
+ template <> struct constraints_< atan_, double > {};
+ template <> struct constraints_< atan_, long double > {};
+
+ template <typename T>
+ struct fun_traits_< atan_<T> >
+ {
+ typedef T arg_type;
+ typedef T res_type;
+ };
+
+
+ template <typename T>
+ struct atan_
+
+ : public abstract::plain_nary_fun_< 1, atan_<T> >,
+
+ private constraints_< atan_, T >
+ {
+ xtd_res(atan_<T>) impl_op(const T& arg) const
+ {
+ return std::atan(arg);
+ }
+ };
+
+
+ typedef m1fun_<atan_> atan_type;
+
+
+ /// \}
+
+
+
+ /// \brief Plain function object xtd::atan_f : float -> float.
+ const atan_<float> atan_f;
+
+ /// \brief Plain function object xtd::atan_d : double -> double.
+ const atan_<double> atan_d;
+
+ /// \brief Plain function object xtd::atan_ld : long double -> long double.
+ const atan_<long double> atan_ld;
+
+ /// \brief Meta function object xtd::atan.
+ const atan_type atan;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_ATAN_HH
Index: xtd/math/cos.hh
--- xtd/math/cos.hh (revision 0)
+++ xtd/math/cos.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_COS_HH
+# define EXTENDED_MATH_COS_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+ /// \{
+ /// Definition of xtd cosine functions.
+
+
+ template <typename T> struct cos_;
+
+ template <> struct constraints_< cos_, float > {};
+ template <> struct constraints_< cos_, double > {};
+ template <> struct constraints_< cos_, long double > {};
+
+ template <typename T>
+ struct fun_traits_< cos_<T> >
+ {
+ typedef T arg_type;
+ typedef T res_type;
+ };
+
+
+ template <typename T>
+ struct cos_
+
+ : public abstract::plain_nary_fun_< 1, cos_<T> >,
+
+ private constraints_< cos_, T >
+ {
+ xtd_res(cos_<T>) impl_op(const T& arg) const
+ {
+ return std::cos(arg);
+ }
+ };
+
+
+ typedef m1fun_<cos_> cos_type;
+
+
+ /// \}
+
+
+
+ /// \brief Plain function object xtd::cos_f : float -> float.
+ const cos_<float> cos_f;
+
+ /// \brief Plain function object xtd::cos_d : double -> double.
+ const cos_<double> cos_d;
+
+ /// \brief Plain function object xtd::cos_ld : long double -> long double.
+ const cos_<long double> cos_ld;
+
+ /// \brief Meta function object xtd::cos.
+ const cos_type cos;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_COS_HH
Index: xtd/math/acos.hh
--- xtd/math/acos.hh (revision 0)
+++ xtd/math/acos.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_ACOS_HH
+# define EXTENDED_MATH_ACOS_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+ /// \{
+ /// Definition of xtd arc cosine functions.
+
+
+ template <typename T> struct acos_;
+
+ template <> struct constraints_< acos_, float > {};
+ template <> struct constraints_< acos_, double > {};
+ template <> struct constraints_< acos_, long double > {};
+
+ template <typename T>
+ struct fun_traits_< acos_<T> >
+ {
+ typedef T arg_type;
+ typedef T res_type;
+ };
+
+
+ template <typename T>
+ struct acos_
+
+ : public abstract::plain_nary_fun_< 1, acos_<T> >,
+
+ private constraints_< acos_, T >
+ {
+ xtd_res(acos_<T>) impl_op(const T& arg) const
+ {
+ return std::acos(arg);
+ }
+ };
+
+
+ typedef m1fun_<acos_> acos_type;
+
+
+ /// \}
+
+
+
+ /// \brief Plain function object xtd::acos_f : float -> float.
+ const acos_<float> acos_f;
+
+ /// \brief Plain function object xtd::acos_d : double -> double.
+ const acos_<double> acos_d;
+
+ /// \brief Plain function object xtd::acos_ld : long double -> long double.
+ const acos_<long double> acos_ld;
+
+ /// \brief Meta function object xtd::acos.
+ const acos_type acos;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_ACOS_HH
Index: xtd/math/sin.hh
--- xtd/math/sin.hh (revision 0)
+++ xtd/math/sin.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_SIN_HH
+# define EXTENDED_MATH_SIN_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+ /// \{
+ /// Definition of xtd sine functions.
+
+
+ template <typename T> struct sin_;
+
+ template <> struct constraints_< sin_, float > {};
+ template <> struct constraints_< sin_, double > {};
+ template <> struct constraints_< sin_, long double > {};
+
+ template <typename T>
+ struct fun_traits_< sin_<T> >
+ {
+ typedef T arg_type;
+ typedef T res_type;
+ };
+
+
+ template <typename T>
+ struct sin_
+
+ : public abstract::plain_nary_fun_< 1, sin_<T> >,
+
+ private constraints_< sin_, T >
+ {
+ xtd_res(sin_<T>) impl_op(const T& arg) const
+ {
+ return std::sin(arg);
+ }
+ };
+
+
+ typedef m1fun_<sin_> sin_type;
+
+
+ /// \}
+
+
+
+ /// \brief Plain function object xtd::sin_f : float -> float.
+ const sin_<float> sin_f;
+
+ /// \brief Plain function object xtd::sin_d : double -> double.
+ const sin_<double> sin_d;
+
+ /// \brief Plain function object xtd::sin_ld : long double -> long double.
+ const sin_<long double> sin_ld;
+
+ /// \brief Meta function object xtd::sin.
+ const sin_type sin;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_SIN_HH
Index: xtd/math/sqrt.hh
--- xtd/math/sqrt.hh (revision 0)
+++ xtd/math/sqrt.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_SQRT_HH
+# define EXTENDED_MATH_SQRT_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+ /// \{
+ /// Definition of xtd square root functions.
+
+
+ template <typename T> struct sqrt_;
+
+ template <> struct constraints_< sqrt_, float > {};
+ template <> struct constraints_< sqrt_, double > {};
+ template <> struct constraints_< sqrt_, long double > {};
+
+ template <typename T>
+ struct fun_traits_< sqrt_<T> >
+ {
+ typedef T arg_type;
+ typedef T res_type;
+ };
+
+
+ template <typename T>
+ struct sqrt_
+
+ : public abstract::plain_nary_fun_< 1, sqrt_<T> >,
+
+ private constraints_< sqrt_, T >
+ {
+ xtd_res(sqrt_<T>) impl_op(const T& arg) const
+ {
+ return std::sqrt(arg);
+ }
+ };
+
+
+ typedef m1fun_<sqrt_> sqrt_type;
+
+
+ /// \}
+
+
+
+ /// \brief Plain function object xtd::sqrt_f : float -> float.
+ const sqrt_<float> sqrt_f;
+
+ /// \brief Plain function object xtd::sqrt_d : double -> double.
+ const sqrt_<double> sqrt_d;
+
+ /// \brief Plain function object xtd::sqrt_ld : long double -> long double.
+ const sqrt_<long double> sqrt_ld;
+
+ /// \brief Meta function object xtd::sqrt.
+ const sqrt_type sqrt;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_SQRT_HH
Index: xtd/math/asin.hh
--- xtd/math/asin.hh (revision 0)
+++ xtd/math/asin.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_ASIN_HH
+# define EXTENDED_MATH_ASIN_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+ /// \{
+ /// Definition of xtd arc sine functions.
+
+
+ template <typename T> struct asin_;
+
+ template <> struct constraints_< asin_, float > {};
+ template <> struct constraints_< asin_, double > {};
+ template <> struct constraints_< asin_, long double > {};
+
+ template <typename T>
+ struct fun_traits_< asin_<T> >
+ {
+ typedef T arg_type;
+ typedef T res_type;
+ };
+
+
+ template <typename T>
+ struct asin_
+
+ : public abstract::plain_nary_fun_< 1, asin_<T> >,
+
+ private constraints_< asin_, T >
+ {
+ xtd_res(asin_<T>) impl_op(const T& arg) const
+ {
+ return std::asin(arg);
+ }
+ };
+
+
+ typedef m1fun_<asin_> asin_type;
+
+
+ /// \}
+
+
+
+ /// \brief Plain function object xtd::asin_f : float -> float.
+ const asin_<float> asin_f;
+
+ /// \brief Plain function object xtd::asin_d : double -> double.
+ const asin_<double> asin_d;
+
+ /// \brief Plain function object xtd::asin_ld : long double -> long double.
+ const asin_<long double> asin_ld;
+
+ /// \brief Meta function object xtd::asin.
+ const asin_type asin;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_ASIN_HH
Index: xtd/math/tanh.hh
--- xtd/math/tanh.hh (revision 0)
+++ xtd/math/tanh.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_TANH_HH
+# define EXTENDED_MATH_TANH_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+ /// \{
+ /// Definition of xtd hyperbolic tangent functions.
+
+
+ template <typename T> struct tanh_;
+
+ template <> struct constraints_< tanh_, float > {};
+ template <> struct constraints_< tanh_, double > {};
+ template <> struct constraints_< tanh_, long double > {};
+
+ template <typename T>
+ struct fun_traits_< tanh_<T> >
+ {
+ typedef T arg_type;
+ typedef T res_type;
+ };
+
+
+ template <typename T>
+ struct tanh_
+
+ : public abstract::plain_nary_fun_< 1, tanh_<T> >,
+
+ private constraints_< tanh_, T >
+ {
+ xtd_res(tanh_<T>) impl_op(const T& arg) const
+ {
+ return std::tanh(arg);
+ }
+ };
+
+
+ typedef m1fun_<tanh_> tanh_type;
+
+
+ /// \}
+
+
+
+ /// \brief Plain function object xtd::tanh_f : float -> float.
+ const tanh_<float> tanh_f;
+
+ /// \brief Plain function object xtd::tanh_d : double -> double.
+ const tanh_<double> tanh_d;
+
+ /// \brief Plain function object xtd::tanh_ld : long double -> long double.
+ const tanh_<long double> tanh_ld;
+
+ /// \brief Meta function object xtd::tanh.
+ const tanh_type tanh;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_TANH_HH
Index: xtd/math/exp.hh
--- xtd/math/exp.hh (revision 0)
+++ xtd/math/exp.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_EXP_HH
+# define EXTENDED_MATH_EXP_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+ /// \{
+ /// Definition of xtd exponential functions.
+
+
+ template <typename T> struct exp_;
+
+ template <> struct constraints_< exp_, float > {};
+ template <> struct constraints_< exp_, double > {};
+ template <> struct constraints_< exp_, long double > {};
+
+ template <typename T>
+ struct fun_traits_< exp_<T> >
+ {
+ typedef T arg_type;
+ typedef T res_type;
+ };
+
+
+ template <typename T>
+ struct exp_
+
+ : public abstract::plain_nary_fun_< 1, exp_<T> >,
+
+ private constraints_< exp_, T >
+ {
+ xtd_res(exp_<T>) impl_op(const T& arg) const
+ {
+ return std::exp(arg);
+ }
+ };
+
+
+ typedef m1fun_<exp_> exp_type;
+
+
+ /// \}
+
+
+
+ /// \brief Plain function object xtd::exp_f : float -> float.
+ const exp_<float> exp_f;
+
+ /// \brief Plain function object xtd::exp_d : double -> double.
+ const exp_<double> exp_d;
+
+ /// \brief Plain function object xtd::exp_ld : long double -> long double.
+ const exp_<long double> exp_ld;
+
+ /// \brief Meta function object xtd::exp.
+ const exp_type exp;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_EXP_HH
Index: xtd/math/cosh.hh
--- xtd/math/cosh.hh (revision 0)
+++ xtd/math/cosh.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_COSH_HH
+# define EXTENDED_MATH_COSH_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+ /// \{
+ /// Definition of xtd hyperbolic cosine functions.
+
+
+ template <typename T> struct cosh_;
+
+ template <> struct constraints_< cosh_, float > {};
+ template <> struct constraints_< cosh_, double > {};
+ template <> struct constraints_< cosh_, long double > {};
+
+ template <typename T>
+ struct fun_traits_< cosh_<T> >
+ {
+ typedef T arg_type;
+ typedef T res_type;
+ };
+
+
+ template <typename T>
+ struct cosh_
+
+ : public abstract::plain_nary_fun_< 1, cosh_<T> >,
+
+ private constraints_< cosh_, T >
+ {
+ xtd_res(cosh_<T>) impl_op(const T& arg) const
+ {
+ return std::cosh(arg);
+ }
+ };
+
+
+ typedef m1fun_<cosh_> cosh_type;
+
+
+ /// \}
+
+
+
+ /// \brief Plain function object xtd::cosh_f : float -> float.
+ const cosh_<float> cosh_f;
+
+ /// \brief Plain function object xtd::cosh_d : double -> double.
+ const cosh_<double> cosh_d;
+
+ /// \brief Plain function object xtd::cosh_ld : long double -> long double.
+ const cosh_<long double> cosh_ld;
+
+ /// \brief Meta function object xtd::cosh.
+ const cosh_type cosh;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_COSH_HH
Index: xtd/math/id.hh
--- xtd/math/id.hh (revision 449)
+++ xtd/math/id.hh (working copy)
@@ -28,8 +28,7 @@
#ifndef EXTENDED_MATH_ID_HH
# define EXTENDED_MATH_ID_HH
-# include <xtd/abstract/plain_nary_fun.hh>
-# include <xtd/mfun.hh>
+# include <xtd/math/includes.hh>
namespace xtd
Index: xtd/math/logic.hh
--- xtd/math/logic.hh (revision 0)
+++ xtd/math/logic.hh (revision 0)
@@ -0,0 +1,48 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_LOGIC_HH
+# define EXTENDED_MATH_LOGIC_HH
+
+# include <xtd/internal/opmacros.hh>
+
+
+namespace xtd
+{
+
+ xtd_internal_decl_binary_operator( land, and );
+ xtd_internal_decl_binary_operator( lor, or );
+ xtd_internal_decl_binary_operator( lxor, xor );
+
+ xtd_internal_decl_unary_operator( lnot, not );
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_LOGIC_HH
Index: xtd/math/sinh.hh
--- xtd/math/sinh.hh (revision 0)
+++ xtd/math/sinh.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_SINH_HH
+# define EXTENDED_MATH_SINH_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+ /// \{
+ /// Definition of xtd hyperbolic sine functions.
+
+
+ template <typename T> struct sinh_;
+
+ template <> struct constraints_< sinh_, float > {};
+ template <> struct constraints_< sinh_, double > {};
+ template <> struct constraints_< sinh_, long double > {};
+
+ template <typename T>
+ struct fun_traits_< sinh_<T> >
+ {
+ typedef T arg_type;
+ typedef T res_type;
+ };
+
+
+ template <typename T>
+ struct sinh_
+
+ : public abstract::plain_nary_fun_< 1, sinh_<T> >,
+
+ private constraints_< sinh_, T >
+ {
+ xtd_res(sinh_<T>) impl_op(const T& arg) const
+ {
+ return std::sinh(arg);
+ }
+ };
+
+
+ typedef m1fun_<sinh_> sinh_type;
+
+
+ /// \}
+
+
+
+ /// \brief Plain function object xtd::sinh_f : float -> float.
+ const sinh_<float> sinh_f;
+
+ /// \brief Plain function object xtd::sinh_d : double -> double.
+ const sinh_<double> sinh_d;
+
+ /// \brief Plain function object xtd::sinh_ld : long double -> long double.
+ const sinh_<long double> sinh_ld;
+
+ /// \brief Meta function object xtd::sinh.
+ const sinh_type sinh;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_SINH_HH
Index: xtd/math/atan2.hh
--- xtd/math/atan2.hh (revision 0)
+++ xtd/math/atan2.hh (revision 0)
@@ -0,0 +1,94 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_ATAN2_HH
+# define EXTENDED_MATH_ATAN2_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+ /// \{
+ /// Definition of xtd arc tangent functions taking two arguments.
+
+
+ template <typename T1, typename T2> struct atan2_;
+
+ template <> struct constraints_2_< atan2_, float, float > {};
+ template <> struct constraints_2_< atan2_, double, double > {};
+ template <> struct constraints_2_< atan2_, long double, long double > {};
+
+ template <typename T>
+ struct fun_traits_< atan2_<T, T> >
+ {
+ typedef T arg1_type;
+ typedef T arg2_type;
+ typedef T res_type;
+ };
+
+
+ template <typename T1, typename T2>
+ struct atan2_
+
+ : public abstract::plain_nary_fun_< 2, atan2_<T1, T2> >,
+
+ private constraints_2_< atan2_, T1, T2 >
+ {
+ xtd_res(mlc_comma_1(atan2_<T1,T2>)) impl_op(const T1& arg1, const T2& arg2) const
+ {
+ return std::atan2(arg1, arg2);
+ }
+ };
+
+
+ typedef m2fun_<atan2_> atan2_type;
+
+
+ /// \}
+
+
+
+ /// \brief Plain function object xtd::atan2_f : (float, float) -> float.
+ const atan2_<float, float> atan2_f;
+
+ /// \brief Plain function object xtd::atan2_d : (double, double) -> double.
+ const atan2_<double, double> atan2_d;
+
+ /// \brief Plain function object xtd::atan2_ld : (long double, long double) -> long double.
+ const atan2_<long double, long double> atan2_ld;
+
+ /// \brief Meta function object xtd::atan2.
+ const atan2_type atan2;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_ATAN2_HH
Index: xtd/math/abs.hh
--- xtd/math/abs.hh (revision 0)
+++ xtd/math/abs.hh (revision 0)
@@ -0,0 +1,115 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_ABS_HH
+# define EXTENDED_MATH_ABS_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+ /// \{
+ /// Definition of xtd absolute value functions.
+
+
+ template <typename T> struct abs_;
+
+ template <> struct constraints_< abs_, int > {};
+ template <> struct constraints_< abs_, long int > {};
+
+ template <> struct constraints_< abs_, float > {};
+ template <> struct constraints_< abs_, double > {};
+ template <> struct constraints_< abs_, long double > {};
+
+ template <typename T>
+ struct fun_traits_< abs_<T> >
+ {
+ typedef T arg_type;
+ typedef T res_type;
+ };
+
+ namespace internal {
+
+ int abs_(int i) { return std::abs(i); }
+ long int abs_(long int i) { return std::abs(i); }
+
+ float abs_(float i) { return std::fabs(i); }
+ double abs_(double i) { return std::fabs(i); }
+ long double abs_(long double i) { return std::fabs(i); }
+
+ } // end of namespace xtd::internal
+
+
+ template <typename T>
+ struct abs_
+
+ : public abstract::plain_nary_fun_< 1, abs_<T> >,
+
+ private constraints_< abs_, T >
+ {
+ xtd_res(abs_<T>) impl_op(const T& arg) const
+ {
+ return internal::abs_(arg);
+ }
+ };
+
+
+ typedef m1fun_<abs_> abs_type;
+
+
+ /// \}
+
+
+
+ /// \brief Plain function object xtd::abs_f : int -> int.
+ const abs_<int> abs_i;
+
+ /// \brief Plain function object xtd::abs_d : long int -> long int.
+ const abs_<long int> abs_li;
+
+
+ /// \brief Plain function object xtd::abs_f : float -> float.
+ const abs_<float> abs_f;
+
+ /// \brief Plain function object xtd::abs_d : double -> double.
+ const abs_<double> abs_d;
+
+ /// \brief Plain function object xtd::abs_ld : long double -> long double.
+ const abs_<long double> abs_ld;
+
+
+ /// \brief Meta function object xtd::abs.
+ const abs_type abs;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_ABS_HH
Index: xtd/math/pow.hh
--- xtd/math/pow.hh (revision 0)
+++ xtd/math/pow.hh (revision 0)
@@ -0,0 +1,109 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_POW_HH
+# define EXTENDED_MATH_POW_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+ /// \{
+ /// Definition of xtd arc tangent functions taking two arguments.
+
+
+ template <typename T1, typename T2> struct pow_;
+
+ template <> struct constraints_2_< pow_, float, float > {};
+ template <> struct constraints_2_< pow_, double, double > {};
+ template <> struct constraints_2_< pow_, long double, long double > {};
+
+ template <> struct constraints_2_< pow_, float, int > {};
+ template <> struct constraints_2_< pow_, double, int > {};
+ template <> struct constraints_2_< pow_, long double, int > {};
+
+ template <typename T1, typename T2>
+ struct fun_traits_< pow_<T1, T2> >
+ {
+ typedef T1 arg1_type;
+ typedef T2 arg2_type;
+ typedef T1 res_type;
+ };
+
+
+ template <typename T1, typename T2>
+ struct pow_
+
+ : public abstract::plain_nary_fun_< 2, pow_<T1, T2> >,
+
+ private constraints_2_< pow_, T1, T2 >
+ {
+ xtd_res(mlc_comma_1(pow_<T1,T2>)) impl_op(const T1& arg1, const T2& arg2) const
+ {
+ return std::pow(arg1, arg2);
+ }
+ };
+
+
+ typedef m2fun_<pow_> pow_type;
+
+
+ /// \}
+
+
+
+ /// \brief Plain function object xtd::pow_f : (float, float) -> float.
+ const pow_<float, float> pow_f;
+
+ /// \brief Plain function object xtd::pow_d : (double, double) -> double.
+ const pow_<double, double> pow_d;
+
+ /// \brief Plain function object xtd::pow_ld : (long double, long double) -> long double.
+ const pow_<long double, long double> pow_ld;
+
+
+ /// \brief Plain function object xtd::pow_f : (float, int) -> float.
+ const pow_<float, int> pow_fi;
+
+ /// \brief Plain function object xtd::pow_d : (double, int) -> double.
+ const pow_<double, int> pow_di;
+
+ /// \brief Plain function object xtd::pow_ld : (long double, int) -> long double.
+ const pow_<long double, int> pow_ldi;
+
+
+ /// \brief Meta function object xtd::pow.
+ const pow_type pow;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_POW_HH
Index: xtd/math/includes.hh
--- xtd/math/includes.hh (revision 0)
+++ xtd/math/includes.hh (revision 0)
@@ -0,0 +1,40 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_INCLUDES_HH
+# define EXTENDED_MATH_INCLUDES_HH
+
+
+# include <cmath>
+# include <cassert>
+
+# include <xtd/abstract/plain_nary_fun.hh>
+# include <xtd/mfun.hh>
+# include <xtd/math/constraints.hh>
+
+
+#endif // ! EXTENDED_MATH_INCLUDES_HH
Index: xtd/math/arith.hh
--- xtd/math/arith.hh (revision 449)
+++ xtd/math/arith.hh (working copy)
@@ -28,109 +28,19 @@
#ifndef EXTENDED_MATH_ARITH_HH
# define EXTENDED_MATH_ARITH_HH
-# include <xtd/builtin/traits.hh>
-# include <xtd/abstract/plain_nary_fun.hh>
-# include <xtd/mfun.hh>
-
-
-// FIXME: doc
-
-# define xtd_internal_decl_plain_unary_fun_op(OperatorName, OperatorSymbol) \
- \
- template <typename T> \
- struct plain_##OperatorName##_; \
- \
- template <typename T> \
- struct fun_traits_< plain_##OperatorName##_<T> > \
- { \
- typedef T arg_type; \
- typedef xtd_##OperatorName(T) res_type; \
- }; \
- \
- template <typename T> \
- struct plain_##OperatorName##_ \
- \
- : public abstract::plain_nary_fun_< 1, plain_##OperatorName##_<T> > \
- { \
- typedef plain_##OperatorName##_<T> self; \
- xtd_res(self) impl_op(const T& arg) const \
- { \
- return OperatorSymbol arg; \
- } \
- }; \
- \
- typedef m1fun_<plain_##OperatorName##_> OperatorName##_type; \
- const OperatorName##_type OperatorName; \
- \
- struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
-
-
-
-
-# define xtd_internal_decl_plain_binary_fun_op(OperatorName, OperatorSymbol) \
- \
- template <typename T1, typename T2> \
- struct plain_##OperatorName##_; \
- \
- template <typename T1, typename T2> \
- struct fun_traits_< plain_##OperatorName##_<T1, T2> > \
- { \
- typedef T1 arg1_type; \
- typedef T2 arg2_type; \
- typedef xtd_##OperatorName(T1, T2) res_type; \
- }; \
- \
- template <typename T1, typename T2> \
- struct plain_##OperatorName##_ \
- \
- : public abstract::plain_nary_fun_< 2, plain_##OperatorName##_<T1, T2> > \
- { \
- typedef plain_##OperatorName##_<T1, T2> self; \
- xtd_res(self) impl_op(const T1& arg1, const T2& arg2) const \
- { \
- return arg1 OperatorSymbol arg2; \
- } \
- }; \
- \
- typedef m2fun_<plain_##OperatorName##_> OperatorName##_type; \
- const OperatorName##_type OperatorName; \
- \
- struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
-
-
+# include <xtd/internal/opmacros.hh>
namespace xtd
{
- // logic
-
- xtd_internal_decl_plain_binary_fun_op( land, and );
- xtd_internal_decl_plain_binary_fun_op( lor, or );
- xtd_internal_decl_plain_binary_fun_op( lxor, xor );
-
- xtd_internal_decl_plain_unary_fun_op( lnot, not );
-
-
- // cmp
-
- xtd_internal_decl_plain_binary_fun_op( eq, == );
- xtd_internal_decl_plain_binary_fun_op( neq, != );
- xtd_internal_decl_plain_binary_fun_op( less, < );
- xtd_internal_decl_plain_binary_fun_op( leq, <= );
- xtd_internal_decl_plain_binary_fun_op( greater, > );
- xtd_internal_decl_plain_binary_fun_op( geq, >= );
-
-
- // arith
-
- xtd_internal_decl_plain_binary_fun_op( plus, + );
- xtd_internal_decl_plain_binary_fun_op( minus, - );
- xtd_internal_decl_plain_binary_fun_op( mult, * );
- xtd_internal_decl_plain_binary_fun_op( div, / );
- xtd_internal_decl_plain_binary_fun_op( mod, % );
+ xtd_internal_decl_binary_operator( plus, + );
+ xtd_internal_decl_binary_operator( minus, - );
+ xtd_internal_decl_binary_operator( mult, * );
+ xtd_internal_decl_binary_operator( div, / );
+ xtd_internal_decl_binary_operator( mod, % );
- xtd_internal_decl_plain_unary_fun_op( uminus, - );
+ xtd_internal_decl_unary_operator( uminus, - );
} // end of namespace xtd
Index: xtd/math/constraints.hh
--- xtd/math/constraints.hh (revision 0)
+++ xtd/math/constraints.hh (revision 0)
@@ -0,0 +1,63 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_CONSTRAINTS_HH
+# define EXTENDED_MATH_CONSTRAINTS_HH
+
+# include <mlc/abort.hh>
+
+
+namespace xtd
+{
+
+ namespace ERROR
+ {
+ struct FIXME;
+
+ } // end of namespace xtd::ERROR
+
+
+ template < template<typename> class pfun,
+ typename T >
+ struct constraints_ : private mlc::abort_< ERROR::FIXME >
+ {
+ };
+
+
+ template < template<typename, typename> class pfun,
+ typename T1,
+ typename T2 >
+ struct constraints_2_ : private mlc::abort_< ERROR::FIXME >
+ {
+ };
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_CONSTRAINTS_HH
Index: xtd/math/ceil.hh
--- xtd/math/ceil.hh (revision 0)
+++ xtd/math/ceil.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_CEIL_HH
+# define EXTENDED_MATH_CEIL_HH
+
+# include <xtd/math/includes.hh>
+
+
+namespace xtd
+{
+
+ /// \{
+ /// Definition of xtd ceil functions.
+
+
+ template <typename T> struct ceil_;
+
+ template <> struct constraints_< ceil_, float > {};
+ template <> struct constraints_< ceil_, double > {};
+ template <> struct constraints_< ceil_, long double > {};
+
+ template <typename T>
+ struct fun_traits_< ceil_<T> >
+ {
+ typedef T arg_type;
+ typedef T res_type;
+ };
+
+
+ template <typename T>
+ struct ceil_
+
+ : public abstract::plain_nary_fun_< 1, ceil_<T> >,
+
+ private constraints_< ceil_, T >
+ {
+ xtd_res(ceil_<T>) impl_op(const T& arg) const
+ {
+ return std::ceil(arg);
+ }
+ };
+
+
+ typedef m1fun_<ceil_> ceil_type;
+
+
+ /// \}
+
+
+
+ /// \brief Plain function object xtd::ceil_f : float -> float.
+ const ceil_<float> ceil_f;
+
+ /// \brief Plain function object xtd::ceil_d : double -> double.
+ const ceil_<double> ceil_d;
+
+ /// \brief Plain function object xtd::ceil_ld : long double -> long double.
+ const ceil_<long double> ceil_ld;
+
+ /// \brief Meta function object xtd::ceil.
+ const ceil_type ceil;
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_CEIL_HH
Index: xtd/math/cmp.hh
--- xtd/math/cmp.hh (revision 0)
+++ xtd/math/cmp.hh (revision 0)
@@ -0,0 +1,49 @@
+// Copyright (C) 2002, 2005, 2006 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 EXTENDED_MATH_CMP_HH
+# define EXTENDED_MATH_CMP_HH
+
+# include <xtd/internal/opmacros.hh>
+
+
+namespace xtd
+{
+
+ xtd_internal_decl_binary_operator( eq, == );
+ xtd_internal_decl_binary_operator( neq, != );
+ xtd_internal_decl_binary_operator( less, < );
+ xtd_internal_decl_binary_operator( leq, <= );
+ xtd_internal_decl_binary_operator( greater, > );
+ xtd_internal_decl_binary_operator( geq, >= );
+
+
+} // end of namespace xtd
+
+
+
+#endif // ! EXTENDED_MATH_CMP_HH
Index: xtd/optraits.hh
--- xtd/optraits.hh (revision 443)
+++ xtd/optraits.hh (working copy)
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef EXTENDED_TRAITS_HH
-# define EXTENDED_TRAITS_HH
+#ifndef EXTENDED_OPTRAITS_HH
+# define EXTENDED_OPTRAITS_HH
# include <mlc/flags.hh>
@@ -165,4 +165,4 @@
-#endif // ! EXTENDED_TRAITS_HH
+#endif // ! EXTENDED_OPTRAITS_HH
Index: xtd/builtin/traits.hh
--- xtd/builtin/traits.hh (revision 449)
+++ xtd/builtin/traits.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef EXTENDED_BUILTIN_TRAITS_HH
# define EXTENDED_BUILTIN_TRAITS_HH
-# include <xtd/traits.hh>
+# include <xtd/optraits.hh>
Index: xtd/internal/opmacros.hh
--- xtd/internal/opmacros.hh (revision 443)
+++ xtd/internal/opmacros.hh (working copy)
@@ -25,22 +25,51 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef EXTENDED_OPS_EXPR_HH
-# define EXTENDED_OPS_EXPR_HH
+#ifndef EXTENDED_INTERNAL_OPMACROS_HH
+# define EXTENDED_INTERNAL_OPMACROS_HH
+
+# include <xtd/math/includes.hh>
# include <xtd/abstract/fun_expr.hh>
# include <xtd/mexpr.hh>
-# include <xtd/math/arith.hh>
-
-
-
+# include <xtd/literal.hh>
-// FIXME: doc
+# include <xtd/optraits.hh>
+# include <xtd/builtin/traits.hh>
# define xtd_internal_decl_unary_operator(OperatorName, OperatorSymbol) \
\
+ \
+ template <typename T> \
+ struct plain_##OperatorName##_; \
+ \
+ template <typename T> \
+ struct fun_traits_< plain_##OperatorName##_<T> > \
+ { \
+ typedef T arg_type; \
+ typedef xtd_##OperatorName(T) res_type; \
+ }; \
+ \
+ \
+ template <typename T> \
+ struct plain_##OperatorName##_ \
+ \
+ : public abstract::plain_nary_fun_< 1, plain_##OperatorName##_<T> > \
+ { \
+ typedef plain_##OperatorName##_<T> self; \
+ xtd_res(self) impl_op(const T& arg) const \
+ { \
+ return OperatorSymbol arg; \
+ } \
+ }; \
+ \
+ \
+ typedef m1fun_<plain_##OperatorName##_> OperatorName##_type; \
+ const OperatorName##_type OperatorName; \
+ \
+ \
template <typename Expr> \
xtd::m1expr_<xtd::OperatorName##_type, Expr> \
operator OperatorSymbol (const xtd::abstract::fun_expr_<Expr>& expr) \
@@ -49,10 +78,11 @@
return tmp; \
} \
\
- struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
+ \
+ struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n \
-// FIXME: add something like:
+// FIXME: does not specialize any template arguments
// template <typename Expr>
// struct OperatorName##_trait_ < Expr >
@@ -62,9 +92,38 @@
-
# define xtd_internal_decl_binary_operator(OperatorName, OperatorSymbol) \
\
+ \
+ template <typename T1, typename T2> \
+ struct plain_##OperatorName##_; \
+ \
+ template <typename T1, typename T2> \
+ struct fun_traits_< plain_##OperatorName##_<T1, T2> > \
+ { \
+ typedef T1 arg1_type; \
+ typedef T2 arg2_type; \
+ typedef xtd_##OperatorName(T1, T2) res_type; \
+ }; \
+ \
+ \
+ template <typename T1, typename T2> \
+ struct plain_##OperatorName##_ \
+ \
+ : public abstract::plain_nary_fun_< 2, plain_##OperatorName##_<T1, T2> > \
+ { \
+ typedef plain_##OperatorName##_<T1, T2> self; \
+ xtd_res(self) impl_op(const T1& arg1, const T2& arg2) const \
+ { \
+ return arg1 OperatorSymbol arg2; \
+ } \
+ }; \
+ \
+ \
+ typedef m2fun_<plain_##OperatorName##_> OperatorName##_type; \
+ const OperatorName##_type OperatorName; \
+ \
+ \
template <typename Lexpr, typename Rexpr> \
xtd::m2expr_<xtd::OperatorName##_type, Lexpr, Rexpr> \
operator OperatorSymbol (const xtd::abstract::fun_expr_<Lexpr>& lexpr, \
@@ -74,10 +133,11 @@
return tmp; \
} \
\
- struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
+ \
+ struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n \
-// FIXME: add something like:
+// FIXME: does not specialize any template arguments
// template <typename Lexpr, typename Rexpr>
// struct OperatorName##_trait_ < Lexpr, Rexpr >
@@ -86,42 +146,4 @@
// };
-
-
-
-namespace xtd
-{
-
- // logic
-
- xtd_internal_decl_binary_operator( land, and );
- xtd_internal_decl_binary_operator( lor, or );
- xtd_internal_decl_binary_operator( lxor, xor );
-
- xtd_internal_decl_unary_operator( lnot, not );
-
-
- // cmp
-
- xtd_internal_decl_binary_operator( eq, == );
- xtd_internal_decl_binary_operator( neq, != );
- xtd_internal_decl_binary_operator( less, < );
- xtd_internal_decl_binary_operator( leq, <= );
- xtd_internal_decl_binary_operator( greater, > );
- xtd_internal_decl_binary_operator( geq, >= );
-
-
- // arith
-
- xtd_internal_decl_binary_operator( plus, + );
- xtd_internal_decl_binary_operator( minus, - );
- xtd_internal_decl_binary_operator( mult, * );
- xtd_internal_decl_binary_operator( div, / );
- xtd_internal_decl_binary_operator( mod, % );
-
- xtd_internal_decl_unary_operator( uminus, - );
-
-} // end of namespace xtd
-
-
-#endif // ! EXTENDED_OPS_EXPR_HH
+#endif // ! EXTENDED_INTERNAL_OPMACROS_HH
Index: tests/cos.cc
--- tests/cos.cc (revision 449)
+++ tests/cos.cc (working copy)
@@ -1,6 +1,6 @@
#include <iostream>
-#include <xtd/math.hh>
+#include <xtd/math/cos.hh>
int main()
@@ -29,11 +29,11 @@
// std::cout << (cos(_1)(_2)).nargs() << std::endl; // gives: 2
// }
- {
- using xtd::cos;
- using xtd::sin;
- using xtd::_1;
- using xtd::_2;
+// {
+// using xtd::cos;
+// using xtd::sin;
+// using xtd::_1;
+// using xtd::_2;
// std::cout << (cos(_1) * cos(_1) + sin(_2) * sin(_2))(5.f, 5.f) << std::endl;
@@ -44,9 +44,9 @@
// (cos(_1) + sin(_1))(_1);
// std::cout << (cos(_1) * cos(_1) + sin(_1) * sin(_1))(_1)(51.f) << std::endl;
- std::cout << (_1 * _1 + _2 * _2)(cos(_1), sin(_1))(51.f) << std::endl;
+// std::cout << (_1 * _1 + _2 * _2)(cos(_1), sin(_1))(51.f) << std::endl;
// std::cout << ((cos(_1) + sin(_2))(_1, _1)).nargs() << std::endl;
- }
+// }
}
Index: tests/Makefile.am
--- tests/Makefile.am (revision 449)
+++ tests/Makefile.am (working copy)
@@ -13,7 +13,8 @@
cast \
cfun \
cos \
- lit
+ lit \
+ math
id_SOURCES = id.cc
bind_SOURCES = bind.cc
@@ -21,5 +22,6 @@
cfun_SOURCES = cfun.cc
cos_SOURCES = cos.cc
lit_SOURCES = lit.cc
+math_SOURCES = math.cc
TESTS = $(check_PROGRAMS)
Index: tests/math.cc
--- tests/math.cc (revision 0)
+++ tests/math.cc (revision 0)
@@ -0,0 +1,14 @@
+#include <iostream>
+#include <xtd/math.hh>
+
+
+int main()
+{
+ using xtd::cos;
+ using xtd::sin;
+ using xtd::_1;
+ using xtd::_2;
+
+ std::cout << (cos(_1) * cos(_1) + sin(_2) * sin(_2))(_1, _1)(51.f) << std::endl;
+ std::cout << (_1 * _1 + _2 * _2)(cos(_1), sin(_1))(51.f) << std::endl;
+}
Index: tests/cast.cc
--- tests/cast.cc (revision 449)
+++ tests/cast.cc (working copy)
@@ -1,7 +1,7 @@
#include <iostream>
#include <xtd/cast.hh>
#include <xtd/arg.hh>
-#include <xtd/math/trigo.hh>
+#include <xtd/math/cos.hh>
int main()
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/metalic
I had to help the compiler regarding mlc_is_a (within a template context).
Tell me if the tests fail because of this change.
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add mlc::any.
* mlc/contract.hh: New (imported from Olena proto-1.0).
* mlc/any.hh: New (imported from Olena proto-1.0).
Aesthetic changes.
(any__simple): New class.
* mlc/is_a.hh (mlc_is_a, mlc_is_not_a): Use the `template' keyword
to remove an ambiguity w.r.t the nature of the template struct
`ret' within mlc::form::of.
* tests/any.cc: New test.
* tests/Makefile.am (check_PROGRAMS): Add any.
(any_SOURCES): New.
mlc/Makefile.am | 1
mlc/any.hh | 78 +++++++++++++++++++----------
mlc/contract.hh | 12 +---
mlc/is_a.hh | 8 ++-
tests/Makefile.am | 2
tests/any.cc | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 209 insertions(+), 35 deletions(-)
Index: tests/Makefile.am
--- tests/Makefile.am (revision 448)
+++ tests/Makefile.am (working copy)
@@ -8,6 +8,7 @@
# when oln.m4 is available in the distribution.
check_PROGRAMS = \
+ any \
case \
if \
is_a \
@@ -17,6 +18,7 @@
switch \
typedef
+any_SOURCES = any.cc
case_SOURCES = case.cc
if_SOURCES = if.cc
is_a_SOURCES = is_a.cc
Index: tests/any.cc
--- tests/any.cc (revision 0)
+++ tests/any.cc (revision 0)
@@ -0,0 +1,143 @@
+/// Test mlc::any.
+
+#include <mlc/any.hh>
+#include <mlc/cmp.hh>
+#include <mlc/assert.hh>
+#include <mlc/logic.hh>
+#include <mlc/is_a.hh>
+
+// FIXME: Test other flavors of mlc::any.
+
+/* Linear hierachy.
+
+ - Abstractions.
+
+ mlc::any<Exact>
+ ^
+ |
+ A<Exact>
+ ^
+ |
+ B<Exact>
+ ^
+ |
+ Exact
+
+
+ - Concrete class C, deriving from B.
+
+ mlc::any<C>
+ ^
+ |
+ A<C>
+ ^
+ |
+ B<C>
+ ^
+ |
+ C
+
+*/
+
+template <typename Exact>
+struct A : public mlc::any__simple< Exact > {};
+
+template <typename Exact>
+struct B : public A< Exact > {};
+
+struct C : public B<C> {};
+
+
+/* A more complex hierarchy (several subclasses, diamond inheritance).
+
+ - Abstractions.
+
+ mlc::any<Exact>
+ ^
+ |
+ T<Exact>
+ ^ ^ ^
+ / | \
+ / | \
+ U<Exact> X<Exact> Y<Exact>
+ ^ ^ ^
+ | | |
+ Exact Exact Exact
+
+ - Concrete classes V and Z, deriving from U and from X and Y resp.
+
+
+ mlc::any<Z> mlc::any<Z>
+ ^ ^
+ | |
+ T<Z> T<Z>
+ ^ ^
+ | / \
+ U<Z> X<Z> Y<Z>
+ ^ ^ ^
+ | \ /
+ V Z
+
+*/
+
+template <typename Exact>
+struct T : public mlc::any__simple< Exact > {};
+
+template <typename Exact>
+struct U : public T< Exact > {};
+
+struct V : public U<V> {};
+
+template <typename Exact>
+struct X : virtual public T< Exact > {};
+
+template <typename Exact>
+struct Y : virtual public T< Exact > {};
+
+struct Z : public X<Z>, public Y<Z> {};
+
+// The struct enclosing these two functions (methods) is used to
+// factor the code w.r.t. the tested hierarchy.
+template <template < class > class Top>
+struct assuming_top_class_is
+{
+ template <template < class > class T, typename E>
+ static void
+ test_exact_is_a(Top<E>& a)
+ {
+ typedef typeof(a.exact()) exact_type;
+
+ mlc::assert_< mlc::eq_<exact_type, E> >::check();
+ mlc::assert_< mlc_is_a(exact_type, T) >::check();
+ };
+
+ template <template <class> class T, typename E>
+ static void
+ test_exact_is_not_a(Top<E>& a)
+ {
+ typedef typeof(a.exact()) exact_type;
+
+ mlc::assert_< mlc::eq_<exact_type, E> >::check();
+ mlc::assert_< mlc_is_not_a(exact_type, T) >::check();
+ }
+};
+
+int
+main()
+{
+ C c;
+ assuming_top_class_is<A>::test_exact_is_a<A>(c);
+ assuming_top_class_is<A>::test_exact_is_a<B>(c);
+
+ Z z;
+ assuming_top_class_is<T>::test_exact_is_a<T>(z);
+ assuming_top_class_is<T>::test_exact_is_a<X>(z);
+ assuming_top_class_is<T>::test_exact_is_a<Y>(z);
+
+ X<Z> x;
+ assuming_top_class_is<T>::test_exact_is_a<T>(x);
+ // Bad branch.
+ assuming_top_class_is<T>::test_exact_is_not_a<U>(x);
+ // Bad hierachy.
+ assuming_top_class_is<T>::test_exact_is_not_a<B>(x);
+}
Index: mlc/any.hh
--- mlc/any.hh (revision 0)
+++ mlc/any.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 EPITA Research and Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 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
@@ -29,19 +30,21 @@
#ifndef METALIC_ANY_HH
# define METALIC_ANY_HH
-# include <mlc/contract.hh>
+/// \file mlc/any.hh
+/// \brief Implementation of mlc::any classes (top of static hierachies).
-// abbrev
-#define any_mem(E) any <E, dispatch_policy::best_memory>
+# include <mlc/contract.hh>
+// \def Shortcut.
+#define any_mem(E) any<E, dispatch_policy::best_memory>
-// 'any' classes
namespace mlc
{
+ /// Tags selecting a dispatch for mlc::any.
struct dispatch_policy
{
struct best_speed;
@@ -50,14 +53,16 @@
};
- // any
-
+ /// Top class of a static hierachy.
template <typename E, typename Dispatch_Policy = dispatch_policy::simple>
struct any;
- // "best speed" version of 'any'
+ /*-----------------------.
+ | mlc::any__best_speed. |
+ `-----------------------*/
+ /// "Best speed" version of `any'.
template <typename E>
struct any <E,
dispatch_policy::best_speed>
@@ -72,7 +77,6 @@
}
/// Assignment (op=).
-
any& operator=(const any& rhs)
{
// do nothing
@@ -81,19 +85,19 @@
}
/// Copy Ctor.
-
any(const any& rhs) :
- exact_ptr(0) // safety
+ // For safety purpose.
+ exact_ptr(0)
{
- // this->exact_ptr is *not* copied
- // its value has to be set in subclasses copy ctors.
+ // this->exact_ptr is *not* copied; its value has to be set in
+ // subclasses copy ctors.
}
protected:
any(E* exact_ptr) : exact_ptr(exact_ptr) {}
virtual ~any() {}
- /// Only attribute.
+ /// Sole attribute.
E* exact_ptr;
};
@@ -106,14 +110,21 @@
any__best_speed(E* exact_ptr = 0) : super(exact_ptr) {}
};
- // "best memory" version of 'any'
- // FIXME:
- // We should test with autotools if the compiler allows us to write a
- // static_cast or not (diamond inheritance problem). gcc-2.95 gives a
- // different adress but not gcc-3.
- // On Mac OS X, the compilation fails with a strange link error if you
- // try to use the offset computation.
+ /*------------------------.
+ | mlc::any__best_memory. |
+ `------------------------*/
+
+ /// "Best memory" version of 'any'
+ /* FIXME:
+ We should test with autotools if the compiler allows us to write a
+ static_cast or not (diamond inheritance problem). gcc-2.95 gives a
+ different adress but not gcc-3.
+ On Mac OS X, the compilation fails with a strange link error if you
+ try to use the offset computation.
+
+ 2006-03-24 Roland: Investigate this bug/behavior of Apple's GCC.
+ This is not the first time that Apple GCC 3.3 behaves strangely. */
template <typename E>
struct any <E,
dispatch_policy::best_memory>
@@ -141,8 +152,10 @@
protected:
any() {}
- any(E* exact_ptr_does_not_exist_in_this_version); // safety
- virtual ~any() {} // FIXME: virtual for a "best memory" version!?
+ // For safety purpose.
+ any(E* exact_ptr_does_not_exist_in_this_version);
+ // FIXME: virtual for a "best memory" version!?
+ virtual ~any() {}
};
template <typename E>
@@ -155,15 +168,19 @@
# if not defined __GNUC__ || __GNUC__ < 3
template <typename E> const E any_mem(E)::exact_obj = E();
- template <typename E> const any_mem(E)& any_mem(E)::ref_exact_obj = any_mem(E)::exact_obj;
+ template <typename E> const any_mem(E)& any_mem(E)::ref_exact_obj =
+ any_mem(E)::exact_obj;
template <typename E> const int any_mem(E)::exact_offset =
(const char*)(void*)(&any_mem(E)::ref_exact_obj)
- (const char*)(void*)(&any_mem(E)::exact_obj);
# endif
- // "simple" version of 'any'
+ /*-------------------.
+ | mlc::any__simple. |
+ `-------------------*/
+ /// "Simple" version of `any'.
template <typename E>
struct any <E,
dispatch_policy::simple>
@@ -176,7 +193,16 @@
}
protected:
any() {}
- any(E* exact_ptr_does_not_exist_in_this_version); // safety
+ // For safety purpose.
+ any(E* exact_ptr_does_not_exist_in_this_version);
+ };
+
+ template <typename E>
+ struct any__simple : public any<E, dispatch_policy::simple>
+ {
+ protected:
+ typedef any<E, dispatch_policy::simple> super;
+ any__simple() : super() {}
};
Index: mlc/is_a.hh
--- mlc/is_a.hh (revision 448)
+++ mlc/is_a.hh (working copy)
@@ -239,7 +239,9 @@
*/
# define mlc_is_a(T, U) \
-mlc::wrap_< typename mlc::is_a_< sizeof(mlc::form::of< U >()) >::ret< T, U > >
+mlc::wrap_< \
+ typename mlc::is_a_< sizeof(mlc::form::of< U >()) >::template ret< T, U > \
+>
# define mlc_is_a_(T, U) \
mlc::is_a_< sizeof(mlc::form::of< U >()) >::ret< T, U >
@@ -254,7 +256,9 @@
*/
# define mlc_is_not_a(T, U) \
-mlc::not_< typename mlc::is_a_<sizeof(mlc::form::of<U >())>::ret<T,U > >
+mlc::not_< \
+ typename mlc::is_a_<sizeof(mlc::form::of<U >())>::template ret< T, U > \
+>
# define mlc_is_not_a_(T, U) \
mlc::not_< mlc::is_a_< sizeof(mlc::form::of<U >())>::ret<T,U > >
Index: mlc/Makefile.am
--- mlc/Makefile.am (revision 448)
+++ mlc/Makefile.am (working copy)
@@ -2,6 +2,7 @@
mlcdir = $(includedir)/mlc
nobase_mlc_HEADERS = \
+ any.hh \
bool.hh \
case.hh \
cmp.hh \
Index: mlc/contract.hh
--- mlc/contract.hh (revision 0)
+++ mlc/contract.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 EPITA Research and Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004, 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
@@ -28,11 +29,10 @@
#ifndef METALIC_CONTRACT_HH
# define METALIC_CONTRACT_HH
+# include <cassert>
-# include <assert.h>
-
-// FIXME: a lot of code has been removed here
-// for simplification purpose only
+// FIXME: a lot of code has been removed here for simplification
+// purpose only.
# define assertion(expr) assert(expr)
# define invariant(expr) assert(expr)
@@ -40,7 +40,6 @@
# define postcondition(expr) assert(expr)
-
# define mlc_check_method_impl(WHERE, RETURN, NAME, ARG, CONST) \
{ \
typedef RETURN (WHERE::*meth)(ARG) CONST; \
@@ -58,5 +57,4 @@
} \
struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
-
#endif // ! METALIC_CONTRACT_HH
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/static
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Static: Catch up with current Metalic
* tests/entry.cc (mlc::abort_): Remove this fake and use
mlc/abort.hh instead.
* stc/properties.hh: s/mlc::is_found/mlc::is_found_/g.
stc/properties.hh | 4 ++--
tests/entry.cc | 8 +-------
2 files changed, 3 insertions(+), 9 deletions(-)
Index: tests/entry.cc
--- tests/entry.cc (revision 447)
+++ tests/entry.cc (working copy)
@@ -5,13 +5,7 @@
#include <mlc/case.hh>
#include <mlc/assert.hh>
#include <mlc/is_a.hh>
-
-// FIXME: Fake. Remove this when mlc::abort_ is added to the project.
-namespace mlc
-{
- template <typename T>
- class abort_ {};
-}
+#include <mlc/abort.hh>
/*----------.
Index: stc/properties.hh
--- stc/properties.hh (revision 447)
+++ stc/properties.hh (working copy)
@@ -333,9 +333,9 @@
\
/* Did we found the virtual type? */ \
static const bool found_external_p = \
- mlc_bool(mlc::is_found<external_typedef>); \
+ mlc_bool(mlc::is_found_<external_typedef>); \
static const bool found_internal_p = \
- mlc_bool(mlc::is_found<internal_typedef>); \
+ mlc_bool(mlc::is_found_<internal_typedef>); \
\
typedef typename \
internal::select_typedef<found_external_p, found_internal_p, \
1
0
Nicolas Widynski <nicolas.widynski(a)lrde.epita.fr> writes:
> https://svn/svn/oln/prototypes/proto-1.0
>
> Index: ChangeLog
> from Nicolas Widynski <nicolas.widynski(a)lrde.epita.fr>
>
> Add GPL to trunk.
>
> * COPYING: Modify FDL to Gnu General Public License.
>
> COPYING | 721 +++++++++++++++++++++++++++++-----------------------------------
> 1 file changed, 332 insertions(+), 389 deletions(-)
>
HUGE !...
--
| Mieux vaut se taire Michaël 'Micha' Cadilhac |
| Que de parler trop fort. cadilh_m - Epita 2007 - CSI |
| -- As de trèfle JID: micha(a)amessage.be |
`-- - - - - --'
6
7
03 Apr '06
https://svn.lrde.epita.fr/svn/oln/trunk/metalic
Index: ChangeLog
from Thierry Geraud <theo(a)lrde.epita.fr>
Add protection mechanism to case definitions and update.
* tests/switch.cc: Update.
* tests/protected.cc: New file.
* tests/Makefile.am (protected): New entry.
* mlc/ret.hh (mlc_ret_, mlc_ret_found_in): New macros.
(ret_found_in_): Update.
* mlc/if.hh (FIXME): Remove.
(if_): Change inheritance into composition.
* mlc/typedef.hh: Cosmetics.
* mlc/switch.hh (mlc_switch, mlc_switch_): New macros.
* mlc/TODO: Update.
* mlc/case.hh (mlc_case, mlc_case_): New macros.
(ERROR): Update and augment.
(WARNING): New.
(mlc_case_equipment_for_namespace): Update to handle protected_.
* mlc/cmp.hh (mlc_is_found, mlc_is_not_found): New macros.
(mlc_is_undefined, mlc_is_defined): New macros.
(mlc_is_ok, mlc_is_not_ok): New macros.
(is_value, is_not_value): Update.
(is_not_found_, is_found_): Update.
(is_not_ok_, is_ok_): Update.
mlc/TODO | 51 ++++++++++---
mlc/case.hh | 194 +++++++++++++++++++++++++++++++++++++++++++++--------
mlc/cmp.hh | 64 +++++++++++++++--
mlc/if.hh | 12 ++-
mlc/ret.hh | 13 +++
mlc/switch.hh | 12 +++
mlc/typedef.hh | 4 -
tests/Makefile.am | 2
tests/protected.cc | 149 ++++++++++++++++++++++++++++++++++++++++
tests/switch.cc | 54 ++++++++++++++
10 files changed, 501 insertions(+), 54 deletions(-)
Index: tests/switch.cc
--- tests/switch.cc (revision 446)
+++ tests/switch.cc (working copy)
@@ -31,7 +31,7 @@
typedef int ret;
};
-// // or:
+// // ok
// template <class T>
// struct case_ <test, T, 3> : public mlc::where_< mlc_is_a(T, char) >
@@ -39,6 +39,20 @@
// typedef mlc::not_found ret;
// };
+// // ok
+
+// template <class T>
+// struct case_ <test, T, 3> : public mlc::where_< mlc_is_a(T, char) >
+// {
+// struct protected_ {
+// typedef mlc::not_found ret;
+// };
+// };
+
+
+
+
+
// // ko
@@ -54,6 +68,21 @@
// };
// template <class T>
+// struct case_ <test, T, 3> : public mlc::where_< mlc_is_a(T, char) >
+// {
+// struct protected_ {
+// };
+// typedef int ret;
+// };
+
+// template <class T>
+// struct case_ <test, T, 3> : public mlc::where_< mlc_is_a(T, char) >
+// {
+// struct protected_ {
+// };
+// };
+
+// template <class T>
// struct case_ <test, T, 3>
// {
// typedef int ret;
@@ -70,10 +99,33 @@
// {
// };
+// template <class T>
+// struct default_case_ <test, T> : public mlc::where_< mlc_is_a(T, char) >
+// {
+// typedef int ret;
+// };
+
+// template <class T>
+// struct default_case_ <test, T>
+// {
+// struct protected_ {
+// typedef int ret;
+// }
+// typedef int ret;
+// };
+
+// template <class T>
+// struct default_case_ <test, T>
+// {
+// struct protected_ {
+// }
+// };
+
} // end of namespace client
+
template <class T>
void print()
{
Index: tests/Makefile.am
--- tests/Makefile.am (revision 446)
+++ tests/Makefile.am (working copy)
@@ -12,6 +12,7 @@
if \
is_a \
or \
+ protected \
ret \
switch \
typedef
@@ -20,6 +21,7 @@
if_SOURCES = if.cc
is_a_SOURCES = is_a.cc
or_SOURCES = or.cc
+protected_SOURCES = protected.cc
ret_SOURCES = ret.cc
switch_SOURCES = switch.cc
typedef_SOURCES = typedef.cc
Index: tests/protected.cc
--- tests/protected.cc (revision 0)
+++ tests/protected.cc (revision 0)
@@ -0,0 +1,149 @@
+#include <mlc/switch.hh>
+#include <mlc/cmp.hh>
+#include <mlc/typedef.hh>
+#include <mlc/assert.hh>
+#include <mlc/implies.hh>
+
+
+mlc_case_equipment_for_namespace(client);
+mlc_decl_typedef(protected_);
+
+template <typename T>
+void reveal()
+{
+ T tmp;
+}
+
+
+
+namespace client
+{
+
+ struct A
+ {
+ typedef bool typedef_in_A_only;
+ };
+
+ struct B
+ {
+ typedef char typedef_in_B_only;
+ };
+
+
+
+ // simple_test
+
+ struct simple_test;
+
+ template <class T>
+ struct case_ <simple_test, T, 1> : public mlc::where_< mlc_eq(T, A) >
+ {
+ typedef A ret;
+ };
+
+ template <class T>
+ struct case_ <simple_test, T, 2> : public mlc::where_< mlc_eq(T, B) >
+ {
+ typedef B ret;
+ };
+
+
+ // test_ok
+
+ struct test_ok;
+
+ template <class T>
+ struct case_ <test_ok, T, 1> : public mlc::where_< mlc_eq(T, A) >
+ {
+ typedef typename A::typedef_in_A_only ret;
+ };
+
+ template <class T>
+ struct case_ <test_ok, T, 2> : public mlc::where_< mlc_eq(T, B) >
+ {
+ typedef typename B::typedef_in_B_only ret;
+ };
+
+
+
+ // test_KO
+
+ struct test_KO;
+
+ template <class T>
+ struct case_ <test_KO, T, 1> : public mlc::where_< mlc_eq(T, A) >
+ {
+ typedef typename T::typedef_in_A_only ret;
+ };
+
+ template <class T>
+ struct case_ <test_KO, T, 2> : public mlc::where_< mlc_eq(T, B) >
+ {
+ typedef typename T::typedef_in_B_only ret;
+ };
+
+
+ // test_soluce
+
+ struct test_soluce;
+
+ template <class T>
+ struct case_ <test_soluce, T, 1> : public mlc::where_< mlc_eq(T, A) >
+ {
+ struct protected_ {
+ typedef typename T::typedef_in_A_only ret;
+ };
+ };
+
+ template <class T>
+ struct case_ <test_soluce, T, 2> : public mlc::where_< mlc_eq(T, B) >
+ {
+ // typedef mlc::dummy ret;
+ struct protected_ {
+ typedef typename T::typedef_in_B_only ret;
+ };
+ };
+
+
+
+} // end of namespace client
+
+
+struct ERROR_USE_EITHER_PROTECT_OR_RET_IN_A_CASE;
+
+
+
+int main()
+{
+
+ using namespace client;
+
+ typedef switch_<simple_test, B>::ret type;
+ reveal<type>();
+
+
+ // typedef switch_<test, B> ::ret type;
+ // which is equiv to:
+ // typedef case_<test, B>::ret ::ret type;
+
+// typedef case_<test_soluce, B>::ret ::protect::ret type;
+
+
+
+
+// typedef case_<test_soluce, B>::ret the_case;
+// typedef mlc_typedef_(the_case, protected_) the_case_protected;
+// typedef mlc_ret_(the_case) the_case_ret;
+
+// mlc::assert_< mlc::xor_< mlc_is_found(the_case_protected),
+// mlc_is_found(the_case_ret) >,
+// ERROR_USE_EITHER_PROTECT_OR_RET_IN_A_CASE
+// >::check();
+
+// typedef mlc::if_< mlc::eq_< the_case_protected, mlc::not_found >,
+// the_case_ret,
+// mlc_ret_(the_case_protected) >::ret result;
+
+
+// reveal<result>();
+}
Index: mlc/ret.hh
--- mlc/ret.hh (revision 446)
+++ mlc/ret.hh (working copy)
@@ -48,7 +48,14 @@
+/// \{
+/// Macros mlc_ret and mlc_ret_.
+
# define mlc_ret(Type) typename mlc::typedef_::ret::from_<Type>::ret
+# define mlc_ret_(Type) mlc::typedef_::ret::from_<Type>::ret
+
+/// \}
+
// test code
@@ -62,10 +69,14 @@
template <typename T>
struct ret_found_in_
: public mlc::eq_< typename mlc::typedef_::ret::from_<T>::ret2::first_elt,
- mlc::found >
+ mlc::found >::bexpr
{};
} // end of namespace mlc
+# define mlc_ret_found_in(T) mlc::ret_found_in_<T>
+
+
+
#endif // ! METALIC_RET_HH
Index: mlc/if.hh
--- mlc/if.hh (revision 446)
+++ mlc/if.hh (working copy)
@@ -53,10 +53,11 @@
namespace ERROR
{
- struct FIXME;
+ struct THE_FIRST_PARAMETER_OF_AN_mlc_if_SHOULD_BE_AN_mlc_bexpr;
} // end of mlc::ERROR
+
namespace internal
{
@@ -92,13 +93,16 @@
** \note \a Then and \a Else must be valid types, since they are both
** evaluated, whatever the result of \a Cond.
*/
+
template <typename cond_type, typename then_type, typename else_type>
struct if_ :
- // FIXME: enable the static assertion below!!!
+
private assert_< mlc_is_a(cond_type, mlc::abstract::bexpr),
- mlc::ERROR::FIXME >,
- public internal::if_ < mlc_bool(cond_type), then_type, else_type >
+ mlc::ERROR::THE_FIRST_PARAMETER_OF_AN_mlc_if_SHOULD_BE_AN_mlc_bexpr >
{
+ typedef typename internal::if_< mlc_bool(cond_type),
+ then_type,
+ else_type >::ret ret;
};
} // end of namespace mlc
Index: mlc/typedef.hh
--- mlc/typedef.hh (revision 446)
+++ mlc/typedef.hh (working copy)
@@ -242,6 +242,9 @@
+
+
+
/*! \macro mlc_typedef_in(Namespace, Type, TypedefName)
**
** FIXME: doc
@@ -254,7 +257,6 @@
Namespace::typedef_::TypedefName::from_<Type>::ret
-
/*! \macro mlc_typedef_onlyif(Type, TypedefName, Bexpr)
**
** FIXME: doc
Index: mlc/switch.hh
--- mlc/switch.hh (revision 446)
+++ mlc/switch.hh (working copy)
@@ -32,4 +32,16 @@
# include <mlc/case.hh>
+/// Macros mlc_switch and mlc_switch_.
+/// \{
+
+# define mlc_switch(Namespace, Context, Data) \
+ typename Namespace::switch_<Context, Data>::ret
+
+# define mlc_switch_(Namespace, Context, Data) \
+ Namespace::switch_<Context, Data>::ret
+
+/// \}
+
+
#endif // ! METALIC_SWITCH_HH
Index: mlc/TODO
--- mlc/TODO (revision 446)
+++ mlc/TODO (working copy)
@@ -2,15 +2,6 @@
* files
-** bool.hh
-
-create assert.hh from parts of bool.hh
-
-** boolean and bexpr
-
-there is a confusion between mlc::abstract::boolean and the notion of
-bexpr (Boolean expression type)!
-
** value.hh
This file mixes bool_, int_, etc. so I should be split into several
@@ -21,7 +12,22 @@
* addition
-mlc_eval (such as mlc_bool and mlc_value)
+** macros
+
+*** mlc_eval
+
+mlc_eval should exist (in a similar way to mlc_bool and mlc_value)
+
+*** mlc_value
+
+rec pb
+
+** cmp.hh
+
+clearly check that params are neither values not bexprs
+
+clearly state the difference (and use cases) between mlc_eq and mlc_is_a
+then check that is_something facilities conform to the use case rules
* renaming
@@ -50,6 +56,29 @@
works well and we do not have to write mlc_is_a_ with the '_' at the end
so that's better. yet is it a direct consequence of the wrapping?
+** if_
+
+then_type and else_type are not protected; find a solution
+
+** logic.hh
+
+add some tests to check that err msg are ok
+(the pb is that they may propagate...)
+
+
+
+
+* DONE!
+
+** bool.hh
+
+create assert.hh from parts of bool.hh
+
+** boolean and bexpr
+
+there is a confusion between mlc::abstract::boolean and the notion of
+bexpr (Boolean expression type)!
+
** boolean and bexpr
the last part of the disambiguation between boolean and bexpr is to
@@ -63,5 +92,3 @@
static checks should change
*** remove
eval in true_ and false_
-
-
Index: mlc/case.hh
--- mlc/case.hh (revision 446)
+++ mlc/case.hh (working copy)
@@ -30,6 +30,7 @@
# include <mlc/bexpr.hh>
# include <mlc/assert.hh>
+# include <mlc/abort.hh>
# include <mlc/ret.hh>
# include <mlc/is_a.hh>
# include <mlc/implies.hh>
@@ -38,6 +39,19 @@
# include <mlc/if.hh>
+/// Macros mlc_case and mlc_case_.
+/// \{
+
+# define mlc_case(Namespace, Context, Data) \
+ typename Namespace::case_<Context, Data>::ret
+
+# define mlc_case_(Namespace, Context, Data) \
+ Namespace::case_<Context, Data>::ret
+
+/// \}
+
+
+
// FIXME: doc this file!
@@ -59,14 +73,52 @@
namespace ERROR
{
+ struct PARAMETER_OF_mlc_where_SHOULD_BE_A_BEXPR;
+
struct A_case_STATEMENT_SHOULD_NOT_START_AT_INDEX_0_BUT_1;
+
struct A_case_STATEMENT_SHOULD_DERIVE_FROM_mlc_where_;
struct A_default_case_STATEMENT_SHOULD_NOT_DERIVE_FROM_mlc_where_;
+
+ struct A_default_case_STATEMENT_IN_A_switch_SHOULD_HAVE_EITHER_A_ret_OR_A_protected;
+ struct A_default_case_STATEMENT_IN_A_switch_SHOULD_NOT_HAVE_BOTH_A_ret_AND_A_protected;
+ struct THE_protected_PART_OF_A_default_case_STATEMENT_IN_A_switch_SHOULD_HAVE_A_ret;
+
+ struct A_case_STATEMENT_IN_A_switch_SHOULD_HAVE_EITHER_A_ret_OR_A_protected;
+ struct A_case_STATEMENT_IN_A_switch_SHOULD_NOT_HAVE_BOTH_A_ret_AND_A_protected;
+ struct THE_protected_PART_OF_A_case_STATEMENT_IN_A_switch_SHOULD_HAVE_A_ret;
+
struct NO_case_STATEMENT_CAN_BE_SELECTED;
- struct A_default_case_STATEMENT_IN_A_switch_SHOULD_HAVE_A_ret;
- struct A_case_STATEMENT_IN_A_switch_SHOULD_HAVE_A_ret;
- struct PARAMETER_OF_mlc_where_SHOULD_BE_A_BEXPR;
- }
+
+ } // end of namespace mlc::ERROR
+
+
+ namespace WARNING
+ {
+ struct NO_default_case_STATEMENT_HAS_BEEN_DEFINED;
+
+ } // end of namespace mlc::WARNING
+
+
+
+ namespace internal
+ {
+
+ template <typename T, typename T_is_bexpr>
+ struct where_;
+
+ template <typename bexpr>
+ struct where_ < bexpr, mlc::true_ >
+ : public mlc_if_(bexpr, case_selected, case_not_selected)
+ {
+ };
+
+ template <typename T>
+ struct where_ < T, mlc::false_ >
+ {
+ };
+
+ } // end of namespace mlc::internal
template <typename bexpr>
@@ -75,11 +127,17 @@
private assert_< mlc_is_a(bexpr, mlc::abstract::bexpr),
mlc::ERROR::PARAMETER_OF_mlc_where_SHOULD_BE_A_BEXPR >,
- public mlc_if_( bexpr, case_selected, case_not_selected )
+ // hack so that the error above cannot propagate to the mlc_if_
+ public internal::where_< bexpr,
+ typename mlc_is_a(bexpr, mlc::abstract::bexpr)::eval >
{
};
+
+ mlc_decl_typedef(protected_);
+
+
} // end of namespace mlc
@@ -114,6 +172,17 @@
}; \
\
\
+ template <typename a_case> \
+ struct protected_in_ \
+ { \
+ typedef typename mlc::typedef_::protected_::from_<a_case>::ret the; \
+ typedef typename mlc::is_found_<the>::bexpr is_found; \
+ typedef typename mlc::ret_found_in_<the>::bexpr is_found_with_ret; \
+ typedef mlc_ret(the) ret; \
+ }; \
+ \
+ \
+ \
namespace internal \
{ \
\
@@ -129,20 +198,53 @@
struct handle_case_ <use, context, data, i, 1, 1>; \
\
\
- template <typename use, typename context, typename data> \
- struct handle_default_case_ \
+ template <typename use, \
+ typename context, typename data> \
+ struct handle_default_case_; \
+ \
\
- : private mlc::assert_< mlc::implies_< mlc_is_not_a(mlc_comma_1(NAMESPACE::default_case_<context, data>), \
- mlc::undefined), \
+ \
+ template <typename context, typename data> \
+ struct handle_default_case_ < mlc::internal::a_simple_case, context, data > \
+ \
+ : private mlc::assert_< mlc::implies_< mlc::is_defined_< NAMESPACE::default_case_<context, data> >, \
mlc_is_not_a(mlc_comma_1(NAMESPACE::default_case_<context, data>), \
mlc::where_) >, \
- mlc::ERROR::A_default_case_STATEMENT_SHOULD_NOT_DERIVE_FROM_mlc_where_ >, \
+ mlc::ERROR::A_default_case_STATEMENT_SHOULD_NOT_DERIVE_FROM_mlc_where_ > \
+ { \
+ typedef NAMESPACE::default_case_<context, data> case_t; \
+ typedef typename protected_in_<case_t>::the protected_case_t; \
\
- private mlc::assert_< mlc::implies_< mlc::and_< mlc::eq_<use, mlc::internal::a_switch_case>, \
+ typedef typename mlc::if_< mlc::is_found_<protected_case_t>, \
+ protected_case_t, \
+ case_t >::ret ret; \
+ }; \
+ \
+ \
+ template <typename context, typename data> \
+ struct handle_default_case_ < mlc::internal::a_switch_case, context, data > \
+ \
+ : private mlc::assert_< mlc::implies_< mlc::is_defined_< NAMESPACE::default_case_<context, data> >, \
mlc_is_not_a(mlc_comma_1(NAMESPACE::default_case_<context, data>), \
- mlc::undefined) >, \
- mlc::ret_found_in_< NAMESPACE::default_case_<context, data> > >, \
- mlc::ERROR::A_default_case_STATEMENT_IN_A_switch_SHOULD_HAVE_A_ret > \
+ mlc::where_) >, \
+ mlc::ERROR::A_default_case_STATEMENT_SHOULD_NOT_DERIVE_FROM_mlc_where_ >, \
+ \
+ private mlc::assert_< mlc::implies_< mlc::is_defined_< NAMESPACE::default_case_<context, data> >, \
+ mlc::or_< mlc::ret_found_in_< NAMESPACE::default_case_<context, data> >, \
+ typename protected_in_< NAMESPACE::default_case_<context, data> >::is_found > >, \
+ mlc::ERROR::A_default_case_STATEMENT_IN_A_switch_SHOULD_HAVE_EITHER_A_ret_OR_A_protected >, \
+ \
+ private mlc::assert_< mlc::implies_< mlc::and_< mlc::is_defined_< NAMESPACE::default_case_<context, data> >, \
+ mlc::or_< mlc::ret_found_in_< NAMESPACE::default_case_<context, data> >, \
+ typename protected_in_< NAMESPACE::default_case_<context, data> >::is_found > >, \
+ mlc::xor_< mlc::ret_found_in_< NAMESPACE::default_case_<context, data> >, \
+ typename protected_in_< NAMESPACE::default_case_<context, data> >::is_found > >, \
+ mlc::ERROR::A_default_case_STATEMENT_IN_A_switch_SHOULD_NOT_HAVE_BOTH_A_ret_AND_A_protected >, \
+ \
+ private mlc::assert_< mlc::implies_< typename protected_in_< NAMESPACE::default_case_<context, data> >::is_found, \
+ typename protected_in_< NAMESPACE::default_case_<context, data> >::is_found_with_ret >, \
+ mlc::ERROR::THE_protected_PART_OF_A_default_case_STATEMENT_IN_A_switch_SHOULD_HAVE_A_ret > \
+ \
{ \
typedef NAMESPACE::default_case_<context, data> case_t; \
typedef typename mlc::if_<mlc_is_a(case_t, mlc::undefined), \
@@ -154,14 +256,19 @@
template <typename use, typename context, typename data, unsigned i> \
struct handle_case_ <use, context, data, i, 0, 0> \
\
- : private mlc::assert_< mlc::implies_< mlc_is_not_a(mlc_comma_2(NAMESPACE::case_<context, data, i>), \
- mlc::undefined), \
+ : private mlc::assert_< mlc::implies_< mlc::is_defined_< NAMESPACE::case_<context, data, i> >, \
mlc_is_a(mlc_comma_2(NAMESPACE::case_<context, data, i>), \
mlc::where_) >, \
- mlc::ERROR::A_case_STATEMENT_SHOULD_DERIVE_FROM_mlc_where_ > \
+ mlc::ERROR::A_case_STATEMENT_SHOULD_DERIVE_FROM_mlc_where_ >, \
+ \
+ private mlc::assert_< mlc::is_defined_< NAMESPACE::default_case_<context, data> >, \
+ mlc::WARNING::NO_default_case_STATEMENT_HAS_BEEN_DEFINED > \
+ \
{ \
typedef handle_default_case_<use, context, data> handle_t; \
- typedef typename handle_t::ret ret; \
+ typedef typename mlc::if_< mlc::is_defined_< NAMESPACE::default_case_<context, data> >, \
+ typename handle_t::ret, \
+ mlc::none >::ret ret; \
}; \
\
\
@@ -177,12 +284,31 @@
mlc::ERROR::A_case_STATEMENT_SHOULD_DERIVE_FROM_mlc_where_ >, \
\
private mlc::assert_< mlc::implies_< mlc::and_< mlc::eq_<use, mlc::internal::a_switch_case>, \
- mlc_is_not_a(mlc_comma_2(NAMESPACE::case_<context, data, i>), \
- mlc::undefined) >, \
- mlc::ret_found_in_< NAMESPACE::case_<context, data, i> > >, \
- mlc::ERROR::A_case_STATEMENT_IN_A_switch_SHOULD_HAVE_A_ret > \
+ mlc::is_defined_< NAMESPACE::case_<context, data, i> > >, \
+ mlc::or_< mlc::ret_found_in_< NAMESPACE::case_<context, data, i> >, \
+ typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found > >, \
+ mlc::ERROR::A_case_STATEMENT_IN_A_switch_SHOULD_HAVE_EITHER_A_ret_OR_A_protected >, \
+ \
+ private mlc::assert_< mlc::implies_< mlc::and_list_< mlc::eq_<use, mlc::internal::a_switch_case>, \
+ mlc::is_defined_< NAMESPACE::case_<context, data, i> >, \
+ mlc::or_< mlc::ret_found_in_< NAMESPACE::case_<context, data, i> >, \
+ typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found > >, \
+ mlc::xor_< mlc::ret_found_in_< NAMESPACE::case_<context, data, i> >, \
+ typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found > >, \
+ mlc::ERROR::A_case_STATEMENT_IN_A_switch_SHOULD_NOT_HAVE_BOTH_A_ret_AND_A_protected >, \
+ \
+ private mlc::assert_< mlc::implies_< mlc::and_list_< mlc::eq_<use, mlc::internal::a_switch_case>, \
+ mlc::is_defined_< NAMESPACE::case_<context, data, i> >, \
+ typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found >, \
+ typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found_with_ret >, \
+ mlc::ERROR::THE_protected_PART_OF_A_case_STATEMENT_IN_A_switch_SHOULD_HAVE_A_ret > \
{ \
- typedef NAMESPACE::case_<context, data, i> ret; \
+ typedef NAMESPACE::case_<context, data, i> case_t; \
+ typedef typename protected_in_<case_t>::the protected_case_t; \
+ \
+ typedef typename mlc::if_< mlc::is_found_<protected_case_t>, \
+ protected_case_t, \
+ case_t >::ret ret; \
}; \
\
\
@@ -198,10 +324,24 @@
mlc::ERROR::A_case_STATEMENT_SHOULD_DERIVE_FROM_mlc_where_ >, \
\
private mlc::assert_< mlc::implies_< mlc::and_< mlc::eq_<use, mlc::internal::a_switch_case>, \
- mlc_is_not_a(mlc_comma_2(NAMESPACE::case_<context, data, i>), \
- mlc::undefined) >, \
- mlc::ret_found_in_< NAMESPACE::case_<context, data, i> > >, \
- mlc::ERROR::A_case_STATEMENT_IN_A_switch_SHOULD_HAVE_A_ret > \
+ mlc::is_defined_< NAMESPACE::case_<context, data, i> > >, \
+ mlc::or_< mlc::ret_found_in_< NAMESPACE::case_<context, data, i> >, \
+ typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found > >, \
+ mlc::ERROR::A_case_STATEMENT_IN_A_switch_SHOULD_HAVE_EITHER_A_ret_OR_A_protected >, \
+ \
+ private mlc::assert_< mlc::implies_< mlc::and_list_< mlc::eq_<use, mlc::internal::a_switch_case>, \
+ mlc::is_defined_< NAMESPACE::case_<context, data, i> >, \
+ mlc::or_< mlc::ret_found_in_< NAMESPACE::case_<context, data, i> >, \
+ typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found > >, \
+ mlc::xor_< mlc::ret_found_in_< NAMESPACE::case_<context, data, i> >, \
+ typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found > >, \
+ mlc::ERROR::A_case_STATEMENT_IN_A_switch_SHOULD_NOT_HAVE_BOTH_A_ret_AND_A_protected >, \
+ \
+ private mlc::assert_< mlc::implies_< mlc::and_list_< mlc::eq_<use, mlc::internal::a_switch_case>, \
+ mlc::is_defined_< NAMESPACE::case_<context, data, i> >, \
+ typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found >, \
+ typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found_with_ret >, \
+ mlc::ERROR::THE_protected_PART_OF_A_case_STATEMENT_IN_A_switch_SHOULD_HAVE_A_ret > \
{ \
typedef mlc_is_a(mlc_comma_2(NAMESPACE::case_<context, data, i+1>), \
mlc::case_selected) next_case_is_selected; \
Index: mlc/cmp.hh
--- mlc/cmp.hh (revision 446)
+++ mlc/cmp.hh (working copy)
@@ -33,23 +33,45 @@
# include <mlc/logic.hh>
-/// Macros mlc_eq and mlc_neq.
+
+/// \{
+/// Macros mlc_eq(T1, T2) and mlc_neq(T1, T2).
+
# define mlc_eq( T1, T2) mlc::eq_ <T1, T2>
# define mlc_neq(T1, T2) mlc::neq_<T1, T2>
+/// \}
+
+
+
+/// \{
+/// Macros mlc_something(T) corresponding to mlc::something_<T>.
+
+# define mlc_is_found(T) mlc::is_found_<T>
+# define mlc_is_not_found(T) mlc::is_not_found_<T>
+
+# define mlc_is_undefined(T) mlc::is_undefined_<T>
+# define mlc_is_defined(T) mlc::is_defined_<T>
+
+# define mlc_is_ok(T) mlc::is_ok_<T>
+# define mlc_is_not_ok(T) mlc::is_not_ok_<T>
+
+/// \}
+
+
namespace mlc
{
/// Check whether \a T is a mlc::abstract::value.
template <typename T>
- struct is_value : public mlc_is_a(T, mlc::abstract::value)
+ struct is_value : public mlc_is_a(T, mlc::abstract::value)::bexpr
{
};
/// Check whether \a T is not a mlc::abstract::value.
template <typename T>
- struct is_not_value : public not_<mlc_is_a(T, mlc::abstract::value)>
+ struct is_not_value : public not_<mlc_is_a(T, mlc::abstract::value)>::bexpr
{
};
@@ -71,6 +93,8 @@
};
/// \}
+
+
/// Inequality test between a couple of types.
/// \{
template <typename T1, typename T2>
@@ -95,24 +119,48 @@
/// Shortcuts for comparison with mlc::not_found.
/// \{
template <typename T>
- struct is_found : public neq_<T, not_found>
+ struct is_not_found_ : public mlc_is_a(T, mlc::not_found)::bexpr
{
};
template <typename T>
- struct is_not_found : public neq_<T, not_found>
+ struct is_found_ : public mlc_is_not_a(T, mlc::not_found)::bexpr
+ {
+ };
+ /// \}
+
+
+ /// Shortcuts for testing inheritance from mlc::undefined.
+ /// \{
+ template <typename T>
+ struct is_undefined_ : public mlc_is_a(T, mlc::undefined)::bexpr
+ {
+ };
+
+ template <typename T>
+ struct is_defined_ : public mlc_is_not_a(T, mlc::undefined)::bexpr
{
};
/// \}
/// Check whether a type is a sound (supposedly before using it).
+ /// \{
+ template <typename T>
+ struct is_not_ok_ : public or_list_< is_not_found_<T>,
+ is_undefined_<T>,
+ mlc_is_a(T, mlc::not_ok) >::bexpr
+ {
+ };
+
template <typename T>
- struct is_ok : public and_< neq_<T, not_found>,
- and_< neq_<T, not_ok>,
- neq_<T, undefined > > >
+ struct is_ok_ : public and_list_< is_found_<T>,
+ is_defined_<T>,
+ mlc_is_not_a(T, mlc::not_ok) >::bexpr
{
};
+ /// \}
+
} // end of namespace mlc
1
0