[PATCH 1 of 4] Add identity_val and conj_val functor objects to functor.h
Jason Riedy
jason at acm.org
Mon Mar 9 16:52:19 CDT 2009
# HG changeset patch
# User Jason Riedy <jason at acm.org>
# Date 1236635352 14400
# Node ID 8ec69bd63c7360d9b186677968a5f93038c8c899
# Parent 42e24f4ebc8c70db07d0fcfd08d70b7a40e5519c
Add identity_val and conj_val functor objects to functor.h.
>From 059be213f0d43ff6f5874b689357119961b9dce7 Mon Sep 17 00:00:00 2001
Date: Sun, 8 Mar 2009 16:12:49 -0400
This is a stop-gap. Both of these are unnecessary given features in
the upcoming C++ revision, but wide implementation is some distance
off. Note that both are in an octave_impl namespace to avoid rampant
pollution. Namespaces are widely enough supported now.
Signed-off-by: Jason Riedy <jason at acm.org>
---
liboctave/ChangeLog | 12 ++++++++++++
liboctave/functor.h | 22 ++++++++++++++++++++++
2 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog
--- a/liboctave/ChangeLog
+++ b/liboctave/ChangeLog
@@ -1,3 +1,15 @@
+2009-03-08 Jason Riedy <jason at acm.org>
+
+ * functor.h (octave_impl::identity_val): New function object.
+ Takes a value and returns that value. Should eventually be
+ replaced by standard C++ functor, but those are in newer standards
+ versions.
+ (octave_impl::conj_val): New function object. Takes a value and
+ returns its conjugate. Imports std::conj rather than calling it
+ directly to allow non-standard types to pull in their own conj.
+ Again, this should be replaced by fancier functionality using
+ future C++ features eventually.
+
2009-03-08 Jaroslav Hajek <highegg at gmail.com>
* idx-vector.h (idx_vector::bloop): loop --> bloop.
diff --git a/liboctave/functor.h b/liboctave/functor.h
--- a/liboctave/functor.h
+++ b/liboctave/functor.h
@@ -72,6 +72,28 @@
return functor_with_conversion<CT, RT, PT> (f);
}
+namespace octave_impl {
+
+template <typename T>
+struct identity_val
+ : public std::unary_function <T, T>
+{
+ T operator () (const T x) { return x; }
+};
+
+template <typename T>
+struct conj_val
+ : public std::unary_function <T, T>
+{
+ T operator () (const T x)
+ {
+ using std::conj;
+ return conj (x);
+ }
+};
+
+} // namespace octave_impl
+
#endif
/*
More information about the Octave-maintainers
mailing list