summaryrefslogtreecommitdiff
path: root/libs/phoenix/test/function/lazy_templated_struct_tests.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2015-04-08 03:09:47 +0000
committer <>2015-05-05 14:37:32 +0000
commitf2541bb90af059680aa7036f315f052175999355 (patch)
treea5b214744b256f07e1dc2bd7273035a7808c659f /libs/phoenix/test/function/lazy_templated_struct_tests.cpp
parented232fdd34968697a68783b3195b1da4226915b5 (diff)
downloadboost-tarball-master.tar.gz
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_58_0.tar.bz2.HEADboost_1_58_0master
Diffstat (limited to 'libs/phoenix/test/function/lazy_templated_struct_tests.cpp')
-rw-r--r--libs/phoenix/test/function/lazy_templated_struct_tests.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/libs/phoenix/test/function/lazy_templated_struct_tests.cpp b/libs/phoenix/test/function/lazy_templated_struct_tests.cpp
new file mode 100644
index 000000000..b7c990435
--- /dev/null
+++ b/libs/phoenix/test/function/lazy_templated_struct_tests.cpp
@@ -0,0 +1,68 @@
+////////////////////////////////////////////////////////////////////////////
+// lazy_templated_struct_tests.cpp
+//
+// lazy templated struct test to check this works everywhere.
+//
+////////////////////////////////////////////////////////////////////////////
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2015 John Fletcher
+
+ 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)
+==============================================================================*/
+
+#include <boost/phoenix/core/limits.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/function.hpp>
+#include <boost/function.hpp>
+
+namespace example {
+
+ namespace impl {
+ // Example of templated struct.
+ template <typename Result>
+ struct what {
+
+ typedef Result result_type;
+
+ Result operator()(Result const & r) const
+ {
+ return r;
+ }
+ };
+
+ template <typename Result>
+ struct what0 {
+
+ typedef Result result_type;
+
+ Result operator()() const
+ {
+ return Result(100);
+ }
+
+ };
+
+ }
+
+ boost::function1<int, int > what_int = impl::what<int>();
+ boost::function0<int> what0_int = impl::what0<int>();
+ BOOST_PHOENIX_ADAPT_FUNCTION(int,what,what_int,1)
+ BOOST_PHOENIX_ADAPT_FUNCTION_NULLARY(int,what0,what0_int)
+}
+
+int main()
+{
+ int a = 99;
+ using boost::phoenix::arg_names::arg1;
+ BOOST_TEST(example::what_int(a) == a);
+ BOOST_TEST(example::what(a)() == a);
+ BOOST_TEST(example::what(arg1)(a) == a);
+ BOOST_TEST(example::what0_int() == 100);
+ BOOST_TEST(example::what0()() == 100);
+
+ return boost::report_errors();
+}