|
Boost-Commit : |
From: eric_at_[hidden]
Date: 2008-05-20 21:04:39
Author: eric_niebler
Date: 2008-05-20 21:04:39 EDT (Tue, 20 May 2008)
New Revision: 45592
URL: http://svn.boost.org/trac/boost/changeset/45592
Log:
updated function test for TR1-style function objects
Text files modified:
branches/proto/v4/libs/phoenix/test/function/function_tests.cpp | 50 +++++++++++++++++++++++++++++++++------
1 files changed, 42 insertions(+), 8 deletions(-)
Modified: branches/proto/v4/libs/phoenix/test/function/function_tests.cpp
==============================================================================
--- branches/proto/v4/libs/phoenix/test/function/function_tests.cpp (original)
+++ branches/proto/v4/libs/phoenix/test/function/function_tests.cpp 2008-05-20 21:04:39 EDT (Tue, 20 May 2008)
@@ -28,11 +28,19 @@
struct sqr_impl
{
- template <typename Arg>
- struct result
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Arg>
+ struct result<This(Arg)>
{
typedef Arg type;
};
+
+ template <typename This, typename Arg>
+ struct result<This(Arg &)>
+ : result<This(Arg)>
+ {};
template <typename Arg>
Arg operator()(Arg n) const
@@ -45,11 +53,19 @@
struct fact_impl
{
- template <typename Arg>
- struct result
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Arg>
+ struct result<This(Arg)>
{
typedef Arg type;
};
+
+ template <typename This, typename Arg>
+ struct result<This(Arg &)>
+ : result<This(Arg)>
+ {};
template <typename Arg>
Arg operator()(Arg n) const
@@ -62,15 +78,24 @@
struct pow_impl
{
- template <typename Arg1, typename Arg2>
- struct result
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Arg1, typename Arg2>
+ struct result<This(Arg1, Arg2)>
{
typedef Arg1 type;
};
+
+ template <typename This, typename Arg1, typename Arg2>
+ struct result<This(Arg1 &, Arg2)>
+ : result<This(Arg1, Arg2)>
+ {};
template <typename Arg1, typename Arg2>
Arg1 operator()(Arg1 a, Arg2 b) const
{
+ using std::pow;
return pow(a, b);
}
};
@@ -79,12 +104,20 @@
struct add_impl
{
- template <typename Arg1, typename Arg2, typename Arg3, typename Arg4>
- struct result
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
+ struct result<This(Arg1, Arg2, Arg3, Arg4)>
{
typedef Arg1 type;
};
+ template <typename This, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
+ struct result<This(Arg1 &, Arg2, Arg3, Arg4)>
+ : result<This(Arg1, Arg2, Arg3, Arg4)>
+ {};
+
template <typename Arg1, typename Arg2, typename Arg3, typename Arg4>
Arg1 operator()(Arg1 a, Arg2 b, Arg3 c, Arg4 d) const
{
@@ -97,6 +130,7 @@
int
main()
{
+ using std::pow;
int i5 = 5;
double d5 = 5, d3 = 3;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk