|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69093 - in sandbox/local: boost/detail/preprocessor/keyword boost/detail/preprocessor/keyword/utility boost/local/aux_ libs/local/eval libs/local/example libs/local/simpler_syntax
From: lorcaminiti_at_[hidden]
Date: 2011-02-20 14:30:32
Author: lcaminiti
Date: 2011-02-20 14:30:28 EST (Sun, 20 Feb 2011)
New Revision: 69093
URL: http://svn.boost.org/trac/boost/changeset/69093
Log:
Preparing to move variadic syntax files into main boost/ dir.
Added:
sandbox/local/boost/detail/preprocessor/keyword/const.hpp (contents, props changed)
sandbox/local/boost/detail/preprocessor/keyword/default.hpp (contents, props changed)
sandbox/local/boost/detail/preprocessor/keyword/this.hpp (contents, props changed)
sandbox/local/boost/detail/preprocessor/keyword/utility/
sandbox/local/boost/detail/preprocessor/keyword/utility/add.hpp (contents, props changed)
sandbox/local/boost/detail/preprocessor/keyword/utility/is.hpp (contents, props changed)
sandbox/local/boost/detail/preprocessor/keyword/utility/remove.hpp (contents, props changed)
sandbox/local/boost/detail/preprocessor/keyword/void.hpp (contents, props changed)
sandbox/local/libs/local/eval/
sandbox/local/libs/local/eval/01.cpp (contents, props changed)
sandbox/local/libs/local/example/add_num_factor_sum_va.cpp (contents, props changed)
sandbox/local/libs/local/example/factorial_va.cpp (contents, props changed)
Text files modified:
sandbox/local/boost/local/aux_/function_ref.hpp | 11 +++++++----
sandbox/local/libs/local/example/add_num_factor_sum.cpp | 8 +++-----
sandbox/local/libs/local/example/factorial.cpp | 22 ++++++++--------------
sandbox/local/libs/local/simpler_syntax/TODO.txt | 24 ++++++++++++++++++++++++
sandbox/local/libs/local/simpler_syntax/factorial_nomacros.07.cpp | 8 ++++----
5 files changed, 46 insertions(+), 27 deletions(-)
Added: sandbox/local/boost/detail/preprocessor/keyword/const.hpp
==============================================================================
--- (empty file)
+++ sandbox/local/boost/detail/preprocessor/keyword/const.hpp 2011-02-20 14:30:28 EST (Sun, 20 Feb 2011)
@@ -0,0 +1,56 @@
+
+// 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).
+
+#ifndef BOOST_DETAIL_PP_KEYWORD_CONST_HPP_
+#define BOOST_DETAIL_PP_KEYWORD_CONST_HPP_
+
+#include "utility/is.hpp"
+#include "utility/add.hpp"
+#include "utility/remove.hpp"
+
+// These are not local macros -- DO NOT #UNDEF.
+#define BOOST_DETAIL_PP_KEYWORD_CONST_IS_const (1) /* unary */
+#define const_BOOST_DETAIL_PP_KEYWORD_CONST_IS (1) /* unary */
+#define BOOST_DETAIL_PP_KEYWORD_CONST_REMOVE_const /* nothing */
+#define const_BOOST_DETAIL_PP_KEYWORD_CONST_REMOVE /* nothing */
+
+// Is.
+
+#define BOOST_DETAIL_PP_KEYWORD_IS_CONST_FRONT(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_IS_FRONT(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_CONST_IS_)
+
+#define BOOST_DETAIL_PP_KEYWORD_IS_CONST_BACK(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_IS_BACK(tokens, \
+ _BOOST_DETAIL_PP_KEYWORD_CONST_IS)
+
+// Rremove.
+
+#define BOOST_DETAIL_PP_KEYWORD_CONST_REMOVE_FRONT(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_REMOVE_FRONT(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_IS_CONST_FRONT, \
+ BOOST_DETAIL_PP_KEYWORD_CONST_REMOVE_)
+
+#define BOOST_DETAIL_PP_KEYWORD_CONST_REMOVE_BACK(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_REMOVE_BACK(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_IS_CONST_BACK, \
+ _BOOST_DETAIL_PP_KEYWORD_CONST_REMOVE)
+
+// Add.
+
+#define BOOST_DETAIL_PP_KEYWORD_CONST_ADD_FRONT(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_ADD_FRONT(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_IS_CONST_FRONT, \
+ const)
+
+#define BOOST_DETAIL_PP_KEYWORD_CONST_ADD_BACK(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_ADD_BACK(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_IS_CONST_BACK, \
+ const)
+
+#endif // #include guard
+
Added: sandbox/local/boost/detail/preprocessor/keyword/default.hpp
==============================================================================
--- (empty file)
+++ sandbox/local/boost/detail/preprocessor/keyword/default.hpp 2011-02-20 14:30:28 EST (Sun, 20 Feb 2011)
@@ -0,0 +1,56 @@
+
+// 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).
+
+#ifndef BOOST_DETAIL_PP_KEYWORD_DEFAULT_HPP_
+#define BOOST_DETAIL_PP_KEYWORD_DEFAULT_HPP_
+
+#include "utility/is.hpp"
+#include "utility/add.hpp"
+#include "utility/remove.hpp"
+
+// These are not local macros -- DO NOT #UNDEF.
+#define BOOST_DETAIL_PP_KEYWORD_DEFAULT_IS_default (1) /* unary */
+#define default_BOOST_DETAIL_PP_KEYWORD_DEFAULT_IS (1) /* unary */
+#define BOOST_DETAIL_PP_KEYWORD_DEFAULT_REMOVE_default /* nothing */
+#define default_BOOST_DETAIL_PP_KEYWORD_DEFAULT_REMOVE /* nothing */
+
+// Is.
+
+#define BOOST_DETAIL_PP_KEYWORD_IS_DEFAULT_FRONT(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_IS_FRONT(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_DEFAULT_IS_)
+
+#define BOOST_DETAIL_PP_KEYWORD_IS_DEFAULT_BACK(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_IS_BACK(tokens, \
+ _BOOST_DETAIL_PP_KEYWORD_DEFAULT_IS)
+
+// Rremove.
+
+#define BOOST_DETAIL_PP_KEYWORD_DEFAULT_REMOVE_FRONT(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_REMOVE_FRONT(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_IS_DEFAULT_FRONT, \
+ BOOST_DETAIL_PP_KEYWORD_DEFAULT_REMOVE_)
+
+#define BOOST_DETAIL_PP_KEYWORD_DEFAULT_REMOVE_BACK(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_REMOVE_BACK(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_IS_DEFAULT_BACK, \
+ _BOOST_DETAIL_PP_KEYWORD_DEFAULT_REMOVE)
+
+// Add.
+
+#define BOOST_DETAIL_PP_KEYWORD_DEFAULT_ADD_FRONT(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_ADD_FRONT(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_IS_DEFAULT_FRONT, \
+ default)
+
+#define BOOST_DETAIL_PP_KEYWORD_DEFAULT_ADD_BACK(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_ADD_BACK(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_IS_DEFAULT_BACK, \
+ default)
+
+#endif // #include guard
+
Added: sandbox/local/boost/detail/preprocessor/keyword/this.hpp
==============================================================================
--- (empty file)
+++ sandbox/local/boost/detail/preprocessor/keyword/this.hpp 2011-02-20 14:30:28 EST (Sun, 20 Feb 2011)
@@ -0,0 +1,56 @@
+
+// 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).
+
+#ifndef BOOST_DETAIL_PP_KEYWORD_THIS_HPP_
+#define BOOST_DETAIL_PP_KEYWORD_THIS_HPP_
+
+#include "utility/is.hpp"
+#include "utility/add.hpp"
+#include "utility/remove.hpp"
+
+// These are not local macros -- DO NOT #UNDEF.
+#define BOOST_DETAIL_PP_KEYWORD_THIS_IS_this (1) /* unary */
+#define this_BOOST_DETAIL_PP_KEYWORD_THIS_IS (1) /* unary */
+#define BOOST_DETAIL_PP_KEYWORD_THIS_REMOVE_this /* nothing */
+#define this_BOOST_DETAIL_PP_KEYWORD_THIS_REMOVE /* nothing */
+
+// Is.
+
+#define BOOST_DETAIL_PP_KEYWORD_IS_THIS_FRONT(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_IS_FRONT(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_THIS_IS_)
+
+#define BOOST_DETAIL_PP_KEYWORD_IS_THIS_BACK(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_IS_BACK(tokens, \
+ _BOOST_DETAIL_PP_KEYWORD_THIS_IS)
+
+// Rremove.
+
+#define BOOST_DETAIL_PP_KEYWORD_THIS_REMOVE_FRONT(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_REMOVE_FRONT(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_IS_THIS_FRONT, \
+ BOOST_DETAIL_PP_KEYWORD_THIS_REMOVE_)
+
+#define BOOST_DETAIL_PP_KEYWORD_THIS_REMOVE_BACK(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_REMOVE_BACK(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_IS_THIS_BACK, \
+ _BOOST_DETAIL_PP_KEYWORD_THIS_REMOVE)
+
+// Add.
+
+#define BOOST_DETAIL_PP_KEYWORD_THIS_ADD_FRONT(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_ADD_FRONT(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_IS_THIS_FRONT, \
+ this)
+
+#define BOOST_DETAIL_PP_KEYWORD_THIS_ADD_BACK(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_ADD_BACK(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_IS_THIS_BACK, \
+ this)
+
+#endif // #include guard
+
Added: sandbox/local/boost/detail/preprocessor/keyword/utility/add.hpp
==============================================================================
--- (empty file)
+++ sandbox/local/boost/detail/preprocessor/keyword/utility/add.hpp 2011-02-20 14:30:28 EST (Sun, 20 Feb 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).
+
+#ifndef BOOST_DETAIL_PP_KEYWORD_UTILITY_ADD_HPP_
+#define BOOST_DETAIL_PP_KEYWORD_UTILITY_ADD_HPP_
+
+#include <boost/preprocessor/control/expr_iif.hpp>
+#include <boost/preprocessor/logical/not.hpp>
+
+// `is_front_macro(tokens)` is 1 iff `tokens` start with `keyword` to add.
+#define BOOST_DETAIL_PP_KEYWORD_UTILITY_ADD_FRONT( \
+ tokens, is_front_macro, keyword) \
+ BOOST_PP_EXPR_IIF(BOOST_PP_NOT(is_front_macro(tokens)), keyword) tokens
+
+// `is_back_macro(tokens)` is 1 iff `tokens` end with `keyword` to add.
+#define BOOST_DETAIL_PP_KEYWORD_UTILITY_ADD_BACK(tokens, \
+ is_back_macro, keyword) \
+ tokens BOOST_PP_EXPR_IIF(BOOST_PP_NOT(is_back_macro(tokens)), keyword)
+
+#endif // #include guard
+
Added: sandbox/local/boost/detail/preprocessor/keyword/utility/is.hpp
==============================================================================
--- (empty file)
+++ sandbox/local/boost/detail/preprocessor/keyword/utility/is.hpp 2011-02-20 14:30:28 EST (Sun, 20 Feb 2011)
@@ -0,0 +1,30 @@
+
+// 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).
+
+#ifndef BOOST_DETAIL_PP_KEYWORD_UTILITY_IS_HPP_
+#define BOOST_DETAIL_PP_KEYWORD_UTILITY_IS_HPP_
+
+// Boost.Preprocessor author P. Mensodines confirmed on an Boost email thread
+// (subject ``check if a token is a keyword (was "BOOST_PP_IS_UNARY()")'')
+// that it is OK to used `PP_IS_UNARY()` to check if tokens match predefined
+// "keyword" as it is done by the macros below (even if `PP_IS_UNARY()` is
+// technically only part of Boost.Preprocessor private API).
+#include <boost/preprocessor/detail/is_unary.hpp>
+#include <boost/preprocessor/cat.hpp>
+
+// `chekcing_prefix ## tokens` expand to unary (e.g., `(1)`) iff `tokens` start
+// with keyword to check.
+#define BOOST_DETAIL_PP_KEYWORD_UTILITY_IS_FRONT(tokens, checking_prefix) \
+ BOOST_PP_IS_UNARY(BOOST_PP_CAT(checking_prefix, tokens))
+
+// `tokens ## chekcing_postfix` expand to unary (e.g., `(1)`) iff `tokens` end
+// with keyword to check.
+#define BOOST_DETAIL_PP_KEYWORD_UTILITY_IS_BACK(tokens, checking_postfix) \
+ BOOST_PP_IS_UNARY(BOOST_PP_CAT(tokens, checking_postfix))
+
+#endif // #include guard
+
Added: sandbox/local/boost/detail/preprocessor/keyword/utility/remove.hpp
==============================================================================
--- (empty file)
+++ sandbox/local/boost/detail/preprocessor/keyword/utility/remove.hpp 2011-02-20 14:30:28 EST (Sun, 20 Feb 2011)
@@ -0,0 +1,38 @@
+
+// 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).
+
+#ifndef BOOST_DETAIL_PP_KEYWORD_UTILITY_REMOVE_HPP_
+#define BOOST_DETAIL_PP_KEYWORD_UTILITY_REMOVE_HPP_
+
+#include <boost/preprocessor/control/iif.hpp>
+#include <boost/preprocessor/tuple/eat.hpp>
+#include <boost/preprocessor/cat.hpp>
+
+// `is_front_macro(tokens)` is 1 iff `tokens` start with keyword to remove.
+// `removing_prefix ## <keyword-to-remove>` must expand to nothing.
+#define BOOST_DETAIL_PP_KEYWORD_UTILITY_REMOVE_FRONT( \
+ tokens, is_front_macro, removing_prefix) \
+ BOOST_PP_EXPAND( /* without EXPAND doesn't expand on MSVC */ \
+ BOOST_PP_IIF(is_front_macro(tokens), \
+ BOOST_PP_CAT \
+ , \
+ tokens BOOST_PP_TUPLE_EAT(2) \
+ )(removing_prefix, tokens) \
+ )
+
+// `is_back_macro(tokens)` is 1 iff `tokens` end with keyword to remove.
+// `<keyword-to-remove> ## removing_postfix` must expand to nothing.
+#define BOOST_DETAIL_PP_KEYWORD_UTILITY_REMOVE_BACK( \
+ tokens, is_back_macro, removing_prefix) \
+ BOOST_PP_IIF(is_back_macro(tokens), \
+ BOOST_PP_CAT \
+ , \
+ tokens BOOST_PP_TUPLE_EAT(2) \
+ )(tokens, removing_postfix)
+
+#endif // #include guard
+
Added: sandbox/local/boost/detail/preprocessor/keyword/void.hpp
==============================================================================
--- (empty file)
+++ sandbox/local/boost/detail/preprocessor/keyword/void.hpp 2011-02-20 14:30:28 EST (Sun, 20 Feb 2011)
@@ -0,0 +1,56 @@
+
+// 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).
+
+#ifndef BOOST_DETAIL_PP_KEYWORD_VOID_HPP_
+#define BOOST_DETAIL_PP_KEYWORD_VOID_HPP_
+
+#include "utility/is.hpp"
+#include "utility/add.hpp"
+#include "utility/remove.hpp"
+
+// These are not local macros -- DO NOT #UNDEF.
+#define BOOST_DETAIL_PP_KEYWORD_VOID_IS_void (1) /* unary */
+#define void_BOOST_DETAIL_PP_KEYWORD_VOID_IS (1) /* unary */
+#define BOOST_DETAIL_PP_KEYWORD_VOID_REMOVE_void /* nothing */
+#define void_BOOST_DETAIL_PP_KEYWORD_VOID_REMOVE /* nothing */
+
+// Is.
+
+#define BOOST_DETAIL_PP_KEYWORD_IS_VOID_FRONT(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_IS_FRONT(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_VOID_IS_)
+
+#define BOOST_DETAIL_PP_KEYWORD_IS_VOID_BACK(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_IS_BACK(tokens, \
+ _BOOST_DETAIL_PP_KEYWORD_VOID_IS)
+
+// Rremove.
+
+#define BOOST_DETAIL_PP_KEYWORD_VOID_REMOVE_FRONT(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_REMOVE_FRONT(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_IS_VOID_FRONT, \
+ BOOST_DETAIL_PP_KEYWORD_VOID_REMOVE_)
+
+#define BOOST_DETAIL_PP_KEYWORD_VOID_REMOVE_BACK(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_REMOVE_BACK(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_IS_VOID_BACK, \
+ _BOOST_DETAIL_PP_KEYWORD_VOID_REMOVE)
+
+// Add.
+
+#define BOOST_DETAIL_PP_KEYWORD_VOID_ADD_FRONT(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_ADD_FRONT(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_IS_VOID_FRONT, \
+ void)
+
+#define BOOST_DETAIL_PP_KEYWORD_VOID_ADD_BACK(tokens) \
+ BOOST_DETAIL_PP_KEYWORD_UTILITY_ADD_BACK(tokens, \
+ BOOST_DETAIL_PP_KEYWORD_IS_VOID_BACK, \
+ void)
+
+#endif // #include guard
+
Modified: sandbox/local/boost/local/aux_/function_ref.hpp
==============================================================================
--- sandbox/local/boost/local/aux_/function_ref.hpp (original)
+++ sandbox/local/boost/local/aux_/function_ref.hpp 2011-02-20 14:30:28 EST (Sun, 20 Feb 2011)
@@ -24,6 +24,7 @@
# include <boost/preprocessor/arithmetic/sub.hpp>
# include <boost/preprocessor/arithmetic/inc.hpp>
# include <boost/preprocessor/cat.hpp>
+# include <cassert>
#define BOOST_LOCAL_arg_type(z, arg_n, unused) \
BOOST_PP_CAT(A, arg_n)
@@ -41,7 +42,8 @@
#define BOOST_LOCAL_operator_call(z, defaults_n, arity) \
inline R operator()(BOOST_PP_ENUM_ ## z(BOOST_PP_SUB(arity, defaults_n), \
BOOST_LOCAL_arg, ~)) { \
- return ref_(BOOST_PP_ENUM_ ## z(BOOST_PP_SUB(arity, defaults_n), \
+ assert(ptr_); \
+ return (*ptr_)(BOOST_PP_ENUM_ ## z(BOOST_PP_SUB(arity, defaults_n), \
BOOST_LOCAL_arg_name, ~)); \
}
@@ -90,10 +92,11 @@
> base;
public:
- /* implicit */ function_ref(base& ref): ref_(ref) {}
+ /* implicit */ function_ref(): ptr_(0) {}
+ /* implicit */ function_ref(base& ref): ptr_(&ref) {}
function_ref& operator=(base& ref) {
- ref_ = ref;
+ ptr_ = &ref;
return *this;
}
@@ -105,7 +108,7 @@
BOOST_LOCAL_operator_call, BOOST_LOCAL_arity)
private:
- base& ref_;
+ base* ptr_;
};
}} // namespace boost::local
Added: sandbox/local/libs/local/eval/01.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/eval/01.cpp 2011-02-20 14:30:28 EST (Sun, 20 Feb 2011)
@@ -0,0 +1,13 @@
+
+
+struct X {
+};
+
+template<typename T>
+void f() {}
+
+int main() {
+ f<struct Y {}>();
+ return 0;
+}
+
Modified: sandbox/local/libs/local/example/add_num_factor_sum.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_num_factor_sum.cpp (original)
+++ sandbox/local/libs/local/example/add_num_factor_sum.cpp 2011-02-20 14:30:28 EST (Sun, 20 Feb 2011)
@@ -15,15 +15,13 @@
double sum = 0.0;
int factor = 10;
- BOOST_LOCAL_FUNCTION(
- (void) (add)( (double)(num) (const bind)((factor)) (bind)((&sum)) )
- ) {
+ void BOOST_LOCAL_FUNCTION_PARAMS( (double num) (const bind factor)
+ (bind& sum) ) {
sum += factor * num;
std::clog << "Summed: " << sum << std::endl;
- } BOOST_LOCAL_FUNCTION_END(add)
+ } BOOST_LOCAL_FUNCTION_NAME(add)
add(100.0);
-
return 0;
}
//]
Added: sandbox/local/libs/local/example/add_num_factor_sum_va.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/add_num_factor_sum_va.cpp 2011-02-20 14:30:28 EST (Sun, 20 Feb 2011)
@@ -0,0 +1,29 @@
+
+// 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).
+
+// Simple parenthesized syntax example used by the documentation
+// (syntax for variadic macros only).
+
+//[ add_num_factor_sum_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, const bind factor,
+ bind& sum) {
+ sum += factor * num;
+ std::clog << "Summed: " << sum << std::endl;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ add(100.0);
+ return 0;
+}
+//]
+
Modified: sandbox/local/libs/local/example/factorial.cpp
==============================================================================
--- sandbox/local/libs/local/example/factorial.cpp (original)
+++ sandbox/local/libs/local/example/factorial.cpp 2011-02-20 14:30:28 EST (Sun, 20 Feb 2011)
@@ -15,30 +15,24 @@
#include <vector>
int main () {
- std::vector<int> v;
- v.resize(3);
- v[0] = 1; v[1] = 4; v[2] = 7;
- std::ostringstream factorials;
+ std::ostringstream output;
- BOOST_LOCAL_FUNCTION(
- (int) (factorial)(
- (int)(n)
- (bool)(recursion)(default)(false)
- (bind)((&factorials))
- )
- ) {
+ int BOOST_LOCAL_FUNCTION_PARAMS( (int n) (bool recursion)(default false)
+ (bind& output) ) {
int result = 0;
if (n < 2 ) result = 1;
else result = n * factorial(n - 1, true); // Recursive call.
- if (!recursion) factorials << result << " ";
+ if (!recursion) output << result << " ";
return result;
- } BOOST_LOCAL_FUNCTION_END(factorial)
+ } BOOST_LOCAL_FUNCTION_NAME(factorial)
+ std::vector<int> v(3);
+ v[0] = 1; v[1] = 4; v[2] = 7;
std::for_each(v.begin(), v.end(), factorial);
- std::cout << factorials.str() << std::endl;
+ std::cout << output.str() << std::endl;
return 0;
}
//]
Added: sandbox/local/libs/local/example/factorial_va.cpp
==============================================================================
--- (empty file)
+++ sandbox/local/libs/local/example/factorial_va.cpp 2011-02-20 14:30:28 EST (Sun, 20 Feb 2011)
@@ -0,0 +1,40 @@
+
+// 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).
+
+// Use recursion, default parameters, and bind by non-const reference
+// (syntax for variadic macros only).
+
+//[ factorial_va_cpp
+#include <boost/local/function.hpp>
+#include <iostream>
+#include <sstream>
+#include <algorithm>
+#include <vector>
+
+int main () {
+ std::ostringstream output;
+
+ int BOOST_LOCAL_FUNCTION_PARAMS(int n, bool recursion, default false,
+ bind& output) {
+ int result = 0;
+
+ if (n < 2 ) result = 1;
+ else result = n * factorial(n - 1, true); // Recursive call.
+
+ if (!recursion) output << result << " ";
+ return result;
+ } BOOST_LOCAL_FUNCTION_NAME(factorial)
+
+ std::vector<int> v(3);
+ v[0] = 1; v[1] = 4; v[2] = 7;
+ std::for_each(v.begin(), v.end(), factorial);
+
+ std::cout << output.str() << std::endl;
+ return 0;
+}
+//]
+
Modified: sandbox/local/libs/local/simpler_syntax/TODO.txt
==============================================================================
--- sandbox/local/libs/local/simpler_syntax/TODO.txt (original)
+++ sandbox/local/libs/local/simpler_syntax/TODO.txt 2011-02-20 14:30:28 EST (Sun, 20 Feb 2011)
@@ -14,6 +14,14 @@
* Provide bound parameter types within the body (via private typdefs in the functor class) as `BOUND_PARAM_NAME>_type` -- these can be used for concept checking, etc. Actually, provide access to the bind types via a macro BOOST_LOCAL_TYPEOF() so to hide the type name and to strip eventual const& (Vicente's idea).
+* In docs that local functions cannot appear on same line (because __LINE__ is used to generate unique symbols).
+
+* Ask Paul why nil-seq are not part of pp-lib.
+
+* Try to use PP_LIST instead of nil-seq.
+
+* Ask (Paul) for interest in addition PP_KEYWORD to pp-lib.
+
* Rename is_xxx.hpp to xxx.hpp for all PP_KEYWORD and add REMOVE and ADD macros:
> #include <boost/preprocessor.hpp>
> #include <boost/preprocessor/detail/is_unary.hpp>
@@ -43,6 +51,22 @@
> ADD_AUTO(int x) // auto int x
The names should actually be AUTO_IN_FRONT, AUTO_ADD_FRONT, AUTO_REMOVE_FRONT, AUTO_IN_BACK, AUTO_ADD_BACK, AUTO_REMOVE_BACK (the general stuff could go into keyword/utility/in.hpp, add.hpp, remove.hpp).
+* Add to docs that this can never be bound by ref (as in C++).
+
+* Add to docs that MSVC is not C99 because it does not support empty params (so `()` can't be used for empty params and `void` -- or `(void)` -- should be used. However, MSVC supports variadics you can use `..., ...` to separate params instead of parenthesis `(...)...`.
+
+* Add to docs that if `, default ...` syntax seems strange for C99, programmers can always #define and use the following macro (or somenthing similar).
+> #define WITH_DEFAULT(x) , default x
+
+
+
+* Try seriously to make nested locals to work...
+
+* Add to docs that object `this` can never be bound by reference `&this` (as usual in C++ it is not legal to get a reference to the `this` pointer).
+
+* Make sure that non of the binding (outside and inside the functor) code is generated when no param is bound.
+
+* Rename `function_base` to `abstract_function` (because it's abstract) and `function_ref` to `function` (as for Boost.Function because it's no longer a ref since it can be init empty and uses ptr internally).
* Send comments on variadic_macro_data:
Modified: sandbox/local/libs/local/simpler_syntax/factorial_nomacros.07.cpp
==============================================================================
--- sandbox/local/libs/local/simpler_syntax/factorial_nomacros.07.cpp (original)
+++ sandbox/local/libs/local/simpler_syntax/factorial_nomacros.07.cpp 2011-02-20 14:30:28 EST (Sun, 20 Feb 2011)
@@ -9,6 +9,7 @@
//[ factorial_cpp
#include <boost/local/function.hpp>
+#include <boost/type_tratis.hpp>
#include <iostream>
#include <sstream>
#include <algorithm>
@@ -110,7 +111,7 @@
, arg_0, arg_1
);
}
- // Overloading to support default parameters.
+ // Overloads to support default parameters.
result_type_29 operator()(arg_type_0_29 arg_0) {
assert(binds_);
return body(
@@ -186,11 +187,10 @@
// outside the expansion of the PARAMS macro (where the PARAMS symbols
// are no longer available because of the different __LINE__ number).
functor_type factorial;
- } functor_factorial_31(boost_local_auxXargs.value);
+ } functor_factorial(boost_local_auxXargs.value);
// The struct type cannot be passed as template parameter but the function
// type `function_ref<...>` deduced here can.
- BOOST_TYPEOF(functor_factorial_31.factorial) factorial(
- functor_factorial_31);
+ BOOST_TYPEOF(functor_factorial.factorial) factorial(functor_factorial);
// Rest of the program.
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