[Libreoffice-commits] .: canvas/source o3tl/inc
Thorsten Behrens
thorsten at kemper.freedesktop.org
Tue Feb 8 11:34:04 PST 2011
canvas/source/vcl/impltools.cxx | 3 ++-
o3tl/inc/o3tl/compat_functional.hxx | 20 +++++++++++++++++++-
2 files changed, 21 insertions(+), 2 deletions(-)
New commits:
commit bca38f48296305f1dfc48416691159d3e0d4bf44
Author: Thorsten Behrens <tbehrens at novell.com>
Date: Tue Feb 8 20:25:25 2011 +0100
Added iota to stl compat header, switch canvas to use that
diff --git a/canvas/source/vcl/impltools.cxx b/canvas/source/vcl/impltools.cxx
index 86d8209..5a40ebd 100644
--- a/canvas/source/vcl/impltools.cxx
+++ b/canvas/source/vcl/impltools.cxx
@@ -60,6 +60,7 @@
#include <basegfx/numeric/ftools.hxx>
#include <canvas/canvastools.hxx>
+#include <o3tl/compat_functional.hxx>
#include "impltools.hxx"
#include "canvasbitmap.hxx"
@@ -302,7 +303,7 @@ namespace vclcanvas
{
// source already has alpha channel - 1:1 mapping,
// i.e. aAlphaMap[0]=0,...,aAlphaMap[255]=255.
- ::std::iota( aAlphaMap, &aAlphaMap[256], 0 );
+ ::o3tl::iota( aAlphaMap, &aAlphaMap[256], 0 );
}
else
{
diff --git a/o3tl/inc/o3tl/compat_functional.hxx b/o3tl/inc/o3tl/compat_functional.hxx
index 40c78ff..00ae33c 100644
--- a/o3tl/inc/o3tl/compat_functional.hxx
+++ b/o3tl/inc/o3tl/compat_functional.hxx
@@ -25,7 +25,8 @@
*/
/*
- * Lifted and paraphrased from STLport
+ * Lifted and paraphrased from STLport - with additions from Fridrich
+ * Strba and Thorsten Behrens
*/
#ifndef INCLUDED_O3TL_COMPAT_FUNCTIONAL_HXX
@@ -36,6 +37,7 @@
namespace o3tl
{
+/// Identity functor - return the input value
template<class T>
struct identity : public std::unary_function<T, T>
{
@@ -45,6 +47,7 @@ struct identity : public std::unary_function<T, T>
}
};
+/// Functor, given two parameters, return the first
template<class T1,class T2>
struct project1st : public std::binary_function<T1, T2, T1>
{
@@ -54,6 +57,7 @@ struct project1st : public std::binary_function<T1, T2, T1>
}
};
+/// Functor, given two parameters, return the second
template<class T1,class T2>
struct project2nd : public std::binary_function<T1, T2, T2>
{
@@ -63,6 +67,7 @@ struct project2nd : public std::binary_function<T1, T2, T2>
}
};
+/// Select first value of a pair
template<class P>
struct select1st : public std::unary_function<P, typename P::first_type>
{
@@ -72,6 +77,7 @@ struct select1st : public std::unary_function<P, typename P::first_type>
}
};
+/// Select second value of a pair
template<class P>
struct select2nd : public std::unary_function<P, typename P::second_type>
{
@@ -81,6 +87,7 @@ struct select2nd : public std::unary_function<P, typename P::second_type>
}
};
+/// Call F1 with the result of F2 applied to the one input parameter
template<class F1, class F2>
class unary_compose : public std::unary_function<typename F2::argument_type, typename F1::result_type>
{
@@ -97,12 +104,14 @@ class unary_compose : public std::unary_function<typename F2::argument_type, typ
F2 ftor2;
};
+/// Create functor that calls F1 with the result of F2 applied to the one input parameter
template<class F1, class F2>
inline unary_compose<F1, F2> compose1(const F1& fnction1, const F2& fnction2)
{
return (unary_compose<F1, F2>(fnction1, fnction2));
}
+/// Calls F2 and F3 for the two args of F1, respectively
template<class F1, class F2, class F3>
class binary_compose : public std::unary_function<typename F2::argument_type,typename F1::result_type>
{
@@ -120,12 +129,21 @@ class binary_compose : public std::unary_function<typename F2::argument_type,typ
F3 ftor3;
};
+/// Creates functor that calls F2 and F3 for the two args of F1, respectively
template<class F1, class F2, class F3>
inline binary_compose<F1, F2, F3> compose2(const F1& fnction1, const F2& fnction2, const F3& fnction3)
{
return (binary_compose<F1, F2, F3>(fnction1, fnction2, fnction3));
}
+/// Algo that assigns val, val+1, ... to the given range
+template<typename FwdIter, typename ValueType>
+inline void iota(FwdIter first, FwdIter last, ValueType val)
+{
+ while(first != last)
+ *first++ = val++;
+}
+
} // namespace o3tl
#endif
More information about the Libreoffice-commits
mailing list