|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67198 - trunk/libs/proto/example
From: eric_at_[hidden]
Date: 2010-12-12 21:53:47
Author: eric_niebler
Date: 2010-12-12 21:53:44 EST (Sun, 12 Dec 2010)
New Revision: 67198
URL: http://svn.boost.org/trac/boost/changeset/67198
Log:
misc example clean-up
Text files modified:
trunk/libs/proto/example/calc2.cpp | 23 +++++++++--------------
trunk/libs/proto/example/calc3.cpp | 17 ++++++++---------
trunk/libs/proto/example/futures.cpp | 11 ++++-------
trunk/libs/proto/example/hello.cpp | 1 +
trunk/libs/proto/example/lazy_vector.cpp | 22 ++++++++++------------
trunk/libs/proto/example/mixed.cpp | 2 +-
6 files changed, 33 insertions(+), 43 deletions(-)
Modified: trunk/libs/proto/example/calc2.cpp
==============================================================================
--- trunk/libs/proto/example/calc2.cpp (original)
+++ trunk/libs/proto/example/calc2.cpp 2010-12-12 21:53:44 EST (Sun, 12 Dec 2010)
@@ -16,13 +16,17 @@
namespace proto = boost::proto;
using proto::_;
+template<typename Expr>
+struct calculator_expression;
+
+// Tell proto how to generate expressions in the calculator_domain
+struct calculator_domain
+ : proto::domain<proto::generator<calculator_expression> >
+{};
+
// Will be used to define the placeholders _1 and _2
template<int I> struct placeholder {};
-// For expressions in the calculator domain, operator ()
-// will be special; it will evaluate the expression.
-struct calculator_domain;
-
// Define a calculator context, for evaluating arithmetic expressions
// (This is as before, in calc1.cpp)
struct calculator_context
@@ -54,12 +58,8 @@
struct calculator_expression
: proto::extends<Expr, calculator_expression<Expr>, calculator_domain>
{
- typedef
- proto::extends<Expr, calculator_expression<Expr>, calculator_domain>
- base_type;
-
explicit calculator_expression(Expr const &expr = Expr())
- : base_type(expr)
+ : calculator_expression::proto_extends(expr)
{}
BOOST_PROTO_EXTENDS_USING_ASSIGN(calculator_expression)
@@ -84,11 +84,6 @@
}
};
-// Tell proto how to generate expressions in the calculator_domain
-struct calculator_domain
- : proto::domain<proto::generator<calculator_expression> >
-{};
-
// Define some placeholders (notice they're wrapped in calculator_expression<>)
calculator_expression<proto::terminal< placeholder< 1 > >::type> const _1;
calculator_expression<proto::terminal< placeholder< 2 > >::type> const _2;
Modified: trunk/libs/proto/example/calc3.cpp
==============================================================================
--- trunk/libs/proto/example/calc3.cpp (original)
+++ trunk/libs/proto/example/calc3.cpp 2010-12-12 21:53:44 EST (Sun, 12 Dec 2010)
@@ -51,12 +51,16 @@
// is not used, is mpl::void_.
template<typename Expr>
struct calculator_arity
- : boost::result_of<CalculatorGrammar(Expr, mpl::int_<0>, mpl::void_)>
+ : boost::result_of<CalculatorGrammar(Expr)>
{};
-// For expressions in the calculator domain, operator ()
-// will be special; it will evaluate the expression.
-struct calculator_domain;
+template<typename Expr>
+struct calculator_expression;
+
+// Tell proto how to generate expressions in the calculator_domain
+struct calculator_domain
+ : proto::domain<proto::generator<calculator_expression> >
+{};
// Define a calculator context, for evaluating arithmetic expressions
// (This is as before, in calc1.cpp and calc2.cpp)
@@ -125,11 +129,6 @@
}
};
-// Tell proto how to generate expressions in the calculator_domain
-struct calculator_domain
- : proto::domain<proto::generator<calculator_expression> >
-{};
-
// Define some placeholders (notice they're wrapped in calculator_expression<>)
calculator_expression<proto::terminal< placeholder< mpl::int_<1> > >::type> const _1;
calculator_expression<proto::terminal< placeholder< mpl::int_<2> > >::type> const _2;
Modified: trunk/libs/proto/example/futures.cpp
==============================================================================
--- trunk/libs/proto/example/futures.cpp (original)
+++ trunk/libs/proto/example/futures.cpp 2010-12-12 21:53:44 EST (Sun, 12 Dec 2010)
@@ -80,16 +80,15 @@
: proto::extends<E, future_expr<E>, future_dom>
{
explicit future_expr(E const &e)
- : proto::extends<E, future_expr<E>, future_dom>(e)
+ : future_expr::proto_extends(e)
{}
typename fusion::result_of::as_vector<
- typename boost::result_of<FutureGroup(E,int,int)>::type
+ typename boost::result_of<FutureGroup(E)>::type
>::type
get() const
{
- int i = 0;
- return fusion::as_vector(FutureGroup()(*this, i, i));
+ return fusion::as_vector(FutureGroup()(*this));
}
};
@@ -100,9 +99,7 @@
: future_expr<typename proto::terminal<T>::type>
{
future(T const &t = T())
- : future_expr<typename proto::terminal<T>::type>(
- proto::terminal<T>::type::make(t)
- )
+ : future::proto_derived_expr(future::proto_base_expr::make(t))
{}
T get() const
Modified: trunk/libs/proto/example/hello.cpp
==============================================================================
--- trunk/libs/proto/example/hello.cpp (original)
+++ trunk/libs/proto/example/hello.cpp 2010-12-12 21:53:44 EST (Sun, 12 Dec 2010)
@@ -7,6 +7,7 @@
#include <iostream>
#include <boost/proto/core.hpp>
#include <boost/proto/context.hpp>
+// This #include is only needed for compilers that use typeof emulation:
#include <boost/typeof/std/ostream.hpp>
namespace proto = boost::proto;
Modified: trunk/libs/proto/example/lazy_vector.cpp
==============================================================================
--- trunk/libs/proto/example/lazy_vector.cpp (original)
+++ trunk/libs/proto/example/lazy_vector.cpp 2010-12-12 21:53:44 EST (Sun, 12 Dec 2010)
@@ -21,6 +21,9 @@
namespace proto = boost::proto;
using proto::_;
+template<typename Expr>
+struct lazy_vector_expr;
+
// This grammar describes which lazy vector expressions
// are allowed; namely, vector terminals and addition
// and subtraction of lazy vector expressions.
@@ -32,9 +35,12 @@
>
{};
-// Expressions in the lazy vector domain must conform
-// to the lazy vector grammar
-struct lazy_vector_domain;
+// Tell proto that in the lazy_vector_domain, all
+// expressions should be wrapped in laxy_vector_expr<>
+// and must conform to the lazy vector grammar.
+struct lazy_vector_domain
+ : proto::domain<proto::generator<lazy_vector_expr>, LazyVectorGrammar>
+{};
// Here is an evaluation context that indexes into a lazy vector
// expression, and combines the result.
@@ -72,10 +78,8 @@
struct lazy_vector_expr
: proto::extends<Expr, lazy_vector_expr<Expr>, lazy_vector_domain>
{
- typedef proto::extends<Expr, lazy_vector_expr<Expr>, lazy_vector_domain> base_type;
-
lazy_vector_expr( Expr const & expr = Expr() )
- : base_type( expr )
+ : lazy_vector_expr::proto_extends( expr )
{}
// Use the lazy_subscript_context<> to implement subscripting
@@ -115,12 +119,6 @@
}
};
-// Tell proto that in the lazy_vector_domain, all
-// expressions should be wrapped in laxy_vector_expr<>
-struct lazy_vector_domain
- : proto::domain<proto::generator<lazy_vector_expr>, LazyVectorGrammar>
-{};
-
int main()
{
// lazy_vectors with 4 elements each.
Modified: trunk/libs/proto/example/mixed.cpp
==============================================================================
--- trunk/libs/proto/example/mixed.cpp (original)
+++ trunk/libs/proto/example/mixed.cpp 2010-12-12 21:53:44 EST (Sun, 12 Dec 2010)
@@ -182,7 +182,7 @@
: proto::extends<Expr, MixedExpr<Expr>, MixedDomain>
{
explicit MixedExpr(Expr const &expr)
- : proto::extends<Expr, MixedExpr<Expr>, MixedDomain>(expr)
+ : MixedExpr::proto_extends(expr)
{}
private:
// hide this:
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