Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76563 - in sandbox/closure: boost/functional boost/functional/detail boost/functional/overloaded_function boost/functional/overloaded_function/detail libs/functional/overloaded_function libs/functional/overloaded_function/doc libs/functional/overloaded_function/doc/html libs/functional/overloaded_function/test libs/functional/test libs/scope_exit/doc
From: lorcaminiti_at_[hidden]
Date: 2012-01-17 17:19:51


Author: lcaminiti
Date: 2012-01-17 17:19:49 EST (Tue, 17 Jan 2012)
New Revision: 76563
URL: http://svn.boost.org/trac/boost/changeset/76563

Log:
Overload.
Added:
   sandbox/closure/boost/functional/overloaded_function/
   sandbox/closure/boost/functional/overloaded_function/detail/
   sandbox/closure/libs/functional/overloaded_function/
   sandbox/closure/libs/functional/overloaded_function/doc/
   sandbox/closure/libs/functional/overloaded_function/doc/html/
   sandbox/closure/libs/functional/overloaded_function/test/
   sandbox/closure/libs/functional/overloaded_function/test/overloaded_function.cpp (contents, props changed)
Removed:
   sandbox/closure/boost/functional/config.hpp
   sandbox/closure/boost/functional/detail/
   sandbox/closure/boost/functional/overload.hpp
   sandbox/closure/libs/functional/test/
Text files modified:
   sandbox/closure/libs/scope_exit/doc/scope_exit.qbk | 28 ++++++++++++++--------------
   1 files changed, 14 insertions(+), 14 deletions(-)

Deleted: sandbox/closure/boost/functional/config.hpp
==============================================================================
--- sandbox/closure/boost/functional/config.hpp 2012-01-17 17:19:49 EST (Tue, 17 Jan 2012)
+++ (empty file)
@@ -1,14 +0,0 @@
-
-#ifndef BOOST_FUNCTIONAL_CONFIG_HPP_
-#define BOOST_FUNCTIONAL_CONFIG_HPP_
-
-#ifndef BOOST_FUNCTIONAL_CONFIG_ARITY_MAX
-#define BOOST_FUNCTIONAL_CONFIG_ARITY_MAX 5
-#endif
-
-#ifndef BOOST_FUNCTIONAL_CONFIG_OVERLOAD_MAX
-#define BOOST_FUNCTIONAL_CONFIG_OVERLOAD_MAX 5
-#endif
-
-#endif // #include guard
-

Deleted: sandbox/closure/boost/functional/overload.hpp
==============================================================================
--- sandbox/closure/boost/functional/overload.hpp 2012-01-17 17:19:49 EST (Tue, 17 Jan 2012)
+++ (empty file)
@@ -1,240 +0,0 @@
-
-// 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 DOXY // Doxygen documentation only.
-
-#if !BOOST_PP_IS_ITERATING
-# ifndef BOOST_FUNCTIONAL_OVERLOAD_HPP_
-# define BOOST_FUNCTIONAL_OVERLOAD_HPP_
-
-# include <boost/functional/detail/overload_base.hpp>
-# include <boost/functional/detail/function_type.hpp>
-# include <boost/functional/config.hpp>
-# include <boost/preprocessor/iteration/iterate.hpp>
-# include <boost/preprocessor/repetition/enum.hpp>
-# include <boost/preprocessor/repetition/repeat.hpp>
-# include <boost/preprocessor/control/expr_iif.hpp>
-# include <boost/preprocessor/control/expr_if.hpp>
-# include <boost/preprocessor/comparison/greater.hpp>
-# include <boost/preprocessor/comparison/less.hpp>
-# include <boost/preprocessor/cat.hpp>
-# include <boost/preprocessor/arithmetic/add.hpp>
-# include <boost/preprocessor/tuple/eat.hpp>
-# include <boost/preprocessor/logical/and.hpp>
-# include <boost/preprocessor/logical/not.hpp>
-# include <boost/preprocessor/facilities/expand.hpp>
-
-#define BOOST_FUNCTIONAL_f_type(z, n, unused) \
- BOOST_PP_CAT(F, n)
-
-#define BOOST_FUNCTIONAL_f_arg(z, n, unused) \
- BOOST_PP_CAT(f, n)
-
-#define BOOST_FUNCTIONAL_f_tparam(z, n, unused) \
- typename BOOST_FUNCTIONAL_f_type(z, n, ~) \
-
-#define BOOST_FUNCTIONAL_f_tparam_dflt(z, n, is_tspec) \
- BOOST_FUNCTIONAL_f_tparam(z, n, ~) \
- /* overload requires at least 2 functors so F0 and F1 not optional */ \
- BOOST_PP_EXPR_IIF(BOOST_PP_AND(BOOST_PP_NOT(is_tspec), \
- BOOST_PP_GREATER(n, 1)), \
- = void \
- )
-
-#define BOOST_FUNCTIONAL_f_arg_decl(z, n, unused) \
- BOOST_FUNCTIONAL_f_type(z, n, ~) /* no qualifier to deduce tparam */ \
- BOOST_FUNCTIONAL_f_arg(z, n, ~)
-
-#define BOOST_FUNCTIONAL_g_type(z, n, unused) \
- BOOST_PP_CAT(G, n)
-
-#define BOOST_FUNCTIONAL_g_arg(z, n, unused) \
- BOOST_PP_CAT(g, n)
-
-#define BOOST_FUNCTIONAL_g_tparam(z, n, unused) \
- typename BOOST_FUNCTIONAL_g_type(z, n, ~)
-
-#define BOOST_FUNCTIONAL_g_arg_decl(z, n, unused) \
- BOOST_FUNCTIONAL_g_type(z, n, ~) /* no qualifier to deduce tparam */ \
- BOOST_FUNCTIONAL_g_arg(z, n, ~)
-
-#define BOOST_FUNCTIONAL_overload_base(z, n, unused) \
- ::boost::functional::detail::overload_base< \
- BOOST_FUNCTIONAL_f_type(z, n, ~) \
- >
-
-#define BOOST_FUNCTIONAL_overload_inherit(z, n, unused) \
- public BOOST_FUNCTIONAL_overload_base(z, n, ~)
-
-#define BOOST_FUNCTIONAL_overload_base_init(z, n, unused) \
- BOOST_FUNCTIONAL_overload_base(z, n, ~)( /* base init paren `()` */ \
- BOOST_FUNCTIONAL_g_arg(z, n, ~))
-
-#define BOOST_FUNCTIONAL_using_operator_call(z, n, unused) \
- using BOOST_FUNCTIONAL_overload_base(z, n, ~)::operator();
-
-#define BOOST_FUNCTIONAL_function_type(z, n, unused) \
- typename detail::function_type< BOOST_FUNCTIONAL_f_type(z, n, ~) >::type
-
-namespace boost { namespace functional {
-
-// Iterate within namespace.
-# define BOOST_PP_ITERATION_PARAMS_1 \
- /* need at least 2 functors to overload so iter 2, 3, ... */ \
- (3, (0, BOOST_PP_SUB(BOOST_FUNCTIONAL_CONFIG_OVERLOAD_MAX, 2), \
- "boost/functional/overload.hpp"))
-# include BOOST_PP_ITERATE() // Iterate over function arity.
-
-} }
-
-#undef BOOST_FUNCTIONAL_f_type
-#undef BOOST_FUNCTIONAL_f_arg
-#undef BOOST_FUNCTIONAL_f_tparam
-#undef BOOST_FUNCTIONAL_f_arg_decl
-#undef BOOST_FUNCTIONAL_f_tparam_dflt
-#undef BOOST_FUNCTIONAL_g_type
-#undef BOOST_FUNCTIONAL_g_arg
-#undef BOOST_FUNCTIONAL_g_tparam
-#undef BOOST_FUNCTIONAL_g_arg_decl
-#undef BOOST_FUNCTIONAL_overload_base
-#undef BOOST_FUNCTIONAL_overload_inherit
-#undef BOOST_FUNCTIONAL_overload_base_init
-#undef BOOST_FUNCTIONAL_using_operator_call
-#undef BOOST_FUNCTIONAL_function_type
-
-# endif // #include guard
-
-#elif BOOST_PP_ITERATION_DEPTH() == 1
-# define BOOST_FUNCTIONAL_overloads \
- /* iterate as OVERLOADS, OVERLOADS-1, OVERLOADS-2, ... */ \
- BOOST_PP_SUB(BOOST_FUNCTIONAL_CONFIG_OVERLOAD_MAX, \
- BOOST_PP_FRAME_ITERATION(1))
-# define BOOST_FUNCTIONAL_is_tspec \
- /* if template specialization */ \
- BOOST_PP_LESS(BOOST_FUNCTIONAL_overloads, \
- BOOST_FUNCTIONAL_CONFIG_OVERLOAD_MAX)
-
-template<
- BOOST_PP_ENUM(BOOST_FUNCTIONAL_overloads, BOOST_FUNCTIONAL_f_tparam_dflt,
- BOOST_FUNCTIONAL_is_tspec)
->
-class overload
- // Template specialization.
- BOOST_PP_EXPR_IIF(BOOST_PP_EXPAND(BOOST_FUNCTIONAL_is_tspec), <)
- BOOST_PP_IIF(BOOST_FUNCTIONAL_is_tspec,
- BOOST_PP_ENUM
- ,
- BOOST_PP_TUPLE_EAT(3)
- )(BOOST_FUNCTIONAL_overloads, BOOST_FUNCTIONAL_f_type, ~)
- BOOST_PP_EXPR_IIF(BOOST_PP_EXPAND(BOOST_FUNCTIONAL_is_tspec), >)
- // Bases (overloads >= 2 so always at least 2 bases).
- : BOOST_PP_ENUM(BOOST_FUNCTIONAL_overloads,
- BOOST_FUNCTIONAL_overload_inherit, ~)
-{
-public:
- template<
- BOOST_PP_ENUM(BOOST_FUNCTIONAL_overloads, BOOST_FUNCTIONAL_g_tparam, ~)
- > /* implicit */ inline overload(
- BOOST_PP_ENUM(BOOST_FUNCTIONAL_overloads,
- BOOST_FUNCTIONAL_g_arg_decl, ~))
- // Overloads >= 2 so always at least 2 bases to initialize.
- : BOOST_PP_ENUM(BOOST_FUNCTIONAL_overloads,
- BOOST_FUNCTIONAL_overload_base_init, ~)
- {}
-
- BOOST_PP_REPEAT(BOOST_FUNCTIONAL_overloads,
- BOOST_FUNCTIONAL_using_operator_call, ~)
-};
-
-template<
- BOOST_PP_ENUM(BOOST_FUNCTIONAL_overloads, BOOST_FUNCTIONAL_f_tparam, ~)
->
-overload<
- BOOST_PP_ENUM(BOOST_FUNCTIONAL_overloads, BOOST_FUNCTIONAL_function_type, ~)
-> make_overload(
- BOOST_PP_ENUM(BOOST_FUNCTIONAL_overloads, BOOST_FUNCTIONAL_f_arg_decl, ~)
-) {
- return overload<
- BOOST_PP_ENUM(BOOST_FUNCTIONAL_overloads,
- BOOST_FUNCTIONAL_function_type, ~)
- >(BOOST_PP_ENUM(BOOST_FUNCTIONAL_overloads, BOOST_FUNCTIONAL_f_arg, ~));
-}
-
-# undef BOOST_FUNCTIONAL_overloads
-# undef BOOST_FUNCTIONAL_is_tspec
-#endif // iteration
-
-#else // DOXY: Doxygen documentation only.
-
-/** @file
- * @brief Defines a functor that can be used to overload the call operator of
- * a set of specified functors.
- */
-
-namespace boost { namespace funcational {
-
-/**
- * @brief Functor to overload local functions and other functors.
- *
- * This functor aggregates together calls to functions of all the specified
- * function types <c>F1</c>, <c>F2</c>, etc.
- * Each function type must be specified following the Boost.Function preferred
- * syntax:
- * @code
- * ResultType (ArgumentType1, ArgumgnetType2, ...)
- * @endcode
- *
- * The maximum number of overloaded function types is specified by the
- * @RefMacro{BOOST_FUNCTIONAL_CONFIG_OVERLOAD_MAX} configuration macro.
- * The maximum number of function parameters for each of the specified function
- * type is specified by the @RefMacro{BOOST_FUNCTIONAL_CONFIG_OVERLOAD_MAX}
- * configuration macro.
- *
- * @See @RefSect2{Advanced_Topics, Advanced Topics} section,
- * @RefMacro{BOOST_FUNCTIONAL_CONFIG_OVERLOAD_MAX},
- * @RefMacro{BOOST_FUNCTIONAL_CONFIG_OVERLOAD_MAX}, Boost.Function.
- */
-template<typename F1, typename F2, ...>
-class overload {
-public:
- /**
- * @brief Construct the overloading functor.
- *
- * Any functor that can be converted to a <c>boost::function</c> funcotr
- * can be specified (local functions, function pointers, other functors,
- * etc).
- */
- overload(const boost::function<F1>&, const boost::function<F2>&, ...);
-
- /**
- * @brief Call operator matching the signature of the function type
- * specified as first.
- *
- * This will in turn invoke the call operator of the first functor that was
- * passed to the constructor.
- */
- typename boost::function_traits<F1>::result_type operator()(
- typename boost::function_traits<F1>::arg1_type,
- typename boost::function_traits<F1>::arg2_type,
- ...) const;
-
- /**
- * @brief Call operator matching the signature of the function type
- * specified as second.
- *
- * This will in turn invoke the call operator of the second functor that
- * was passed to the constructor.
- */
- typename boost::function_traits<F2>::result_type operator()(
- typename boost::function_traits<F2>::arg1_type,
- typename boost::function_traits<F2>::arg2_type,
- ...) const;
-};
-
-} }
-
-#endif // DOXY
-

Added: sandbox/closure/libs/functional/overloaded_function/test/overloaded_function.cpp
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/functional/overloaded_function/test/overloaded_function.cpp 2012-01-17 17:19:49 EST (Tue, 17 Jan 2012)
@@ -0,0 +1,60 @@
+
+#include <boost/functional/overloaded_function.hpp>
+#include <boost/function.hpp>
+#define BOOST_TEST_MODULE TestOverloadedFunction
+#include <boost/test/unit_test.hpp>
+#include <string>
+
+//[test_make_overloaded_function_check
+template<typename F>
+void check(F identity) {
+ BOOST_CHECK( identity("abc") == "abc" );
+ BOOST_CHECK( identity(123) == 123 );
+ BOOST_CHECK( identity(1.23) == 1.23 );
+}
+//]
+
+//[test_overloaded_function_declarations
+const std::string& identity_s(const std::string& x) { return x; }
+int identity_i(int x) { return x; }
+double identity_d_impl(double x) { return x; }
+boost::function<double (double)> identity_d = identity_d_impl;
+//]
+
+BOOST_AUTO_TEST_CASE( test_overloaded_function ) {
+ //[test_overloaded_function_calls
+ BOOST_CHECK( identity_s("abc") == "abc" );
+ BOOST_CHECK( identity_i(123) == 123 );
+ BOOST_CHECK( identity_d(1.23) == 1.23 );
+ //]
+
+ {
+ //[test_overloaded_function
+ boost::overloaded_function<
+ const std::string& (const std::string&)
+ , int (int)
+ , double (double)
+ > identity(identity_s, identity_i, identity_d);
+
+ BOOST_CHECK( identity("abc") == "abc" );
+ BOOST_CHECK( identity(123) == 123 );
+ BOOST_CHECK( identity(1.23) == 1.23 );
+ //]
+ }
+
+ {
+ //[test_make_overloaded_function
+ BOOST_AUTO(identity, boost::make_overloaded_function(
+ identity_s, identity_i, identity_d));
+
+ BOOST_CHECK( identity("abc") == "abc" );
+ BOOST_CHECK( identity(123) == 123 );
+ BOOST_CHECK( identity(1.23) == 1.23 );
+ //]
+ }
+
+ //[test_make_overloaded_function_call
+ check(boost::make_overloaded_function(identity_s, identity_i, identity_d));
+ //]
+}
+

Modified: sandbox/closure/libs/scope_exit/doc/scope_exit.qbk
==============================================================================
--- sandbox/closure/libs/scope_exit/doc/scope_exit.qbk (original)
+++ sandbox/closure/libs/scope_exit/doc/scope_exit.qbk 2012-01-17 17:19:49 EST (Tue, 17 Jan 2012)
@@ -5,8 +5,8 @@
     [copyright 2006-2012 Alexander Nasonov, Lorenzo Caminiti]
     [purpose execute arbitrary code at scope exit]
     [license
- Distributed under the Boost Software License, Version 1.0
- (see accompanying file LICENSE_1_0.txt or copy at
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
         [@http://www.boost.org/LICENSE_1_0.txt])
     ]
     [authors [Nasonov, Alexander] [Caminiti, Lorenzo]]
@@ -123,7 +123,7 @@
 
 In particular, the last added person must be deleted from `persons_` if the function throws.
 All we need is to define a delayed action (release of a resource) right after the direct action (resource acquisition).
-For example (see also [@../../test/world.cpp "world.cpp"]):
+For example (see also [@../../test/world.cpp `"world.cpp"`]):
 
 [test_world]
 
@@ -153,7 +153,7 @@
 We use `person::evolution_` to store a version of the changes and increment it to cancel all rollback actions associated with those changes.
 If we pass a current value of `evolution_` stored in the `checkpoint` variable by value, it remains unchanged within the __scope_exit__ body so we can compare it with the final value of `evolution_`.
 If the latter was not incremented since we saved it, the rollback action inside the __scope_exit__ body should be executed.
-For example (see also [@../../test/world_checkpoint.cpp "world_checkpoint.cpp"]):
+For example (see also [@../../test/world_checkpoint.cpp `"world_checkpoint.cpp"`]):
 
 [test_world_checkpoint]
 
@@ -165,7 +165,7 @@
 
 Within a member function, it is also possible to capture the object `this`.
 However, the special symbol `this_` must be used instead of `this` in the __scope_exit__ declaration and body to capture and access the object.
-For example (see also [@../../test/world_this.cpp "world_this.cpp"]):
+For example (see also [@../../test/world_this.cpp `"world_this.cpp"`]):
 
 [test_world_this_]
 
@@ -174,7 +174,7 @@
 The special symbol `this_` can still be used on C++11 to write portable code that can be used on both C++03 and C++11 compilers.
 Unfortunately, using `this` instead of `this_` on C++03 compilers leads to undefined behaviour (it will likely generate a compiler error but that is not guaranteed).
 ]
-For example (see also [@../../test/world_this.cpp "world_this.cpp"]):
+For example (see also [@../../test/world_this.cpp `"world_this.cpp"`]):
 
 [test_world_this]
 
@@ -190,7 +190,7 @@
 [footnote
 Unfortunately, it is not possible to simply invoke the __scope_exit__ macro with no parameters `BOOST_SCOPE_EXIT()` because the preprocessor cannot detect emptiness of a macro parameter when the parameter can start with a non-alphanumeric symbol (which is the case when capturing a variable by reference `&variable`).
 ]
-For example, this can be useful when the __scope_exit__ body only needs to access global variables (see also [@../../test/world_void.cpp "world_void.cpp"]):
+For example, this can be useful when the __scope_exit__ body only needs to access global variables (see also [@../../test/world_void.cpp `"world_void.cpp"`]):
 
 [test_world_void]
 
@@ -209,7 +209,7 @@
 
 Following the same syntax adopted by C++11 lambdas, the [macroref BOOST_SCOPE_EXIT_ALL] macro accepts a comma-separated list of captures which must start with either `&` or `=` to capture all variables in scope respectively by reference or by value (note that no variable name is specified by these leading captures).
 Additional captures of specific variables can follow the leading `&` or `=` and they will override the default reference or value captures.
-For example (see also [@../../test/world_checkpoint_all.cpp "world_checkpoint_all.cpp"]):
+For example (see also [@../../test/world_checkpoint_all.cpp `"world_checkpoint_all.cpp"`]):
 
 [test_world_checkpoint_all]
 
@@ -242,7 +242,7 @@
 
 This is an example of using a badly designed `file` class.
 An instance of `file` does not close the file in its destructor, a programmer is expected to call the `close` member function explicitly.
-For example (see also [@../../example/try_catch.cpp "try_catch.cpp"]):
+For example (see also [@../../example/try_catch.cpp `"try_catch.cpp"`]):
 
 [example_try_catch_bad]
 
@@ -254,7 +254,7 @@
 * If opening throws, the `passwd.close()` should not be called, hence the call to `passwd.is_open()`.
 
 The __scope_exit__ approach does not have any of these issues.
-For example (see also [@../../example/try_catch.cpp "try_catch.cpp"]):
+For example (see also [@../../example/try_catch.cpp `"try_catch.cpp"`]):
 
 [example_try_catch_good]
 
@@ -348,7 +348,7 @@
     
     commit = true;
 
-With __scope_exit__ we can simply do the following (see also [@../../example/scope_guard.cpp "scope_guard.cpp"]):
+With __scope_exit__ we can simply do the following (see also [@../../example/scope_guard.cpp `"scope_guard.cpp"`]):
 
 [example_scope_guard_exit]
 
@@ -367,7 +367,7 @@
 [section C++11 Lambdas]
 
 Using C++11 lambdas, it is relatively easy to implement the __scope_exit__ construct.
-For example (see also [@../../test/world_lambda.cpp "world_lambda.cpp"]):
+For example (see also [@../../test/world_lambda.cpp `"world_lambda.cpp"`]):
 
 [test_world_lambda]
 
@@ -392,12 +392,12 @@
 
     capture1, capture2, ...
 
-For example, the following syntax is accepted on all compilers with and without variadic macro support (see also [@../../test/world_seq.cpp "world_seq.cpp"]):
+For example, the following syntax is accepted on all compilers with and without variadic macro support (see also [@../../test/world_seq.cpp `"world_seq.cpp"`]):
 
 [test_world_seq]
 
 Furthermore, older versions of this library used to only support the __pp_seq__ syntax so the above syntax is also supported for backward compatibility.
-However, in the current version of this library and on compilers with variadic macro support, the following syntax is preferred (see also [@../../test/world.cpp "world.cpp"]):
+However, in the current version of this library and on compilers with variadic macro support, the following syntax is preferred (see also [@../../test/world.cpp `"world.cpp"`]):
 [footnote
 Note that on compilers with variadic macro support, the same [macroref BOOST_SCOPE_EXIT] macro accepts both a comma-separated list and a __pp_seq__ for specifying the capture list.
 That is true also for [macroref BOOST_SCOPE_EXIT_TPL] and [macroref BOOST_SCOPE_EXIT_ALL].


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