From b14a690506b0786083714489099bc995a464df97 Mon Sep 17 00:00:00 2001 From: Thorsten Behrens Date: Tue, 8 Feb 2011 20:25:25 +0100 Subject: Added iota to stl compat header, switch canvas to use that --- o3tl/inc/o3tl/compat_functional.hxx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'o3tl/inc') diff --git a/o3tl/inc/o3tl/compat_functional.hxx b/o3tl/inc/o3tl/compat_functional.hxx index 40c78ff9b449..00ae33cb23bb 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 struct identity : public std::unary_function { @@ -45,6 +47,7 @@ struct identity : public std::unary_function } }; +/// Functor, given two parameters, return the first template struct project1st : public std::binary_function { @@ -54,6 +57,7 @@ struct project1st : public std::binary_function } }; +/// Functor, given two parameters, return the second template struct project2nd : public std::binary_function { @@ -63,6 +67,7 @@ struct project2nd : public std::binary_function } }; +/// Select first value of a pair template struct select1st : public std::unary_function { @@ -72,6 +77,7 @@ struct select1st : public std::unary_function } }; +/// Select second value of a pair template struct select2nd : public std::unary_function { @@ -81,6 +87,7 @@ struct select2nd : public std::unary_function } }; +/// Call F1 with the result of F2 applied to the one input parameter template class unary_compose : public std::unary_function { @@ -97,12 +104,14 @@ class unary_compose : public std::unary_function inline unary_compose compose1(const F1& fnction1, const F2& fnction2) { return (unary_compose(fnction1, fnction2)); } +/// Calls F2 and F3 for the two args of F1, respectively template class binary_compose : public std::unary_function { @@ -120,12 +129,21 @@ class binary_compose : public std::unary_function inline binary_compose compose2(const F1& fnction1, const F2& fnction2, const F3& fnction3) { return (binary_compose(fnction1, fnction2, fnction3)); } +/// Algo that assigns val, val+1, ... to the given range +template +inline void iota(FwdIter first, FwdIter last, ValueType val) +{ + while(first != last) + *first++ = val++; +} + } // namespace o3tl #endif -- cgit