|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69598 - in sandbox/local: . libs/local/example
From: lorcaminiti_at_[hidden]
Date: 2011-03-05 21:06:27
Author: lcaminiti
Date: 2011-03-05 21:06:26 EST (Sat, 05 Mar 2011)
New Revision: 69598
URL: http://svn.boost.org/trac/boost/changeset/69598
Log:
Added WITH_DEFAULT examples.
Added:
sandbox/local/libs/local/example/add_num_factor_sum_default.cpp (contents, props changed)
sandbox/local/libs/local/example/add_num_factor_sum_default_va.cpp (contents, props changed)
sandbox/local/libs/local/example/add_num_factor_sum_with_default_va.cpp (contents, props changed)
Text files modified:
sandbox/local/TODO.txt | 2 +-
sandbox/local/libs/local/example/Jamfile.jam | 4 ++++
2 files changed, 5 insertions(+), 1 deletions(-)
Modified: sandbox/local/TODO.txt
==============================================================================
--- sandbox/local/TODO.txt (original)
+++ sandbox/local/TODO.txt 2011-03-05 21:06:26 EST (Sat, 05 Mar 2011)
@@ -1,6 +1,6 @@
-* Docs: The simplified syntax removes the function name repetition. However, to supoprt recursion the body cannot be static (to access the member functor variable with the local function name defined by the NAME macro). Therefore the limitation that no compiler error if `this` is used instead of `this_` as a pointer within the body (if not used as pointer, compiler will most likely error because `this` is the functor which has a rather different structure than the user's object `this_`).
+* Docs: The simplified syntax removes the function name repetition. However, to supoprt recursion (and nesting) the body cannot be static (to access the member functor variable with the local function name defined by the NAME macro). Therefore the limitation that no compiler error if `this` is used instead of `this_` as a pointer within the body (if not used as pointer, compiler will most likely error because `this` is the functor which has a rather different structure than the user's object `this_`).
* Docs: `inline` does not apply to local function which are already inlined (because they are defined where they are declared).
Modified: sandbox/local/libs/local/example/Jamfile.jam
==============================================================================
--- sandbox/local/libs/local/example/Jamfile.jam (original)
+++ sandbox/local/libs/local/example/Jamfile.jam 2011-03-05 21:06:26 EST (Sat, 05 Mar 2011)
@@ -22,6 +22,10 @@
exe add_num_factor_sum : add_num_factor_sum.cpp ;
exe add_num_factor_sum_va : add_num_factor_sum_va.cpp ;
+exe add_num_factor_sum_default : add_num_factor_sum_default.cpp ;
+exe add_num_factor_sum_default_va : add_num_factor_sum_default_va.cpp ;
+exe add_num_factor_sum_with_default_va : add_num_factor_sum_with_default_va.cpp ;
+
exe add_num_sum : add_num_sum.cpp ;
exe add_num_sum_va : add_num_sum_va.cpp ;
Added: sandbox/local/libs/local/example/add_num_factor_sum_default.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/add_num_factor_sum_default.cpp 2011-03-05 21:06:26 EST (Sat, 05 Mar 2011)
@@ -0,0 +1,25 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the Boost Software
+// License, Version 1.0 (see accompanying file LICENSE_1_0.txt or a
+// copy at http://www.boost.org/LICENSE_1_0.txt).
+
+//[ add_num_factor_sum_default_cpp
+#include <boost/local/function.hpp>
+#include <iostream>
+
+int main() {
+ double sum = 0.0;
+ int factor = 10;
+
+ void BOOST_LOCAL_FUNCTION_PARAMS( (double num)(default +1.23)
+ (const bind factor) (bind& sum) ) {
+ sum += factor * num;
+ std::clog << "Summed: " << sum << std::endl;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ add();
+ return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/add_num_factor_sum_default_va.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/add_num_factor_sum_default_va.cpp 2011-03-05 21:06:26 EST (Sat, 05 Mar 2011)
@@ -0,0 +1,25 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the Boost Software
+// License, Version 1.0 (see accompanying file LICENSE_1_0.txt or a
+// copy at http://www.boost.org/LICENSE_1_0.txt).
+
+//[ add_num_factor_sum_default_va_cpp
+#include <boost/local/function.hpp>
+#include <iostream>
+
+int main() {
+ double sum = 0.0;
+ int factor = 10;
+
+ void BOOST_LOCAL_FUNCTION_PARAMS(double num, default +1.23,
+ const bind factor, bind& sum) {
+ sum += factor * num;
+ std::clog << "Summed: " << sum << std::endl;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ add();
+ return 0;
+}
+//]
+
Added: sandbox/local/libs/local/example/add_num_factor_sum_with_default_va.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/add_num_factor_sum_with_default_va.cpp 2011-03-05 21:06:26 EST (Sat, 05 Mar 2011)
@@ -0,0 +1,27 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the Boost Software
+// License, Version 1.0 (see accompanying file LICENSE_1_0.txt or a
+// copy at http://www.boost.org/LICENSE_1_0.txt).
+
+//[ add_num_factor_sum_with_default_va_cpp
+#include <boost/local/function.hpp>
+#include <iostream>
+
+#define WITH_DEFAULT(value) , default value
+
+int main() {
+ double sum = 0.0;
+ int factor = 10;
+
+ void BOOST_LOCAL_FUNCTION_PARAMS(double num WITH_DEFAULT(+1.23),
+ const bind factor, bind& sum) {
+ sum += factor * num;
+ std::clog << "Summed: " << sum << std::endl;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ add();
+ return 0;
+}
+//]
+
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