|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r77709 - in trunk: boost/functional libs/functional/overloaded_function/test
From: lorcaminiti_at_[hidden]
Date: 2012-04-01 21:08:21
Author: lcaminiti
Date: 2012-04-01 21:08:20 EDT (Sun, 01 Apr 2012)
New Revision: 77709
URL: http://svn.boost.org/trac/boost/changeset/77709
Log:
Registering all types so Boost.Functional/OverloadedFunction works in type-of emulation mode (and not just native).
Text files modified:
trunk/boost/functional/overloaded_function.hpp | 16 ++++++++++++----
trunk/libs/functional/overloaded_function/test/Jamfile.v2 | 2 --
trunk/libs/functional/overloaded_function/test/functor.cpp | 19 ++++++++++---------
trunk/libs/functional/overloaded_function/test/identity.hpp | 6 ++++++
trunk/libs/functional/overloaded_function/test/make_call.cpp | 12 ++++++------
trunk/libs/functional/overloaded_function/test/make_decl.cpp | 12 ++++++------
6 files changed, 40 insertions(+), 27 deletions(-)
Modified: trunk/boost/functional/overloaded_function.hpp
==============================================================================
--- trunk/boost/functional/overloaded_function.hpp (original)
+++ trunk/boost/functional/overloaded_function.hpp 2012-04-01 21:08:20 EDT (Sun, 01 Apr 2012)
@@ -14,6 +14,7 @@
# include <boost/functional/overloaded_function/detail/base.hpp>
# include <boost/functional/overloaded_function/detail/function_type.hpp>
# include <boost/functional/overloaded_function/config.hpp>
+# include <boost/typeof/typeof.hpp>
# include <boost/preprocessor/iteration/iterate.hpp>
# include <boost/preprocessor/repetition/enum.hpp>
# include <boost/preprocessor/repetition/repeat.hpp>
@@ -81,8 +82,6 @@
BOOST_FUNCTIONAL_f_type(z, n, ~) \
>::type
-namespace boost {
-
// Iterate within namespace.
# define BOOST_PP_ITERATION_PARAMS_1 \
(3, (0, BOOST_PP_SUB( /*at least 2 func to overload 2, 3, ...*/\
@@ -90,8 +89,6 @@
"boost/functional/overloaded_function.hpp"))
# include BOOST_PP_ITERATE() // Iterate over function arity.
-} // namespace
-
#undef BOOST_FUNCTIONAL_f_type
#undef BOOST_FUNCTIONAL_f_arg
#undef BOOST_FUNCTIONAL_f_tparam
@@ -119,6 +116,11 @@
BOOST_PP_LESS(BOOST_FUNCTIONAL_overloads, \
BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX)
+// For type-of emulation: This must be included at this pp iteration level.
+# include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+
+namespace boost {
+
template<
BOOST_PP_ENUM(BOOST_FUNCTIONAL_overloads, BOOST_FUNCTIONAL_f_tparam_dflt,
BOOST_FUNCTIONAL_is_tspec)
@@ -165,6 +167,12 @@
>(BOOST_PP_ENUM(BOOST_FUNCTIONAL_overloads, BOOST_FUNCTIONAL_f_arg, ~));
}
+} // namespace
+
+// For type-of emulation: Register overloaded function type (for _AUTO, etc).
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::overloaded_function,
+ BOOST_FUNCTIONAL_overloads)
+
# undef BOOST_FUNCTIONAL_overloads
# undef BOOST_FUNCTIONAL_is_tspec
#endif // iteration
Modified: trunk/libs/functional/overloaded_function/test/Jamfile.v2
==============================================================================
--- trunk/libs/functional/overloaded_function/test/Jamfile.v2 (original)
+++ trunk/libs/functional/overloaded_function/test/Jamfile.v2 2012-04-01 21:08:20 EDT (Sun, 01 Apr 2012)
@@ -7,8 +7,6 @@
import testing ;
-project : requirements <library>/boost//unit_test_framework ;
-
run functor.cpp ;
run make_decl.cpp ;
run make_call.cpp ;
Modified: trunk/libs/functional/overloaded_function/test/functor.cpp
==============================================================================
--- trunk/libs/functional/overloaded_function/test/functor.cpp (original)
+++ trunk/libs/functional/overloaded_function/test/functor.cpp 2012-04-01 21:08:20 EDT (Sun, 01 Apr 2012)
@@ -7,14 +7,13 @@
#include "identity.hpp"
#include <boost/functional/overloaded_function.hpp>
-#define BOOST_TEST_MODULE TestFunctor
-#include <boost/test/unit_test.hpp>
+#include <boost/detail/lightweight_test.hpp>
-BOOST_AUTO_TEST_CASE(test_functor) {
+int main() {
//[identity_calls
- BOOST_CHECK(identity_s("abc") == "abc");
- BOOST_CHECK(identity_i(123) == 123);
- BOOST_CHECK(identity_d(1.23) == 1.23);
+ BOOST_TEST(identity_s("abc") == "abc");
+ BOOST_TEST(identity_i(123) == 123);
+ BOOST_TEST(identity_d(1.23) == 1.23);
//]
//[identity_functor
@@ -25,9 +24,11 @@
> 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);
+ BOOST_TEST(identity("abc") == "abc");
+ BOOST_TEST(identity(123) == 123);
+ BOOST_TEST(identity(1.23) == 1.23);
//]
+
+ return boost::report_errors();
}
Modified: trunk/libs/functional/overloaded_function/test/identity.hpp
==============================================================================
--- trunk/libs/functional/overloaded_function/test/identity.hpp (original)
+++ trunk/libs/functional/overloaded_function/test/identity.hpp 2012-04-01 21:08:20 EDT (Sun, 01 Apr 2012)
@@ -19,6 +19,12 @@
double identity_d_impl(double x) { return x; }
boost::function<double (double)> identity_d = identity_d_impl; // Functor.
+
+// For type-of emulation on compilers without native type-of.
+#include <boost/typeof/typeof.hpp>
+#include <boost/typeof/std/string.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function1, 2) // Use `functionN`.
//]
#endif // #include guard
Modified: trunk/libs/functional/overloaded_function/test/make_call.cpp
==============================================================================
--- trunk/libs/functional/overloaded_function/test/make_call.cpp (original)
+++ trunk/libs/functional/overloaded_function/test/make_call.cpp 2012-04-01 21:08:20 EDT (Sun, 01 Apr 2012)
@@ -7,21 +7,21 @@
#include "identity.hpp"
#include <boost/functional/overloaded_function.hpp>
-#define BOOST_TEST_MODULE TestMakeCall
-#include <boost/test/unit_test.hpp>
+#include <boost/detail/lightweight_test.hpp>
//[identity_make_checks
template<typename F>
void check(F identity) {
- BOOST_CHECK(identity("abc") == "abc");
- BOOST_CHECK(identity(123) == 123);
- BOOST_CHECK(identity(1.23) == 1.23);
+ BOOST_TEST(identity("abc") == "abc");
+ BOOST_TEST(identity(123) == 123);
+ BOOST_TEST(identity(1.23) == 1.23);
}
//]
-BOOST_AUTO_TEST_CASE(test_identity) {
+int main() {
//[identity_make_call
check(boost::make_overloaded_function(identity_s, identity_i, identity_d));
//]
+ return boost::report_errors();
}
Modified: trunk/libs/functional/overloaded_function/test/make_decl.cpp
==============================================================================
--- trunk/libs/functional/overloaded_function/test/make_decl.cpp (original)
+++ trunk/libs/functional/overloaded_function/test/make_decl.cpp 2012-04-01 21:08:20 EDT (Sun, 01 Apr 2012)
@@ -7,17 +7,17 @@
#include "identity.hpp"
#include <boost/functional/overloaded_function.hpp>
-#define BOOST_TEST_MODULE TestMakeDecl
-#include <boost/test/unit_test.hpp>
+#include <boost/detail/lightweight_test.hpp>
-BOOST_AUTO_TEST_CASE(test_make_decl) {
+int main() {
//[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);
+ BOOST_TEST(identity("abc") == "abc");
+ BOOST_TEST(identity(123) == 123);
+ BOOST_TEST(identity(1.23) == 1.23);
//]
+ return boost::report_errors();
}
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