From 3a8795996f0b4198fd06a7ced9b1d106b4298b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Wed, 29 Apr 2015 11:56:29 +0000 Subject: [PATCH] new functions min and max for 2 - 6 parameters --- src/mrw/mrw.hxx.in | 72 +---------------------------------- src/mrw/stdext.hxx | 94 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 71 deletions(-) diff --git a/src/mrw/mrw.hxx.in b/src/mrw/mrw.hxx.in index 5fcdb66..8747787 100644 --- a/src/mrw/mrw.hxx.in +++ b/src/mrw/mrw.hxx.in @@ -1,16 +1,8 @@ /** @mainpage The official homepage is on: - - http://marc.waeckerlin.org/computer/c_/mrw-c_/index + - https://dev.marc.waeckerlin.org/redmine/projects/mrw-cxx - The minimal runtime package (for use with VideoreKorder): - - Minimalpaket (für den VideoreKorder): - - - @PACKAGE_NAME@-minimal-@PACKAGE_VERSION@-1.i586.rpm - - More downloads see @ref downloads. - All features are listed on the "Modules" page. @@ -43,68 +35,6 @@ and I'll try to help you! My email address is in the file AUTHORS and on my website: http://marc.waeckerlin.org - @section moreinfo Additional Information - - See the "Related Pages". - - - @ref downloads - - @ref readme - - @ref usage - - @ref threads - - @ref libversion - - @ref license - - @ref install - - @ref news - - @ref changes -*/ - -/** @page downloads Download and Installation of the MRW-C++ Library - - Download this documentation in PDF: - - @PACKAGE_NAME@-@PACKAGE_VERSION@.pdf - - Download this version from here: - - Source - - Source TAR-Ball: - - @PACKAGE_NAME@-@PACKAGE_VERSION@.tar.gz - - Installation: - -# tar xzf @PACKAGE_NAME@-@PACKAGE_VERSION@.tar.gz - -# cd @PACKAGE_NAME@-@PACKAGE_VERSION@ - -# ./configure && make all install - - Source RPM Packages: - - @PACKAGE_NAME@-@PACKAGE_VERSION@-1.src.rpm - - Installation:@n sudo rpmbuild --rebuild @PACKAGE_NAME@-@PACKAGE_VERSION@-1.src.rpm - - Requirements to build from source: - - boost: http://boost.org - - cppunit: http://cppunit.sf.net - - log4cxx: http://logging.apache.org/log4cxx - - doxygen: http://doxygen.org - - graphviz: http://www.research.att.com/sw/tools/graphviz - - GNU binutils (you also need the development package, if it is separete (e.g. in Debian)) - - GNU g++, GNU make, GNU autotools: http://gnu.org - - Binary - - Binary RPM Packages (built on i586/SuSE): - - @PACKAGE_NAME@-minimal-@PACKAGE_VERSION@-1.i586.rpm - - Minimal runtime package without debugging support.@n Does not depend on boost and log4cxx and ltdl.@n To be used e.g. with [[:Computer:Linux:Programme:Videorekorder]] - - Installation:@n rpm -Uvh @PACKAGE_NAME@-minimal-@PACKAGE_VERSION@-1.i586.rpm - - @PACKAGE_NAME@-@PACKAGE_VERSION@-1.i586.rpm - - Full runtime library, no multithreading. - - Installation:@n rpm -Uvh @PACKAGE_NAME@-@PACKAGE_VERSION@-1.i586.rpm - - @PACKAGE_NAME@-mt-@PACKAGE_VERSION@-1.i586.rpm - - Full runtime library, with multithreading support. - - Installation:@n rpm -Uvh @PACKAGE_NAME@-mt-@PACKAGE_VERSION@-1.i586.rpm - - @PACKAGE_NAME@-devel-@PACKAGE_VERSION@-1.i586.rpm - - The package for developers. - - Installation:@n rpm -Uvh @PACKAGE_NAME@-devel-@PACKAGE_VERSION@-1.i586.rpm - - Requirements: - - Boost thread library for multi threading:@n http://boost.org - - log4cxx for automated tracing and function traces: - - http://logging.apache.org/log4cxx - - RPM: log4cxx-0.9.7-3.i386.rpm - - mrw::StackTrace requires: - - the GNU Binutils - - either GNU Compiler gcc or GNU C library glibc - - runs better on: either Linux or Solaris */ /** @page usage Usage of the Library: Include and Link diff --git a/src/mrw/stdext.hxx b/src/mrw/stdext.hxx index 65911a2..065f41a 100644 --- a/src/mrw/stdext.hxx +++ b/src/mrw/stdext.hxx @@ -46,6 +46,100 @@ namespace mrw { */ //@{ + /** @defgroup getmax Get the Maximum of Values */ + //@{ + //! Get the maximum out of two values + template T& max(T& t1, T& t2) { + return t2 T& max(T& t1, T& t2, T& t3) { + return max(t1, max(t2, t3)); + } + //! Get the maximum out of four values + template T& max(T& t1, T& t2, T& t3, T& t4) { + return max(max(t1, t2), max(t3, t4)); + } + //! Get the maximum out of five values + template T& max(T& t1, T& t2, T& t3, T& t4, T& t5) { + return max(max(t1, t2), max(t3, t4, t5)); + } + //! Get the maximum out of six values + template T& max(T& t1, T& t2, T& t3, T& t4, T& t5, T& t6) { + return max(max(t1, t2, t3), max(t4, t5, t6)); + } + //! Get the maximum out of two values + template const T& max(const T& t1, const T& t2) { + return t2 const T& max(const T& t1, const T& t2, const T& t3) { + return max(t1, max(t2, t3)); + } + //! Get the maximum out of four values + template const T& max(const T& t1, const T& t2, const T& t3, + const T& t4) { + return max(max(t1, t2), max(t3, t4)); + } + //! Get the maximum out of five values + template const T& max(const T& t1, const T& t2, const T& t3, + const T& t4, const T& t5) { + return max(max(t1, t2), max(t3, t4, t5)); + } + //! Get the maximum out of six values + template const T& max(const T& t1, const T& t2, const T& t3, + const T& t4, const T& t5, const T& t6) { + return max(max(t1, t2, t3), max(t4, t5, t6)); + } + //@} + + /** @defgroup getmin Get the Minimum of Values */ + //@{ + //! Get the minimum out of two values + template T& min(T& t1, T& t2) { + return t1 T& min(T& t1, T& t2, T& t3) { + return min(t1, min(t2, t3)); + } + //! Get the minimum out of four values + template T& min(T& t1, T& t2, T& t3, T& t4) { + return min(min(t1, t2), min(t3, t4)); + } + //! Get the minimum out of five values + template T& min(T& t1, T& t2, T& t3, T& t4, T& t5) { + return min(min(t1, t2), min(t3, t4, t5)); + } + //! Get the minimum out of six values + template T& min(T& t1, T& t2, T& t3, T& t4, T& t5, T& t6) { + return min(min(t1, t2, t3), min(t4, t5, t6)); + } + //! Get the minimum out of two values + template const T& min(const T& t1, const T& t2) { + return t2 const T& min(const T& t1, const T& t2, const T& t3) { + return min(t1, min(t2, t3)); + } + //! Get the minimum out of four values + template const T& min(const T& t1, const T& t2, const T& t3, + const T& t4) { + return min(min(t1, t2), min(t3, t4)); + } + //! Get the minimum out of five values + template const T& min(const T& t1, const T& t2, const T& t3, + const T& t4, const T& t5) { + return min(min(t1, t2), min(t3, t4, t5)); + } + //! Get the minimum out of six values + template const T& min(const T& t1, const T& t2, const T& t3, + const T& t4, const T& t5, const T& t6) { + return min(min(t1, t2, t3), min(t4, t5, t6)); + } + //@} + /** @brief Dual ?: operation: a ? a : b