From fb43f4ed8e5cb73f8772abcff30b2b187dcd013f Mon Sep 17 00:00:00 2001
From: John Fletcher
Date: Sat, 7 Mar 2015 08:48:22 +0000
Subject: [PATCH 1/7] patch for #11085
---
test/function/function_tests.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/function/function_tests.cpp b/test/function/function_tests.cpp
index 05c6d5a..6f979fa 100644
--- a/test/function/function_tests.cpp
+++ b/test/function/function_tests.cpp
@@ -85,7 +85,7 @@ struct pow_impl
Arg1
operator()(Arg1 a, Arg2 b) const
{
- return pow(a, b);
+ return std::pow(a, b);
}
};
@@ -125,7 +125,7 @@ main()
BOOST_TEST(sqr(arg1)(i5) == (i5*i5));
BOOST_TEST(fact(4)() == 24);
BOOST_TEST(fact(arg1)(i5) == 120);
- BOOST_TEST((int)power(arg1, arg2)(d5, d3) == (int)pow(d5, d3));
+ BOOST_TEST((int)power(arg1, arg2)(d5, d3) == (int)std::pow(d5, d3));
BOOST_TEST((sqr(arg1) + 5)(i5) == ((i5*i5)+5));
BOOST_TEST(add(arg1, arg1, arg1, arg1)(i5) == (5+5+5+5));
From 94ce78bf0d4cd5853c7563ed3230b18b9f9c4db6 Mon Sep 17 00:00:00 2001
From: John Fletcher
Date: Sat, 7 Mar 2015 08:48:56 +0000
Subject: [PATCH 2/7] path for #10927
---
test/stdlib/cmath.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/stdlib/cmath.cpp b/test/stdlib/cmath.cpp
index 95f4a8a..fa17c71 100644
--- a/test/stdlib/cmath.cpp
+++ b/test/stdlib/cmath.cpp
@@ -25,6 +25,6 @@ int main()
BOOST_TEST(f(0.0, 0 * eps));
BOOST_TEST(!f(0.0, eps));
- BOOST_TEST(fabs(x-4.) < eps );
- BOOST_TEST(fabs(z-1.) < eps );
+ BOOST_TEST(std::fabs(x-4.) < eps );
+ BOOST_TEST(std::fabs(z-1.) < eps );
}
From b1885bc5dbefee1bb1c131f0c2b6248334da9c95 Mon Sep 17 00:00:00 2001
From: John Fletcher
Date: Sat, 7 Mar 2015 08:52:07 +0000
Subject: [PATCH 3/7] ChangeLog add note of patches for #10927 and #11085
---
ChangeLog | 2 ++
1 file changed, 2 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index e940f8b..80269fc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -46,6 +46,8 @@ Added test bug5875 - test withdrawn for further checking.
CHANGELOG
- DEVELOP
+- patch for #10927 in test/stdlib/cmath.cpp
+- patch for #11085 in test/function/function_tests.cpp
- V3.2.0
From f62771f33aaf3c1f8d599176fe54a458b63e234c Mon Sep 17 00:00:00 2001
From: John Fletcher
Date: Mon, 9 Mar 2015 11:20:45 +0000
Subject: [PATCH 4/7] doc/*.qbk Updates to documentation
---
doc/lazy_list.qbk | 84 +++++++++++++++++++++++++++++++++++++++-------
doc/what_s_new.qbk | 6 +++-
2 files changed, 77 insertions(+), 13 deletions(-)
diff --git a/doc/lazy_list.qbk b/doc/lazy_list.qbk
index 36e718e..7b85f27 100644
--- a/doc/lazy_list.qbk
+++ b/doc/lazy_list.qbk
@@ -14,10 +14,20 @@
[h1 Summary]
Phoenix now has a lazy list implementation which is very similar but not identical to the implementation provided by __fcpp__. This provides a set of objects defined by list, for example this which defines an empty list of type int.
- list l0;
+ list example;
A list can contain zero or more elements of the same type. It can also be declared using a function returning values of the correct type. Such lists are only evaluated on demand. A set of functions are defined which enable many ways of manipulating and using lists. Examples are provided for the features available.
+Exceptions are provided to deal with certain cases and these can be turned off if desired. There is a check on the maximum list length which has a default of 1000 which can be changed by the user.
+
+This is an extension to Boost Phoenix which does not change the public interface except to define new features in the namespace
+
+ boost::phoenix
+
+It has to be explicitly included using the header
+
+ boost/phoenix/function/lazy_prelude.hpp
+
[/section Introduction]
[h1 Introduction]
@@ -55,7 +65,7 @@ The functions are in the namespace
boost::phoenix
-by the header file
+defined by the header file
boost/phoenix/function/lazy_prelude.hpp
@@ -211,6 +221,59 @@ To be developed.
[endsect]
+[section Exceptions]
+
+Exceptions are used when there is a danger of a runaway or illegal operations on an empty list.
+
+The key example is to take the length of a non-terminating list, e.g.
+
+ length(enum_from(1))
+
+This is protected using an exception:
+
+ lazy_exception
+
+Note that this is implemented such that defining
+
+ BOOST_PHOENIX_NO_LAZY_EXCEPTIONS
+
+will enable the user to turn off the exceptions at their own risk.
+
+ BOOST_PHOENIX_FUNCTION_MAX_LAZY_LIST_LENGTH
+
+is currently defined as 1000 and again the user can define their own value.
+
+In the length function this how it is implemented:
+
+ struct Length {
+ template struct result;
+
+ template
+ struct result
+ {
+ typedef size_t type;
+ };
+
+ template
+ size_t operator()( const L& ll ) const {
+ typename L::delay_result_type l = delay(ll);
+ size_t x = 0;
+ while( !null(l)() ) {
+ l = tail(l);
+ ++x;
+ if (x > BOOST_PHOENIX_FUNCTION_MAX_LAZY_LIST_LENGTH)
+ break;
+ }
+ #ifndef BOOST_PHOENIX_NO_LAZY_EXCEPTIONS
+ if (x > BOOST_PHOENIX_FUNCTION_MAX_LAZY_LIST_LENGTH)
+ throw lazy_exception("Your list is too long!!");
+ #endif
+ return x;
+ }
+ };
+
+[endsect]
+
[section Implementation Details]
[h2 Introduction]
@@ -328,17 +391,15 @@ The code in EFH is used to build a series of objects which each add one element
template
struct EFH
{
- typedef typename boost::remove_reference TT;
- typedef typename boost::remove_const::type TTT;
mutable T x;
EFH( const T& xx) : x(xx) {}
template struct result;
- template
- struct result
+ template
+ struct result
{
typedef typename boost::phoenix::UseList::template
- List::type LType;
+ List::type LType;
typedef typename boost::phoenix::result_of::
ListType::delay_result_type type;
};
@@ -347,13 +408,14 @@ The code in EFH is used to build a series of objects which each add one element
typedef typename result_of::ListType::
delay_result_type result_type;
typedef boost::function0 fun1_R_TTT;
- //std::cout << "EFH (" << x << ")" << std::endl;
++x;
fun1_R_TTT efh_R_TTT = EFH(x);
typedef boost::phoenix::function EFH_R_T;
EFH_R_T efh_R_T(efh_R_TTT);
- if (x > MAX_LIST_LENGTH)
+ #ifndef BOOST_PHOENIX_NO_LAZY_EXCEPTIONS
+ if (x > BOOST_PHOENIX_FUNCTION_MAX_LAZY_LIST_LENGTH)
throw lazy_exception("Running away in EFH!!");
+ #endif
return cons( x-1, efh_R_T() );
}
};
@@ -402,9 +464,7 @@ These implementation mechanisms have been carried through consistently in the im
[section Testing]
-Several tests are currently on develop with the hope of release to master in time for Boost 1.58.0.
-
-At present all tests pass except for list tests on __msvc__ 8.0 and 9.0 which reject a reference of a reference. Corrections for this have now been sucessfuly made.
+Several tests are currently on develop and master in time for Boost 1.58.0.
[endsect]
diff --git a/doc/what_s_new.qbk b/doc/what_s_new.qbk
index 463a579..2650376 100644
--- a/doc/what_s_new.qbk
+++ b/doc/what_s_new.qbk
@@ -23,7 +23,11 @@
[section Phoenix 3.2.0]
-* Phoenix now has a lazy list implementation which is very similar but not identical to the implementation provided by __fcpp__. Details can be found in __phoenix_lazy_list__. Tests have been added for the new features provided.
+* Phoenix now has a lazy list implementation which is very similar but not identical to the implementation provided by __fcpp__.
+ * Details can be found in __phoenix_lazy_list__.
+ * Tests have been added for the new features provided.
+ * This is an addition which causes no changes to the previous public interface.
+* Fixes for #10927 and #11085
[endsect]
From 71c52c4cd4fae2d3900b1c5f77e975803cc05d44 Mon Sep 17 00:00:00 2001
From: John Fletcher
Date: Mon, 9 Mar 2015 11:21:18 +0000
Subject: [PATCH 5/7] function/lazy_prelude.hpp Remove redundant code.
---
include/boost/phoenix/function/lazy_prelude.hpp | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/include/boost/phoenix/function/lazy_prelude.hpp b/include/boost/phoenix/function/lazy_prelude.hpp
index fc1e35a..bfd4cdd 100644
--- a/include/boost/phoenix/function/lazy_prelude.hpp
+++ b/include/boost/phoenix/function/lazy_prelude.hpp
@@ -668,8 +668,6 @@ namespace boost {
template
struct EFH
{
- typedef typename boost::remove_reference TT;
- typedef typename boost::remove_const::type TTT;
mutable T x;
EFH( const T& xx) : x(xx) {}
template struct result;
@@ -693,7 +691,7 @@ namespace boost {
typedef boost::phoenix::function EFH_R_T;
EFH_R_T efh_R_T(efh_R_TTT);
#ifndef BOOST_PHOENIX_NO_LAZY_EXCEPTIONS
- if (x > BOOST_PHOENIX_FUNCTION_MAX_LAZY_LIST_LENGTH)
+ if (x > BOOST_PHOENIX_FUNCTION_MAX_LAZY_LIST_LENGTH)
throw lazy_exception("Running away in EFH!!");
#endif
return cons( x-1, efh_R_T() );
@@ -734,8 +732,6 @@ namespace boost {
template
struct EFTH
{
- typedef typename boost::remove_reference TT;
- typedef typename boost::remove_const::type TTT;
mutable T x;
T y;
EFTH( const T& xx, const T& yy) : x(xx), y(yy) {}
From 49daafbe698900e9f11d5cf0910aecb9161ca4cb Mon Sep 17 00:00:00 2001
From: John Fletcher
Date: Mon, 9 Mar 2015 11:21:33 +0000
Subject: [PATCH 6/7] Updated html pages
---
doc/html/index.html | 3 +-
doc/html/phoenix-doc_HTML.manifest | 1 +
doc/html/phoenix/lazy_list.html | 19 ++-
doc/html/phoenix/lazy_list/exceptions.html | 101 ++++++++++++++
.../lazy_list/implementation_details.html | 123 +++++++++---------
doc/html/phoenix/lazy_list/testing.html | 8 +-
.../list_generation.html | 6 +-
.../phoenix/lazy_list/what_is_provided.html | 2 +-
.../phoenix/what_s_new/phoenix_3_2_0.html | 24 +++-
9 files changed, 208 insertions(+), 79 deletions(-)
create mode 100644 doc/html/phoenix/lazy_list/exceptions.html
diff --git a/doc/html/index.html b/doc/html/index.html
index 20fb02a..e4cd625 100644
--- a/doc/html/index.html
+++ b/doc/html/index.html
@@ -163,6 +163,7 @@
@@ -52,7 +53,7 @@
This provides a set of objects defined by list<type>, for example this
which defines an empty list of type int.
-
list<int>l0;
+
list<int>example;
A list can contain zero or more elements of the same type. It can also be declared
@@ -60,6 +61,22 @@
evaluated on demand. A set of functions are defined which enable many ways
of manipulating and using lists. Examples are provided for the features available.
+
+ Exceptions are provided to deal with certain cases and these can be turned
+ off if desired. There is a check on the maximum list length which has a default
+ of 1000 which can be changed by the user.
+
+
+ This is an extension to Boost Phoenix which does not change the public interface
+ except to define new features in the namespace
+
+
boost::phoenix
+
+
+ It has to be explicitly included using the header
+