diff --git a/overloaded_function/doc/html/BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX.html b/overloaded_function/doc/html/BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX.html index e51036e..75aa0dd 100644 --- a/overloaded_function/doc/html/BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX.html +++ b/overloaded_function/doc/html/BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX.html @@ -33,7 +33,7 @@ BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX
-

Description

+

Description

If this macro is left undefined by the user, it has a default value of 5 (increasing this number might increase compilation time). When specified by the user, this macro must be a non-negative integer number.

See: Getting Started, boost::overloaded_function.

diff --git a/overloaded_function/doc/html/BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX.html b/overloaded_function/doc/html/BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX.html index a8a75b6..380227d 100644 --- a/overloaded_function/doc/html/BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX.html +++ b/overloaded_function/doc/html/BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX.html @@ -33,7 +33,7 @@ BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX
-

Description

+

Description

If this macro is left undefined by the user, it has a default value of 5 (increasing this number might increase compilation time). When defined by the user, this macro must be an integer number greater or equal than 2 (because at least two distinct functions need to be specified in order to define an overload).

See: Getting Started, boost::overloaded_function.

diff --git a/overloaded_function/doc/html/boost/make_overloaded_function.html b/overloaded_function/doc/html/boost/make_overloaded_function.html index 65d1fce..276cea5 100644 --- a/overloaded_function/doc/html/boost/make_overloaded_function.html +++ b/overloaded_function/doc/html/boost/make_overloaded_function.html @@ -36,7 +36,7 @@ overloaded_function< __function_type__< F1 >, __function_type__< F2 >,...> make_overloaded_function(F1 f1, F2 f2, ...);
-

Description

+

Description

This function template creates and returns an overloaded_function function object that overloads all the specified functions f1, f2, etc.

The function types are internally determined from the template parameter types so they do not need to be explicitly specified. Therefore, this function template usually has a more concise syntax when compared with overloaded_function. This is especially useful when the explicit type of the returned overloaded_function does not need to be known (e.g., when used with Boost.Typeof's BOOST_AUTO (or C++11 auto) or when the overloaded function object is handled using a function template parameter, see the Tutorial section).

The maximum number of functions to overload is given by the BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX configuration macro.

diff --git a/overloaded_function/doc/html/boost/overloaded_function.html b/overloaded_function/doc/html/boost/overloaded_function.html index 4f70698..fd63c83 100644 --- a/overloaded_function/doc/html/boost/overloaded_function.html +++ b/overloaded_function/doc/html/boost/overloaded_function.html @@ -35,19 +35,19 @@ class overloaded_function { public: // construct/copy/destruct - overloaded_function(const boost::function< F1 > &, + overloaded_function(const boost::function< F1 > &, const boost::function< F2 > &, ...); - // public member functions + // public member functions boost::function_traits< F1 >::result_type - operator()(typename boost::function_traits< F1 >::arg1_type, + operator()(typename boost::function_traits< F1 >::arg1_type, typename boost::function_traits< F1 >::arg2_type, ...) const; boost::function_traits< F2 >::result_type - operator()(typename boost::function_traits< F2 >::arg1_type, + operator()(typename boost::function_traits< F2 >::arg1_type, typename boost::function_traits< F2 >::arg2_type, ...) const; };
-

Description

+

Description

This function object aggregates together calls to functions of all the specified function types F1, F2, etc. The specified function types must have distinct parameters from one another and they must be in the following format (which is the Boost.Function preferred syntax):

    result_type (argument1_type, argumgnet2_type, ...)
 
@@ -55,27 +55,27 @@

The maximum number of functions to overload is given by the BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX configuration macro. The maximum number of function parameters for each of the specified function types is given by the BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX configuration macro.

See: Tutorial section, make_overloaded_function, BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX, BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX, Boost.Function.

-

+

overloaded_function public construct/copy/destruct

  1. -
    overloaded_function(const boost::function< F1 > &, 
    +
    overloaded_function(const boost::function< F1 > &, 
                         const boost::function< F2 > &, ...);
    Construct the overloaded function object.

    Any function pointer, function reference, and monomorphic function object that can be converted to a boost::function function object can be specified as parameter.

-

-overloaded_function public member functions

+

+overloaded_function public member functions

  1. boost::function_traits< F1 >::result_type 
    -operator()(typename boost::function_traits< F1 >::arg1_type, 
    +operator()(typename boost::function_traits< F1 >::arg1_type, 
                typename boost::function_traits< F1 >::arg2_type, ...) const;
    Call operator matching the signature of the function type specified as 1st template parameter.

    This will in turn invoke the call operator of the 1st function passed to the constructor.

  2. boost::function_traits< F2 >::result_type 
    -operator()(typename boost::function_traits< F2 >::arg1_type, 
    +operator()(typename boost::function_traits< F2 >::arg1_type, 
                typename boost::function_traits< F2 >::arg2_type, ...) const;
    Call operator matching the signature of the function type specified as 2nd template parameter.

    This will in turn invoke the call operator of the 2nd function passed to the constructor.

    Note: Similar call operators are present for all specified function types F1, F2, etc (even if not exhaustively listed by this documentation).

  3. diff --git a/overloaded_function/doc/html/boost_functional_overloadedfunction/Getting_Started.html b/overloaded_function/doc/html/boost_functional_overloadedfunction/Getting_Started.html index 0a15517..da6325e 100644 --- a/overloaded_function/doc/html/boost_functional_overloadedfunction/Getting_Started.html +++ b/overloaded_function/doc/html/boost_functional_overloadedfunction/Getting_Started.html @@ -41,9 +41,22 @@ and Platforms

- The library was tested by the authors on GCC 4.5.3 (with and without C++11 - features -std=c++0x) and MSVC 8.0 under Linux, Cygwin, - and Windows 7. + The authors originally developed and tested the library on: +

+
    +
  1. + GNU Compiler Collection (GCC) C++ 4.5.3 (with and without C++11 features + enabled -std=c++0x) + on Cygwin. +
  2. +
  3. + Miscrosoft Visual C++ (MSVC) 8.0 on Windows 7. +
  4. +
+

+ See the library regressions + test results for detailed information on supported compilers and + platforms.

diff --git a/overloaded_function/doc/html/boost_functional_overloadedfunction/Tutorial.html b/overloaded_function/doc/html/boost_functional_overloadedfunction/Tutorial.html index cbb370d..1f565ef 100644 --- a/overloaded_function/doc/html/boost_functional_overloadedfunction/Tutorial.html +++ b/overloaded_function/doc/html/boost_functional_overloadedfunction/Tutorial.html @@ -42,23 +42,15 @@ Consider the following functions with distinct signatures:

-

-
const std::string& identity_s(const std::string& x) { return x; } // As pointer.
-
-int identity_i_impl(int x) { return x; }
-int (&identity_i)(int) = identity_i_impl; // Function reference.
-
-double identity_d_impl(double x) { return x; }
-boost::function<double (double)> identity_d = identity_d_impl; // Functor.
-
-

+ [identity_decls]

This library header boost/functional/overloaded_function.hpp provides a boost::overloaded_function class template that creates a single overloaded function object that can be used to call the specified functions instead of using the separate function - names (see also identity.cpp): + names (see also functor.cpp + and identity.hpp):

@@ -114,7 +106,8 @@

The boost::make_overloaded_function function template can be useful when used together with Boost.Typeof's - BOOST_AUTO (or C++11 auto). For example (see also identity.cpp): + BOOST_AUTO (or C++11 auto). For example (see also make_decl.cpp + and identity.hpp):

@@ -143,7 +136,8 @@ Another case where boost::make_overloaded_function can be useful is when the overloaded function object is passed to a function template which can hide the specific boost::overloaded_function - type using a template parameter. For example (see also identity.cpp): + type using a template parameter. For example (see also make_call.cpp + and identity.hpp):

diff --git a/overloaded_function/doc/html/index.html b/overloaded_function/doc/html/index.html index f900f8e..1ca359c 100644 --- a/overloaded_function/doc/html/index.html +++ b/overloaded_function/doc/html/index.html @@ -69,16 +69,7 @@ Consider the following functions with distinct signatures:

-

-
const std::string& identity_s(const std::string& x) { return x; } // As pointer.
-
-int identity_i_impl(int x) { return x; }
-int (&identity_i)(int) = identity_i_impl; // Function reference.
-
-double identity_d_impl(double x) { return x; }
-boost::function<double (double)> identity_d = identity_d_impl; // Functor.
-
-

+ [identity_decls]

Instead of calling them using their separate names (here BOOST_CHECK @@ -97,7 +88,8 @@ It is possible to use this library to create a single overloaded function object (or functor) named identity that aggregates - together the calls to the specific functions (see also identity.cpp): + together the calls to the specific functions (see also functor.cpp + and identity.hpp):

@@ -133,7 +125,7 @@
- +

Last revised: February 20, 2012 at 20:10:59 GMT

Last revised: March 22, 2012 at 20:51:03 GMT


diff --git a/overloaded_function/doc/overloaded_function.qbk b/overloaded_function/doc/overloaded_function.qbk index 0c1d589..8d2bf06 100644 --- a/overloaded_function/doc/overloaded_function.qbk +++ b/overloaded_function/doc/overloaded_function.qbk @@ -27,7 +27,9 @@ [def __Boost_Function__ [@http://www.boost.org/libs/function Boost.Function]] [def __Boost_Typeof__ [@http://www.boost.org/doc/libs/typeof Boost.Typeof]] -[import ../test/identity.cpp] +[import ../test/functor.cpp] +[import ../test/make_decl.cpp] +[import ../test/make_call.cpp] This library allows to overload different functions into a single function object. @@ -45,9 +47,9 @@ The examples of this documentation are executed as part of the library test suit [identity_calls] -It is possible to use this library to create a single [@http://en.wikipedia.org/wiki/Function_overloading overloaded] function object (or [@http://en.wikipedia.org/wiki/Functor functor]) named `identity` that aggregates together the calls to the specific functions (see also [@../../test/identity.cpp =identity.cpp=]): +It is possible to use this library to create a single [@http://en.wikipedia.org/wiki/Function_overloading overloaded] function object (or [@http://en.wikipedia.org/wiki/Functor functor]) named `identity` that aggregates together the calls to the specific functions (see also [@../../test/functor.cpp =functor.cpp=] and [@../../test/identity.hpp =identity.hpp=]): -[identity] +[identity_functor] Note how the functions are called via a single overloaded function object `identity` instead of using their different names `identity_s`, `identity_i`, and `identity_d`. @@ -59,7 +61,12 @@ This section explains how to setup a system to use this library. [section Compilers and Platforms] -The library was tested by the authors on GCC 4.5.3 (with and without C++11 features [^-std=c++0x]) and MSVC 8.0 under Linux, Cygwin, and Windows 7. +The authors originally developed and tested the library on: + +# GNU Compiler Collection (GCC) C++ 4.5.3 (with and without C++11 features enabled `-std=c++0x`) on Cygwin. +# Miscrosoft Visual C++ (MSVC) 8.0 on Windows 7. + +See the library [@http://www.boost.org/development/tests/release/developer/functional-overloaded_function.html regressions test results] for detailed information on supported compilers and platforms. [endsect] @@ -87,9 +94,9 @@ Consider the following functions with distinct signatures: [identity_decls] -This library header [headerref boost/functional/overloaded_function.hpp] provides a [classref boost::overloaded_function] class template that creates a single overloaded function object that can be used to call the specified functions instead of using the separate function names (see also [@../../test/identity.cpp =identity.cpp=]): +This library header [headerref boost/functional/overloaded_function.hpp] provides a [classref boost::overloaded_function] class template that creates a single overloaded function object that can be used to call the specified functions instead of using the separate function names (see also [@../../test/functor.cpp =functor.cpp=] and [@../../test/identity.hpp =identity.hpp=]): -[identity] +[identity_functor] Note how function types in the following format are passed as template parameters to [classref boost::overloaded_function] (this is the format of __Boost_Function__'s preferred syntax): @@ -119,7 +126,7 @@ For convenience, this library also provides the [funcref boost::make_overloaded_ The function types are automatically deduced from the specified functions and the appropriate [classref boost::overloaded_function] instantiation is returned by [funcref boost::make_overloaded_function]. The [funcref boost::make_overloaded_function] function template can be useful when used together with __Boost_Typeof__'s `BOOST_AUTO` (or C++11 `auto`). -For example (see also [@../../test/identity.cpp =identity.cpp=]): +For example (see also [@../../test/make_decl.cpp =make_decl.cpp=] and [@../../test/identity.hpp =identity.hpp=]): [identity_make] @@ -127,7 +134,7 @@ Note how the overloaded function object `identity` has been created specifying o Therefore, [funcref boost::make_overloaded_function] provides a more concise syntax in this context when compared with [classref boost::overloaded_function]. Another case where [funcref boost::make_overloaded_function] can be useful is when the overloaded function object is passed to a function template which can hide the specific [classref boost::overloaded_function] type using a template parameter. -For example (see also [@../../test/identity.cpp =identity.cpp=]): +For example (see also [@../../test/make_call.cpp =make_call.cpp=] and [@../../test/identity.hpp =identity.hpp=]): [identity_make_checks] [identity_make_call] diff --git a/overloaded_function/test/Jamfile.v2 b/overloaded_function/test/Jamfile.v2 index 8856aac..70d65f9 100644 --- a/overloaded_function/test/Jamfile.v2 +++ b/overloaded_function/test/Jamfile.v2 @@ -9,5 +9,7 @@ import testing ; project : requirements /boost//unit_test_framework ; -run identity.cpp ; +run functor.cpp ; +run make_decl.cpp ; +run make_call.cpp ; diff --git a/overloaded_function/test/functor.cpp b/overloaded_function/test/functor.cpp new file mode 100644 index 0000000..6f028a3 --- /dev/null +++ b/overloaded_function/test/functor.cpp @@ -0,0 +1,33 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under 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) +// Home at http://www.boost.org/libs/functional/overloaded_function + +#include "identity.hpp" +#include +#define BOOST_TEST_MODULE TestFunctor +#include + +BOOST_AUTO_TEST_CASE(test_functor) { + //[identity_calls + BOOST_CHECK(identity_s("abc") == "abc"); + BOOST_CHECK(identity_i(123) == 123); + BOOST_CHECK(identity_d(1.23) == 1.23); + //] + + //[identity_functor + boost::overloaded_function< + const std::string& (const std::string&) + , int (int) + , double (double) + > identity(identity_s, identity_i, identity_d); + + // All calls via single `identity` function. + BOOST_CHECK(identity("abc") == "abc"); + BOOST_CHECK(identity(123) == 123); + BOOST_CHECK(identity(1.23) == 1.23); + //] +} + diff --git a/overloaded_function/test/identity.cpp b/overloaded_function/test/identity.cpp deleted file mode 100644 index 9028af7..0000000 --- a/overloaded_function/test/identity.cpp +++ /dev/null @@ -1,70 +0,0 @@ - -// Copyright (C) 2009-2012 Lorenzo Caminiti -// Distributed under 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) -// Home at http://www.boost.org/libs/functional/overloaded_function - -#include -#include -#define BOOST_TEST_MODULE TestIdentity -#include -#include - -//[identity_make_checks -template -void check(F identity) { - BOOST_CHECK(identity("abc") == "abc"); - BOOST_CHECK(identity(123) == 123); - BOOST_CHECK(identity(1.23) == 1.23); -} -//] - -//[identity_decls -const std::string& identity_s(const std::string& x) { return x; } // As pointer. - -int identity_i_impl(int x) { return x; } -int (&identity_i)(int) = identity_i_impl; // Function reference. - -double identity_d_impl(double x) { return x; } -boost::function identity_d = identity_d_impl; // Functor. -//] - -BOOST_AUTO_TEST_CASE(test_identity) { - //[identity_calls - BOOST_CHECK(identity_s("abc") == "abc"); - BOOST_CHECK(identity_i(123) == 123); - BOOST_CHECK(identity_d(1.23) == 1.23); - //] - - { - //[identity - boost::overloaded_function< - const std::string& (const std::string&) - , int (int) - , double (double) - > identity(identity_s, identity_i, identity_d); - - // All calls via single `identity` function. - BOOST_CHECK(identity("abc") == "abc"); - BOOST_CHECK(identity(123) == 123); - BOOST_CHECK(identity(1.23) == 1.23); - //] - } - - { - //[identity_make - 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); - //] - } - - //[identity_make_call - check(boost::make_overloaded_function(identity_s, identity_i, identity_d)); - //] -} - diff --git a/overloaded_function/test/identity.hpp b/overloaded_function/test/identity.hpp new file mode 100644 index 0000000..6602152 --- /dev/null +++ b/overloaded_function/test/identity.hpp @@ -0,0 +1,25 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under 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) +// Home at http://www.boost.org/libs/functional/overloaded_function + +#ifndef IDENTITY_HPP_ +#define IDENTITY_HPP_ + +#include +#include + +//[identity_decls +const std::string& identity_s(const std::string& x) { return x; } // As pointer. + +int identity_i_impl(int x) { return x; } +int (&identity_i)(int) = identity_i_impl; // Function reference. + +double identity_d_impl(double x) { return x; } +boost::function identity_d = identity_d_impl; // Functor. +//] + +#endif // #include guard + diff --git a/overloaded_function/test/make_call.cpp b/overloaded_function/test/make_call.cpp new file mode 100644 index 0000000..651fb10 --- /dev/null +++ b/overloaded_function/test/make_call.cpp @@ -0,0 +1,27 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under 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) +// Home at http://www.boost.org/libs/functional/overloaded_function + +#include "identity.hpp" +#include +#define BOOST_TEST_MODULE TestMakeCall +#include + +//[identity_make_checks +template +void check(F identity) { + BOOST_CHECK(identity("abc") == "abc"); + BOOST_CHECK(identity(123) == 123); + BOOST_CHECK(identity(1.23) == 1.23); +} +//] + +BOOST_AUTO_TEST_CASE(test_identity) { + //[identity_make_call + check(boost::make_overloaded_function(identity_s, identity_i, identity_d)); + //] +} + diff --git a/overloaded_function/test/make_decl.cpp b/overloaded_function/test/make_decl.cpp new file mode 100644 index 0000000..4348e9c --- /dev/null +++ b/overloaded_function/test/make_decl.cpp @@ -0,0 +1,23 @@ + +// Copyright (C) 2009-2012 Lorenzo Caminiti +// Distributed under 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) +// Home at http://www.boost.org/libs/functional/overloaded_function + +#include "identity.hpp" +#include +#define BOOST_TEST_MODULE TestMakeDecl +#include + +BOOST_AUTO_TEST_CASE(test_make_decl) { + //[identity_make + 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); + //] +} +