diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/phoenix | |
parent | Initial commit. (diff) | |
download | ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/phoenix')
297 files changed, 22424 insertions, 0 deletions
diff --git a/src/boost/libs/phoenix/ChangeLog b/src/boost/libs/phoenix/ChangeLog new file mode 100644 index 00000000..ec63b484 --- /dev/null +++ b/src/boost/libs/phoenix/ChangeLog @@ -0,0 +1,257 @@ +Boost Phoenix: A Library for Functional Programming in C++ +http://www.boost.org/ + +Copyright (c) 2005-2010 Joel de Guzman +Copyright (c) 2010-2013 Thomas Heller +Copyright (c) 2014-2015 John Fletcher +Copyright (c) 2016 Kohei Takahashi + +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) + +------------------------------------------------------------------------------- + +TODO (known issues): +- Create a full list of known issues. +- Check all the examples and ammend as needed. +- Update documentation to be consistent with examples. +- Identify other boost libraries using Phoenix in order to + decide on priorities for fixing the bugs below. + One such library is Boost log. +- Identify dependencies on other libraries and cooperate on bugs. + It is now known that the other libraries which use Boost Phoenix + are Boost Spirit and Boost Meta State Machine (MSM) +- Add more examples +- Develop documentation. + A start has been made on this in release 3.1.0 +- Inspection report outstanding issues + Fix libs/phoenix/doc/html/boostbook.css: Unlinked File +- Investigate fixes needed for the following bugs +(all refer to phoenix though not all may be in fact phoenix bugs +#9742 (NEW) +#9291, #9260, #8820, #8800 +#8558, #8504, #8187, #8156, #7996 +#7953, #7946, #7481, #7480, #7423 +#7391, #7356, #6911, #6848, +#6202, #6133, #6026, #5687 +- Feature requests +#7730 Potential fixes for this have been removed for further work. +#7633, #5541 +- Complete work on the following under investigation +#9363, #9362, #8564, #7199 +- #5875 local variable in phoenix let discards value +This seemed already fixed but is not doing well in tests. +Added test bug5875 - test withdrawn for further checking. +------------------------------------------------------------------------------- + +CHANGELOG + +- DEVELOP + +- Many of components now supports C++11 variadic templates. + This is not a breaking change. + +- Boost 1.59.0 + +- Support for <unordered_set> and <unordered_map> + This involves the following changes. + phoenix/config.hpp - New section with the following description: + + This section is to sort out whether hash types or unordered types + are available. This depends on whether stdlib or libc++ is being used + and also whether C++11 or C++03 is being used. + + Client code should contain this: + + #ifdef BOOST_PHOENIX_HAS_HASH + #include BOOST_PHOENIX_HASH_SET_HEADER + #include BOOST_PHOENIX_HASH_MAP_HEADER + #endif + + #ifdef BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP + #define BOOST_PHOENIX_UNORDERED_SET_HEADER <unordered_set> + #define BOOST_PHOENIX_UNORDERED_MAP_HEADER <unordered_map> + #endif + + The client code can then chose the implementation provided. + See the example in test/stl/querying_find2.cpp + This example file has been adjusted for a problem with MSVC 10 + + Modified files: + phoenix/stl/algorithm/detail/has_find.hpp + New files: + phoenix/stl/algorithm/detail/is_unordered_set_or_map.hpp + phoenix/stl/algorithm/detail/std_unordered_set_or_map_fwd.hpp + New test file: + phoenix/test/algorithm/querying_find2.cpp + + Support for retrieving the return type of boost::phoenix::function objects. + This is needed in the lazy functionality. + Modified file: boost/phoenix/function/function.hpp + + Revised version of lazy functionality with added functions. + Modified files in boost/phoenix/function: + lazy_operator.hpp lazy_prelude.hpp lazy_reuse.hpp + New files: + lazy_signature.hpp lazy_smart.hpp + New test files: + lazy_compose_tests.cpp lazy_fold_tests.cpp lazy_scan_tests.cpp + +- Feature enhancements #5604 Sequenced statements of a catch_ statement is + now able to handle thrown exception via local variables. + + Modified files: + boost/phoenix/statement/try_catch.hpp + Modified test files: + exceptions.cpp + +- V3.2.0 in Boost 1.58.0 + +- patch for #10927 in test/stdlib/cmath.cpp +- patch for #11085 in test/function/function_tests.cpp + +- Bump version number to 3.2.0 in version.hpp. + +- New header files in boost/phoenix/function + These are the first versions of the lazy functionality being introduced. + This is reimplementation of the ideas in FC++ on top of Phoenix. + The Phoenix code used is Phoenix.Function, along with Boost.Function. + lazy_prelude.hpp This is the top level header and also has prelude functions. + lazy_operator.hpp This defines lazy operators such as plus and minus. + lazy_list.hpp This defines list<T> a lazy list class and associated code. + lazy_reuser.hpp This defines the reuser functions used in the code. + +- New tests for lazy functionality. + test/include/function/lazy_headers Test of the header structure. + test/function/lazy_list_tests Simple tests of list<T>. + test/function/lazy_list2_tests More tests of list<T>. +- Develop documentation for version 3.2.0 + This includes a new section on the lazy list implementation. + +- Fixed name clash by renaming 'at' to be 'at_' because the name 'at' is + used in phoenix/stl/container/container.hpp. + +- Fixed an unused typedef in phoenix/scope/let.hpp + - contributed by Kohei Takahashi + +- V3.1.1 + +- Bump version number to 3.1.1 in version.hpp and branch for release. + +- New tests for lazy functions using existing phoenix/function capability. + lazy_argument_tests, lazy_make_pair_tests, lazy_templated_struct_tests + +- New example bind_goose.cpp comparing boost.bind and boost.phoenix.bind. + +- Changes to let_tests and more_let_tests to avoid failing cases. + +- Updates to documentation. + +- V3.1.0 +- Bump version number to 3.1.0 in version.hpp and branch for release. +- New file boost/phoenix/config.hpp to centralise configuration issues. + At the moment it simply includes boost/config.hpp +- Changes to some tests to identify problems with several compilers. +- Add more cases to cmath test to test failures on some compilers. +- #7165 and #7166 Change tests to phoenix/core.hpp to reduce compiler load +- Testing fix for failures of tests as follows + bind_member_function_tests, bind_mf2_test, bind_test + with compilers including gcc 4.9.0 and clang 3.5 + This involves use of boost::lazy_disable_if to resolve + the choice of overloaded bind functions in + bind/bind_member_variable.hpp + bind/bind_member_function.hpp Add reverse test boost::lazy_enable_if + This resolves a smaller number of failures. +- #9742 New tests for_each and for_test to attempt to resolve this. +- bind_rv_sp_test changed to give workaround for MSVC 8,9,10, + This removes a COMDAT error which does not occur with boost/bind. + +- V3.0.6 +- Fixed bug in example/container_actor.cpp in end() function. +- Fixed bug4853 and 5626 - added header <utility> for std::forward. +- Fixed bug4853 - added header <iostream> for gcc 4.9 test +- New Feature - boost::phoenix::display_expr(expr) + In file boost/phoenix/core/debug.hpp + and also included from boost/phoenix/core.hpp + For now this drops through to the boost Proto version. + I intend to add some more tags for better information. + New test debug for the new header. +KNOWN BUG - WARNING +- New test more_let_tests to check for problems with losing temporary values. + I think this is a serious problem which is affecting some compilers + and not others. I have seen the problem with Clang 3.4 although not + when run with C++11. These tests should find out where else there is a + problem. At the moment these tests are passing. + I now have cases which fail for Clang 3.4 with optimization -O2 but not + without optimization. Under investigation. + +- V3.0.5 +- Documentation + Start on fixing main documentation - whats new. + Fixed reference for FC++ in two locations. + Fixed example for nested let (#8564) +- Fixed #9113 warnings on -Wshadow + Fixed all warnings +- Fixed #8298 Clang error with Boost Phoenix Local Name Assignment using C++11 + This is not expected to compile in the form supplied. + Added test bug8298 to show correct operation. + Added test bug8298f to show expected failure. +- Fixed #7730 Generic specializations of is_nullary for custom terminals + are not possible + Fix to specialize custom terminals is now set as a default. + Define BOOST_PHOENIX_NO_SPECIALIZE_CUSTOM_TERMINAL not to use this. + Test bug7730 tests the not use case. + +- V3.0.4 +- Inspection report outstanding issues + Fixed copyright and licence in preprocessed files for function_equal +- boost/phoenix/version.hpp Added BOOST_PHOENIX_VERSION_NUMBER + when boost/predef is available. +- Fixed tabs in ChangeLog!! +- Fixed #9295 PHOENIX_LIMIT macro clash: property_tree -- log/sink + This will not show up in phoenix - used in spirit/classic +- Fixed #8704 Using Phoenix lambdas on top of custom Proto expressions + This works for C++11 only. + Test cmath applies to this. +- Fixed #7624 Deduction failure + This works for C++11 and has a workaround for C++03 + Test bug7624 tests both versions. +- Fixed #7166 Phoenix unconditionally sets BOOST_PROTO_MAX_ARITY + using patch supplied + Added test bug7166 +- Fixed #7165 cannot change BOOST_PHOENIX_LIMIT + using patch supplied + Added test bug7165 +- Fixed #6665 not-unary phoenix stl cmath adapted functions not working + Added test cmath + +- V3.0.3 +- Fixed #5824 Block statement headers and docs + Added test bug5824 + +- V3.0.2 +- Fixed #5715 sequencing with comma does not work for boost::phoenix::bind + Added test bug5715 + +- V3.0.1 +- Started CHANGELOG +- Fixed bug_000008 to use phoenix headers correctly. + This fixes it for most systems but not for + Clang Linux C++11 with libstdc++ where the problem seems + to be in boost/thread. + Clang Linux C++11 with libc++ works. +- Fixed #9113 warnings on -Wshadow (some fixed) +- Fixed #9111 unused parameter warning in phoenix bind +- Fixed #8417 Minor documentation +- Fixed #7181 MSVC warnings +- Fixed #6268 phoenix and fusion operator < and added test bug6268 +- Fixed many issues from Inspection report + phoenix/core/detail/phx_result.hpp Fixed clash with Apple macro 'check' + Fixed copyright and licence issues + Fixed tabs in some files + Deleted some empty unused files + Added tests for includes not being tested. + +Boost V1.55: +- V3.0.0 +- Boost Phoenix as passed on to new maintainer John Fletcher diff --git a/src/boost/libs/phoenix/example/adapted_echo_server.cpp b/src/boost/libs/phoenix/example/adapted_echo_server.cpp new file mode 100644 index 00000000..71ea5276 --- /dev/null +++ b/src/boost/libs/phoenix/example/adapted_echo_server.cpp @@ -0,0 +1,111 @@ +// +// Copyright (c) 2011 Thomas Heller +// +// 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 <cstdlib> +#include <iostream> + +#define BOOST_PHOENIX_NO_PREDEFINED_TERMINALS + +#include <boost/phoenix.hpp> +#include <boost/asio.hpp> + +namespace phx = boost::phoenix; + +using boost::phoenix::ref; + +BOOST_PHOENIX_ADAPT_FUNCTION(void, read, boost::asio::async_read, 4) +BOOST_PHOENIX_ADAPT_FUNCTION(void, write, boost::asio::async_write, 3) +BOOST_PHOENIX_ADAPT_FUNCTION(boost::asio::mutable_buffers_1, buffer, boost::asio::buffer, 2) + +template <typename Acceptor, typename Socket, typename Handler> +void accept_impl(Acceptor & acceptor, Socket & socket, Handler const & handler) +{ + acceptor.async_accept(socket, handler); +} +BOOST_PHOENIX_ADAPT_FUNCTION(void, accept, accept_impl, 3) + +typedef phx::expression::local_variable<struct action_key>::type action; + +#include <boost/function.hpp> + +int main(int argc, char* argv[]) +{ + try + { + if (argc != 2) + { + std::cerr << "Usage: async_tcp_echo_server <port>\n"; + return 1; + } + + phx::lambda_type lambda; + phx::arg_names::_1_type _1; + + boost::asio::io_service io_service; + boost::asio::ip::tcp::acceptor acceptor(io_service, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), std::atoi(argv[1]))); + boost::asio::ip::tcp::socket socket(io_service); + std::size_t const max_length = 1024; + char buf[max_length]; + + std::cout << "server starting...\n"; + + boost::function<void(boost::system::error_code const &)> accept_handler; + phx::expression::argument<1>::type _error; + phx::expression::argument<2>::type _length; + action _action; + BOOST_AUTO( + create_handler + , (lambda(_action = lambda[_1]) + [ + if_(!_error) + [ + bind(_action, ref(socket), ref(buf), _error, _length) + ] + .else_ + [ + bind(&boost::asio::ip::tcp::socket::close, ref(socket)) + , accept(ref(acceptor), ref(socket), phx::ref(accept_handler)) + ] + ]) + ); + boost::function<void(boost::system::error_code const &, std::size_t)> read_handler; + boost::function<void(boost::system::error_code const &, std::size_t)> write_handler; + + accept_handler = + if_(!_error) + [ + read(ref(socket), buffer(ref(buf), max_length), boost::asio::transfer_at_least(1), phx::ref(read_handler)) + ]; + + { + phx::expression::argument<1>::type _socket; + phx::expression::argument<2>::type _buf; + phx::expression::argument<3>::type _error; + phx::expression::argument<4>::type _length; + read_handler = create_handler( + write(_socket, buffer(_buf, _length), phx::ref(write_handler)) + ); + + write_handler = create_handler( + read(_socket, buffer(_buf, max_length), boost::asio::transfer_at_least(1), phx::ref(read_handler)) + ); + } + + acceptor.async_accept( + socket + , accept_handler + ); + + io_service.run(); + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + } + + return 0; +} diff --git a/src/boost/libs/phoenix/example/all_odds.cpp b/src/boost/libs/phoenix/example/all_odds.cpp new file mode 100644 index 00000000..66a846c1 --- /dev/null +++ b/src/boost/libs/phoenix/example/all_odds.cpp @@ -0,0 +1,35 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <vector> +#include <algorithm> +#include <iostream> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/statement.hpp> + +int +main() +{ + using boost::phoenix::if_; + using boost::phoenix::arg_names::arg1; + + int init[] = { 2, 10, 4, 5, 1, 6, 8, 3, 9, 7 }; + std::vector<int> c(init, init + 10); + typedef std::vector<int>::iterator iterator; + + // Print all odd contents of an stl container c + std::for_each(c.begin(), c.end(), + if_(arg1 % 2 == 1) + [ + std::cout << arg1 << ' ' + ] + ); + + std::cout << std::endl; + + return 0; +} diff --git a/src/boost/libs/phoenix/example/arguments.cpp b/src/boost/libs/phoenix/example/arguments.cpp new file mode 100644 index 00000000..25ec58d3 --- /dev/null +++ b/src/boost/libs/phoenix/example/arguments.cpp @@ -0,0 +1,21 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <boost/phoenix/core.hpp> + +int +main() +{ + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + + int i = 3; + char const* s = "Hello World"; + std::cout << arg1(i) << std::endl; // prints 3 + std::cout << arg2(i, s) << std::endl; // prints "Hello World" + return 0; +} diff --git a/src/boost/libs/phoenix/example/bind_goose.cpp b/src/boost/libs/phoenix/example/bind_goose.cpp new file mode 100644 index 00000000..66c51994 --- /dev/null +++ b/src/boost/libs/phoenix/example/bind_goose.cpp @@ -0,0 +1,144 @@ +/*============================================================================= +For Boost Bind: + Copyright (c) 2001-2004 Peter Dimov and Multi Media Ltd. + Copyright (c) 2001 David Abrahams + Copyright (c) 2005 Peter Dimov +For Boost Phoenix: + Copyright (c) 2001-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller +For the example: + Copyright (c) 2011 Paul Heil + 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) +==============================================================================*/ +// bind_goose.cpp +// This example is based on code by Paul Heil to be found here: +// http://www.codeproject.com/Tips/248492/How-does-boost-phoenix-improve-boost-bind +// +// Show different ways of using boost bind and phoenix to handle deletion. +// + + +#include <iostream> +#include <boost/function.hpp> +#include <boost/bind.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/operator/comparison.hpp> +#include <boost/phoenix/stl/algorithm/transformation.hpp> +#include <functional> +#include <string> +#include <vector> + +//////////////////////////////////////////// +// Set up the list here +//////////////////////////////////////////// +std::vector< std::string > make_list() { + std::vector< std::string > list; + list.push_back( "duck" ); + list.push_back( "duck" ); + list.push_back( "goose" ); + return list; +} +////////////////////////////////////////////// +// First example using standard library only +////////////////////////////////////////////// +bool IsGoose( const std::string& s ) +{ + return s == "goose"; +} + +void delete_value1(std::vector< std::string > &list ) +{ + list.erase( std::remove_if( list.begin(), list.end(), IsGoose ), list.end() ); +} + +void out_string(const std::string &s) +{ + std::cout << s << std::endl; +} + +void show_list1( const std::vector< std::string > &list ) +{ + std::for_each(list.begin(), list.end(), out_string); +} + +////////////////////////////////////////////// +// Second example using boost bind +////////////////////////////////////////////// + +bool isValue(const std::string &s1, const std::string &s2) +{ + return s1==s2; +} + +void delete_value2(std::vector< std::string > &list, const std::string & value) +{ + list.erase( + std::remove_if( + list.begin(), + list.end(), + boost::bind( + isValue, // &isValue works as well. + _1, // Boost.Bind placeholder + boost::cref( value ) ) ), + list.end() ); +} + +/////////////////////////////////////////////////////// +// Third example using boost phoenix for the comparison +/////////////////////////////////////////////////////// + +namespace phx = boost::phoenix; +using phx::placeholders::arg1; +using phx::placeholders::arg2; + +void delete_value3(std::vector< std::string > &list, const std::string & value) +{ + list.erase( std::remove_if( + list.begin(), + list.end(), + // This needs header boost/phoenix/operator/comparison. + // arg1 is a Boost.Phoenix placeholder. + arg1 == phx::cref( value ) ), + list.end() ); +} + +////////////////////////////////////////////////////////////// +// Third example using boost phoenix for the algorithm as well +////////////////////////////////////////////////////////////// + +void delete_value4(std::vector< std::string > &list, const std::string & value) +{ + // This need header boost/phoenix/stl/algorithm/transformation + list.erase( phx::remove_if( arg1, arg2 ) + ( list, arg1 == phx::cref( value ) ), + list.end() ); +} + +int main() { + std::cout << "--------------------------------" << std::endl; + std::cout << "Delete the goose examples." << std::endl; + std::cout << "--------------------------------" << std::endl; + std::string value = "goose"; + + std::vector< std::string > list1 = make_list(); + delete_value1(list1); + show_list1(list1); + std::cout << "--------------------------------" << std::endl; + std::vector< std::string > list2 = make_list(); + delete_value2(list2,value); + show_list1(list2); + std::cout << "--------------------------------" << std::endl; + std::vector< std::string > list3 = make_list(); + delete_value3(list3,value); + show_list1(list3); + std::cout << "--------------------------------" << std::endl; + std::vector< std::string > list4 = make_list(); + delete_value4(list4,value); + show_list1(list4); + std::cout << "--------------------------------" << std::endl; + return 0; +} diff --git a/src/boost/libs/phoenix/example/callback.cpp b/src/boost/libs/phoenix/example/callback.cpp new file mode 100644 index 00000000..dba286ba --- /dev/null +++ b/src/boost/libs/phoenix/example/callback.cpp @@ -0,0 +1,24 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <boost/phoenix/core.hpp> + +template <typename F> +void print(F f) +{ + std::cout << f() << std::endl; +} + +int +main() +{ + using boost::phoenix::val; + + print(val(3)); + print(val("Hello World")); + return 0; +} diff --git a/src/boost/libs/phoenix/example/container_actor.cpp b/src/boost/libs/phoenix/example/container_actor.cpp new file mode 100644 index 00000000..a784ee2d --- /dev/null +++ b/src/boost/libs/phoenix/example/container_actor.cpp @@ -0,0 +1,117 @@ +/*============================================================================== + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/stl/container.hpp> +#include <boost/phoenix/stl/algorithm.hpp> + +#include <vector> + +#include <iostream> + +namespace phoenix = boost::phoenix; + +using phoenix::actor; +using phoenix::function; +using phoenix::arg_names::arg1; + +struct size_impl +{ + // result_of protocol: + template <typename Sig> + struct result; + + template <typename This, typename Container> + struct result<This(Container)> + { + // Note, remove reference here, because Container can be anything + typedef typename boost::remove_reference<Container>::type container_type; + + // The result will be size_type + typedef typename container_type::size_type type; + }; + + template <typename Container> + typename result<size_impl(Container const&)>::type + operator()(Container const& container) const + { + return container.size(); + } +}; + +template <typename Expr> +struct container_actor + : actor<Expr> +{ + typedef actor<Expr> base_type; + typedef container_actor<Expr> that_type; + + container_actor( base_type const& base = base_type() ) + : base_type( base ) {} + + typename phoenix::expression::function<phoenix::stl::begin, that_type>::type const + begin() const + { + return phoenix::begin(*this); + } + + typename phoenix::expression::function<phoenix::stl::end, that_type>::type const + end() const + { + return phoenix::end(*this); + } + + typename phoenix::expression::function<size_impl, that_type>::type const + size() const + { + function<size_impl> const f = size_impl(); + return f(*this); + } + + typename phoenix::expression::function<phoenix::stl::max_size, that_type>::type const + max_size() const + { + return phoenix::max_size(*this); + } + + typename phoenix::expression::function<phoenix::stl::empty, that_type>::type const + empty() const + { + return phoenix::empty(*this); + } + + template <typename Container> + typename phoenix::expression::function<phoenix::impl::swap, that_type, Container>::type const + swap(actor<Container> const& expr) const + { + return phoenix::swap(*this, expr); + } +}; + +template <typename Expr> +container_actor<Expr> const +container( actor<Expr> const& expr ) +{ + return expr; +} + +int main() +{ + container_actor<phoenix::expression::argument<1>::type> const con1; + std::vector<int> v; + v.push_back(0); + v.push_back(1); + v.push_back(2); + v.push_back(3); + + std::cout << (container(arg1).size())(v) << " == " << v.size() << "\n"; + + + std::cout << (con1.size())(v) << " == " << v.size() << "\n"; +} diff --git a/src/boost/libs/phoenix/example/define_expression.cpp b/src/boost/libs/phoenix/example/define_expression.cpp new file mode 100644 index 00000000..f2744bd7 --- /dev/null +++ b/src/boost/libs/phoenix/example/define_expression.cpp @@ -0,0 +1,60 @@ +/*============================================================================== + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2011 Thomas Heller + + 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.hpp> + +namespace phoenix = boost::phoenix; +namespace proto = boost::proto; + + +// define the expression +namespace expression +{ + template <typename Lhs, typename Rhs> + struct plus + : phoenix::expr<proto::tag::plus, Lhs, Rhs> + {}; +} + +// extend the grammar, to recognice the expression +namespace boost { namespace phoenix { + + template <> + struct meta_grammar::case_<proto::tag::plus> + : enable_rule< + ::expression::plus< + meta_grammar + , meta_grammar + > + > + {}; + +}} + +// build a generator +template <typename Lhs, typename Rhs> +typename expression::plus<Lhs, Rhs>::type +plus(Lhs const & lhs, Rhs const & rhs) +{ + return expression::plus<Lhs, Rhs>::make(lhs, rhs); +} + +#include <boost/proto/proto.hpp> +#include <iostream> + +int main() +{ + + plus(6, 5); + + proto::display_expr(plus(6, 5)); + + std::cout << plus(5, 6)() << "\n"; +} + + diff --git a/src/boost/libs/phoenix/example/factorial.cpp b/src/boost/libs/phoenix/example/factorial.cpp new file mode 100644 index 00000000..619a5f05 --- /dev/null +++ b/src/boost/libs/phoenix/example/factorial.cpp @@ -0,0 +1,46 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + + 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 <vector> +#include <algorithm> +#include <iostream> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/function.hpp> + +struct factorial_impl +{ + template <typename Sig> + struct result; + + template <typename This, typename Arg> + struct result<This(Arg)> + : result<This(Arg const &)> + {}; + + template <typename This, typename Arg> + struct result<This(Arg &)> + { + typedef Arg type; + }; + + template <typename Arg> + Arg operator()(Arg n) const + { + return (n <= 0) ? 1 : n * this->operator()(n-1); + } +}; + + +int +main() +{ + using boost::phoenix::arg_names::arg1; + boost::phoenix::function<factorial_impl> factorial; + int i = 4; + std::cout << factorial(i)() << std::endl; + std::cout << factorial(arg1)(i) << std::endl; + return 0; +} diff --git a/src/boost/libs/phoenix/example/find_if.cpp b/src/boost/libs/phoenix/example/find_if.cpp new file mode 100644 index 00000000..476e331b --- /dev/null +++ b/src/boost/libs/phoenix/example/find_if.cpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <vector> +#include <algorithm> +#include <iostream> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> + +int +main() +{ + using boost::phoenix::arg_names::arg1; + + int init[] = { 2, 10, 4, 5, 1, 6, 8, 3, 9, 7 }; + std::vector<int> c(init, init + 10); + typedef std::vector<int>::iterator iterator; + + // Find the first odd number in container c + iterator it = std::find_if(c.begin(), c.end(), arg1 % 2 == 1); + + if (it != c.end()) + std::cout << *it << std::endl; // if found, print the result + return 0; +} diff --git a/src/boost/libs/phoenix/example/function.cpp b/src/boost/libs/phoenix/example/function.cpp new file mode 100644 index 00000000..ecf97634 --- /dev/null +++ b/src/boost/libs/phoenix/example/function.cpp @@ -0,0 +1,43 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + + 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 <vector> +#include <algorithm> +#include <iostream> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/function.hpp> + +using boost::phoenix::function; + +struct is_odd_ +{ + typedef bool result_type; + + template <typename Arg> + bool operator()(Arg arg1) const + { + return arg1 % 2 == 1; + } +}; + +function<is_odd_> is_odd; + +int +main() +{ + using boost::phoenix::arg_names::arg1; + + int init[] = { 2, 10, 4, 5, 1, 6, 8, 3, 9, 7 }; + std::vector<int> c(init, init + 10); + typedef std::vector<int>::iterator iterator; + + // Find the first odd number in container c + iterator it = std::find_if(c.begin(), c.end(), is_odd(arg1)); + + if (it != c.end()) + std::cout << *it << std::endl; // if found, print the result + return 0; +} diff --git a/src/boost/libs/phoenix/example/generator.cpp b/src/boost/libs/phoenix/example/generator.cpp new file mode 100644 index 00000000..e3120683 --- /dev/null +++ b/src/boost/libs/phoenix/example/generator.cpp @@ -0,0 +1,34 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + + 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 <vector> +#include <algorithm> +#include <iostream> +#include <boost/phoenix.hpp> + +template <typename> struct wrap {}; + +int main() +{ + using boost::phoenix::val; + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::construct; + using boost::phoenix::placeholders::_1; + using boost::phoenix::local_names::_a; + + int const n = 10; + std::vector<int> v1(n); + + let(_a = construct<int>(0)) + [ + generate(_1, lambda(_a = ref(_a))[_a++]) + , std::cout << val("result:\n") + , for_each(_1, lambda[std::cout << _1 << ' ']) + , std::cout << val('\n') + ](v1); +} diff --git a/src/boost/libs/phoenix/example/generator2.cpp b/src/boost/libs/phoenix/example/generator2.cpp new file mode 100644 index 00000000..aef2f986 --- /dev/null +++ b/src/boost/libs/phoenix/example/generator2.cpp @@ -0,0 +1,38 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + + 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.hpp> +#include <boost/typeof/typeof.hpp> +#include <iostream> +#include <vector> +#include <algorithm> + +int main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::construct; + using boost::phoenix::local_names::_a; + using boost::phoenix::arg_names::_1; + + BOOST_AUTO( + generator + , (lambda + ( + _a = val(_1) + ) + [ + std::cout << _a << " " + , _a++ + ] ) + ); + + int i = 0; + std::vector<int> v(10); + std::for_each(v.begin(), v.end(), generator(0)); +} diff --git a/src/boost/libs/phoenix/example/identity_transform.cpp b/src/boost/libs/phoenix/example/identity_transform.cpp new file mode 100644 index 00000000..471bec09 --- /dev/null +++ b/src/boost/libs/phoenix/example/identity_transform.cpp @@ -0,0 +1,124 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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.hpp> + +#include <iostream> +#include <sstream> + +namespace proto = boost::proto; +namespace phoenix = boost::phoenix; + +template <typename Rule> +struct identity_transform; + +struct identity_actions +{ + template <typename Rule> + struct when : phoenix::call<identity_transform<Rule> > {}; +}; + +template <> +struct identity_actions::when<phoenix::rule::argument> + : proto::call< + identity_transform<phoenix::rule::argument>(proto::_value, phoenix::_context) + > {}; + +template <> +struct identity_actions::when<phoenix::rule::terminal> + : proto::call< + identity_transform<phoenix::rule::terminal>(proto::_value, phoenix::_context) + > {}; + +template <> +struct identity_actions::when<phoenix::rule::custom_terminal> + : proto::lazy< + identity_transform<proto::_value>(proto::_value, phoenix::_context) + > {}; + +template <> +struct identity_transform<phoenix::rule::terminal> +{ + typedef std::string result_type; + + template <typename Terminal, typename Context> + std::string operator()(Terminal const & terminal, Context) const + { + std::stringstream ss; + ss << "val(" << terminal << ")"; + return ss.str(); + } + + template <typename Context> + std::string operator()(char const * terminal, Context) const + { + std::stringstream ss; + ss << "val(\"" << terminal << "\")"; + return ss.str(); + } +}; + +template <typename T> +struct identity_transform<boost::reference_wrapper<T> > +{ + typedef std::string result_type; + + template <typename Terminal, typename Context> + std::string operator()(Terminal const & terminal, Context) const + { + std::stringstream ss; + ss << "ref(" << terminal << ")"; + return ss.str(); + } + + + template <int N, typename Context> + std::string operator()(boost::reference_wrapper<char const *> terminal, Context) const + { + std::stringstream ss; + ss << "ref(\"" << terminal << "\")"; + return ss.str(); + } + + template <int N, typename Context> + std::string operator()(boost::reference_wrapper<char const [N]> terminal, Context) const + { + std::stringstream ss; + ss << "ref(\"" << terminal << "\")"; + return ss.str(); + } +}; + +template <> +struct identity_transform<phoenix::rule::argument> +{ + typedef std::string result_type; + + template <typename N, typename Context> + std::string operator()(N, Context) const + { + std::stringstream ss; + ss << "_" << N::value; + return ss.str(); + } +}; + + +template <typename Expr> +void identity(Expr const & expr) +{ + std::cout << phoenix::eval(expr, phoenix::context(int(), identity_actions())) << "\n"; +} + +int main() +{ + + identity(phoenix::val(8)); + identity(phoenix::val("8")); + identity(phoenix::ref("blubb")); + identity(phoenix::arg_names::_1); +} diff --git a/src/boost/libs/phoenix/example/if.cpp b/src/boost/libs/phoenix/example/if.cpp new file mode 100644 index 00000000..8ed95a74 --- /dev/null +++ b/src/boost/libs/phoenix/example/if.cpp @@ -0,0 +1,36 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <vector> +#include <algorithm> +#include <boost/phoenix/statement.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/core.hpp> + +int +main() +{ + using boost::phoenix::if_; + using boost::phoenix::arg_names::arg1; + + int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + std::vector<int> v(init, init+10); + + std::cout << std::dec; + int x = 0; + + std::for_each(v.begin(), v.end(), + if_(arg1 > 5) + [ + std::cout << arg1 << ", " + ] + ); + + std::cout << std::endl; + + return 0; +} diff --git a/src/boost/libs/phoenix/example/invert.cpp b/src/boost/libs/phoenix/example/invert.cpp new file mode 100644 index 00000000..3c5e64f0 --- /dev/null +++ b/src/boost/libs/phoenix/example/invert.cpp @@ -0,0 +1,138 @@ +/*============================================================================== + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/phoenix.hpp> +#include <boost/proto/proto.hpp> +#include <boost/proto/debug.hpp> + +namespace phoenix = boost::phoenix; +namespace proto = boost::proto; + +using phoenix::evaluator; + +#ifdef _MSC_VER +// redifining evaluator, this is because MSVC chokes on function types like: +// F(G(...)) +#define evaluator(A0, A1) proto::call<phoenix::evaluator(A0, A1)> +#endif + +struct invert_actions +{ + template <typename Rule> + struct when + : proto::nary_expr< + proto::_ + , proto::vararg< + proto::when<proto::_, evaluator(proto::_, phoenix::_context)> + > + > + {}; +}; + +template <> +struct invert_actions::when<phoenix::rule::plus> + : proto::call< + phoenix::functional::make_minus( + evaluator(proto::_left, phoenix::_context) + , evaluator(proto::_right, phoenix::_context) + ) + > +{}; + +template <> +struct invert_actions::when<phoenix::rule::minus> + : proto::call< + phoenix::functional::make_plus( + evaluator(proto::_left, phoenix::_context) + , evaluator(proto::_right, phoenix::_context) + ) + > +{}; + +template <> +struct invert_actions::when<phoenix::rule::multiplies> + : proto::call< + phoenix::functional::make_divides( + evaluator(proto::_left, phoenix::_context) + , evaluator(proto::_right, phoenix::_context) + ) + > +{}; + +template <> +struct invert_actions::when<phoenix::rule::divides> + : proto::call< + phoenix::functional::make_multiplies( + evaluator(proto::_left, phoenix::_context) + , evaluator(proto::_right, phoenix::_context) + ) + > +{}; + +#ifdef _MSC_VER +#undef evaluator +#endif + +template <typename Expr> +void print_expr(Expr const & expr) +{ + std::cout << "before inversion:\n"; + proto::display_expr(expr); + std::cout << "after inversion:\n"; + proto::display_expr( + phoenix::eval( + expr + , phoenix::context( + phoenix::nothing + , invert_actions() + ) + ) + ); + std::cout << "\n"; +} + +template <typename Expr> +typename + boost::phoenix::result_of::eval< + Expr const& + , phoenix::result_of::make_context< + phoenix::result_of::make_env<>::type + , invert_actions + >::type + >::type +invert(Expr const & expr) +{ + return + phoenix::eval( + expr + , phoenix::make_context( + phoenix::make_env() + , invert_actions() + ) + ); +} + +int main() +{ + using phoenix::placeholders::_1; + using phoenix::placeholders::_2; + using phoenix::placeholders::_3; + using phoenix::placeholders::_4; + + print_expr(_1); + print_expr(_1 + _2); + print_expr(_1 + _2 - _3); + print_expr(_1 * _2); + print_expr(_1 * _2 / _3); + print_expr(_1 * _2 + _3); + print_expr(_1 * _2 - _3); + print_expr(if_(_1 * _4)[_2 - _3]); + + print_expr(_1 * invert(_2 - _3)); +} + diff --git a/src/boost/libs/phoenix/example/lambda.cpp b/src/boost/libs/phoenix/example/lambda.cpp new file mode 100644 index 00000000..adfd798e --- /dev/null +++ b/src/boost/libs/phoenix/example/lambda.cpp @@ -0,0 +1,73 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/scope.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> + +namespace lazy_stuff +{ + using boost::phoenix::function; + + struct for_each_impl + { + typedef void result_type; + + template <typename C, typename F> + void operator()(C& c, F f) const + { + std::for_each(c.begin(), c.end(), f); + } + }; + + function<for_each_impl> const for_each = for_each_impl(); + + struct push_back_impl + { + typedef void result_type; + + template <typename C, typename T> + void operator()(C& c, T& x) const + { + c.push_back(x); + } + }; + + function<push_back_impl> const push_back = push_back_impl(); +} + +int +main() +{ + { + using lazy_stuff::for_each; + using lazy_stuff::push_back; + + using boost::phoenix::lambda; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + using boost::phoenix::local_names::_a; + + int x = 10; + std::vector<std::vector<int> > v(10); + + for_each(arg1, + lambda(_a = arg2) + [ + push_back(arg1, _a) + ] + ) + (v, x); + } + + return 0; +} + diff --git a/src/boost/libs/phoenix/example/parallel_for.cpp b/src/boost/libs/phoenix/example/parallel_for.cpp new file mode 100644 index 00000000..1fc11d14 --- /dev/null +++ b/src/boost/libs/phoenix/example/parallel_for.cpp @@ -0,0 +1,245 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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.hpp> + +struct omp_for_eval +{ + typedef void result_type; + + template <typename Init, typename Cond, typename Step, typename Do, typename Context> + result_type + operator()( + Init const& init + , Cond const& cond + , Step const& step + , Do const& do_ + , Context & ctx + ) const + { +#pragma omp parallel + for( + boost::phoenix::eval(init, ctx); + boost::phoenix::eval(cond, ctx); + boost::phoenix::eval(step, ctx) + ) + { + boost::phoenix::eval(do_, ctx); + } + } +}; + + +//////////////////////////////////////////////////////////////////////////////// +// Define new custom expression +BOOST_PHOENIX_DEFINE_EXPRESSION( + (omp_for) + , (boost::phoenix::meta_grammar) // Cond + (boost::phoenix::meta_grammar) // Init + (boost::phoenix::meta_grammar) // Step + (boost::phoenix::meta_grammar) // Do +) + +namespace boost { namespace phoenix +{ + template <> + struct default_actions::when< ::rule::omp_for> + : boost::phoenix::call< ::omp_for_eval> + {}; +}} + +template <typename Init, typename Cond, typename Step> +struct omp_for_gen +{ + omp_for_gen(Init const& init, Cond const& cond, Step const& step) + : init(init), cond(cond), step(step) {} + + template <typename Do> + typename result_of::make_omp_for<Init, Cond, Step, Do>::type const + operator[](Do const& do_) const + { + return make_omp_for(init, cond, step, do_); + } + + Init init; + Cond cond; + Step step; +}; + +template <typename Init, typename Cond, typename Step> +inline +omp_for_gen<Init, Cond, Step> const +omp_for(Init const& init, Cond const& cond, Step const& step) +{ + return omp_for_gen<Init, Cond, Step>(init, cond, step); +} +//////////////////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////////////////// +// Define new evaluation scheme + +struct parallel_actions +{ + template <typename Rule> + struct when + : boost::phoenix::default_actions::when<Rule> + {}; +}; + +template <> +struct parallel_actions::when<boost::phoenix::rule::for_> + : boost::phoenix::call<omp_for_eval> +{}; + +// Doing the same as actor<Expr>::operator +template <typename Expr, typename A0, typename A1, typename A2> +typename boost::phoenix::result_of::eval< + Expr const & + , typename boost::phoenix::result_of::make_context< + typename boost::phoenix::result_of::make_env< + Expr const * + , A0 & + , A1 & + , A2 & + >::type + , parallel_actions + >::type +>::type +parallel_eval(Expr & expr, A0 & a0, A1 & a1, A2 & a2) +{ + Expr const * this_ = boost::addressof(expr); + return + boost::phoenix::eval( + expr + , boost::phoenix::make_context( + boost::phoenix::make_env(this_, a0, a1, a2) + , parallel_actions() + ) + ); +} + +// changing evaluation mechanism on the fly +BOOST_PHOENIX_DEFINE_EXPRESSION( + (parallel) + , (boost::phoenix::meta_grammar) +) + +namespace boost { namespace phoenix +{ + template <> + struct default_actions::when< ::rule::parallel> + : proto::call< + evaluator( + proto::_child0 + , functional::make_context( + _env + , parallel_actions() + ) + , unused()//mpl::void_() + ) + > + {}; +}} + +template <typename Expr> +typename result_of::make_parallel<Expr>::type +parallel(Expr const & expr) +{ + return make_parallel(expr); +} +//////////////////////////////////////////////////////////////////////////////// + + +#include <vector> +#include <iostream> + +int main() +{ + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::arg_names::_3; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + using boost::phoenix::local_names::_c; + using boost::phoenix::let; + using boost::phoenix::bind; + using boost::phoenix::lambda; + using boost::phoenix::nothing; + + const int NUM = 1; + + { + std::vector<int> a(NUM, 1); + std::vector<int> b(NUM, 2); + std::vector<int> c(NUM, 0); + + ( + let(_a = begin(_1), _b = begin(_2), _c = begin(_3)) + [ + for_(nothing, _a != end(_1), (++_a, ++_b, ++_c)) + [ + *_c = *_a + *_b + ] + ] + , std::cout << accumulate(_3, 0) << "\n" + )(a, b, c); + } + + { + std::vector<int> a(NUM, 1); + std::vector<int> b(NUM, 2); + std::vector<int> c(NUM, 0); + + ( + let(_a = begin(_1), _b = begin(_2), _c = begin(_3)) + [ + omp_for(nothing, _a != end(_1), (++_a, ++_b, ++_c)) + [ + *_c = *_a + *_b + ] + , std::cout << accumulate(_3, 0) << "\n" + ] + )(a, b, c); + } + + { + std::vector<int> a(NUM, 1); + std::vector<int> b(NUM, 2); + std::vector<int> c(NUM, 0); + + parallel_eval( + let(_a = begin(_1), _b = begin(_2), _c = begin(_3)) + [ + for_(nothing, _a != end(_1), (++_a, ++_b, ++_c)) + [ + *_c = *_a + *_b + ] + , std::cout << accumulate(_3, 0) << "\n" + ] + , a, b, c); + } + + { + std::vector<int> a(NUM, 1); + std::vector<int> b(NUM, 2); + std::vector<int> c(NUM, 0); + + ( + let(_a = begin(_1), _b = begin(_2), _c = begin(_3)) + [ + parallel( + for_(nothing, _a != end(_1), (++_a, ++_b, ++_c)) + [ + *_c = *_a + *_b + ] + ) + ] + , std::cout << accumulate(_3, 0) << "\n" + )(a, b, c); + } +} diff --git a/src/boost/libs/phoenix/example/references.cpp b/src/boost/libs/phoenix/example/references.cpp new file mode 100644 index 00000000..26d35ca0 --- /dev/null +++ b/src/boost/libs/phoenix/example/references.cpp @@ -0,0 +1,20 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <boost/phoenix/core.hpp> + +int +main() +{ + using boost::phoenix::ref; + + int i = 3; + char const* s = "Hello World"; + std::cout << ref(i)() << std::endl; + std::cout << ref(s)() << std::endl; + return 0; +} diff --git a/src/boost/libs/phoenix/example/values.cpp b/src/boost/libs/phoenix/example/values.cpp new file mode 100644 index 00000000..ec58e29e --- /dev/null +++ b/src/boost/libs/phoenix/example/values.cpp @@ -0,0 +1,18 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <boost/phoenix/core.hpp> + +int +main() +{ + using boost::phoenix::val; + + std::cout << val(3)() << std::endl; + std::cout << val("Hello World")() << std::endl; + return 0; +} diff --git a/src/boost/libs/phoenix/index.html b/src/boost/libs/phoenix/index.html new file mode 100644 index 00000000..de106e3d --- /dev/null +++ b/src/boost/libs/phoenix/index.html @@ -0,0 +1,15 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> + <head> + <meta http-equiv="refresh" content="0; URL=doc/html/index.html"> + </head> + <body> + Automatic redirection failed, click this + <a href="doc/html/index.html">link</a> <hr> + <p>© Copyright Beman Dawes, 2001</p> + <p>Distributed under the Boost Software License, Version 1.0. (See + accompanying file <a href="../../LICENSE_1_0.txt"> + LICENSE_1_0.txt</a> or copy at + <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p> + </body> +</html> diff --git a/src/boost/libs/phoenix/meta/explicit-failures-markup.xml b/src/boost/libs/phoenix/meta/explicit-failures-markup.xml new file mode 100644 index 00000000..b2a97810 --- /dev/null +++ b/src/boost/libs/phoenix/meta/explicit-failures-markup.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<explicit-failures-markup> + <!-- phoenix --> + <library name="phoenix"> + <mark-expected-failures> + <test name="lambda_tests7"/> + <test name="lambda_tests10"/> + <test name="lambda_tests11"/> + <test name="lambda_tests14"/> + <test name="lambda_tests15"/> + <toolset name="msvc-12.0"/> + <note author="Kohei Takahsahi"> + Wrokaround: define BOOST_RESULT_OF_USE_TR1 + </note> + </mark-expected-failures> + </library> +</explicit-failures-markup> + diff --git a/src/boost/libs/phoenix/meta/libraries.json b/src/boost/libs/phoenix/meta/libraries.json new file mode 100644 index 00000000..7b7d5fdd --- /dev/null +++ b/src/boost/libs/phoenix/meta/libraries.json @@ -0,0 +1,19 @@ +{ + "key": "phoenix", + "name": "Phoenix", + "authors": [ + "Joel de Guzman", + "Dan Marsden", + "Thomas Heller", + "John Fletcher" + ], + "description": "Define small unnamed function objects at the actual call site, and more.", + "category": [ + "Function-objects" + ], + "maintainers": [ + "Joel de Guzman <djowel -at- gmail.com>", + "Thomas Heller <thom.heller -at- gmail.com>", + "John Fletcher <J.P.Fletcher -at- aston.ac.uk>" + ] +} diff --git a/src/boost/libs/phoenix/preprocess/Jamfile.v2 b/src/boost/libs/phoenix/preprocess/Jamfile.v2 new file mode 100644 index 00000000..ffd36147 --- /dev/null +++ b/src/boost/libs/phoenix/preprocess/Jamfile.v2 @@ -0,0 +1,41 @@ +# (C) Copyright 2012: Eric Niebler +# 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) + +# Generates preprocessed files with wave. + +project : requirements <link>static <variant>release ; + +import feature ; +import toolset ; + +feature.feature phoenix-limit : : free ; +toolset.flags wave PHOENIX-LIMIT <phoenix-limit> ; + +actions wave bind PHOENIX-LIMIT +{ + echo Preprocessing with BOOST_PHOENIX_LIMIT=$(PHOENIX-LIMIT)... + $(>[2]) -o- -DBOOST_PHOENIX_LIMIT=$(PHOENIX-LIMIT) --config-file wave.cfg $(>[1]) +} + +W = /boost/libs/wave/tool//wave ; + +make preprocess_phoenix_10 + : preprocess_phoenix.cpp $(W) : wave : <phoenix-limit>10 + ; + +make preprocess_phoenix_20 + : preprocess_phoenix.cpp $(W) : wave : <phoenix-limit>20 + ; + +make preprocess_phoenix_30 + : preprocess_phoenix.cpp $(W) : wave : <phoenix-limit>30 + ; + +make preprocess_phoenix_40 + : preprocess_phoenix.cpp $(W) : wave : <phoenix-limit>40 + ; + +make preprocess_phoenix_50 + : preprocess_phoenix.cpp $(W) : wave : <phoenix-limit>50 + ; diff --git a/src/boost/libs/phoenix/preprocess/preprocess_phoenix.cpp b/src/boost/libs/phoenix/preprocess/preprocess_phoenix.cpp new file mode 100644 index 00000000..4bb1a6a5 --- /dev/null +++ b/src/boost/libs/phoenix/preprocess/preprocess_phoenix.cpp @@ -0,0 +1,16 @@ +// Copyright (c) 2011 Hartmut Kaiser +// +// 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 "../include/boost/phoenix/version.hpp" +#include "../include/boost/phoenix/core.hpp" +#include "../include/boost/phoenix/bind.hpp" +#include "../include/boost/phoenix/function.hpp" +#include "../include/boost/phoenix/fusion.hpp" +#include "../include/boost/phoenix/object.hpp" +#include "../include/boost/phoenix/operator.hpp" +#include "../include/boost/phoenix/scope.hpp" +#include "../include/boost/phoenix/scope/dynamic.hpp" +#include "../include/boost/phoenix/statement.hpp" +#include "../include/boost/phoenix/stl.hpp" diff --git a/src/boost/libs/phoenix/preprocess/wave-msvc-10.0.cfg b/src/boost/libs/phoenix/preprocess/wave-msvc-10.0.cfg new file mode 100644 index 00000000..dd639714 --- /dev/null +++ b/src/boost/libs/phoenix/preprocess/wave-msvc-10.0.cfg @@ -0,0 +1,22 @@ +-DBOOST_PHOENIX_DONT_USE_PREPROCESSED_FILES +-DBOOST_PHOENIX_CREATE_PREPROCESSED_FILES +-S../include +-S../../.. +-S"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include" +-S. +--variadics +-D_WIN32 +-NBOOST_STATIC_ASSERT +-NBOOST_STATIC_CONSTANT +-NBOOST_MPL_HAS_XXX_TRAIT_DEF +-NBOOST_MPL_ASSERT_MSG +-NBOOST_FORCEINLINE +-NBOOST_MPL_ASSERT +-NBOOST_MPL_ASSERT_MSG +-NBOOST_MPL_ASSERT_RELATION +-NBOOST_PROTO_USE_GET_POINTER +-NBOOST_PROTO_GET_POINTER +-NBOOST_PROTO_CALLABLE +-NBOOST_PROTO_TRANSFORM +-NBOOST_FUSION_ADAPT_TPL_STRUCT_NO_PARTIAL +--timer diff --git a/src/boost/libs/phoenix/preprocess/wave.cfg b/src/boost/libs/phoenix/preprocess/wave.cfg new file mode 100644 index 00000000..199d1ff7 --- /dev/null +++ b/src/boost/libs/phoenix/preprocess/wave.cfg @@ -0,0 +1,34 @@ +-DBOOST_PHOENIX_DONT_USE_PREPROCESSED_FILES +-DBOOST_PHOENIX_CREATE_PREPROCESSED_FILES +-S../include +-S../../.. +-S/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/include +-S/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.1/include +-S/usr/lib/gcc/x86_64-linux-gnu/4.6.3/include +-S/usr/lib/gcc/i486-linux-gnu/4.4.5/include +-S/usr/include/c++/4.6.0 +-S/usr/include/c++/4.6.1 +-S/usr/include/c++/4.6.3 +-S/usr/include/c++/4.4.5 +-S/usr/include/c++/4.6.0/x86_64-unknown-linux-gnu +-S/usr/include/c++/4.6.1/x86_64-unknown-linux-gnu +-S/usr/include/c++/4.6.3/x86_64-linux-gnu +-S/usr/include/c++/4.4.5/i486-linux-gnu +-S/usr/include +--variadics +-NBOOST_ATTRIBUTE_UNUSED +-NBOOST_FUSION_ADAPT_TPL_STRUCT_NO_PARTIAL +-NBOOST_STATIC_ASSERT +-NBOOST_STATIC_CONSTANT +-NBOOST_MPL_HAS_XXX_TRAIT_DEF +-NBOOST_MPL_ASSERT_MSG +-NBOOST_FORCEINLINE +-NBOOST_MPL_ASSERT +-NBOOST_MPL_ASSERT_MSG +-NBOOST_MPL_ASSERT_RELATION +-NBOOST_PROTO_USE_GET_POINTER +-NBOOST_PROTO_GET_POINTER +-NBOOST_PROTO_CALLABLE +-NBOOST_PROTO_TRANSFORM +-NBOOST_PHOENIX_SFINAE_AND_OVERLOADS +--timer diff --git a/src/boost/libs/phoenix/test/Jamfile b/src/boost/libs/phoenix/test/Jamfile new file mode 100644 index 00000000..1c9cb3a5 --- /dev/null +++ b/src/boost/libs/phoenix/test/Jamfile @@ -0,0 +1,305 @@ +#============================================================================== +# Copyright (c) 2003-2006 Joel de Guzman +# Copyright (c) 2014-2015 John Fletcher +# +# Use, modification and distribution is subject to 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) +#============================================================================== + +# bring in rules for testing +import testing ; +import os ; + +import ../../config/checks/config : requires ; + +if [ os.environ CI ] +{ + CI_DEFINES = <define>CI_SKIP_KNOWN_FAILURE=1 ; + CI_DEFINES += <define>RUNNING_ON_TRAVIS=1 ; # for backward compatibility + CI_DEFINES += <define>RUNNING_ON_APPVEYOR=1 ; # for backward compatibility +} + +project + : requirements + <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE + <toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS + <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE + <toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS + $(CI_DEFINES) + ; + +local multi-threading = <library>/boost/thread + <threading>multi <define>BOOST_ALL_NO_LIB=1 ; + +test-suite phoenix_core : + [ run core/custom_terminal.cpp ] + [ run core/intel_test.cpp ] + [ run core/primitives_tests.cpp ] + ; + +test-suite phoenix_stdlib : + [ run stdlib/cmath.cpp ] + ; + +test-suite phoenix_operator : + [ run operator/arithmetic_tests.cpp ] + [ run operator/bitwise_tests.cpp ] + [ run operator/comparison_tests.cpp ] + [ run operator/if_else_tests.cpp ] + [ run operator/io_tests.cpp ] + [ run operator/logical_tests.cpp ] + [ run operator/misc_binary_tests.cpp ] + [ run operator/self_tests.cpp ] + [ run operator/unary_tests.cpp ] + [ run operator/member.cpp ] + ; + +test-suite phoenix_object : + [ run object/cast_tests.cpp ] + [ run object/new_delete_tests.cpp ] + ; + +test-suite phoenix_function : + [ run function/adapt_function.cpp ] + [ run function/function_tests.cpp ] + [ run function/lazy_argument_tests.cpp ] +# [ run function/lazy_compose_tests.cpp ] +# [ run function/lazy_fold_tests.cpp ] + [ run function/lazy_list_tests.cpp ] + [ run function/lazy_list2_tests.cpp ] + [ run function/lazy_list3_tests.cpp ] + [ run function/lazy_make_pair_tests.cpp ] +# [ run function/lazy_ptr_tests.cpp ] +# [ run function/lazy_scan_tests.cpp ] + [ run function/lazy_templated_struct_tests.cpp ] +# [ run function/lazy_thunk_tests.cpp ] + [ run function/lazy_operator_tests.cpp ] +# [ run function/function_tests_phx2.cpp ] + ; + +test-suite phoenix_bind : + [ run bind/bind_function_tests.cpp ] + [ run bind/bind_function_object_tests.cpp ] +# [ run bind/bind_function_object_tests_phx2.cpp ] + [ run bind/bind_member_function_tests.cpp ] + [ run bind/bind_member_variable_tests.cpp ] + [ run bind/bug5782.cpp ] + ; + +test-suite phoenix_statement : + [ run statement/if_tests.cpp ] + [ run statement/loops_tests.cpp ] + [ run statement/switch_tests.cpp ] + [ run statement/exceptions.cpp ] + [ run statement/bug5715.cpp ] + ; + +test-suite phoenix_container : + [ run container/container_tests1a.cpp ] + [ run container/container_tests1b.cpp ] + [ run container/container_tests2a.cpp ] + [ run container/container_tests2b.cpp ] + [ run container/container_tests3a.cpp ] + [ run container/container_tests3b.cpp ] + [ run container/container_tests4a.cpp ] + [ run container/container_tests4b.cpp ] + [ run container/container_tests5a.cpp ] + [ run container/container_tests5b.cpp ] + [ run container/container_tests6a.cpp ] + [ run container/container_tests6b.cpp ] + [ run container/container_tests7a.cpp ] + [ run container/container_tests7b.cpp ] + [ run container/container_tests8a.cpp ] + [ run container/container_tests8b.cpp : : : [ requires cxx11_hdr_unordered_map ] ] + [ run container/container_tests9a.cpp : : : [ requires cxx11_hdr_unordered_map ] ] + [ run container/container_tests9b.cpp : : : [ requires cxx11_hdr_unordered_map ] ] + [ run container/container_tests10a.cpp : : : [ requires cxx11_hdr_unordered_map ] ] + [ run container/container_tests10b.cpp : : : [ requires cxx11_hdr_unordered_map ] ] + [ run container/container_tests11a.cpp : : : [ requires cxx11_hdr_unordered_set ] ] + [ run container/container_tests11b.cpp : : : [ requires cxx11_hdr_unordered_set ] ] + [ run container/container_tests12a.cpp : : : [ requires cxx11_hdr_unordered_set ] ] + [ run container/container_tests12b.cpp : : : [ requires cxx11_hdr_unordered_set ] ] + ; + +test-suite phoenix_scope : + [ run scope/lambda_tests1.cpp ] + [ run scope/lambda_tests2.cpp ] + [ run scope/lambda_tests3.cpp ] + [ run scope/lambda_tests4.cpp ] + [ run scope/lambda_tests5.cpp ] + [ run scope/lambda_tests6.cpp ] + [ run scope/lambda_tests7.cpp ] + [ run scope/lambda_tests8.cpp ] + [ run scope/lambda_tests9.cpp ] + [ run scope/lambda_tests10.cpp ] + [ run scope/lambda_tests11.cpp ] + [ run scope/lambda_tests12.cpp ] + [ run scope/lambda_tests13.cpp ] + [ run scope/lambda_tests14.cpp ] + [ run scope/lambda_tests15.cpp ] + [ run scope/lambda_tests16.cpp ] + [ run scope/lambda_tests17.cpp ] + [ run scope/lambda_tests18.cpp ] + [ run scope/lambda_tests19.cpp ] + [ run scope/lambda_tests20.cpp ] + [ run scope/lambda_tests21.cpp ] + [ run scope/lambda_tests22.cpp ] + [ run scope/lambda_tests23.cpp ] +# [ run scope/lambda_tests_phx2.cpp ] + [ run scope/let_tests.cpp ] + [ run scope/let_tests_113.cpp ] +# [ run scope/let_tests_113a.cpp ] + [ run scope/let_tests_157.cpp ] +# [ run scope/let_tests_157a.cpp ] + [ run scope/let_tests_rest.cpp ] + [ run scope/more_lambda_tests.cpp ] + [ run scope/more_let_tests.cpp ] +# [ run scope/more_let_tests1.cpp ] +# [ run scope/more_let_tests2a.cpp ] +# [ run scope/more_let_tests2b.cpp ] + [ run scope/dynamic_tests.cpp ] + [ run scope/bug3289.cpp ] + [ run scope/bug8298.cpp ] + [ compile-fail scope/bug8298f.cpp ] + [ run scope/bug_000008.cpp : : : $(multi-threading) ] + ; + +test-suite phoenix_algorithm : + [ run algorithm/for_each.cpp ] + [ run algorithm/for_each2.cpp ] + [ run algorithm/for_test.cpp ] + [ run algorithm/for_test2.cpp ] + [ run algorithm/iteration.cpp ] + [ run algorithm/transformation1.cpp ] + [ run algorithm/transformation2.cpp ] + [ run algorithm/transformation3.cpp ] + [ run algorithm/transformation4.cpp ] + [ run algorithm/querying.cpp ] + [ run algorithm/querying_find.cpp ] + [ run algorithm/querying2.cpp ] + [ run algorithm/querying_find2.cpp ] + ; + +test-suite phoenix_boost_bind_compatibility : + [ run boost_bind_compatibility/bind_and_or_test.cpp ] + [ run boost_bind_compatibility/bind_const_test.cpp ] + [ run boost_bind_compatibility/bind_cv_test.cpp ] + [ run boost_bind_compatibility/bind_dm_test.cpp ] +# [ run boost_bind_compatibility/bind_dm1_test.cpp ] + [ run boost_bind_compatibility/bind_dm2_test.cpp ] + [ run boost_bind_compatibility/bind_dm3_test.cpp ] + [ run boost_bind_compatibility/bind_eq_test.cpp ] + [ run boost_bind_compatibility/bind_eq2_test.cpp ] + [ run boost_bind_compatibility/bind_eq3_test.cpp ] + [ run boost_bind_compatibility/bind_fn2_test.cpp ] + [ run boost_bind_compatibility/bind_function_test.cpp ] + [ run boost_bind_compatibility/bind_interoperation_test.cpp ] + [ run boost_bind_compatibility/bind_mf2_test.cpp ] + [ run boost_bind_compatibility/bind_not_test.cpp ] + [ run boost_bind_compatibility/bind_placeholder_test.cpp ] + [ run boost_bind_compatibility/bind_ref_test.cpp ] + [ run boost_bind_compatibility/bind_rel_test.cpp ] + [ run boost_bind_compatibility/bind_rvalue_test.cpp ] + [ run boost_bind_compatibility/bind_rv_sp_test.cpp ] +# [ run boost_bind_compatibility/bind_rv_sp1_test.cpp ] +# [ run boost_bind_compatibility/bind_rv_sp2_test.cpp ] +# [ run boost_bind_compatibility/bind_rv_sp3_test.cpp ] +# [ run boost_bind_compatibility/bind_rv_sp4_test.cpp ] +# [ run boost_bind_compatibility/bind_rv_sp5_test.cpp ] +# [ run boost_bind_compatibility/bind_rv_sp6_test.cpp ] +# [ run boost_bind_compatibility/bind_rv_sp7_test.cpp ] + [ run boost_bind_compatibility/bind_stateful_test.cpp ] + [ run boost_bind_compatibility/bind_test.cpp ] +# [ run boost_bind_compatibility/bind_void_dm_test.cpp ] + ; + +test-suite phoenix_regression : + [ run regression/bug4853.cpp ] + [ run regression/bug5626.cpp ] + [ run regression/bug5824.cpp ] + # [ run regression/bug5875.cpp ] + [ run regression/bug5968.cpp ] + [ run regression/bug6040.cpp ] + [ run regression/bug6268.cpp ] + [ run regression/bug7165.cpp ] + [ compile-fail regression/bug7166.cpp ] + [ run regression/bug7624.cpp ] + [ compile regression/from_array.cpp ] + [ run regression/actor_assignment.cpp ] + ; + +test-suite phoenix_include : + [ run include/bind.cpp ] + [ run include/core.cpp ] + [ run include/function.cpp ] + [ run include/fusion.cpp ] + [ run include/object.cpp ] + [ run include/operator.cpp ] + [ run include/scope.cpp ] +# [ run include/spirit.cpp ] +# [ run include/spirit_no_specialize.cpp ] + [ run include/statement.cpp ] + [ run include/stl.cpp ] + [ run include/version.cpp ] + [ run include/bind/bind_member_function.cpp ] + [ run include/bind/bind_member_variable.cpp ] + [ run include/core/actor.cpp ] + [ run include/core/argument.cpp ] + [ run include/core/arity.cpp ] + [ run include/core/debug.cpp ] + [ run include/core/domain.cpp ] + [ run include/core/environment.cpp ] + [ run include/core/expression.cpp ] + [ run include/core/function_equal.cpp ] + [ run include/core/is_actor.cpp ] + [ run include/core/is_nullary.cpp ] + [ run include/core/limits.cpp ] + [ run include/core/meta_grammar.cpp ] + [ run include/core/nothing.cpp ] + [ run include/core/reference.cpp ] + [ run include/core/terminal.cpp ] + # [ run include/core/bug7730.cpp ] + [ run include/core/value.cpp ] + [ run include/core/visit_each.cpp ] + [ run include/function/function.cpp : : : : function_function ] + [ run include/function/lazy_headers.cpp ] + [ run include/fusion/at.cpp ] + [ run include/object/const_cast.cpp ] + [ run include/object/construct.cpp ] + [ run include/object/delete.cpp ] + [ run include/object/dynamic_cast.cpp ] + [ run include/object/new.cpp ] + [ run include/object/reinterpret_cast.cpp ] + [ run include/object/static_cast.cpp ] + [ run include/operator/arithmetic.cpp ] + [ run include/operator/bitwise.cpp ] + [ run include/operator/comparison.cpp ] + [ run include/operator/if_else.cpp ] + [ run include/operator/io.cpp ] + [ run include/operator/logical.cpp ] + [ run include/operator/member.cpp : : : : operator_member ] + [ run include/operator/self.cpp ] + [ run include/scope/dynamic.cpp ] + [ run include/scope/lambda.cpp ] + [ run include/scope/let.cpp ] + [ run include/scope/local_variable.cpp ] + [ run include/scope/scoped_environment.cpp ] + [ run include/scope/this.cpp ] + [ run include/statement/do_while.cpp ] + [ run include/statement/for.cpp ] + [ run include/statement/if.cpp ] + [ run include/statement/sequence.cpp ] + [ run include/statement/switch.cpp ] + [ run include/statement/throw.cpp ] + [ run include/statement/try_catch.cpp ] + [ run include/statement/while.cpp ] + [ run include/stl/algorithm.cpp ] + [ run include/stl/container.cpp ] + [ run include/stl/container/container.cpp : : : : container_container ] + [ run include/stl/algorithm/iteration.cpp : : : : include_iteration ] + [ run include/stl/algorithm/querying.cpp : : : : include_querying ] + [ run include/stl/algorithm/transformation.cpp ] + [ run include/support/iterate.cpp ] + [ run include/support/preprocessor/round.cpp ] + ; diff --git a/src/boost/libs/phoenix/test/algorithm/for_each.cpp b/src/boost/libs/phoenix/test/algorithm/for_each.cpp new file mode 100644 index 00000000..82e5ca6f --- /dev/null +++ b/src/boost/libs/phoenix/test/algorithm/for_each.cpp @@ -0,0 +1,51 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + Copyright (c) 2014 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.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/stl/algorithm/iteration.hpp> +#include <boost/detail/lightweight_test.hpp> + +#include <functional> +#include <vector> +#include <string> +#include <sstream> + +namespace +{ + + void for_each_test() + { + using boost::phoenix::for_each; + using boost::phoenix::lambda; + using boost::phoenix::val; + using boost::phoenix::arg_names::arg1; + + std::vector<int> v; + for (int i = 1; i < 10; i++) + v.push_back(i); + + std::string test_str("(123456789)"); + std::ostringstream out; + ( + out << val("("), + for_each(arg1, lambda[out << arg1]), + out << val(")") + )(v); + BOOST_TEST(out.str() == test_str); + return; + } + +} + +int main() +{ + for_each_test(); + boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/algorithm/for_each2.cpp b/src/boost/libs/phoenix/test/algorithm/for_each2.cpp new file mode 100644 index 00000000..66aac15c --- /dev/null +++ b/src/boost/libs/phoenix/test/algorithm/for_each2.cpp @@ -0,0 +1,47 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + Copyright (c) 2014-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.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/stl/algorithm/iteration.hpp> +#include <boost/detail/lightweight_test.hpp> + +#include <functional> +#include <vector> +#include <string> +#include <sstream> + +namespace +{ + + void for_each_test() + { + return; + using boost::phoenix::for_each; + using boost::phoenix::lambda; + using boost::phoenix::ref; + using boost::phoenix::arg_names::arg1; + + std::vector<int> v; + for (int i = 1; i < 10; i++) + v.push_back(i); + + int x = 0; + for_each(arg1, lambda[ref(x) += arg1])(v); + BOOST_TEST(x == 45); + return; + } + +} + +int main() +{ + for_each_test(); + boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/algorithm/for_test.cpp b/src/boost/libs/phoenix/test/algorithm/for_test.cpp new file mode 100644 index 00000000..c57d610c --- /dev/null +++ b/src/boost/libs/phoenix/test/algorithm/for_test.cpp @@ -0,0 +1,55 @@ + /*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + Copyright (c) 2014 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.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/stl/algorithm/iteration.hpp> +#include <boost/detail/lightweight_test.hpp> + +#include <functional> +#include <vector> +#include <string> +#include <sstream> +#include <boost/typeof/std/ostream.hpp> + +namespace +{ + + void for_test() + { + using boost::phoenix::for_; + using boost::phoenix::val; + using boost::phoenix::ref; + using boost::phoenix::arg_names::arg1; + + std::vector<int> v; + for (int i = 1; i < 10; i++) + v.push_back(i); + + std::string test_str("(123456789)"); + std::ostringstream out; + int iii; + int size = v.size(); + ( + out << val("("), + for_(ref(iii) = 0, ref(iii) < size, ++ref(iii) ) + [ out << arg1[ref(iii)] ], + out << val(")") + )(v); + BOOST_TEST(out.str() == test_str); + return; + } + +} + +int main() +{ + for_test(); + boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/algorithm/for_test2.cpp b/src/boost/libs/phoenix/test/algorithm/for_test2.cpp new file mode 100644 index 00000000..9fa9baec --- /dev/null +++ b/src/boost/libs/phoenix/test/algorithm/for_test2.cpp @@ -0,0 +1,52 @@ + /*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + Copyright (c) 2014-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.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/stl/algorithm/iteration.hpp> +#include <boost/detail/lightweight_test.hpp> + +#include <functional> +#include <vector> +#include <string> +#include <sstream> +#include <boost/typeof/std/ostream.hpp> + +namespace +{ + + void for_test() + { + using boost::phoenix::for_; + using boost::phoenix::val; + using boost::phoenix::ref; + using boost::phoenix::arg_names::arg1; + + std::vector<int> v; + for (int i = 1; i < 10; i++) + v.push_back(i); + + //std::string test_str("(123456789)"); + //std::ostringstream out; + int iii; + int x = 0; + int size = v.size(); + for_(ref(iii) = 0, ref(iii) < size, ++ref(iii) ) + [ ref(x) += arg1[ref(iii)] ] (v); + BOOST_TEST(x == 45); + return; + } + +} + +int main() +{ + for_test(); + boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/algorithm/iteration.cpp b/src/boost/libs/phoenix/test/algorithm/iteration.cpp new file mode 100644 index 00000000..a809b5eb --- /dev/null +++ b/src/boost/libs/phoenix/test/algorithm/iteration.cpp @@ -0,0 +1,57 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + + 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.hpp> +#include <boost/phoenix/stl/algorithm/iteration.hpp> +#include <boost/detail/lightweight_test.hpp> + +#include <functional> + +namespace +{ + struct for_each_tester + { + int value_; + for_each_tester() : value_(0) { } + void operator()( + int& i) + { + value_ += i++; + return; + } + }; + + void for_each_test() + { + using boost::phoenix::for_each; + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3}; + BOOST_TEST(for_each(arg1, for_each_tester())(array).value_ == 6); + BOOST_TEST(array[0] == 2); + BOOST_TEST(array[1] == 3); + BOOST_TEST(array[2] == 4); + return; + } + + void accumulate_test() + { + using boost::phoenix::accumulate; + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3}; + BOOST_TEST(accumulate(arg1, 0)(array) == 6); + BOOST_TEST(boost::phoenix::accumulate(arg1, 0, std::minus<int>())(array) == -6); + return; + } +} + +int main() +{ + for_each_test(); + accumulate_test(); + boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/algorithm/querying.cpp b/src/boost/libs/phoenix/test/algorithm/querying.cpp new file mode 100644 index 00000000..02704d3c --- /dev/null +++ b/src/boost/libs/phoenix/test/algorithm/querying.cpp @@ -0,0 +1,286 @@ +/*============================================================================= + Copyright (c) 2005 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + Copyright (c) 2007 Hartmut Kaiser + 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.hpp> +#include <boost/phoenix/stl/algorithm/querying.hpp> +#include <boost/detail/lightweight_test.hpp> +#include <boost/assign/list_of.hpp> + +#include <boost/config.hpp> + +#ifdef BOOST_PHOENIX_HAS_HASH +#define _GLIBCXX_PERMIT_BACKWARD_HASH +#include BOOST_PHOENIX_HASH_SET_HEADER +#include BOOST_PHOENIX_HASH_MAP_HEADER +#endif + +#include <set> +#include <map> +#include <functional> + +namespace +{ + struct even + { + bool operator()(const int i) const + { + return i % 2 == 0; + } + }; + + struct mod_2_comparison + { + bool operator()( + const int lhs, + const int rhs) + { + return lhs % 2 == rhs % 2; + } + }; + + void find_test() + { + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3}; + BOOST_TEST(boost::phoenix::find(arg1,2)(array) == array + 1); + + std::set<int> s(array, array + 3); + BOOST_TEST(boost::phoenix::find(arg1, 2)(s) == s.find(2)); + +#if !(defined(BOOST_MSVC) && (BOOST_MSVC >= 1900)) + std::map<int, int> m = boost::assign::map_list_of(0, 1)(2, 3)(4, 5); + BOOST_TEST(boost::phoenix::find(arg1, 2)(m) == m.find(2)); +#endif + +#ifdef BOOST_PHOENIX_HAS_HASH + + BOOST_PHOENIX_HASH_NAMESPACE::hash_set<int> hs(array, array + 3); + BOOST_TEST(boost::phoenix::find(arg1, 2)(hs) == hs.find(2)); + + BOOST_PHOENIX_HASH_NAMESPACE::hash_map<int, int> hm = boost::assign::map_list_of(0, 1)(2, 3)(4, 5); + BOOST_TEST(boost::phoenix::find(arg1, 2)(hm) == hm.find(2)); + +#endif + + return; + } + + + void find_if_test() + { + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3}; + BOOST_TEST(boost::phoenix::find_if(arg1, even())(array) == array + 1); + return; + } + + void find_end_test() + { + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int array[] = {1,2,3,1,2,3,1}; + int pattern[] = {1,2,3}; + BOOST_TEST(boost::phoenix::find_end(arg1, arg2)(array, pattern) == array + 3); + int pattern2[] = {5,6,5}; + BOOST_TEST(boost::phoenix::find_end(arg1, arg2, mod_2_comparison())(array, pattern2) == array + 3); + return; + } + + void find_first_of_test() + { + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int array[] = {1,2,3}; + int search_for[] = {2,3,4}; + BOOST_TEST(boost::phoenix::find_first_of(arg1, arg2)(array, search_for) == array + 1); + + int search_for2[] = {0}; + BOOST_TEST(boost::phoenix::find_first_of(arg1, arg2, mod_2_comparison())(array, search_for2) == array + 1); + return; + } + + void adjacent_find_test() + { + using boost::phoenix::arg_names::arg1; + int array[] = {0,1,3,4,4}; + BOOST_TEST(boost::phoenix::adjacent_find(arg1)(array) == array + 3); + BOOST_TEST(boost::phoenix::adjacent_find(arg1, mod_2_comparison())(array) == array + 1); + return; + } + + void count_test() + { + using boost::phoenix::arg_names::arg1; + int array[] = {1,1,0,1,1}; + BOOST_TEST(boost::phoenix::count(arg1, 1)(array) == 4); + return; + } + + void count_if_test() + { + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3,4,5}; + BOOST_TEST(boost::phoenix::count_if(arg1, even())(array) == 2); + return; + } + + void distance_test() + { + using boost::phoenix::arg_names::arg1; + int array[] = {1,1,0,1,1}; + BOOST_TEST(boost::phoenix::distance(arg1)(array) == 5); + return; + } + + void mismatch_test() + { + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int array[] = {1,2,3,4,5}; + int search[] = {1,2,4}; + + BOOST_TEST( + boost::phoenix::mismatch(arg1, arg2)(array, search) == + std::make_pair(array + 2, search + 2)); + int search2[] = {1,2,1,1}; + BOOST_TEST( + boost::phoenix::mismatch(arg1, arg2, mod_2_comparison())(array, search2) + == std::make_pair(array + 3, search2 + 3)); + + return; + } + + void equal_test() + { + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int array[] = {1,2,3}; + int array2[] = {1,2,3}; + int array3[] = {1,2,4}; + BOOST_TEST( + boost::phoenix::equal(arg1, arg2)(array, array2)); + BOOST_TEST( + !boost::phoenix::equal(arg1, arg2)(array, array3)); + + BOOST_TEST( + boost::phoenix::equal(arg1, arg2, mod_2_comparison())(array, array2)); + BOOST_TEST( + !boost::phoenix::equal(arg1, arg2, mod_2_comparison())(array, array3)); + return; + } + + void search_test() + { + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int array[] = {1,2,3,1,2,3}; + int pattern[] = {2,3}; + BOOST_TEST( + boost::phoenix::search(arg1, arg2)(array, pattern) == array + 1); + int pattern2[] = {1,1}; + BOOST_TEST( + boost::phoenix::search(arg1, arg2, mod_2_comparison())(array, pattern2) == array + 2); + return; + } + + void lower_bound_test() + { + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3}; + const std::set<int> test_set(array, array + 3); + BOOST_TEST(boost::phoenix::lower_bound(arg1, 2)(array) == array + 1); + BOOST_TEST(boost::phoenix::lower_bound(arg1, 2)(test_set) == test_set.lower_bound(2)); + + int array2[] = {3,2,1}; + const std::set<int, std::greater<int> > test_set2(array2, array2 + 3); + BOOST_TEST(boost::phoenix::lower_bound(arg1, 2, std::greater<int>())(array2) == + array2 + 1); + BOOST_TEST(boost::phoenix::lower_bound(arg1, 2, std::greater<int>())(test_set2) == + test_set2.lower_bound(2)); + return; + } + + void upper_bound_test() + { + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3}; + const std::set<int> test_set(array, array + 3); + BOOST_TEST(upper_bound(arg1, 2)(array) == array + 2); + BOOST_TEST(upper_bound(arg1, 2)(test_set) == test_set.upper_bound(2)); + + int array2[] = {3,2,1}; + const std::set<int, std::greater<int> > test_set2(array2, array2 + 3); + BOOST_TEST(boost::phoenix::upper_bound(arg1, 2, std::greater<int>())(array2) == + array2 + 2); + BOOST_TEST(boost::phoenix::upper_bound(arg1, 2, std::greater<int>())(test_set2) == + test_set2.upper_bound(2)); + return; + } + + void equal_range_test() + { + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,2,3}; + const std::set<int> test_set(array, array + 4); + BOOST_TEST(boost::phoenix::equal_range(arg1, 2)(array).first == + array + 1); + BOOST_TEST(boost::phoenix::equal_range(arg1, 2)(array).second == + array + 3); + + BOOST_TEST(boost::phoenix::equal_range(arg1, 2)(test_set).first == + test_set.equal_range(2).first); + BOOST_TEST(boost::phoenix::equal_range(arg1, 2)(test_set).second == + test_set.equal_range(2).second); + + int array2[] = {3,2,2,1}; + const std::set<int, std::greater<int> > test_set2(array2, array2 + 4); + BOOST_TEST(boost::phoenix::equal_range(arg1, 2, std::greater<int>())(array2).first == + array2 + 1); + BOOST_TEST(boost::phoenix::equal_range(arg1, 2, std::greater<int>())(array2).second == + array2 + 3); + + BOOST_TEST(boost::phoenix::equal_range(arg1, 2, std::greater<int>())(test_set2).first == + test_set2.equal_range(2).first); + BOOST_TEST(boost::phoenix::equal_range(arg1, 2, std::greater<int>())(test_set2).second == + test_set2.equal_range(2).second); + + return; + } + + void binary_search_test() + { + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3}; + BOOST_TEST(boost::phoenix::binary_search(arg1, 2)(array)); + BOOST_TEST(!boost::phoenix::binary_search(arg1, 4)(array)); + return; + } + +} + +int main() +{ + find_test(); + find_if_test(); + find_end_test(); + find_first_of_test(); + adjacent_find_test(); + count_test(); + count_if_test(); + distance_test(); + mismatch_test(); + equal_test(); + search_test(); + lower_bound_test(); + upper_bound_test(); + equal_range_test(); + binary_search_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/algorithm/querying2.cpp b/src/boost/libs/phoenix/test/algorithm/querying2.cpp new file mode 100644 index 00000000..c6641186 --- /dev/null +++ b/src/boost/libs/phoenix/test/algorithm/querying2.cpp @@ -0,0 +1,85 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + + 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.hpp> +#include <boost/phoenix/stl/algorithm/querying.hpp> +#include <boost/detail/lightweight_test.hpp> + +#include <boost/range.hpp> + +#include <functional> + +namespace +{ + void includes_test() + { + using boost::phoenix::includes; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int array[] = {1,2,3}; + int array2[] = {1,2}; + BOOST_TEST(includes(arg1, arg2)(array, array2)); + boost::iterator_range<int*> rng(array + 1, array + 3); + BOOST_TEST(!includes(arg1, arg2)(rng, array2)); + + int array3[] = {3,2,1}; + int array4[] = {2,1}; + BOOST_TEST(boost::phoenix::includes(arg1, arg2, std::greater<int>())(array3, array4)); + boost::iterator_range<int*> rng2(array3, array3 + 2); + BOOST_TEST(!boost::phoenix::includes(arg1, arg2, std::greater<int>())(rng2, array4)); + return; + } + + void min_element_test() + { + using boost::phoenix::min_element; + using boost::phoenix::arg_names::arg1; + int array[] = {1,3,2}; + BOOST_TEST(min_element(arg1)(array) == array); + BOOST_TEST(boost::phoenix::min_element(arg1, std::greater<int>())(array) == array + 1); + return; + } + + void max_element_test() + { + using boost::phoenix::max_element; + using boost::phoenix::arg_names::arg1; + int array[] = {1,3,2}; + BOOST_TEST(max_element(arg1)(array) == array + 1); + BOOST_TEST(boost::phoenix::max_element(arg1, std::greater<int>())(array) == array); + return; + } + + void lexicographical_compare_test() + { + using boost::phoenix::lexicographical_compare; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int array[] = {1,2,3}; + int array2[] = {1,2,4}; + + BOOST_TEST(lexicographical_compare(arg1, arg2)(array, array2)); + BOOST_TEST(!lexicographical_compare(arg1, arg2)(array2, array)); + BOOST_TEST(!lexicographical_compare(arg1, arg2)(array, array)); + + BOOST_TEST(!boost::phoenix::lexicographical_compare(arg1, arg2, std::greater<int>())(array, array2)); + BOOST_TEST(boost::phoenix::lexicographical_compare(arg1, arg2, std::greater<int>())(array2, array)); + BOOST_TEST(!boost::phoenix::lexicographical_compare(arg1, arg2, std::greater<int>())(array, array)); + + return; + } +} + +int main() +{ + includes_test(); + min_element_test(); + max_element_test(); + lexicographical_compare_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/algorithm/querying_find.cpp b/src/boost/libs/phoenix/test/algorithm/querying_find.cpp new file mode 100644 index 00000000..99707aa2 --- /dev/null +++ b/src/boost/libs/phoenix/test/algorithm/querying_find.cpp @@ -0,0 +1,96 @@ +/*============================================================================= + Copyright (c) 2005 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + Copyright (c) 2007 Hartmut Kaiser + 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.hpp> +#include <boost/phoenix/stl/algorithm/querying.hpp> +#include <boost/detail/lightweight_test.hpp> +#include <boost/assign/list_of.hpp> + +#include <boost/config.hpp> + +#ifdef BOOST_PHOENIX_HAS_HASH +#include BOOST_PHOENIX_HASH_SET_HEADER +#include BOOST_PHOENIX_HASH_MAP_HEADER +#endif +#ifdef BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP +#include BOOST_PHOENIX_UNORDERED_SET_HEADER +#include BOOST_PHOENIX_UNORDERED_MAP_HEADER +#endif + +#include <set> +#include <map> +#include <functional> + +namespace +{ + struct even + { + bool operator()(const int i) const + { + return i % 2 == 0; + } + }; + + struct mod_2_comparison + { + bool operator()( + const int lhs, + const int rhs) + { + return lhs % 2 == rhs % 2; + } + }; + + void find_test() + { + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3}; + BOOST_TEST(boost::phoenix::find(arg1,2)(array) == array + 1); + + std::set<int> s(array, array + 3); + BOOST_TEST(boost::phoenix::find(arg1, 2)(s) == s.find(2)); + + //#if !(defined(BOOST_MSVC) && (BOOST_MSVC >= 1900)) + //std::map<int, int> m = boost::assign::map_list_of(0, 1)(2, 3)(4, 5).to_container(m); + std::map<int, int> m = boost::assign::map_list_of(0, 1)(2, 3)(4, 5). + convert_to_container<std::map<int, int> >(); + BOOST_TEST(boost::phoenix::find(arg1, 2)(m) == m.find(2)); + //#endif + +#ifdef BOOST_PHOENIX_HAS_HASH + + BOOST_PHOENIX_HASH_NAMESPACE::hash_set<int> hs(array, array + 3); + BOOST_TEST(boost::phoenix::find(arg1, 2)(hs) == hs.find(2)); + + BOOST_PHOENIX_HASH_NAMESPACE::hash_map<int, int> hm = boost::assign::map_list_of(0, 1)(2, 3)(4, 5). + convert_to_container<BOOST_PHOENIX_HASH_NAMESPACE::hash_map<int, int> >(); + BOOST_TEST(boost::phoenix::find(arg1, 2)(hm) == hm.find(2)); + +#endif +#ifdef BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP + + std::unordered_set<int> us(array, array + 3); + BOOST_TEST(boost::phoenix::find(arg1, 2)(us) == us.find(2)); + + std::unordered_map<int, int> um = boost::assign::map_list_of(0, 1)(2, 3)(4, 5). + convert_to_container<std::unordered_map<int, int> >(); + BOOST_TEST(boost::phoenix::find(arg1, 2)(um) == um.find(2)); + +#endif + return; + } +} + +int main() +{ + find_test(); + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/algorithm/querying_find2.cpp b/src/boost/libs/phoenix/test/algorithm/querying_find2.cpp new file mode 100644 index 00000000..a7d2bcdb --- /dev/null +++ b/src/boost/libs/phoenix/test/algorithm/querying_find2.cpp @@ -0,0 +1,103 @@ +/*============================================================================= + Copyright (c) 2005 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + Copyright (c) 2007 Hartmut Kaiser + 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/config.hpp> + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/stl/algorithm/querying.hpp> +#include <boost/detail/lightweight_test.hpp> +#include <boost/assign/list_of.hpp> + +#include <set> +#include <map> +#include <functional> + +#ifdef BOOST_PHOENIX_HAS_HASH +#include BOOST_PHOENIX_HASH_SET_HEADER +#include BOOST_PHOENIX_HASH_MAP_HEADER +#endif +#ifdef BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP +#include BOOST_PHOENIX_UNORDERED_SET_HEADER +#include BOOST_PHOENIX_UNORDERED_MAP_HEADER +#endif + +namespace +{ + struct even + { + bool operator()(const int i) const + { + return i % 2 == 0; + } + }; + + struct mod_2_comparison + { + bool operator()( + const int lhs, + const int rhs) + { + return lhs % 2 == rhs % 2; + } + }; + + void find_test() + { + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3}; + BOOST_TEST(boost::phoenix::find(arg1,2)(array) == array + 1); + + std::set<int> s(array, array + 3); + BOOST_TEST(boost::phoenix::find(arg1, 2)(s) == s.find(2)); + + std::map<int, int> m = boost::assign::map_list_of(0, 1)(2, 3)(4, 5). + convert_to_container<std::map<int, int> >(); + BOOST_TEST(boost::phoenix::find(arg1, 2)(m) == m.find(2)); + +#ifdef BOOST_PHOENIX_HAS_HASH + + BOOST_PHOENIX_HASH_NAMESPACE::hash_set<int> hs(array, array + 3); + BOOST_TEST(boost::phoenix::find(arg1, 2)(hs) == hs.find(2)); + + BOOST_PHOENIX_HASH_NAMESPACE::hash_map<int, int> hm = boost::assign::map_list_of(0, 1)(2, 3)(4, 5). + convert_to_container<BOOST_PHOENIX_HASH_NAMESPACE::hash_map<int, int> >(); + BOOST_TEST(boost::phoenix::find(arg1, 2)(hm) == hm.find(2)); + +#endif +#ifdef BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP + + std::unordered_set<int> us(array, array + 3); + BOOST_TEST(boost::phoenix::find(arg1, 2)(us) == us.find(2)); + + int marray[] = {1,1,2,3,3}; + std::unordered_multiset<int> ums(marray, marray + 5); + BOOST_TEST(boost::phoenix::find(arg1, 2)(ums) == ums.find(2)); + + std::unordered_map<int, int> um = + boost::assign::map_list_of(0, 1)(2, 3)(4, 5). + convert_to_container<std::unordered_map<int, int> >(); + BOOST_TEST(boost::phoenix::find(arg1, 2)(um) == um.find(2)); + + std::unordered_multimap<int, int> umm = + boost::assign::map_list_of(0, 1)(2, 3)(4, 5)(4, 6). + convert_to_container<std::unordered_multimap<int, int> >(); + BOOST_TEST(boost::phoenix::find(arg1, 2)(umm) == umm.find(2)); + +#endif + return; + } +} + +int main() +{ + find_test(); + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/algorithm/transformation1.cpp b/src/boost/libs/phoenix/test/algorithm/transformation1.cpp new file mode 100644 index 00000000..657b9fbe --- /dev/null +++ b/src/boost/libs/phoenix/test/algorithm/transformation1.cpp @@ -0,0 +1,403 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + + 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.hpp> +#include <boost/phoenix/stl/algorithm/transformation.hpp> +#include <boost/detail/lightweight_test.hpp> + +#include <functional> +#include <list> + +namespace +{ + struct even + { + bool operator()(const int i) const + { + return i % 2 == 0; + } + }; + + struct mod_2_comparison + { + bool operator()( + const int lhs, + const int rhs) + { + return lhs % 2 == rhs % 2; + } + }; + + void swap_test() + { + using boost::phoenix::swap; + using boost::phoenix::ref; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + int a = 123; + int b = 456; + swap(ref(a), ref(b))(); + BOOST_TEST(a == 456 && b == 123); + swap(ref(a), _1)(b); + BOOST_TEST(a == 123 && b == 456); + swap(_1, _2)(a, b); + BOOST_TEST(a == 456 && b == 123); + return; + } + + void copy_test() + { + using boost::phoenix::copy; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int array[] = {1,2,3}; + int output[4]; + BOOST_TEST( + copy(arg1, arg2)(array, output) == output + 3); + BOOST_TEST(output[0] == 1); + BOOST_TEST(output[1] == 2); + BOOST_TEST(output[2] == 3); + return; + } + + void copy_backward_test() + { + using boost::phoenix::copy_backward; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int array[] = {1,2,3}; + int output[4]; + int* output_end = output + 3; + BOOST_TEST( + copy_backward(arg1, arg2)(array, output_end) == output); + BOOST_TEST(output[0] == 1); + BOOST_TEST(output[1] == 2); + BOOST_TEST(output[2] == 3); + return; + } + + struct increment + { + int operator()( + int i) const + { + return i+1; + } + }; + + void transform_test() + { + using boost::phoenix::transform; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + using boost::phoenix::arg_names::arg3; + int array[] = {1,2,3}; + BOOST_TEST( + transform(arg1, arg2, increment())(array, array) == + array + 3); + BOOST_TEST(array[0] == 2); + BOOST_TEST(array[1] == 3); + BOOST_TEST(array[2] == 4); + + int array2[] = {1,2,3}; + BOOST_TEST( + boost::phoenix::transform(arg1, arg2, arg3, std::plus<int>())(array, array2, array) == + array +3); + BOOST_TEST(array[0] == 2 + 1); + BOOST_TEST(array[1] == 3 + 2); + BOOST_TEST(array[2] == 4 + 3); + return; + } + + void replace_test() + { + using boost::phoenix::replace; + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3}; + replace(arg1,2,4)(array); + BOOST_TEST(array[0] == 1); + BOOST_TEST(array[1] == 4); + BOOST_TEST(array[2] == 3); + return; + } + + void replace_if_test() + { + using boost::phoenix::replace_if; + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3}; + replace_if(arg1, even(), 4)(array); + BOOST_TEST(array[0] == 1); + BOOST_TEST(array[1] == 4); + BOOST_TEST(array[2] == 3); + return; + } + + void replace_copy_test() + { + using boost::phoenix::replace_copy; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int input[] = {1,2,3}; + int output[3]; + replace_copy(arg1, arg2, 2, 4)(input, output); + BOOST_TEST(output[0] == 1); + BOOST_TEST(output[1] == 4); + BOOST_TEST(output[2] == 3); + return; + } + + void replace_copy_if_test() + { + using boost::phoenix::replace_copy_if; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int input[] = {1,2,3}; + int output[3]; + replace_copy_if(arg1, arg2, even(), 4)(input, output); + BOOST_TEST(output[0] == 1); + BOOST_TEST(output[1] == 4); + BOOST_TEST(output[2] == 3); + return; + } + + void fill_test() + { + using boost::phoenix::fill; + using boost::phoenix::arg_names::arg1; + int array[] = {0,0,0}; + fill(arg1, 1)(array); + BOOST_TEST(array[0] == 1); + BOOST_TEST(array[1] == 1); + BOOST_TEST(array[2] == 1); + return; + } + + void fill_n_test() + { + using boost::phoenix::fill_n; + using boost::phoenix::arg_names::arg1; + int array[] = {0,0,0}; + fill_n(arg1, 2, 1)(array); + BOOST_TEST(array[0] == 1); + BOOST_TEST(array[1] == 1); + BOOST_TEST(array[2] == 0); + return; + } + + class int_seq + { + public: + int_seq() : val_(0) { } + + int operator()() + { + return val_++; + } + private: + int val_; + }; + + void generate_test() + { + using boost::phoenix::generate; + using boost::phoenix::arg_names::arg1; + int array[3]; + generate(arg1, int_seq())(array); + BOOST_TEST(array[0] == 0); + BOOST_TEST(array[1] == 1); + BOOST_TEST(array[2] == 2); + return; + } + + void generate_n_test() + { + using boost::phoenix::generate_n; + using boost::phoenix::arg_names::arg1; + int array[] = {0,0,1}; + generate_n(arg1, 2, int_seq())(array); + BOOST_TEST(array[0] == 0); + BOOST_TEST(array[1] == 1); + BOOST_TEST(array[2] == 1); + return; + } + + + void remove_test() + { + using boost::phoenix::remove; + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3}; + std::list<int> test_list(array, array + 3); + BOOST_TEST(boost::phoenix::remove(arg1, 2)(array) == array + 2); + BOOST_TEST(array[0] == 1); + BOOST_TEST(array[1] == 3); + BOOST_TEST(boost::phoenix::remove(arg1, 2)(test_list) == test_list.end()); + std::list<int>::const_iterator it(test_list.begin()); + BOOST_TEST(*it++ == 1); + BOOST_TEST(*it++ == 3); + return; + } + + void remove_if_test() + { + using boost::phoenix::remove_if; + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3}; + std::list<int> test_list(array, array + 3); + BOOST_TEST(boost::phoenix::remove_if(arg1, even())(array) == array + 2); + BOOST_TEST(array[0] == 1); + BOOST_TEST(array[1] == 3); + BOOST_TEST(boost::phoenix::remove_if(arg1, even())(test_list) == test_list.end()); + std::list<int>::const_iterator it(test_list.begin()); + BOOST_TEST(*it++ == 1); + BOOST_TEST(*it++ == 3); + return; + } + + void remove_copy_test() + { + using boost::phoenix::remove_copy; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int array[] = {1,2,3}; + int array2[2]; + BOOST_TEST(boost::phoenix::remove_copy(arg1, arg2, 2)(array, array2) == array2 + 2); + BOOST_TEST(array2[0] == 1); + BOOST_TEST(array2[1] == 3); + return; + } + + void remove_copy_if_test() + { + using boost::phoenix::remove_copy_if; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int array[] = {1,2,3}; + int array2[2]; + BOOST_TEST(boost::phoenix::remove_copy_if(arg1, arg2, even())(array, array2) == array2 + 2); + BOOST_TEST(array2[0] == 1); + BOOST_TEST(array2[1] == 3); + return; + } + + void unique_test() + { + using boost::phoenix::unique; + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,2,3}; + std::list<int> test_list(array, array + 4); + BOOST_TEST(unique(arg1)(array) == array + 3); + BOOST_TEST(array[0] == 1); + BOOST_TEST(array[1] == 2); + BOOST_TEST(array[2] == 3); + + BOOST_TEST(unique(arg1)(test_list) == test_list.end()); + std::list<int>::const_iterator it(test_list.begin()); + BOOST_TEST(*it++ == 1); + BOOST_TEST(*it++ == 2); + BOOST_TEST(*it++ == 3); + + int array2[] = {1,3,2}; + std::list<int> test_list2(array2, array2 + 3); + BOOST_TEST(unique(arg1, mod_2_comparison())(array2) == array2 + 2); + BOOST_TEST(array2[0] == 1); + BOOST_TEST(array2[1] == 2); + + BOOST_TEST(unique(arg1, mod_2_comparison())(test_list2) == test_list2.end()); + std::list<int>::const_iterator jt(test_list2.begin()); + BOOST_TEST(*jt++ == 1); + BOOST_TEST(*jt++ == 2); + + return; + } + + void unique_copy_test() + { + using boost::phoenix::unique_copy; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int array[] = {1,2,2,3}; + int out[3]; + BOOST_TEST(unique_copy(arg1, arg2)(array, out) == out + 3); + BOOST_TEST(out[0] == 1); + BOOST_TEST(out[1] == 2); + BOOST_TEST(out[2] == 3); + + int array2[] = {1,3,2}; + int out2[2]; + BOOST_TEST(unique_copy(arg1, arg2, mod_2_comparison())(array2, out2) == out2 + 2); + BOOST_TEST(out2[0] == 1); + BOOST_TEST(out2[1] == 2); + + return; + } + + void reverse_test() + { + using boost::phoenix::reverse; + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3}; + std::list<int> test_list(array, array + 3); + reverse(arg1)(array); + BOOST_TEST(array[0] == 3); + BOOST_TEST(array[1] == 2); + BOOST_TEST(array[2] == 1); + + reverse(arg1)(test_list); + std::list<int>::iterator it(test_list.begin()); + BOOST_TEST(*it++ == 3); + BOOST_TEST(*it++ == 2); + BOOST_TEST(*it++ == 1); + return; + } + + void reverse_copy_test() + { + using boost::phoenix::reverse_copy; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int array[] = {1,2,3}; + int array2[3]; + reverse_copy(arg1, arg2)(array, array2); + BOOST_TEST(array[0] == 1); + BOOST_TEST(array[1] == 2); + BOOST_TEST(array[2] == 3); + + BOOST_TEST(array2[0] == 3); + BOOST_TEST(array2[1] == 2); + BOOST_TEST(array2[2] == 1); + + return; + } +} + +int main() +{ + swap_test(); + copy_test(); + copy_backward_test(); + transform_test(); + replace_test(); + replace_if_test(); + replace_copy_test(); + replace_copy_if_test(); + fill_test(); + fill_n_test(); + generate_test(); + generate_n_test(); + remove_test(); + remove_if_test(); + remove_copy_test(); + remove_copy_if_test(); + unique_test(); + unique_copy_test(); + reverse_test(); + reverse_copy_test(); + boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/algorithm/transformation2.cpp b/src/boost/libs/phoenix/test/algorithm/transformation2.cpp new file mode 100644 index 00000000..e22d57bd --- /dev/null +++ b/src/boost/libs/phoenix/test/algorithm/transformation2.cpp @@ -0,0 +1,195 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + + 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 <functional> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/stl/algorithm/transformation.hpp> +#include <boost/detail/lightweight_test.hpp> + +#include <list> + +namespace +{ + struct even + { + bool operator()(const int i) const + { + return i % 2 == 0; + } + }; + + void rotate_test() + { + using boost::phoenix::rotate; + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3}; + rotate(arg1, array + 1)(array); + std::cout << array[0] << array[1] << array[2] << std::endl; + BOOST_TEST(array[0] == 2); + BOOST_TEST(array[1] == 3); + BOOST_TEST(array[2] == 1); + + return; + } + + void rotate_copy_test() + { + using boost::phoenix::rotate_copy; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int array[] = {1,2,3}; + int array2[3]; + rotate_copy(arg1, array + 1, arg2)(array, array2); + BOOST_TEST(array2[0] == 2); + BOOST_TEST(array2[1] == 3); + BOOST_TEST(array2[2] == 1); + + return; + } + + void random_shuffle_test() + { +#ifndef BOOST_NO_CXX98_RANDOM_SHUFFLE + using boost::phoenix::random_shuffle; + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3}; + random_shuffle(arg1)(array); + const int first = array[0]; + BOOST_TEST(first == 1 || first == 2 || first == 3); + const int second = array[1]; + BOOST_TEST(second == 1 || second == 2 || second == 3); + BOOST_TEST(first != second); + const int third = array[2]; + BOOST_TEST(third == 1 || third == 2 || third == 3); + BOOST_TEST(first != third && second != third); + return; +#endif + } + + void partition_test() + { + using boost::phoenix::partition; + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3}; + int* const end = partition(arg1, even())(array); + BOOST_TEST(end == array + 1); + BOOST_TEST(array[0] % 2 == 0); + BOOST_TEST(array[1] % 2 != 0); + BOOST_TEST(array[2] % 2 != 0); + return; + } + + void stable_partition_test() + { + using boost::phoenix::stable_partition; + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3}; + int* const end = stable_partition(arg1, even())(array); + BOOST_TEST(end == array + 1); + BOOST_TEST(array[0] == 2); + BOOST_TEST(array[1] == 1); + BOOST_TEST(array[2] == 3); + return; + } + + void sort_test() + { + using boost::phoenix::sort; + using boost::phoenix::arg_names::arg1; + int array[] = {3,1,2}; + std::list<int> test_list(array, array + 3); + sort(arg1)(array); + BOOST_TEST(array[0] == 1); + BOOST_TEST(array[1] == 2); + BOOST_TEST(array[2] == 3); + + sort(arg1)(test_list); + std::list<int>::const_iterator it(test_list.begin()); + BOOST_TEST(*it++ == 1); + BOOST_TEST(*it++ == 2); + BOOST_TEST(*it++ == 3); + + boost::phoenix::sort(arg1, std::greater<int>())(array); + BOOST_TEST(array[0] == 3); + BOOST_TEST(array[1] == 2); + BOOST_TEST(array[2] == 1); + + boost::phoenix::sort(arg1, std::greater<int>())(test_list); + std::list<int>::const_iterator jt(test_list.begin()); + BOOST_TEST(*jt++ == 3); + BOOST_TEST(*jt++ == 2); + BOOST_TEST(*jt++ == 1); + + return; + } + + void stable_sort_test() + { + using boost::phoenix::stable_sort; + using boost::phoenix::arg_names::arg1; + int array[] = {3,1,2}; + stable_sort(arg1)(array); + BOOST_TEST(array[0] == 1); + BOOST_TEST(array[1] == 2); + BOOST_TEST(array[2] == 3); + + boost::phoenix::stable_sort(arg1, std::greater<int>())(array); + BOOST_TEST(array[0] == 3); + BOOST_TEST(array[1] == 2); + BOOST_TEST(array[2] == 1); + + return; + } + + void partial_sort_test() + { + using boost::phoenix::partial_sort; + using boost::phoenix::arg_names::arg1; + int array[] = {2,4,1,3}; + partial_sort(arg1, array + 2)(array); + BOOST_TEST(array[0] == 1); + BOOST_TEST(array[1] == 2); + + boost::phoenix::partial_sort(arg1, array + 2, std::greater<int>())(array); + BOOST_TEST(array[0] == 4); + BOOST_TEST(array[1] == 3); + return; + } + + void partial_sort_copy_test() + { + using boost::phoenix::partial_sort_copy; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int array[] = {2,4,1,3}; + int array2[2]; + partial_sort_copy(arg1, arg2)(array, array2); + BOOST_TEST(array2[0] == 1); + BOOST_TEST(array2[1] == 2); + + boost::phoenix::partial_sort_copy(arg1, arg2, std::greater<int>())(array, array2); + BOOST_TEST(array2[0] == 4); + BOOST_TEST(array2[1] == 3); + + return; + } +} + +int main() +{ + rotate_test(); + rotate_copy_test(); + random_shuffle_test(); + partition_test(); + stable_partition_test(); + sort_test(); + stable_sort_test(); + partial_sort_test(); + partial_sort_copy_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/algorithm/transformation3.cpp b/src/boost/libs/phoenix/test/algorithm/transformation3.cpp new file mode 100644 index 00000000..8a178748 --- /dev/null +++ b/src/boost/libs/phoenix/test/algorithm/transformation3.cpp @@ -0,0 +1,187 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + + 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 <functional> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/stl/algorithm/transformation.hpp> +#include <boost/detail/lightweight_test.hpp> + +#include <list> + +namespace +{ + void nth_element_test() + { + using boost::phoenix::nth_element; + using boost::phoenix::arg_names::arg1; + int array[] = {5,1,4,3,2}; + nth_element(arg1, array + 2)(array); + BOOST_TEST(array[0] < 3); + BOOST_TEST(array[1] < 3); + BOOST_TEST(array[2] == 3); + BOOST_TEST(array[3] > 3); + BOOST_TEST(array[4] > 3); + + boost::phoenix::nth_element(arg1, array + 2, std::greater<int>())(array); + BOOST_TEST(array[0] > 3); + BOOST_TEST(array[1] > 3); + BOOST_TEST(array[2] == 3); + BOOST_TEST(array[3] < 3); + BOOST_TEST(array[4] < 3); + + return; + } + + void merge_test() + { + using boost::phoenix::merge; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + using boost::phoenix::arg_names::arg3; + int array[] = {1,2,3}; + int array2[] = {2,3,4}; + int output[6]; + + BOOST_TEST(merge(arg1, arg2, arg3)(array, array2, output) == output + 6); + int expected_result[] = {1,2,2,3,3,4}; + BOOST_TEST(std::equal(output, output + 6, expected_result)); + + int array3[] = {5,4,3}; + int array4[] = {3,2,1}; + int output2[6]; + BOOST_TEST(boost::phoenix::merge(arg1, arg2, arg3, std::greater<int>())(array3, array4, output2) == + output2 + 6); + int expected_result2[] = {5,4,3,3,2,1}; + BOOST_TEST(std::equal(output2, output2 + 6, expected_result2)); + return; + } + + void inplace_merge_test() + { + using boost::phoenix::inplace_merge; + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3,2,3,4}; + inplace_merge(arg1, array + 3)(array); + int expected_result[] = {1,2,2,3,3,4}; + BOOST_TEST(std::equal(array, array + 6, expected_result)); + + int array2[] = {5,4,3,4,3,2}; + boost::phoenix::inplace_merge(arg1, array2 + 3, std::greater<int>())(array2); + int expected_result2[] = {5,4,4,3,3,2}; + BOOST_TEST(std::equal(array2, array2 + 6, expected_result2)); + return; + } + + void set_union_test() + { + using boost::phoenix::set_union; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + using boost::phoenix::arg_names::arg3; + int array[] = {1,2,3}; + int array2[] = {2,3,4}; + int output[4]; + BOOST_TEST(set_union(arg1, arg2, arg3)(array, array2, output) == output + 4); + int expected_result[] = {1,2,3,4}; + BOOST_TEST(std::equal(output, output + 4, expected_result)); + + int array3[] = {3,2,1}; + int array4[] = {4,3,2}; + int output2[4]; + BOOST_TEST(boost::phoenix::set_union(arg1, arg2, arg3, std::greater<int>()) + (array3, array4, output2) == + output2 + 4); + int expected_result2[] = {4,3,2,1}; + BOOST_TEST(std::equal(output2, output2 + 4, expected_result2)); + return; + } + + void set_intersection_test() + { + using boost::phoenix::set_intersection; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + using boost::phoenix::arg_names::arg3; + int array[] = {1,2,3}; + int array2[] = {2,3,4}; + int output[2]; + BOOST_TEST(set_intersection(arg1, arg2, arg3)(array, array2, output) == output + 2); + int expected_result[] = {2,3}; + BOOST_TEST(std::equal(output, output + 2, expected_result)); + + int array3[] = {3,2,1}; + int array4[] = {4,3,2}; + int output2[2]; + BOOST_TEST(boost::phoenix::set_intersection(arg1, arg2, arg3, std::greater<int>()) + (array3, array4, output2) == + output2 + 2); + int expected_result2[] = {3,2}; + BOOST_TEST(std::equal(output2, output2 + 2, expected_result2)); + return; + } + + void set_difference_test() + { + using boost::phoenix::set_difference; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + using boost::phoenix::arg_names::arg3; + int array[] = {1,2,3}; + int array2[] = {2,3,4}; + int output[1]; + BOOST_TEST(set_difference(arg1, arg2, arg3)(array, array2, output) == output + 1); + int expected_result[] = {1}; + BOOST_TEST(std::equal(output, output + 1, expected_result)); + + int array3[] = {3,2,1}; + int array4[] = {4,3,2}; + int output2[1]; + BOOST_TEST(boost::phoenix::set_difference(arg1, arg2, arg3, std::greater<int>()) + (array3, array4, output2) == + output2 + 1); + int expected_result2[] = {1}; + BOOST_TEST(std::equal(output2, output2 + 1, expected_result2)); + return; + } + + void set_symmetric_difference_test() + { + using boost::phoenix::set_symmetric_difference; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + using boost::phoenix::arg_names::arg3; + int array[] = {1,2,3}; + int array2[] = {2,3,4}; + int output[2]; + BOOST_TEST(set_symmetric_difference(arg1, arg2, arg3)(array, array2, output) == output + 2); + int expected_result[] = {1,4}; + BOOST_TEST(std::equal(output, output + 2, expected_result)); + + int array3[] = {3,2,1}; + int array4[] = {4,3,2}; + int output2[2]; + BOOST_TEST(boost::phoenix::set_symmetric_difference(arg1, arg2, arg3, std::greater<int>()) + (array3, array4, output2) == + output2 + 2); + int expected_result2[] = {4,1}; + BOOST_TEST(std::equal(output2, output2 + 2, expected_result2)); + return; + } +} + +int main() +{ + nth_element_test(); + merge_test(); + inplace_merge_test(); + set_union_test(); + set_intersection_test(); + set_difference_test(); + set_symmetric_difference_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/algorithm/transformation4.cpp b/src/boost/libs/phoenix/test/algorithm/transformation4.cpp new file mode 100644 index 00000000..f278a4c6 --- /dev/null +++ b/src/boost/libs/phoenix/test/algorithm/transformation4.cpp @@ -0,0 +1,159 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + + 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.hpp> +#include <boost/phoenix/stl/algorithm/transformation.hpp> +#include <boost/detail/lightweight_test.hpp> + +#include <vector> +#include <functional> +#include <algorithm> + +namespace +{ + void heap_test() + { + using boost::phoenix::make_heap; + using boost::phoenix::pop_heap; + using boost::phoenix::push_heap; + using boost::phoenix::sort_heap; + using boost::phoenix::arg_names::arg1; + int array[] = {1,2,3}; + std::vector<int> vec(array, array + 3); + boost::phoenix::make_heap(arg1)(vec); + vec.push_back(5); + boost::phoenix::push_heap(arg1)(vec); + vec.push_back(4); + boost::phoenix::push_heap(arg1)(vec); + boost::phoenix::pop_heap(arg1)(vec); + BOOST_TEST(vec.back() == 5); + vec.pop_back(); + boost::phoenix::sort_heap(arg1)(vec); + int expected_result[] = {1,2,3,4}; + BOOST_TEST(std::equal(vec.begin(), vec.end(), expected_result)); + + int array2[] = {3,2,1}; + std::vector<int> vec2(array2, array2 + 3); + boost::phoenix::make_heap(arg1, std::greater<int>())(vec2); + vec2.push_back(5); + boost::phoenix::push_heap(arg1, std::greater<int>())(vec2); + vec2.push_back(4); + boost::phoenix::push_heap(arg1, std::greater<int>())(vec2); + boost::phoenix::pop_heap(arg1, std::greater<int>())(vec2); + BOOST_TEST(vec2.back() == 1); + vec2.pop_back(); + boost::phoenix::sort_heap(arg1, std::greater<int>())(vec2); + int expected_result2[] = {5,4,3,2}; + BOOST_TEST(std::equal(vec2.begin(), vec2.end(), expected_result2)); + + return; + } + + void next_permutation_test() + { + using boost::phoenix::next_permutation; + using boost::phoenix::arg_names::arg1; + int array[] = {1,2}; + int expected_result[] = {2,1}; + int expected_result2[] = {1,2}; + + BOOST_TEST(next_permutation(arg1)(array)); + BOOST_TEST(std::equal(array, array + 2, expected_result)); + BOOST_TEST(!next_permutation(arg1)(array)); + BOOST_TEST(std::equal(array, array + 2, expected_result2)); + + std::reverse(array, array + 2); + BOOST_TEST(boost::phoenix::next_permutation(arg1, std::greater<int>())(array)); + BOOST_TEST(std::equal(array, array + 2, expected_result2)); + BOOST_TEST(!boost::phoenix::next_permutation(arg1, std::greater<int>())(array)); + BOOST_TEST(std::equal(array, array + 2, expected_result)); + return; + } + + void prev_permutation_test() + { + using boost::phoenix::prev_permutation; + using boost::phoenix::arg_names::arg1; + int array[] = {2,1}; + int expected_result[] = {1,2}; + int expected_result2[] = {2,1}; + + BOOST_TEST(prev_permutation(arg1)(array)); + BOOST_TEST(std::equal(array, array + 2, expected_result)); + BOOST_TEST(!prev_permutation(arg1)(array)); + BOOST_TEST(std::equal(array, array + 2, expected_result2)); + + std::reverse(array, array + 2); + BOOST_TEST(boost::phoenix::prev_permutation(arg1, std::greater<int>())(array)); + BOOST_TEST(std::equal(array, array + 2, expected_result2)); + BOOST_TEST(!boost::phoenix::prev_permutation(arg1, std::greater<int>())(array)); + BOOST_TEST(std::equal(array, array + 2, expected_result)); + return; + } + + void inner_product_test() + { + using boost::phoenix::inner_product; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int lhs[] = {1,2,3}; + int rhs[] = {4,5,6}; + BOOST_TEST(inner_product(arg1, arg2, 0) + (lhs, rhs) == 1*4 + 2*5 + 3*6); + BOOST_TEST(boost::phoenix::inner_product(arg1, arg2, 1, std::multiplies<int>(), std::minus<int>()) + (lhs, rhs) == (1 - 4) * (2 - 5) * (3 - 6)); + return; + } + + void partial_sum_test() + { + using boost::phoenix::partial_sum; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int array[] = {1,2,3}; + int output[3]; + BOOST_TEST(partial_sum(arg1, arg2)(array, output) == output + 3); + int expected_result[] = {1, 3, 6}; + BOOST_TEST(std::equal(output, output + 3, expected_result)); + + BOOST_TEST(boost::phoenix::partial_sum(arg1, arg2, std::multiplies<int>()) + (array, output) == output + 3); + int expected_result2[] = {1, 2, 6}; + BOOST_TEST(std::equal(output, output + 3, expected_result2)); + return; + } + + void adjacent_difference_test() + { + using boost::phoenix::adjacent_difference; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int array[] = {1,2,3}; + int output[3]; + BOOST_TEST(adjacent_difference(arg1, arg2)(array, output) == output + 3); + int expected_result[] = {1, 1, 1}; + BOOST_TEST(std::equal(output, output + 3, expected_result)); + BOOST_TEST(boost::phoenix::adjacent_difference(arg1, arg2, std::plus<int>()) + (array, output) == output + 3); + int expected_result2[] = {1, 3, 5}; + BOOST_TEST(std::equal(output, output + 3, expected_result2)); + return; + } + +} + +int main() +{ + heap_test(); + next_permutation_test(); + prev_permutation_test(); + inner_product_test(); + partial_sum_test(); + adjacent_difference_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/bind/bind_function_object_tests.cpp b/src/boost/libs/phoenix/test/bind/bind_function_object_tests.cpp new file mode 100644 index 00000000..7e2ee94a --- /dev/null +++ b/src/boost/libs/phoenix/test/bind/bind_function_object_tests.cpp @@ -0,0 +1,137 @@ +/*============================================================================= + 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 <iostream> +#include <cmath> +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/bind.hpp> + +namespace phoenix = boost::phoenix; +using std::cout; +using std::pow; + + struct test + { + typedef void result_type; + + void + operator()() const + { + cout << "Test lazy functions...\n"; + } + }; + + struct sqr + { + template <typename Sig> + struct result; + + template <typename This, typename Arg> + struct result<This(Arg&)> + { + typedef Arg type; + }; + + template <typename Arg> + Arg + operator()(Arg n) const + { + return n * n; + } + }; + + struct fact + { + template <typename Sig> + struct result; + + template <typename This, typename Arg> + struct result<This(Arg&)> + { + typedef Arg type; + }; + + template <typename Arg> + Arg + operator()(Arg n) const + { + return (n <= 0) ? 1 : n * (*this)(n-1); + } + }; + + struct power + { + template<typename Sig> + struct result; + + template<typename This, typename Arg1, typename Arg2> + struct result<This(Arg1&, Arg2&)> + { + typedef Arg1 type; + }; + + template <typename Arg1, typename Arg2> + Arg1 + operator()(Arg1 a, Arg2 b) const + { + return pow(a, b); + } + }; + + struct add + { + template <typename Sig> + struct result; + + template <typename This, typename Arg1, typename Arg2, typename Arg3, typename Arg4> + struct result<This(Arg1&, Arg2&, Arg3&, Arg4&)> + { + typedef Arg1 type; + }; + + template <typename Arg1, typename Arg2, typename Arg3, typename Arg4> + Arg1 + operator()(Arg1 a, Arg2 b, Arg3 c, Arg4 d) const + { + return a + b + c + d; + } + }; + +int +main() +{ + using phoenix::bind; + using phoenix::ref; + using phoenix::arg_names::_1; + using phoenix::arg_names::arg1; + using phoenix::arg_names::arg2; + + int i5 = 5; + double d5 = 5, d3 = 3; + + test()(); + BOOST_TEST(bind(sqr(), arg1)(i5) == (i5*i5)); + BOOST_TEST(bind(fact(), 4)() == 24); + BOOST_TEST(bind(fact(), arg1)(i5) == 120); + BOOST_TEST((int)bind(power(), arg1, arg2)(d5, d3) == (int)std::pow(d5, d3)); + BOOST_TEST((bind(sqr(), arg1) + 5)(i5) == ((i5*i5)+5)); + BOOST_TEST(bind(add(), arg1, arg1, arg1, arg1)(i5) == (5+5+5+5)); + + int const ic5 = 5; + // testing consts + BOOST_TEST(bind(sqr(), arg1)(ic5) == (ic5*ic5)); + + // From Steven Watanabe + sqr s; + int x = 2; + int result = bind(ref(s), _1)(x); + BOOST_TEST(result == 4); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/bind/bind_function_object_tests_phx2.cpp b/src/boost/libs/phoenix/test/bind/bind_function_object_tests_phx2.cpp new file mode 100644 index 00000000..45758055 --- /dev/null +++ b/src/boost/libs/phoenix/test/bind/bind_function_object_tests_phx2.cpp @@ -0,0 +1,112 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <cmath> +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/bind.hpp> + +using namespace boost::phoenix; +using namespace boost::phoenix::arg_names; +using namespace std; + + struct test + { + typedef void result_type; + void operator()() const + { + cout << "Test lazy functions...\n"; + } + }; + + struct sqr + { + template <typename Arg> + struct result + { + typedef Arg type; + }; + + template <typename Arg> + Arg operator()(Arg n) const + { + return n * n; + } + }; + + struct fact + { + template <typename Arg> + struct result + { + typedef Arg type; + }; + + template <typename Arg> + Arg operator()(Arg n) const + { + return (n <= 0) ? 1 : n * (*this)(n-1); + } + }; + + struct power + { + template <typename Arg1, typename Arg2> + struct result + { + typedef Arg1 type; + }; + + template <typename Arg1, typename Arg2> + Arg1 operator()(Arg1 a, Arg2 b) const + { + return pow(a, b); + } + }; + + struct add + { + template <typename Arg1, typename Arg2, typename Arg3, typename Arg4> + struct result + { + typedef Arg1 type; + }; + + template <typename Arg1, typename Arg2, typename Arg3, typename Arg4> + Arg1 operator()(Arg1 a, Arg2 b, Arg3 c, Arg4 d) const + { + return a + b + c + d; + } + }; + +int +main() +{ + int i5 = 5; + double d5 = 5, d3 = 3; + + test()(); + BOOST_TEST(bind(sqr(), arg1)(i5) == (i5*i5)); + BOOST_TEST(bind(fact(), 4)() == 24); + BOOST_TEST(bind(fact(), arg1)(i5) == 120); + BOOST_TEST((int)bind(power(), arg1, arg2)(d5, d3) == (int)pow(d5, d3)); + BOOST_TEST((bind(sqr(), arg1) + 5)(i5) == ((i5*i5)+5)); + BOOST_TEST(bind(add(), arg1, arg1, arg1, arg1)(i5) == (5+5+5+5)); + + int const ic5 = 5; + // testing consts + BOOST_TEST(bind(sqr(), arg1)(ic5) == (ic5*ic5)); + + // From Steven Watanabe + sqr s; + int x = 2; + int result = bind(ref(s), _1)(x); + BOOST_TEST(result == 4); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/bind/bind_function_tests.cpp b/src/boost/libs/phoenix/test/bind/bind_function_tests.cpp new file mode 100644 index 00000000..04328b60 --- /dev/null +++ b/src/boost/libs/phoenix/test/bind/bind_function_tests.cpp @@ -0,0 +1,56 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <cmath> +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +namespace test +{ + void + test() + { + std::cout << "Test binding functions...\n"; + } + + int + negate(int n) + { + return -n; + } + + int + plus(int a, int b) + { + return a + b; + } + + int + plus4(int a, int b, int c, int d) + { + return a + b + c + d; + } +} + +int +main() +{ + using boost::phoenix::bind; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + + int a = 123; + int b = 256; + + bind(test::test)(); + BOOST_TEST(bind(test::negate, arg1)(a) == -a); + BOOST_TEST(bind(test::plus, arg1, arg2)(a, b) == a+b); + BOOST_TEST(bind(test::plus4, arg1, arg2, 3, 4)(a, b) == a+b+3+4); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/bind/bind_member_function_tests.cpp b/src/boost/libs/phoenix/test/bind/bind_member_function_tests.cpp new file mode 100644 index 00000000..ee26f00f --- /dev/null +++ b/src/boost/libs/phoenix/test/bind/bind_member_function_tests.cpp @@ -0,0 +1,77 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <cmath> +#include <boost/detail/lightweight_test.hpp> +#include <boost/noncopyable.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/bind.hpp> + +namespace test +{ + struct x //: boost::noncopyable // test non-copyable (hold this by reference) + { + void + test() const + { + std::cout << "Test binding member functions...\n"; + } + }; + + struct y //: boost::noncopyable // test non-copyable (hold this by reference) + { + int + negate(int n) const + { + return -n; + } + }; + + struct z //: boost::noncopyable // test non-copyable (hold this by reference) + { + int + plus(int a, int b) const + { + return a + b; + } + }; + + struct zz //: boost::noncopyable // test non-copyable (hold this by reference) + { + int + plus3(int a, int b, int c) const + { + return a + b + c; + } + }; +} + +int +main() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + using boost::phoenix::arg_names::arg3; + + int a = 123; + int b = 256; + test::x x_; + test::y y_; + test::z z_; + test::zz zz_; + + bind(&test::x::test, x_)(); + BOOST_TEST(bind(&test::y::negate, y_, arg1)(a) == -a); + BOOST_TEST(bind(&test::z::plus, arg1, arg2, arg3)(z_, a, b) == a+b); + BOOST_TEST(bind(&test::zz::plus3, zz_, arg1, arg2, arg3)(a, b, a) == a+b+a); + BOOST_TEST(bind(&test::y::negate, &y_, 777)(a) == -777); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/bind/bind_member_variable_tests.cpp b/src/boost/libs/phoenix/test/bind/bind_member_variable_tests.cpp new file mode 100644 index 00000000..9c525544 --- /dev/null +++ b/src/boost/libs/phoenix/test/bind/bind_member_variable_tests.cpp @@ -0,0 +1,111 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <cmath> +#include <boost/noncopyable.hpp> +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +namespace test +{ + struct x //: boost::noncopyable // test non-copyable (hold this by reference) + { + int m; + }; + + struct xx { + int m; + }; +} + +template <typename T, typename F> +void +write_test(F f) +{ + using boost::phoenix::arg_names::arg1; + using boost::phoenix::bind; + + T x_; + + bind(&T::m, f(x_))() = 122; + BOOST_TEST(x_.m == 122); + bind(&T::m, arg1)(f(x_)) = 123; + BOOST_TEST(x_.m == 123); +} + +template <typename T, typename F> +void +read_test(F f) +{ + using boost::phoenix::arg_names::arg1; + using boost::phoenix::bind; + + T x_; + x_.m = 123; + + BOOST_TEST(bind(&T::m, f(x_))() == 123); + BOOST_TEST(bind(&T::m, arg1)(f(x_)) == 123); +} + +struct identity +{ + template <typename T> + T& + operator()(T& t) const + { + return t; + } +}; + +struct constify +{ + template <typename T> + T const& + operator()(T const& t) const + { + return t; + } +}; + +struct add_pointer +{ + template <typename T> + T* /*const*/ + operator()(T& t) const + { + return &t; + } +}; + +struct add_const_pointer +{ + template <typename T> + const T* /*const*/ + operator()(T const& t) const + { + return &t; + } +}; + +int +main() +{ + write_test<test::x>(add_pointer()); + write_test<test::xx>(add_pointer()); + + read_test<test::x>(identity()); + read_test<test::x>(constify()); + read_test<test::x>(add_pointer()); + read_test<test::x>(add_const_pointer()); + read_test<test::xx>(identity()); + read_test<test::xx>(constify()); + read_test<test::xx>(add_pointer()); + read_test<test::xx>(add_const_pointer()); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/bind/bug5782.cpp b/src/boost/libs/phoenix/test/bind/bug5782.cpp new file mode 100644 index 00000000..37b38c97 --- /dev/null +++ b/src/boost/libs/phoenix/test/bind/bug5782.cpp @@ -0,0 +1,23 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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/bind/bind_function.hpp> +#include <boost/phoenix/core/argument.hpp> + +#include <iostream> + +using namespace boost::phoenix; +using namespace boost::phoenix::placeholders; + +void foo(int n) +{ + std::cout << n << std::endl; +} + +int main() +{ + bind(&foo, arg1)(4); +} diff --git a/src/boost/libs/phoenix/test/bll_compatibility/algorithm_test.cpp b/src/boost/libs/phoenix/test/bll_compatibility/algorithm_test.cpp new file mode 100644 index 00000000..ae8f77a3 --- /dev/null +++ b/src/boost/libs/phoenix/test/bll_compatibility/algorithm_test.cpp @@ -0,0 +1,84 @@ +// bll_and_function.cpp - The Boost Lambda Library ----------------------- +// +// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) +// +// 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) +// +// For more information, see www.boost.org + +// test using BLL and boost::function + +#include <boost/test/minimal.hpp> // see "Header Implementation Option" + +/* +#include "boost/lambda/lambda.hpp" +#include "boost/lambda/bind.hpp" +#include "boost/lambda/algorithm.hpp" +*/ +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> +#include <boost/phoenix/stl/algorithm/iteration.hpp> + +#include <vector> +#include <map> +#include <set> +#include <string> + +#include <iostream> + +namespace phoenix = boost::phoenix; + +void test_foreach() { + + using phoenix::placeholders::_1; + using phoenix::ref; + using phoenix::lambda; + + int a[10][20]; + int sum = 0; + + //for_each(arg1, for_each_tester())(array).value_; + + // Was: + // std::for_each(a, a + 10, + // bind(ll::for_each(), _1, _1 + 20, + // protect((_1 = var(sum), ++var(sum))))); + // var replaced with ref, protect(..) replaced with lambda[..], no need for bind + // phoenix algorithms are range based + std::for_each(a, a + 10, + phoenix::for_each(_1, lambda[_1 = ref(sum), ++ref(sum)])); + /*phoenix::bind(phoenix::for_each, _1, + lambda[_1 = ref(sum), ++ref(sum)]));*/ + + sum = 0; + // Was: + // std::for_each(a, a + 10, + // bind(ll::for_each(), _1, _1 + 20, + // protect((sum += _1)))); + // + std::for_each(a, a + 10, + phoenix::for_each( _1, + lambda[(ref(sum) += _1)])); + + BOOST_CHECK(sum == (199 + 1)/ 2 * 199); +} + +// More tests needed (for all algorithms) + +int test_main(int, char *[]) { + + test_foreach(); + + return 0; +} + + + + + + diff --git a/src/boost/libs/phoenix/test/bll_compatibility/bind_tests_advanced.cpp b/src/boost/libs/phoenix/test/bll_compatibility/bind_tests_advanced.cpp new file mode 100644 index 00000000..954de72e --- /dev/null +++ b/src/boost/libs/phoenix/test/bll_compatibility/bind_tests_advanced.cpp @@ -0,0 +1,433 @@ +// bind_tests_advanced.cpp -- The Boost Lambda Library ------------------ +// +// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) +// Copyright (C) 2010 Steven Watanabe +// +// 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) +// +// For more information, see www.boost.org + +// ----------------------------------------------------------------------- + + +#include <boost/test/minimal.hpp> // see "Header Implementation Option" + +/* +#include "boost/lambda/lambda.hpp" +#include "boost/lambda/bind.hpp" +*/ +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + +#include "boost/any.hpp" +#include "boost/type_traits/is_reference.hpp" +#include "boost/mpl/assert.hpp" +#include "boost/mpl/if.hpp" + +#include <iostream> + +#include <functional> + +#include <algorithm> + +namespace phoenix = boost::phoenix; + +int sum_0() { return 0; } +int sum_1(int a) { return a; } +int sum_2(int a, int b) { return a+b; } + +int product_2(int a, int b) { return a*b; } + +// unary function that returns a pointer to a binary function +typedef int (*fptr_type)(int, int); +fptr_type sum_or_product(bool x) { + return x ? sum_2 : product_2; +} + +// a nullary functor that returns a pointer to a unary function that +// returns a pointer to a binary function. +struct which_one { + typedef fptr_type (*result_type)(bool x); + + // Was: + // template <class T> struct sig { typedef result_type type; }; + // phoenix follows the standard result_of protocol + + result_type operator()() const { return sum_or_product; } +}; + +void test_nested_binds() +{ + using phoenix::bind; + using phoenix::placeholders::_1; + using phoenix::placeholders::_2; + using phoenix::placeholders::_3; + int j = 2; int k = 3; + +// bind calls can be nested (the target function can be a lambda functor) +// The interpretation is, that the innermost lambda functor returns something +// that is bindable (another lambda functor, function pointer ...) + bool condition; + + condition = true; + BOOST_CHECK(bind(bind(&sum_or_product, _1), 1, 2)(condition)==3); + BOOST_CHECK(bind(bind(&sum_or_product, _1), _2, _3)(condition, j, k)==5); + + condition = false; + BOOST_CHECK(bind(bind(&sum_or_product, _1), 1, 2)(condition)==2); + BOOST_CHECK(bind(bind(&sum_or_product, _1), _2, _3)(condition, j, k)==6); + + + which_one wo; + BOOST_CHECK(bind(bind(bind(wo), _1), _2, _3)(condition, j, k)==6); + + + return; +} + + +// unlambda ------------------------------------------------- + + // Sometimes it may be necessary to prevent the argument substitution of + // taking place. For example, we may end up with a nested bind expression + // inadvertently when using the target function is received as a parameter + +template<class F> +int call_with_100(const F& f) { + + + + // bind(f, _1)(make_const(100)); + // This would result in; + // bind(_1 + 1, _1)(make_const(100)) , which would be a compile time error + + //return bl::bind(unlambda(f), _1)(make_const(100)); + return 5; + + // for other functors than lambda functors, unlambda has no effect + // (except for making them const) +} + +template<class F> +int call_with_101(const F& f) { + + //return bind(unlambda(f), _1)(make_const(101)); + return 5; + +} + + +void test_unlambda() { + + using phoenix::placeholders::_1; + using phoenix::placeholders::_2; + + int i = 1; + + //BOOST_CHECK(unlambda(_1 + _2)(i, i) == 2); + //BOOST_CHECK(unlambda(++var(i))() == 2); + //BOOST_CHECK(call_with_100(_1 + 1) == 101); + + + //BOOST_CHECK(call_with_101(_1 + 1) == 102); + + //BOOST_CHECK(call_with_100(bl::bind(std_functor(std::bind1st(std::plus<int>(), 1)), _1)) == 101); + + // Was: + // std_functor insturcts LL that the functor defines a result_type typedef + // rather than a sig template. + //bl::bind(std_functor(std::plus<int>()), _1, _2)(i, i); + // Standard functors can be used without any further action needed. + phoenix::bind(std::plus<int>(), _1, _2)(i, i); +} + + + + +// protect ------------------------------------------------------------ + +// protect protects a lambda functor from argument substitution. +// protect is useful e.g. with nested stl algorithm calls. + +#if 0 +namespace ll { + +struct for_each { + + // Was: + // note, std::for_each returns it's last argument + // We want the same behaviour from our ll::for_each. + // However, the functor can be called with any arguments, and + // the return type thus depends on the argument types. + + // 1. Provide a sig class member template: + + // The return type deduction system instantiate this class as: + // sig<Args>::type, where Args is a boost::tuples::cons-list + // The head type is the function object type itself + // cv-qualified (so it is possilbe to provide different return types + // for differently cv-qualified operator()'s. + + // The tail type is the list of the types of the actual arguments the + // function was called with. + // So sig should contain a typedef type, which defines a mapping from + // the operator() arguments to its return type. + // Note, that it is possible to provide different sigs for the same functor + // if the functor has several operator()'s, even if they have different + // number of arguments. + + // Note, that the argument types in Args are guaranteed to be non-reference + // types, but they can have cv-qualifiers. + + // template <class Args> + //struct sig { + // typedef typename boost::remove_const< + // typename boost::tuples::element<3, Args>::type + // >::type type; + //}; + + // We follow the result_of protocol ... + template <typename Sig> + struct result; + + template <typename This, typename A, typename B, typename C> + struct result<This(A&,B&,C&)> + {typedef C type;}; + + template <class A, class B, class C> + C + operator()(const A& a, const B& b, const C& c) const + { return std::for_each(a, b, c);} +}; + +} // end of ll namespace +#endif + +void test_protect() +{ + using phoenix::placeholders::_1; + int i = 0; + int b[3][5]; + int* a[3]; + + for(int j=0; j<3; ++j) a[j] = b[j]; + + // Was: + //std::for_each(a, a+3, + // bind(ll::for_each(), _1, _1 + 5, protect(_1 = ++var(i)))); +#if 0 + std::for_each(a, a+3, + phoenix::bind(ll::for_each(), _1, _1 + 5, phoenix::lambda[_1 = ++phoenix::ref(i)])); +#endif + + + // This is how you could output the values (it is uncommented, no output + // from a regression test file): + // std::for_each(a, a+3, + // bind(ll::for_each(), _1, _1 + 5, + // std::cout << constant("\nLine ") << (&_1 - a) << " : " + // << protect(_1) + // ) + // ); + + int sum = 0; + + // Was: + //std::for_each(a, a+3, + // bind(ll::for_each(), _1, _1 + 5, + // protect(sum += _1)) + // ); +#if 0 + std::for_each(a, a+3, + phoenix::bind(ll::for_each(), _1, _1 + 5, + phoenix::lambda[phoenix::ref(sum) += _1]) + ); + BOOST_CHECK(sum == (1+15)*15/2); +#endif + + sum = 0; + + // Was: + //std::for_each(a, a+3, + // bind(ll::for_each(), _1, _1 + 5, + // sum += 1 + protect(_1)) // add element count + // ); +#if 0 + std::for_each(a, a+3, + phoenix::bind(ll::for_each(), _1, _1 + 5, + phoenix::ref(sum) += 1 + phoenix::lambda[_1]) // add element count + ); + BOOST_CHECK(sum == (1+15)*15/2 + 15); +#endif + + // Was: + //(1 + protect(_1))(sum); + (1 + phoenix::lambda[_1])(sum); + + int k = 0; + // Was: + //((k += constant(1)) += protect(constant(2)))(); + ((phoenix::ref(k) += 1) += phoenix::lambda[phoenix::cref(2)])(); + BOOST_CHECK(k==1); + + k = 0; + // Was: + //((k += constant(1)) += protect(constant(2)))()(); + //((phoenix::ref(k) += 1) += phoenix::lambda[std::cout << phoenix::cref("ok ...\n"), phoenix::cref(2)])()(); + //std::cout << ((phoenix::ref(k) += 1) + phoenix::lambda[phoenix::cref(2)])()() << "\n"; + ((phoenix::ref(k) += 1) += 2)(); + std::cout << k << "\n"; + BOOST_CHECK(k==3); + + // note, the following doesn't work: + + // ((var(k) = constant(1)) = protect(constant(2)))(); + + // (var(k) = constant(1))() returns int& and thus the + // second assignment fails. + + // We should have something like: + // bind(var, var(k) = constant(1)) = protect(constant(2)))(); + // But currently var is not bindable. + + // The same goes with ret. A bindable ret could be handy sometimes as well + // (protect(std::cout << _1), std::cout << _1)(i)(j); does not work + // because the comma operator tries to store the result of the evaluation + // of std::cout << _1 as a copy (and you can't copy std::ostream). + // something like this: + // (protect(std::cout << _1), bind(ref, std::cout << _1))(i)(j); + + + // the stuff below works, but we do not want extra output to + // cout, must be changed to stringstreams but stringstreams do not + // work due to a bug in the type deduction. Will be fixed... +#if 0 + // But for now, ref is not bindable. There are other ways around this: + + int x = 1, y = 2; + (protect(std::cout << _1), (std::cout << _1, 0))(x)(y); + + // added one dummy value to make the argument to comma an int + // instead of ostream& + + // Note, the same problem is more apparent without protect + // (std::cout << 1, std::cout << constant(2))(); // does not work + + (boost::ref(std::cout << 1), std::cout << constant(2))(); // this does + +#endif + +} + + +void test_lambda_functors_as_arguments_to_lambda_functors() { + using phoenix::bind; + using phoenix::cref; + using phoenix::placeholders::_1; + using phoenix::placeholders::_2; + using phoenix::placeholders::_3; + +// lambda functor is a function object, and can therefore be used +// as an argument to another lambda functors function call object. + + // Note however, that the argument/type substitution is not entered again. + // This means, that something like this will not work: + + (_1 + _2)(_1, cref(7)); + (_1 + _2)(bind(&sum_0), cref(7)); + + // or it does work, but the effect is not to call + // sum_0() + 7, but rather + // bind(sum_0) + 7, which results in another lambda functor + // (lambda functor + int) and can be called again + BOOST_CHECK((_1 + _2)(bind(&sum_0), cref(7))() == 7); + + int i = 3, j = 12; + BOOST_CHECK((_1 - _2)(_2, _1)(i, j) == j - i); + + // also, note that lambda functor are no special case for bind if received + // as a parameter. In oder to be bindable, the functor must + // defint the sig template, or then + // the return type must be defined within the bind call. Lambda functors + // do define the sig template, so if the return type deduction system + // covers the case, there is no need to specify the return type + // explicitly. + + int a = 5, b = 6; + + // Let type deduction find out the return type + //BOOST_CHECK(bind(_1, _2, _3)(unlambda(_1 + _2), a, b) == 11); + + //specify it yourself: + BOOST_CHECK(bind(_1, _2, _3)(_1 + _2, a, b) == 11); + + bind(_1,1.0)(_1+_1); + return; + +} +/* +template<class T> +struct func { + template<class Args> + struct sig { + typedef typename boost::tuples::element<1, Args>::type arg1; + // If the argument type is not the same as the expected type, + // return void, which will cause an error. Note that we + // can't just assert that the types are the same, because + // both const and non-const versions can be instantiated + // even though only one is ultimately used. + typedef typename boost::mpl::if_<boost::is_same<arg1, T>, + typename boost::remove_const<arg1>::type, + void + >::type type; + }; + template<class U> + U operator()(const U& arg) const { + return arg; + } +}; + +void test_sig() +{ + int i = 1; + BOOST_CHECK(bind(func<int>(), 1)() == 1); + BOOST_CHECK(bind(func<const int>(), _1)(static_cast<const int&>(i)) == 1); + BOOST_CHECK(bind(func<int>(), _1)(i) == 1); +} + +class base { +public: + virtual int foo() = 0; +}; + +class derived : public base { +public: + virtual int foo() { + return 1; + } +}; + +void test_abstract() +{ + derived d; + base& b = d; + BOOST_CHECK(bind(&base::foo, var(b))() == 1); + BOOST_CHECK(bind(&base::foo, *_1)(&b) == 1); +} +*/ + +int test_main(int, char *[]) { + + test_nested_binds(); + test_unlambda(); + test_protect(); + test_lambda_functors_as_arguments_to_lambda_functors(); + //test_sig(); + //test_abstract(); + return 0; +} diff --git a/src/boost/libs/phoenix/test/bll_compatibility/bind_tests_simple.cpp b/src/boost/libs/phoenix/test/bll_compatibility/bind_tests_simple.cpp new file mode 100644 index 00000000..d9a05fa5 --- /dev/null +++ b/src/boost/libs/phoenix/test/bll_compatibility/bind_tests_simple.cpp @@ -0,0 +1,170 @@ +// bind_tests_simple.cpp -- The Boost Lambda Library ------------------ +// +// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) +// +// 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) +// +// For more information, see www.boost.org + +// ----------------------------------------------------------------------- + + +#include <boost/test/minimal.hpp> // see "Header Implementation Option" + +#include "boost/lambda/bind.hpp" + +#include <iostream> + +using namespace boost::lambda; + + +int sum_of_args_0() { return 0; } +int sum_of_args_1(int a) { return a; } +int sum_of_args_2(int a, int b) { return a+b; } +int sum_of_args_3(int a, int b, int c) { return a+b+c; } +int sum_of_args_4(int a, int b, int c, int d) { return a+b+c+d; } +int sum_of_args_5(int a, int b, int c, int d, int e) { return a+b+c+d+e; } +int sum_of_args_6(int a, int b, int c, int d, int e, int f) { return a+b+c+d+e+f; } +int sum_of_args_7(int a, int b, int c, int d, int e, int f, int g) { return a+b+c+d+e+f+g; } +int sum_of_args_8(int a, int b, int c, int d, int e, int f, int g, int h) { return a+b+c+d+e+f+g+h; } +int sum_of_args_9(int a, int b, int c, int d, int e, int f, int g, int h, int i) { return a+b+c+d+e+f+g+h+i; } + + +// ---------------------------- + +class A { + int i; +public: + A(int n) : i(n) {}; + int add(const int& j) { return i + j; } + int add2(int a1, int a2) { return i + a1 + a2; } + int add3(int a1, int a2, int a3) { return i + a1 + a2 + a3; } + int add4(int a1, int a2, int a3, int a4) { return i + a1 + a2 + a3 + a4; } + int add5(int a1, int a2, int a3, int a4, int a5) + { return i + a1 + a2 + a3 + a4 + a5; } + int add6(int a1, int a2, int a3, int a4, int a5, int a6) + { return i + a1 + a2 + a3 + a4 + a5 + a6; } + int add7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + { return i + a1 + a2 + a3 + a4 + a5 + a6 + a7; } + int add8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + { return i + a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8; } + +}; + +void test_member_functions() +{ + using boost::ref; + A a(10); + int i = 1; + + + + + BOOST_CHECK(bind(&A::add, ref(a), _1)(i) == 11); + BOOST_CHECK(bind(&A::add, &a, _1)(i) == 11); + BOOST_CHECK(bind(&A::add, _1, 1)(a) == 11); + BOOST_CHECK(bind(&A::add, _1, 1)(make_const(&a)) == 11); + + BOOST_CHECK(bind(&A::add2, _1, 1, 1)(a) == 12); + BOOST_CHECK(bind(&A::add3, _1, 1, 1, 1)(a) == 13); + BOOST_CHECK(bind(&A::add4, _1, 1, 1, 1, 1)(a) == 14); + BOOST_CHECK(bind(&A::add5, _1, 1, 1, 1, 1, 1)(a) == 15); + BOOST_CHECK(bind(&A::add6, _1, 1, 1, 1, 1, 1, 1)(a) == 16); + BOOST_CHECK(bind(&A::add7, _1, 1, 1, 1, 1, 1, 1, 1)(a) == 17); + BOOST_CHECK(bind(&A::add8, _1, 1, 1, 1, 1, 1, 1, 1, 1)(a) == 18); + + // This should fail, as lambda functors store arguments as const + // bind(&A::add, a, _1); +} + +int test_main(int, char *[]) { + + int i = 1; int j = 2; int k = 3; + int result; + + // bind all parameters + BOOST_CHECK(bind(&sum_of_args_0)()==0); + BOOST_CHECK(bind(&sum_of_args_1, 1)()==1); + BOOST_CHECK(bind(&sum_of_args_2, 1, 2)()==3); + BOOST_CHECK(bind(&sum_of_args_3, 1, 2, 3)()==6); + BOOST_CHECK(bind(&sum_of_args_4, 1, 2, 3, 4)()==10); + BOOST_CHECK(bind(&sum_of_args_5, 1, 2, 3, 4, 5)()==15); + BOOST_CHECK(bind(&sum_of_args_6, 1, 2, 3, 4, 5, 6)()==21); + BOOST_CHECK(bind(&sum_of_args_7, 1, 2, 3, 4, 5, 6, 7)()==28); + BOOST_CHECK(bind(&sum_of_args_8, 1, 2, 3, 4, 5, 6, 7, 8)()==36); + BOOST_CHECK(bind(&sum_of_args_9, 1, 2, 3, 4, 5, 6, 7, 8, 9)()==45); + + // first parameter open + BOOST_CHECK(bind(&sum_of_args_0)()==0); + BOOST_CHECK(bind(&sum_of_args_1, _1)(i)==1); + BOOST_CHECK(bind(&sum_of_args_2, _1, 2)(i)==3); + BOOST_CHECK(bind(&sum_of_args_3, _1, 2, 3)(i)==6); + BOOST_CHECK(bind(&sum_of_args_4, _1, 2, 3, 4)(i)==10); + BOOST_CHECK(bind(&sum_of_args_5, _1, 2, 3, 4, 5)(i)==15); + BOOST_CHECK(bind(&sum_of_args_6, _1, 2, 3, 4, 5, 6)(i)==21); + BOOST_CHECK(bind(&sum_of_args_7, _1, 2, 3, 4, 5, 6, 7)(i)==28); + BOOST_CHECK(bind(&sum_of_args_8, _1, 2, 3, 4, 5, 6, 7, 8)(i)==36); + BOOST_CHECK(bind(&sum_of_args_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i)==45); + + // two open arguments + BOOST_CHECK(bind(&sum_of_args_0)()==0); + BOOST_CHECK(bind(&sum_of_args_1, _1)(i)==1); + BOOST_CHECK(bind(&sum_of_args_2, _1, _2)(i, j)==3); + BOOST_CHECK(bind(&sum_of_args_3, _1, _2, 3)(i, j)==6); + BOOST_CHECK(bind(&sum_of_args_4, _1, _2, 3, 4)(i, j)==10); + BOOST_CHECK(bind(&sum_of_args_5, _1, _2, 3, 4, 5)(i, j)==15); + BOOST_CHECK(bind(&sum_of_args_6, _1, _2, 3, 4, 5, 6)(i, j)==21); + BOOST_CHECK(bind(&sum_of_args_7, _1, _2, 3, 4, 5, 6, 7)(i, j)==28); + BOOST_CHECK(bind(&sum_of_args_8, _1, _2, 3, 4, 5, 6, 7, 8)(i, j)==36); + BOOST_CHECK(bind(&sum_of_args_9, _1, _2, 3, 4, 5, 6, 7, 8, 9)(i, j)==45); + + // three open arguments + BOOST_CHECK(bind(&sum_of_args_0)()==0); + BOOST_CHECK(bind(&sum_of_args_1, _1)(i)==1); + BOOST_CHECK(bind(&sum_of_args_2, _1, _2)(i, j)==3); + BOOST_CHECK(bind(&sum_of_args_3, _1, _2, _3)(i, j, k)==6); + BOOST_CHECK(bind(&sum_of_args_4, _1, _2, _3, 4)(i, j, k)==10); + BOOST_CHECK(bind(&sum_of_args_5, _1, _2, _3, 4, 5)(i, j, k)==15); + BOOST_CHECK(bind(&sum_of_args_6, _1, _2, _3, 4, 5, 6)(i, j, k)==21); + BOOST_CHECK(bind(&sum_of_args_7, _1, _2, _3, 4, 5, 6, 7)(i, j, k)==28); + BOOST_CHECK(bind(&sum_of_args_8, _1, _2, _3, 4, 5, 6, 7, 8)(i, j, k)==36); + BOOST_CHECK(bind(&sum_of_args_9, _1, _2, _3, 4, 5, 6, 7, 8, 9)(i, j, k)==45); + + // function compositions with bind + BOOST_CHECK(bind(&sum_of_args_3, bind(&sum_of_args_2, _1, 2), 2, 3)(i)==8); + BOOST_CHECK( + bind(&sum_of_args_9, + bind(&sum_of_args_0), // 0 + bind(&sum_of_args_1, _1), // 1 + bind(&sum_of_args_2, _1, _2), // 3 + bind(&sum_of_args_3, _1, _2, _3), // 6 + bind(&sum_of_args_4, _1, _2, _3, 4), // 10 + bind(&sum_of_args_5, _1, _2, _3, 4, 5), // 15 + bind(&sum_of_args_6, _1, _2, _3, 4, 5, 6), // 21 + bind(&sum_of_args_7, _1, _2, _3, 4, 5, 6, 7), // 28 + bind(&sum_of_args_8, _1, _2, _3, 4, 5, 6, 7, 8) // 36 + )(i, j, k) == 120); + + // deeper nesting + result = + bind(&sum_of_args_1, // 12 + bind(&sum_of_args_4, // 12 + bind(&sum_of_args_2, // 3 + bind(&sum_of_args_1, // 1 + bind(&sum_of_args_1, _1) // 1 + ), + _2), + _2, + _3, + 4) + )(i, j, k); + BOOST_CHECK(result == 12); + + test_member_functions(); + + + return 0; +} diff --git a/src/boost/libs/phoenix/test/bll_compatibility/bind_tests_simple_f_refs.cpp b/src/boost/libs/phoenix/test/bll_compatibility/bind_tests_simple_f_refs.cpp new file mode 100644 index 00000000..df601d79 --- /dev/null +++ b/src/boost/libs/phoenix/test/bll_compatibility/bind_tests_simple_f_refs.cpp @@ -0,0 +1,148 @@ +// bind_tests_simple.cpp -- The Boost Lambda Library ------------------ +// +// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) +// +// 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) +// +// For more information, see www.boost.org + +// ----------------------------------------------------------------------- + + +#include <boost/test/minimal.hpp> // see "Header Implementation Option" + +#include "boost/lambda/bind.hpp" + +#include <iostream> + +using namespace boost::lambda; + + +int sum_of_args_0() { return 0; } +int sum_of_args_1(int a) { return a; } +int sum_of_args_2(int a, int b) { return a+b; } +int sum_of_args_3(int a, int b, int c) { return a+b+c; } +int sum_of_args_4(int a, int b, int c, int d) { return a+b+c+d; } +int sum_of_args_5(int a, int b, int c, int d, int e) { return a+b+c+d+e; } +int sum_of_args_6(int a, int b, int c, int d, int e, int f) { return a+b+c+d+e+f; } +int sum_of_args_7(int a, int b, int c, int d, int e, int f, int g) { return a+b+c+d+e+f+g; } +int sum_of_args_8(int a, int b, int c, int d, int e, int f, int g, int h) { return a+b+c+d+e+f+g+h; } +int sum_of_args_9(int a, int b, int c, int d, int e, int f, int g, int h, int i) { return a+b+c+d+e+f+g+h+i; } + + +// ---------------------------- + +class A { + int i; +public: + A(int n) : i(n) {}; + int add(const int& j) { return i + j; } +}; + +void test_member_functions() +{ + using boost::ref; + A a(10); + int i = 1; + + BOOST_CHECK(bind(&A::add, ref(a), _1)(i) == 11); + BOOST_CHECK(bind(&A::add, &a, _1)(i) == 11); + BOOST_CHECK(bind(&A::add, _1, 1)(a) == 11); + BOOST_CHECK(bind(&A::add, _1, 1)(make_const(&a)) == 11); + + // This should fail, as lambda functors store arguments as const + // bind(&A::add, a, _1); +} + +int test_main(int, char *[]) { + + int i = 1; int j = 2; int k = 3; + int result; + + + // bind all parameters + BOOST_CHECK(bind(sum_of_args_0)()==0); + BOOST_CHECK(bind(sum_of_args_1, 1)()==1); + BOOST_CHECK(bind(sum_of_args_2, 1, 2)()==3); + BOOST_CHECK(bind(sum_of_args_3, 1, 2, 3)()==6); + BOOST_CHECK(bind(sum_of_args_4, 1, 2, 3, 4)()==10); + BOOST_CHECK(bind(sum_of_args_5, 1, 2, 3, 4, 5)()==15); + BOOST_CHECK(bind(sum_of_args_6, 1, 2, 3, 4, 5, 6)()==21); + BOOST_CHECK(bind(sum_of_args_7, 1, 2, 3, 4, 5, 6, 7)()==28); + BOOST_CHECK(bind(sum_of_args_8, 1, 2, 3, 4, 5, 6, 7, 8)()==36); + BOOST_CHECK(bind(sum_of_args_9, 1, 2, 3, 4, 5, 6, 7, 8, 9)()==45); + + // first parameter open + BOOST_CHECK(bind(sum_of_args_0)()==0); + BOOST_CHECK(bind(sum_of_args_1, _1)(i)==1); + BOOST_CHECK(bind(sum_of_args_2, _1, 2)(i)==3); + BOOST_CHECK(bind(sum_of_args_3, _1, 2, 3)(i)==6); + BOOST_CHECK(bind(sum_of_args_4, _1, 2, 3, 4)(i)==10); + BOOST_CHECK(bind(sum_of_args_5, _1, 2, 3, 4, 5)(i)==15); + BOOST_CHECK(bind(sum_of_args_6, _1, 2, 3, 4, 5, 6)(i)==21); + BOOST_CHECK(bind(sum_of_args_7, _1, 2, 3, 4, 5, 6, 7)(i)==28); + BOOST_CHECK(bind(sum_of_args_8, _1, 2, 3, 4, 5, 6, 7, 8)(i)==36); + BOOST_CHECK(bind(sum_of_args_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i)==45); + + // two open arguments + BOOST_CHECK(bind(sum_of_args_0)()==0); + BOOST_CHECK(bind(sum_of_args_1, _1)(i)==1); + BOOST_CHECK(bind(sum_of_args_2, _1, _2)(i, j)==3); + BOOST_CHECK(bind(sum_of_args_3, _1, _2, 3)(i, j)==6); + BOOST_CHECK(bind(sum_of_args_4, _1, _2, 3, 4)(i, j)==10); + BOOST_CHECK(bind(sum_of_args_5, _1, _2, 3, 4, 5)(i, j)==15); + BOOST_CHECK(bind(sum_of_args_6, _1, _2, 3, 4, 5, 6)(i, j)==21); + BOOST_CHECK(bind(sum_of_args_7, _1, _2, 3, 4, 5, 6, 7)(i, j)==28); + BOOST_CHECK(bind(sum_of_args_8, _1, _2, 3, 4, 5, 6, 7, 8)(i, j)==36); + BOOST_CHECK(bind(sum_of_args_9, _1, _2, 3, 4, 5, 6, 7, 8, 9)(i, j)==45); + + // three open arguments + BOOST_CHECK(bind(sum_of_args_0)()==0); + BOOST_CHECK(bind(sum_of_args_1, _1)(i)==1); + BOOST_CHECK(bind(sum_of_args_2, _1, _2)(i, j)==3); + BOOST_CHECK(bind(sum_of_args_3, _1, _2, _3)(i, j, k)==6); + BOOST_CHECK(bind(sum_of_args_4, _1, _2, _3, 4)(i, j, k)==10); + BOOST_CHECK(bind(sum_of_args_5, _1, _2, _3, 4, 5)(i, j, k)==15); + BOOST_CHECK(bind(sum_of_args_6, _1, _2, _3, 4, 5, 6)(i, j, k)==21); + BOOST_CHECK(bind(sum_of_args_7, _1, _2, _3, 4, 5, 6, 7)(i, j, k)==28); + BOOST_CHECK(bind(sum_of_args_8, _1, _2, _3, 4, 5, 6, 7, 8)(i, j, k)==36); + BOOST_CHECK(bind(sum_of_args_9, _1, _2, _3, 4, 5, 6, 7, 8, 9)(i, j, k)==45); + + // function compositions with bind + BOOST_CHECK(bind(sum_of_args_3, bind(sum_of_args_2, _1, 2), 2, 3)(i)==8); + BOOST_CHECK( + bind(sum_of_args_9, + bind(sum_of_args_0), // 0 + bind(sum_of_args_1, _1), // 1 + bind(sum_of_args_2, _1, _2), // 3 + bind(sum_of_args_3, _1, _2, _3), // 6 + bind(sum_of_args_4, _1, _2, _3, 4), // 10 + bind(sum_of_args_5, _1, _2, _3, 4, 5), // 15 + bind(sum_of_args_6, _1, _2, _3, 4, 5, 6), // 21 + bind(sum_of_args_7, _1, _2, _3, 4, 5, 6, 7), // 28 + bind(sum_of_args_8, _1, _2, _3, 4, 5, 6, 7, 8) // 36 + )(i, j, k) == 120); + + // deeper nesting + result = + bind(sum_of_args_1, // 12 + bind(sum_of_args_4, // 12 + bind(sum_of_args_2, // 3 + bind(sum_of_args_1, // 1 + bind(sum_of_args_1, _1) // 1 + ), + _2), + _2, + _3, + 4) + )(i, j, k); + BOOST_CHECK(result == 12); + + test_member_functions(); + + + return 0; +} diff --git a/src/boost/libs/phoenix/test/bll_compatibility/bll_and_function.cpp b/src/boost/libs/phoenix/test/bll_compatibility/bll_and_function.cpp new file mode 100644 index 00000000..03bcc3ec --- /dev/null +++ b/src/boost/libs/phoenix/test/bll_compatibility/bll_and_function.cpp @@ -0,0 +1,68 @@ +// bll_and_function.cpp - The Boost Lambda Library ----------------------- +// +// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) +// +// 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) +// +// For more information, see www.boost.org + +// test using BLL and boost::function + +#include <boost/test/minimal.hpp> // see "Header Implementation Option" + +#include "boost/lambda/lambda.hpp" + +#include "boost/function.hpp" + +#include <vector> +#include <map> +#include <set> +#include <string> + + +using namespace boost::lambda; + +using namespace std; + +void test_function() { + + boost::function<int (int, int)> f; + f = _1 + _2; + + BOOST_CHECK(f(1, 2)== 3); + + int i=1; int j=2; + boost::function<int& (int&, int)> g = _1 += _2; + g(i, j); + BOOST_CHECK(i==3); + + + + int* sum = new int(); + *sum = 0; + boost::function<int& (int)> counter = *sum += _1; + counter(5); // ok, sum* = 5; + BOOST_CHECK(*sum == 5); + delete sum; + + // The next statement would lead to a dangling reference + // counter(3); // error, *sum does not exist anymore + +} + + +int test_main(int, char *[]) { + + test_function(); + + return 0; +} + + + + + + diff --git a/src/boost/libs/phoenix/test/bll_compatibility/cast_test.cpp b/src/boost/libs/phoenix/test/bll_compatibility/cast_test.cpp new file mode 100644 index 00000000..eba4300a --- /dev/null +++ b/src/boost/libs/phoenix/test/bll_compatibility/cast_test.cpp @@ -0,0 +1,107 @@ +// cast_tests.cpp -- The Boost Lambda Library ------------------ +// +// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) +// +// 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) +// +// For more information, see www.boost.org + +// ----------------------------------------------------------------------- + + +#include <boost/test/minimal.hpp> // see "Header Implementation Option" + + +#include "boost/lambda/lambda.hpp" + +#include "boost/lambda/casts.hpp" + +#include <string> + +using namespace boost::lambda; +using namespace std; + +class base { + int x; +public: + virtual std::string class_name() const { return "const base"; } + virtual std::string class_name() { return "base"; } + virtual ~base() {} +}; + +class derived : public base { + int y[100]; +public: + virtual std::string class_name() const { return "const derived"; } + virtual std::string class_name() { return "derived"; } +}; + + + + +void do_test() { + + derived *p_derived = new derived; + base *p_base = new base; + + base *b = 0; + derived *d = 0; + + (var(b) = ll_static_cast<base *>(p_derived))(); + (var(d) = ll_static_cast<derived *>(b))(); + + BOOST_CHECK(b->class_name() == "derived"); + BOOST_CHECK(d->class_name() == "derived"); + + (var(b) = ll_dynamic_cast<derived *>(b))(); + BOOST_CHECK(b != 0); + BOOST_CHECK(b->class_name() == "derived"); + + (var(d) = ll_dynamic_cast<derived *>(p_base))(); + BOOST_CHECK(d == 0); + + + + const derived* p_const_derived = p_derived; + + BOOST_CHECK(p_const_derived->class_name() == "const derived"); + (var(d) = ll_const_cast<derived *>(p_const_derived))(); + BOOST_CHECK(d->class_name() == "derived"); + + int i = 10; + char* cp = reinterpret_cast<char*>(&i); + + int* ip; + (var(ip) = ll_reinterpret_cast<int *>(cp))(); + BOOST_CHECK(*ip == 10); + + + // typeid + + BOOST_CHECK(string(ll_typeid(d)().name()) == string(typeid(d).name())); + + + // sizeof + + BOOST_CHECK(ll_sizeof(_1)(p_derived) == sizeof(p_derived)); + BOOST_CHECK(ll_sizeof(_1)(*p_derived) == sizeof(*p_derived)); + BOOST_CHECK(ll_sizeof(_1)(p_base) == sizeof(p_base)); + BOOST_CHECK(ll_sizeof(_1)(*p_base) == sizeof(*p_base)); + + int an_array[100]; + BOOST_CHECK(ll_sizeof(_1)(an_array) == 100 * sizeof(int)); + + delete p_derived; + delete p_base; + + +} + +int test_main(int, char *[]) { + + do_test(); + return 0; +} diff --git a/src/boost/libs/phoenix/test/bll_compatibility/constructor_tests.cpp b/src/boost/libs/phoenix/test/bll_compatibility/constructor_tests.cpp new file mode 100644 index 00000000..8cef0cb4 --- /dev/null +++ b/src/boost/libs/phoenix/test/bll_compatibility/constructor_tests.cpp @@ -0,0 +1,265 @@ +// constructor_tests.cpp -- The Boost Lambda Library ------------------ +// +// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) +// +// 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) +// +// For more information, see www.boost.org + +// ----------------------------------------------------------------------- + + +#include <boost/test/minimal.hpp> // see "Header Implementation Option" + + +#include "boost/lambda/lambda.hpp" +#include "boost/lambda/bind.hpp" + +#include "boost/lambda/construct.hpp" + +#include <iostream> +#include <algorithm> +#include <vector> + +#ifdef BOOST_MSVC +#pragma warning(disable:4512) +#endif + +using namespace boost::lambda; +namespace bl = boost::lambda; + +template<class T> +bool check_tuple(int n, const T& t) +{ + return (t.get_head() == n) && check_tuple(n+1, t.get_tail()); +} + +template <> +bool check_tuple(int /*n*/, const null_type& ) { return true; } + + +void constructor_all_lengths() +{ + bool ok; + ok = check_tuple( + 1, + bind(constructor<tuple<int> >(), + 1)() + ); + BOOST_CHECK(ok); + + ok = check_tuple( + 1, + bind(constructor<tuple<int, int> >(), + 1, 2)() + ); + BOOST_CHECK(ok); + + ok = check_tuple( + 1, + bind(constructor<tuple<int, int, int> >(), + 1, 2, 3)() + ); + BOOST_CHECK(ok); + + ok = check_tuple( + 1, + bind(constructor<tuple<int, int, int, int> >(), + 1, 2, 3, 4)() + ); + BOOST_CHECK(ok); + + ok = check_tuple( + 1, + bind(constructor<tuple<int, int, int, int, int> >(), + 1, 2, 3, 4, 5)() + ); + BOOST_CHECK(ok); + + ok = check_tuple( + 1, + bind(constructor<tuple<int, int, int, int, int, int> >(), + 1, 2, 3, 4, 5, 6)() + ); + BOOST_CHECK(ok); + + ok = check_tuple( + 1, + bind(constructor<tuple<int, int, int, int, int, int, int> >(), + 1, 2, 3, 4, 5, 6, 7)() + ); + BOOST_CHECK(ok); + + ok = check_tuple( + 1, + bind(constructor<tuple<int, int, int, int, int, int, int, int> >(), + 1, 2, 3, 4, 5, 6, 7, 8)() + ); + BOOST_CHECK(ok); + + ok = check_tuple( + 1, + bind(constructor<tuple<int, int, int, int, int, int, int, int, int> >(), + 1, 2, 3, 4, 5, 6, 7, 8, 9)() + ); + BOOST_CHECK(ok); + +} + +void new_ptr_all_lengths() +{ + bool ok; + ok = check_tuple( + 1, + *(bind(new_ptr<tuple<int> >(), + 1))() + ); + BOOST_CHECK(ok); + + ok = check_tuple( + 1, + *(bind(new_ptr<tuple<int, int> >(), + 1, 2))() + ); + BOOST_CHECK(ok); + + ok = check_tuple( + 1, + *(bind(new_ptr<tuple<int, int, int> >(), + 1, 2, 3))() + ); + BOOST_CHECK(ok); + + ok = check_tuple( + 1, + *(bind(new_ptr<tuple<int, int, int, int> >(), + 1, 2, 3, 4))() + ); + BOOST_CHECK(ok); + + ok = check_tuple( + 1, + *(bind(new_ptr<tuple<int, int, int, int, int> >(), + 1, 2, 3, 4, 5))() + ); + BOOST_CHECK(ok); + + ok = check_tuple( + 1, + *(bind(new_ptr<tuple<int, int, int, int, int, int> >(), + 1, 2, 3, 4, 5, 6))() + ); + BOOST_CHECK(ok); + + ok = check_tuple( + 1, + *(bind(new_ptr<tuple<int, int, int, int, int, int, int> >(), + 1, 2, 3, 4, 5, 6, 7))() + ); + BOOST_CHECK(ok); + + ok = check_tuple( + 1, + *(bind(new_ptr<tuple<int, int, int, int, int, int, int, int> >(), + 1, 2, 3, 4, 5, 6, 7, 8))() + ); + BOOST_CHECK(ok); + + ok = check_tuple( + 1, + *(bind(new_ptr<tuple<int, int, int, int, int, int, int, int, int> >(), + 1, 2, 3, 4, 5, 6, 7, 8, 9))() + ); + BOOST_CHECK(ok); + +} + +class is_destructor_called { + bool& b; +public: + is_destructor_called(bool& bb) : b(bb) { b = false; } + ~is_destructor_called() { b = true; } +}; + +void test_destructor () +{ + char space[sizeof(is_destructor_called)]; + bool flag = false; + + is_destructor_called* idc = new(space) is_destructor_called(flag); + BOOST_CHECK(flag == false); + bind(destructor(), _1)(idc); + BOOST_CHECK(flag == true); + + idc = new(space) is_destructor_called(flag); + BOOST_CHECK(flag == false); + bind(destructor(), _1)(*idc); + BOOST_CHECK(flag == true); +} + + +class count_deletes { +public: + static int count; + ~count_deletes() { ++count; } +}; + +int count_deletes::count = 0; + +void test_news_and_deletes () +{ + int* i[10]; + std::for_each(i, i+10, _1 = bind(new_ptr<int>(), 2)); + int count_errors = 0; + + std::for_each(i, i+10, (*_1 == 2) || ++var(count_errors)); + BOOST_CHECK(count_errors == 0); + + + count_deletes* ct[10]; + std::for_each(ct, ct+10, _1 = bind(new_ptr<count_deletes>())); + count_deletes::count = 0; + std::for_each(ct, ct+10, bind(delete_ptr(), _1)); + BOOST_CHECK(count_deletes::count == 10); + +} + +void test_array_new_and_delete() +{ + count_deletes* c; + (_1 = bind(new_array<count_deletes>(), 5))(c); + count_deletes::count = 0; + + bind(delete_array(), _1)(c); + BOOST_CHECK(count_deletes::count == 5); +} + + +void delayed_construction() +{ + std::vector<int> x(3); + std::vector<int> y(3); + + std::fill(x.begin(), x.end(), 0); + std::fill(y.begin(), y.end(), 1); + + std::vector<std::pair<int, int> > v; + + std::transform(x.begin(), x.end(), y.begin(), std::back_inserter(v), + bl::bind(constructor<std::pair<int, int> >(), _1, _2) ); +} + +int test_main(int, char *[]) { + + constructor_all_lengths(); + new_ptr_all_lengths(); + delayed_construction(); + test_destructor(); + test_news_and_deletes(); + test_array_new_and_delete(); + + return 0; +} diff --git a/src/boost/libs/phoenix/test/bll_compatibility/control_structures.cpp b/src/boost/libs/phoenix/test/bll_compatibility/control_structures.cpp new file mode 100644 index 00000000..12eabf8d --- /dev/null +++ b/src/boost/libs/phoenix/test/bll_compatibility/control_structures.cpp @@ -0,0 +1,123 @@ +// -- control_structures.cpp -- The Boost Lambda Library ------------------ +// +// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) +// +// 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) +// +// For more information, see www.boost.org + +// ----------------------------------------------------------------------- + +#include <boost/test/minimal.hpp> // see "Header Implementation Option" + +#include "boost/lambda/lambda.hpp" +#include "boost/lambda/if.hpp" +#include "boost/lambda/loops.hpp" + +#include <iostream> +#include <algorithm> +#include <vector> + +using namespace boost; + +using boost::lambda::constant; +using boost::lambda::_1; +using boost::lambda::_2; +using boost::lambda::_3; +using boost::lambda::make_const; +using boost::lambda::for_loop; +using boost::lambda::while_loop; +using boost::lambda::do_while_loop; +using boost::lambda::if_then; +using boost::lambda::if_then_else; +using boost::lambda::if_then_else_return; + +// 2 container for_each +template <class InputIter1, class InputIter2, class Function> +Function for_each(InputIter1 first, InputIter1 last, + InputIter2 first2, Function f) { + for ( ; first != last; ++first, ++first2) + f(*first, *first2); + return f; +} + +void simple_loops() { + + // for loops --------------------------------------------------------- + int i; + int arithmetic_series = 0; + for_loop(_1 = 0, _1 < 10, _1++, arithmetic_series += _1)(i); + BOOST_CHECK(arithmetic_series == 45); + + // no body case + for_loop(boost::lambda::var(i) = 0, boost::lambda::var(i) < 100, ++boost::lambda::var(i))(); + BOOST_CHECK(i == 100); + + // while loops ------------------------------------------------------- + int a = 0, b = 0, c = 0; + + while_loop((_1 + _2) >= (_1 * _2), (++_1, ++_2, ++_3))(a, b, c); + BOOST_CHECK(c == 3); + + int count; + count = 0; i = 0; + while_loop(_1++ < 10, ++boost::lambda::var(count))(i); + BOOST_CHECK(count == 10); + + // note that the first parameter of do_while_loop is the condition + count = 0; i = 0; + do_while_loop(_1++ < 10, ++boost::lambda::var(count))(i); + BOOST_CHECK(count == 11); + + a = 0; + do_while_loop(constant(false), _1++)(a); + BOOST_CHECK(a == 1); + + // no body cases + a = 40; b = 30; + while_loop(--_1 > _2)(a, b); + BOOST_CHECK(a == b); + + // (the no body case for do_while_loop is pretty redundant) + a = 40; b = 30; + do_while_loop(--_1 > _2)(a, b); + BOOST_CHECK(a == b); + + +} + +void simple_ifs () { + + int value = 42; + if_then(_1 < 0, _1 = 0)(value); + BOOST_CHECK(value == 42); + + value = -42; + if_then(_1 < 0, _1 = -_1)(value); + BOOST_CHECK(value == 42); + + int min; + if_then_else(_1 < _2, boost::lambda::var(min) = _1, boost::lambda::var(min) = _2) + (make_const(1), make_const(2)); + BOOST_CHECK(min == 1); + + if_then_else(_1 < _2, boost::lambda::var(min) = _1, boost::lambda::var(min) = _2) + (make_const(5), make_const(3)); + BOOST_CHECK(min == 3); + + int x, y; + x = -1; y = 1; + BOOST_CHECK(if_then_else_return(_1 < _2, _2, _1)(x, y) == (std::max)(x ,y)); + BOOST_CHECK(if_then_else_return(_1 < _2, _2, _1)(y, x) == (std::max)(x ,y)); +} + + +int test_main(int, char *[]) +{ + simple_loops(); + simple_ifs(); + return 0; +} diff --git a/src/boost/libs/phoenix/test/bll_compatibility/exception_test.cpp b/src/boost/libs/phoenix/test/bll_compatibility/exception_test.cpp new file mode 100644 index 00000000..ee906668 --- /dev/null +++ b/src/boost/libs/phoenix/test/bll_compatibility/exception_test.cpp @@ -0,0 +1,621 @@ +// -- exception_test.cpp -- The Boost Lambda Library ------------------ +// +// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) +// +// 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) +// +// For more information, see www.boost.org + +// ----------------------------------------------------------------------- + +#include <boost/test/minimal.hpp> // see "Header Implementation Option" + +#include "boost/lambda/lambda.hpp" + +#include "boost/lambda/exceptions.hpp" + +#include "boost/lambda/bind.hpp" + +#include<iostream> +#include<algorithm> +#include <cstdlib> + +#include <iostream> + +using namespace boost::lambda; +using namespace std; + +// to prevent unused variables warnings +template <class T> void dummy(const T&) {} + +void erroneous_exception_related_lambda_expressions() { + + int i = 0; + dummy(i); + + // Uncommenting any of the below code lines should result in a compile + // time error + + // this should fail (a rethrow binder outside of catch + // rethrow()(); + + // this should fail too for the same reason + // try_catch(rethrow(), catch_all(cout << constant("Howdy")))(); + + // this fails too (_e outside of catch_exception) + // (_1 + _2 + _e)(i, i, i); + + // and this (_e outside of catch_exception) + // try_catch( throw_exception(1), catch_all(cout << _e)); + + // and this (_3 in catch_exception + // try_catch( throw_exception(1), catch_exception<int>(cout << _3)); +} + + +class A1 {}; +class A2 {}; +class A3 {}; +class A4 {}; +class A5 {}; +class A6 {}; +class A7 {}; +class A8 {}; +class A9 {}; + +void throw_AX(int j) { + int i = j; + switch(i) { + case 1: throw A1(); + case 2: throw A2(); + case 3: throw A3(); + case 4: throw A4(); + case 5: throw A5(); + case 6: throw A6(); + case 7: throw A7(); + case 8: throw A8(); + case 9: throw A9(); + } +} + +void test_different_number_of_catch_blocks() { + + int ecount; + +// no catch(...) cases + + + ecount = 0; + for(int i=1; i<=1; i++) + { + try_catch( + bind(throw_AX, _1), + catch_exception<A1>( + var(ecount)++ + ) + )(i); + } + BOOST_CHECK(ecount == 1); + + ecount = 0; + for(int i=1; i<=2; i++) + { + try_catch( + bind(throw_AX, _1), + catch_exception<A1>( + var(ecount)++ + ), + catch_exception<A2>( + var(ecount)++ + ) + )(i); + } + BOOST_CHECK(ecount == 2); + + ecount = 0; + for(int i=1; i<=3; i++) + { + try_catch( + bind(throw_AX, _1), + catch_exception<A1>( + var(ecount)++ + ), + catch_exception<A2>( + var(ecount)++ + ), + catch_exception<A3>( + var(ecount)++ + ) + )(i); + } + BOOST_CHECK(ecount == 3); + + ecount = 0; + for(int i=1; i<=4; i++) + { + try_catch( + bind(throw_AX, _1), + catch_exception<A1>( + var(ecount)++ + ), + catch_exception<A2>( + var(ecount)++ + ), + catch_exception<A3>( + var(ecount)++ + ), + catch_exception<A4>( + var(ecount)++ + ) + )(i); + } + BOOST_CHECK(ecount == 4); + + ecount = 0; + for(int i=1; i<=5; i++) + { + try_catch( + bind(throw_AX, _1), + catch_exception<A1>( + var(ecount)++ + ), + catch_exception<A2>( + var(ecount)++ + ), + catch_exception<A3>( + var(ecount)++ + ), + catch_exception<A4>( + var(ecount)++ + ), + catch_exception<A5>( + var(ecount)++ + ) + )(i); + } + BOOST_CHECK(ecount == 5); + + ecount = 0; + for(int i=1; i<=6; i++) + { + try_catch( + bind(throw_AX, _1), + catch_exception<A1>( + var(ecount)++ + ), + catch_exception<A2>( + var(ecount)++ + ), + catch_exception<A3>( + var(ecount)++ + ), + catch_exception<A4>( + var(ecount)++ + ), + catch_exception<A5>( + var(ecount)++ + ), + catch_exception<A6>( + var(ecount)++ + ) + )(i); + } + BOOST_CHECK(ecount == 6); + + ecount = 0; + for(int i=1; i<=7; i++) + { + try_catch( + bind(throw_AX, _1), + catch_exception<A1>( + var(ecount)++ + ), + catch_exception<A2>( + var(ecount)++ + ), + catch_exception<A3>( + var(ecount)++ + ), + catch_exception<A4>( + var(ecount)++ + ), + catch_exception<A5>( + var(ecount)++ + ), + catch_exception<A6>( + var(ecount)++ + ), + catch_exception<A7>( + var(ecount)++ + ) + )(i); + } + BOOST_CHECK(ecount == 7); + + ecount = 0; + for(int i=1; i<=8; i++) + { + try_catch( + bind(throw_AX, _1), + catch_exception<A1>( + var(ecount)++ + ), + catch_exception<A2>( + var(ecount)++ + ), + catch_exception<A3>( + var(ecount)++ + ), + catch_exception<A4>( + var(ecount)++ + ), + catch_exception<A5>( + var(ecount)++ + ), + catch_exception<A6>( + var(ecount)++ + ), + catch_exception<A7>( + var(ecount)++ + ), + catch_exception<A8>( + var(ecount)++ + ) + )(i); + } + BOOST_CHECK(ecount == 8); + + ecount = 0; + for(int i=1; i<=9; i++) + { + try_catch( + bind(throw_AX, _1), + catch_exception<A1>( + var(ecount)++ + ), + catch_exception<A2>( + var(ecount)++ + ), + catch_exception<A3>( + var(ecount)++ + ), + catch_exception<A4>( + var(ecount)++ + ), + catch_exception<A5>( + var(ecount)++ + ), + catch_exception<A6>( + var(ecount)++ + ), + catch_exception<A7>( + var(ecount)++ + ), + catch_exception<A8>( + var(ecount)++ + ), + catch_exception<A9>( + var(ecount)++ + ) + )(i); + } + BOOST_CHECK(ecount == 9); + + + // with catch(...) blocks + + ecount = 0; + for(int i=1; i<=1; i++) + { + try_catch( + bind(throw_AX, _1), + catch_all( + var(ecount)++ + ) + )(i); + } + BOOST_CHECK(ecount == 1); + + ecount = 0; + for(int i=1; i<=2; i++) + { + try_catch( + bind(throw_AX, _1), + catch_exception<A1>( + var(ecount)++ + ), + catch_all( + var(ecount)++ + ) + )(i); + } + BOOST_CHECK(ecount == 2); + + ecount = 0; + for(int i=1; i<=3; i++) + { + try_catch( + bind(throw_AX, _1), + catch_exception<A1>( + var(ecount)++ + ), + catch_exception<A2>( + var(ecount)++ + ), + catch_all( + var(ecount)++ + ) + )(i); + } + BOOST_CHECK(ecount == 3); + + ecount = 0; + for(int i=1; i<=4; i++) + { + try_catch( + bind(throw_AX, _1), + catch_exception<A1>( + var(ecount)++ + ), + catch_exception<A2>( + var(ecount)++ + ), + catch_exception<A3>( + var(ecount)++ + ), + catch_all( + var(ecount)++ + ) + )(i); + } + BOOST_CHECK(ecount == 4); + + ecount = 0; + for(int i=1; i<=5; i++) + { + try_catch( + bind(throw_AX, _1), + catch_exception<A1>( + var(ecount)++ + ), + catch_exception<A2>( + var(ecount)++ + ), + catch_exception<A3>( + var(ecount)++ + ), + catch_exception<A4>( + var(ecount)++ + ), + catch_all( + var(ecount)++ + ) + )(i); + } + BOOST_CHECK(ecount == 5); + + ecount = 0; + for(int i=1; i<=6; i++) + { + try_catch( + bind(throw_AX, _1), + catch_exception<A1>( + var(ecount)++ + ), + catch_exception<A2>( + var(ecount)++ + ), + catch_exception<A3>( + var(ecount)++ + ), + catch_exception<A4>( + var(ecount)++ + ), + catch_exception<A5>( + var(ecount)++ + ), + catch_all( + var(ecount)++ + ) + )(i); + } + BOOST_CHECK(ecount == 6); + + ecount = 0; + for(int i=1; i<=7; i++) + { + try_catch( + bind(throw_AX, _1), + catch_exception<A1>( + var(ecount)++ + ), + catch_exception<A2>( + var(ecount)++ + ), + catch_exception<A3>( + var(ecount)++ + ), + catch_exception<A4>( + var(ecount)++ + ), + catch_exception<A5>( + var(ecount)++ + ), + catch_exception<A6>( + var(ecount)++ + ), + catch_all( + var(ecount)++ + ) + )(i); + } + BOOST_CHECK(ecount == 7); + + ecount = 0; + for(int i=1; i<=8; i++) + { + try_catch( + bind(throw_AX, _1), + catch_exception<A1>( + var(ecount)++ + ), + catch_exception<A2>( + var(ecount)++ + ), + catch_exception<A3>( + var(ecount)++ + ), + catch_exception<A4>( + var(ecount)++ + ), + catch_exception<A5>( + var(ecount)++ + ), + catch_exception<A6>( + var(ecount)++ + ), + catch_exception<A7>( + var(ecount)++ + ), + catch_all( + var(ecount)++ + ) + )(i); + } + BOOST_CHECK(ecount == 8); + + ecount = 0; + for(int i=1; i<=9; i++) + { + try_catch( + bind(throw_AX, _1), + catch_exception<A1>( + var(ecount)++ + ), + catch_exception<A2>( + var(ecount)++ + ), + catch_exception<A3>( + var(ecount)++ + ), + catch_exception<A4>( + var(ecount)++ + ), + catch_exception<A5>( + var(ecount)++ + ), + catch_exception<A6>( + var(ecount)++ + ), + catch_exception<A7>( + var(ecount)++ + ), + catch_exception<A8>( + var(ecount)++ + ), + catch_all( + var(ecount)++ + ) + )(i); + } + BOOST_CHECK(ecount == 9); +} + +void test_empty_catch_blocks() { + try_catch( + bind(throw_AX, _1), + catch_exception<A1>() + )(make_const(1)); + + try_catch( + bind(throw_AX, _1), + catch_all() + )(make_const(1)); + +} + + +void return_type_matching() { + +// Rules for return types of the lambda functors in try and catch parts: +// 1. The try part dictates the return type of the whole +// try_catch lambda functor +// 2. If return type of try part is void, catch parts can return anything, +// but the return types are ignored +// 3. If the return type of the try part is A, then each catch return type +// must be implicitly convertible to A, or then it must throw for sure + + + int i = 1; + + BOOST_CHECK( + + try_catch( + _1 + 1, + catch_exception<int>((&_1, rethrow())), // no match, but ok since throws + catch_exception<char>(_e) // ok, char convertible to int + )(i) + + == 2 + ); + + // note that while e.g. char is convertible to int, it is not convertible + // to int&, (some lambda functors return references) + + // try_catch( + // _1 += 1, + // catch_exception<char>(_e) // NOT ok, char not convertible to int& + // )(i); + + // if you don't care about the return type, you can use make_void + try_catch( + make_void(_1 += 1), + catch_exception<char>(_e) // since try is void, catch can return anything + )(i); + BOOST_CHECK(i == 2); + + try_catch( + (_1 += 1, throw_exception('a')), + catch_exception<char>(_e) // since try throws, it is void, + // so catch can return anything + )(i); + BOOST_CHECK(i == 3); + + char a = 'a'; + try_catch( + try_catch( + throw_exception(1), + catch_exception<int>(throw_exception('b')) + ), + catch_exception<char>( _1 = _e ) + )(a); + BOOST_CHECK(a == 'b'); +} + +int test_main(int, char *[]) { + + try + { + test_different_number_of_catch_blocks(); + return_type_matching(); + test_empty_catch_blocks(); + } + catch (int) + { + BOOST_CHECK(false); + } + catch(...) + { + BOOST_CHECK(false); + } + + + return EXIT_SUCCESS; +} + + + + diff --git a/src/boost/libs/phoenix/test/bll_compatibility/extending_rt_traits.cpp b/src/boost/libs/phoenix/test/bll_compatibility/extending_rt_traits.cpp new file mode 100644 index 00000000..56916ab5 --- /dev/null +++ b/src/boost/libs/phoenix/test/bll_compatibility/extending_rt_traits.cpp @@ -0,0 +1,394 @@ +// extending_return_type_traits.cpp -- The Boost Lambda Library -------- +// +// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) +// +// 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) +// +// For more information, see www.boost.org + +// ----------------------------------------------------------------------- + + +#include <boost/test/minimal.hpp> // see "Header Implementation Option" + +#include "boost/lambda/bind.hpp" +#include "boost/lambda/lambda.hpp" +#include "boost/lambda/detail/suppress_unused.hpp" + +#include <iostream> + +#include <functional> + +#include <algorithm> + +using boost::lambda::detail::suppress_unused_variable_warnings; + +class A {}; +class B {}; + +using namespace boost::lambda; + + +B operator--(const A&, int) { return B(); } +B operator--(A&) { return B(); } +B operator++(const A&, int) { return B(); } +B operator++(A&) { return B(); } +B operator-(const A&) { return B(); } +B operator+(const A&) { return B(); } + +B operator!(const A&) { return B(); } + +B operator&(const A&) { return B(); } +B operator*(const A&) { return B(); } + +namespace boost { +namespace lambda { + + // unary + and - +template<class Act> +struct plain_return_type_1<unary_arithmetic_action<Act>, A > { + typedef B type; +}; + + // post incr/decr +template<class Act> +struct plain_return_type_1<post_increment_decrement_action<Act>, A > { + typedef B type; +}; + + // pre incr/decr +template<class Act> +struct plain_return_type_1<pre_increment_decrement_action<Act>, A > { + typedef B type; +}; + // ! +template<> +struct plain_return_type_1<logical_action<not_action>, A> { + typedef B type; +}; + // & +template<> +struct plain_return_type_1<other_action<addressof_action>, A> { + typedef B type; +}; + // * +template<> +struct plain_return_type_1<other_action<contentsof_action>, A> { + typedef B type; +}; + + +} // lambda +} // boost + +void ok(B /*b*/) {} + +void test_unary_operators() +{ + A a; int i = 1; + ok((++_1)(a)); + ok((--_1)(a)); + ok((_1++)(a)); + ok((_1--)(a)); + ok((+_1)(a)); + ok((-_1)(a)); + ok((!_1)(a)); + ok((&_1)(a)); + ok((*_1)(a)); + + BOOST_CHECK((*_1)(make_const(&i)) == 1); +} + +class X {}; +class Y {}; +class Z {}; + +Z operator+(const X&, const Y&) { return Z(); } +Z operator-(const X&, const Y&) { return Z(); } +X operator*(const X&, const Y&) { return X(); } + +Z operator/(const X&, const Y&) { return Z(); } +Z operator%(const X&, const Y&) { return Z(); } + +class XX {}; +class YY {}; +class ZZ {}; +class VV {}; + +// it is possible to support differently cv-qualified versions +YY operator*(XX&, YY&) { return YY(); } +ZZ operator*(const XX&, const YY&) { return ZZ(); } +XX operator*(volatile XX&, volatile YY&) { return XX(); } +VV operator*(const volatile XX&, const volatile YY&) { return VV(); } + +// the traits can be more complex: +template <class T> +class my_vector {}; + +template<class A, class B> +my_vector<typename return_type_2<arithmetic_action<plus_action>, A&, B&>::type> +operator+(const my_vector<A>& /*a*/, const my_vector<B>& /*b*/) +{ + typedef typename + return_type_2<arithmetic_action<plus_action>, A&, B&>::type res_type; + return my_vector<res_type>(); +} + + + +// bitwise ops: +X operator<<(const X&, const Y&) { return X(); } +Z operator>>(const X&, const Y&) { return Z(); } +Z operator&(const X&, const Y&) { return Z(); } +Z operator|(const X&, const Y&) { return Z(); } +Z operator^(const X&, const Y&) { return Z(); } + +// comparison ops: + +X operator<(const X&, const Y&) { return X(); } +Z operator>(const X&, const Y&) { return Z(); } +Z operator<=(const X&, const Y&) { return Z(); } +Z operator>=(const X&, const Y&) { return Z(); } +Z operator==(const X&, const Y&) { return Z(); } +Z operator!=(const X&, const Y&) { return Z(); } + +// logical + +X operator&&(const X&, const Y&) { return X(); } +Z operator||(const X&, const Y&) { return Z(); } + +// arithh assignment + +Z operator+=( X&, const Y&) { return Z(); } +Z operator-=( X&, const Y&) { return Z(); } +Y operator*=( X&, const Y&) { return Y(); } +Z operator/=( X&, const Y&) { return Z(); } +Z operator%=( X&, const Y&) { return Z(); } + +// bitwise assignment +Z operator<<=( X&, const Y&) { return Z(); } +Z operator>>=( X&, const Y&) { return Z(); } +Y operator&=( X&, const Y&) { return Y(); } +Z operator|=( X&, const Y&) { return Z(); } +Z operator^=( X&, const Y&) { return Z(); } + +// assignment +class Assign { +public: + void operator=(const Assign& /*a*/) {} + X operator[](const int& /*i*/) { return X(); } +}; + + + +namespace boost { +namespace lambda { + + // you can do action groups +template<class Act> +struct plain_return_type_2<arithmetic_action<Act>, X, Y> { + typedef Z type; +}; + + // or specialize the exact action +template<> +struct plain_return_type_2<arithmetic_action<multiply_action>, X, Y> { + typedef X type; +}; + + // if you want to make a distinction between differently cv-qualified + // types, you need to specialize on a different level: +template<> +struct return_type_2<arithmetic_action<multiply_action>, XX, YY> { + typedef YY type; +}; +template<> +struct return_type_2<arithmetic_action<multiply_action>, const XX, const YY> { + typedef ZZ type; +}; +template<> +struct return_type_2<arithmetic_action<multiply_action>, volatile XX, volatile YY> { + typedef XX type; +}; +template<> +struct return_type_2<arithmetic_action<multiply_action>, volatile const XX, const volatile YY> { + typedef VV type; +}; + + // the mapping can be more complex: +template<class A, class B> +struct plain_return_type_2<arithmetic_action<plus_action>, my_vector<A>, my_vector<B> > { + typedef typename + return_type_2<arithmetic_action<plus_action>, A&, B&>::type res_type; + typedef my_vector<res_type> type; +}; + + // bitwise binary: + // you can do action groups +template<class Act> +struct plain_return_type_2<bitwise_action<Act>, X, Y> { + typedef Z type; +}; + + // or specialize the exact action +template<> +struct plain_return_type_2<bitwise_action<leftshift_action>, X, Y> { + typedef X type; +}; + + // comparison binary: + // you can do action groups +template<class Act> +struct plain_return_type_2<relational_action<Act>, X, Y> { + typedef Z type; +}; + + // or specialize the exact action +template<> +struct plain_return_type_2<relational_action<less_action>, X, Y> { + typedef X type; +}; + + // logical binary: + // you can do action groups +template<class Act> +struct plain_return_type_2<logical_action<Act>, X, Y> { + typedef Z type; +}; + + // or specialize the exact action +template<> +struct plain_return_type_2<logical_action<and_action>, X, Y> { + typedef X type; +}; + + // arithmetic assignment : + // you can do action groups +template<class Act> +struct plain_return_type_2<arithmetic_assignment_action<Act>, X, Y> { + typedef Z type; +}; + + // or specialize the exact action +template<> +struct plain_return_type_2<arithmetic_assignment_action<multiply_action>, X, Y> { + typedef Y type; +}; + + // arithmetic assignment : + // you can do action groups +template<class Act> +struct plain_return_type_2<bitwise_assignment_action<Act>, X, Y> { + typedef Z type; +}; + + // or specialize the exact action +template<> +struct plain_return_type_2<bitwise_assignment_action<and_action>, X, Y> { + typedef Y type; +}; + + // assignment +template<> +struct plain_return_type_2<other_action<assignment_action>, Assign, Assign> { + typedef void type; +}; + // subscript +template<> +struct plain_return_type_2<other_action<subscript_action>, Assign, int> { + typedef X type; +}; + + +} // end lambda +} // end boost + + + +void test_binary_operators() { + + X x; Y y; + (_1 + _2)(x, y); + (_1 - _2)(x, y); + (_1 * _2)(x, y); + (_1 / _2)(x, y); + (_1 % _2)(x, y); + + + // make a distinction between differently cv-qualified operators + XX xx; YY yy; + const XX& cxx = xx; + const YY& cyy = yy; + volatile XX& vxx = xx; + volatile YY& vyy = yy; + const volatile XX& cvxx = xx; + const volatile YY& cvyy = yy; + + ZZ dummy1 = (_1 * _2)(cxx, cyy); + YY dummy2 = (_1 * _2)(xx, yy); + XX dummy3 = (_1 * _2)(vxx, vyy); + VV dummy4 = (_1 * _2)(cvxx, cvyy); + + suppress_unused_variable_warnings(dummy1); + suppress_unused_variable_warnings(dummy2); + suppress_unused_variable_warnings(dummy3); + suppress_unused_variable_warnings(dummy4); + + my_vector<int> v1; my_vector<double> v2; + my_vector<double> d = (_1 + _2)(v1, v2); + + suppress_unused_variable_warnings(d); + + // bitwise + + (_1 << _2)(x, y); + (_1 >> _2)(x, y); + (_1 | _2)(x, y); + (_1 & _2)(x, y); + (_1 ^ _2)(x, y); + + // comparison + + (_1 < _2)(x, y); + (_1 > _2)(x, y); + (_1 <= _2)(x, y); + (_1 >= _2)(x, y); + (_1 == _2)(x, y); + (_1 != _2)(x, y); + + // logical + + (_1 || _2)(x, y); + (_1 && _2)(x, y); + + // arithmetic assignment + (_1 += _2)(x, y); + (_1 -= _2)(x, y); + (_1 *= _2)(x, y); + (_1 /= _2)(x, y); + (_1 %= _2)(x, y); + + // bitwise assignment + (_1 <<= _2)(x, y); + (_1 >>= _2)(x, y); + (_1 |= _2)(x, y); + (_1 &= _2)(x, y); + (_1 ^= _2)(x, y); + +} + + +int test_main(int, char *[]) { + test_unary_operators(); + test_binary_operators(); + return 0; +} + + + + + + diff --git a/src/boost/libs/phoenix/test/bll_compatibility/is_instance_of_test.cpp b/src/boost/libs/phoenix/test/bll_compatibility/is_instance_of_test.cpp new file mode 100644 index 00000000..d1c57b36 --- /dev/null +++ b/src/boost/libs/phoenix/test/bll_compatibility/is_instance_of_test.cpp @@ -0,0 +1,79 @@ +// is_instance_of_test.cpp -- The Boost Lambda Library ------------------ +// +// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) +// +// 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) +// +// For more information, see www.boost.org + +// ----------------------------------------------------------------------- + + +#include <boost/test/minimal.hpp> // see "Header Implementation Option" + + +#include "boost/lambda/detail/is_instance_of.hpp" + +#include <iostream> + +template <class T1> struct A1 {}; +template <class T1, class T2> struct A2 {}; +template <class T1, class T2, class T3> struct A3 {}; +template <class T1, class T2, class T3, class T4> struct A4 {}; + +class B1 : public A1<int> {}; +class B2 : public A2<int,int> {}; +class B3 : public A3<int,int,int> {}; +class B4 : public A4<int,int,int,int> {}; + +// classes that are convertible to classes that derive from A instances +// This is not enough to make the test succeed + +class C1 { public: operator A1<int>() { return A1<int>(); } }; +class C2 { public: operator B2() { return B2(); } }; +class C3 { public: operator B3() { return B3(); } }; +class C4 { public: operator B4() { return B4(); } }; + +// test that the result is really a constant +// (in an alternative implementation, gcc 3.0.2. claimed that it was +// a non-constant) +template <bool b> class X {}; +// this should compile +X<boost::lambda::is_instance_of_2<int, A2>::value> x; + + +int test_main(int, char *[]) { + +using boost::lambda::is_instance_of_1; +using boost::lambda::is_instance_of_2; +using boost::lambda::is_instance_of_3; +using boost::lambda::is_instance_of_4; + + +BOOST_CHECK((is_instance_of_1<B1, A1>::value == true)); +BOOST_CHECK((is_instance_of_1<A1<float>, A1>::value == true)); +BOOST_CHECK((is_instance_of_1<int, A1>::value == false)); +BOOST_CHECK((is_instance_of_1<C1, A1>::value == false)); + +BOOST_CHECK((is_instance_of_2<B2, A2>::value == true)); +BOOST_CHECK((is_instance_of_2<A2<int, float>, A2>::value == true)); +BOOST_CHECK((is_instance_of_2<int, A2>::value == false)); +BOOST_CHECK((is_instance_of_2<C2, A2>::value == false)); + +BOOST_CHECK((is_instance_of_3<B3, A3>::value == true)); +BOOST_CHECK((is_instance_of_3<A3<int, float, char>, A3>::value == true)); +BOOST_CHECK((is_instance_of_3<int, A3>::value == false)); +BOOST_CHECK((is_instance_of_3<C3, A3>::value == false)); + +BOOST_CHECK((is_instance_of_4<B4, A4>::value == true)); +BOOST_CHECK((is_instance_of_4<A4<int, float, char, double>, A4>::value == true)); +BOOST_CHECK((is_instance_of_4<int, A4>::value == false)); +BOOST_CHECK((is_instance_of_4<C4, A4>::value == false)); + +return 0; + +} + diff --git a/src/boost/libs/phoenix/test/bll_compatibility/istreambuf_test.cpp b/src/boost/libs/phoenix/test/bll_compatibility/istreambuf_test.cpp new file mode 100644 index 00000000..6db0842c --- /dev/null +++ b/src/boost/libs/phoenix/test/bll_compatibility/istreambuf_test.cpp @@ -0,0 +1,30 @@ +// istreambuf_test - test lambda function objects with istreambuf_iterator +// +// Copyright (c) 2007 Peter Dimov +// +// 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/lambda/lambda.hpp> +#include <boost/detail/lightweight_test.hpp> +#include <iterator> +#include <sstream> +#include <algorithm> + +int main() +{ + using namespace boost::lambda; + + std::stringstream is( "ax2" ); + + std::istreambuf_iterator<char> b2( is ); + std::istreambuf_iterator<char> e2; + + std::istreambuf_iterator<char> i = std::find_if( b2, e2, _1 == 'x' ); + + BOOST_TEST( *i == 'x' ); + BOOST_TEST( std::distance( i, e2 ) == 2 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/bll_compatibility/member_pointer_test.cpp b/src/boost/libs/phoenix/test/bll_compatibility/member_pointer_test.cpp new file mode 100644 index 00000000..e8121d56 --- /dev/null +++ b/src/boost/libs/phoenix/test/bll_compatibility/member_pointer_test.cpp @@ -0,0 +1,192 @@ +// member_pointer_test.cpp -- The Boost Lambda Library ------------------ +// +// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) +// +// 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) +// +// For more information, see www.boost.org + +// ----------------------------------------------------------------------- + + +#include <boost/test/minimal.hpp> // see "Header Implementation Option" + + +#include "boost/lambda/lambda.hpp" +#include "boost/lambda/bind.hpp" + +#include <string> + +using namespace boost::lambda; +using namespace std; + + +struct my_struct { +my_struct(int x) : mem(x) {}; + + int mem; + + int fooc() const { return mem; } + int foo() { return mem; } + int foo1c(int y) const { return y + mem; } + int foo1(int y) { return y + mem; } + int foo2c(int y, int x) const { return y + x + mem; } + int foo2(int y, int x) { return y + x + mem; } + int foo3c(int y, int x, int z) const { return y + x + z + mem; } + int foo3(int y, int x, int z ){ return y + x + z + mem; } + int foo4c(int a1, int a2, int a3, int a4) const { return a1+a2+a3+a4+mem; } + int foo4(int a1, int a2, int a3, int a4){ return a1+a2+a3+a4+mem; } + + int foo3default(int y = 1, int x = 2, int z = 3) { return y + x + z + mem; } +}; + +my_struct x(3); + +void pointer_to_data_member_tests() { + + // int i = 0; + my_struct *y = &x; + + BOOST_CHECK((_1 ->* &my_struct::mem)(y) == 3); + + (_1 ->* &my_struct::mem)(y) = 4; + BOOST_CHECK(x.mem == 4); + + ((_1 ->* &my_struct::mem) = 5)(y); + BOOST_CHECK(x.mem == 5); + + // &my_struct::mem is a temporary, must be constified + ((y ->* _1) = 6)(make_const(&my_struct::mem)); + BOOST_CHECK(x.mem == 6); + + ((_1 ->* _2) = 7)(y, make_const(&my_struct::mem)); + BOOST_CHECK(x.mem == 7); + +} + +void pointer_to_member_function_tests() { + + my_struct *y = new my_struct(1); + BOOST_CHECK( (_1 ->* &my_struct::foo)(y)() == (y->mem)); + BOOST_CHECK( (_1 ->* &my_struct::fooc)(y)() == (y->mem)); + BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo))() == (y->mem)); + BOOST_CHECK( (y ->* _1)(make_const(&my_struct::fooc))() == (y->mem)); + BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo))() == (y->mem)); + BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::fooc))() == (y->mem)); + + BOOST_CHECK( (_1 ->* &my_struct::foo1)(y)(1) == (y->mem+1)); + BOOST_CHECK( (_1 ->* &my_struct::foo1c)(y)(1) == (y->mem+1)); + BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo1))(1) == (y->mem+1)); + BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo1c))(1) == (y->mem+1)); + BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo1))(1) == (y->mem+1)); + BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo1c))(1) == (y->mem+1)); + + BOOST_CHECK( (_1 ->* &my_struct::foo2)(y)(1,2) == (y->mem+1+2)); + BOOST_CHECK( (_1 ->* &my_struct::foo2c)(y)(1,2) == (y->mem+1+2)); + BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo2))(1,2) == (y->mem+1+2)); + BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo2c))(1,2) == (y->mem+1+2)); + BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo2))(1,2) == (y->mem+1+2)); + BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo2c))(1,2) == (y->mem+1+2)); + + BOOST_CHECK( (_1 ->* &my_struct::foo3)(y)(1,2,3) == (y->mem+1+2+3)); + BOOST_CHECK( (_1 ->* &my_struct::foo3c)(y)(1,2,3) == (y->mem+1+2+3)); + BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo3))(1,2,3) == (y->mem+1+2+3)); + BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo3c))(1,2,3) == (y->mem+1+2+3)); + BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo3))(1,2,3) == (y->mem+1+2+3)); + BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo3c))(1,2,3) == (y->mem+1+2+3)); + + BOOST_CHECK( (_1 ->* &my_struct::foo4)(y)(1,2,3,4) == (y->mem+1+2+3+4)); + BOOST_CHECK( (_1 ->* &my_struct::foo4c)(y)(1,2,3,4) == (y->mem+1+2+3+4)); + BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo4))(1,2,3,4) == (y->mem+1+2+3+4)); + BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo4c))(1,2,3,4) == (y->mem+1+2+3+4)); + BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo4))(1,2,3,4) == (y->mem+1+2+3+4)); + BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo4c))(1,2,3,4) == (y->mem+1+2+3+4)); + + + + // member functions with default values do not work (inherent language issue) + // BOOST_CHECK( (_1 ->* &my_struct::foo3default)(y)() == (y->mem+1+2+3)); + +} + +class A {}; +class B {}; +class C {}; +class D {}; + +// ->* can be overloaded to do anything +bool operator->*(A /*a*/, B /*b*/) { + return false; +} + +bool operator->*(B /*b*/, A /*a*/) { + return true; +} + +// let's provide specializations to take care of the return type deduction. +// Note, that you need to provide all four cases for non-const and const +// or use the plain_return_type_2 template. +namespace boost { +namespace lambda { + +template <> +struct return_type_2<other_action<member_pointer_action>, B, A> { + typedef bool type; +}; + +template<> +struct return_type_2<other_action<member_pointer_action>, const B, A> { + typedef bool type; +}; + +template<> +struct return_type_2<other_action<member_pointer_action>, B, const A> { + typedef bool type; +}; + +template<> +struct return_type_2<other_action<member_pointer_action>, const B, const A> { + typedef bool type; +}; + + + + +} // lambda +} // boost + +void test_overloaded_pointer_to_member() +{ + A a; B b; + + // this won't work, can't deduce the return type + // BOOST_CHECK((_1->*_2)(a, b) == false); + + // ret<bool> gives the return type + BOOST_CHECK(ret<bool>(_1->*_2)(a, b) == false); + BOOST_CHECK(ret<bool>(a->*_1)(b) == false); + BOOST_CHECK(ret<bool>(_1->*b)(a) == false); + BOOST_CHECK((ret<bool>((var(a))->*b))() == false); + BOOST_CHECK((ret<bool>((var(a))->*var(b)))() == false); + + + // this is ok without ret<bool> due to the return_type_2 spcialization above + BOOST_CHECK((_1->*_2)(b, a) == true); + BOOST_CHECK((b->*_1)(a) == true); + BOOST_CHECK((_1->*a)(b) == true); + BOOST_CHECK((var(b)->*a)() == true); + return; +} + + +int test_main(int, char *[]) { + + pointer_to_data_member_tests(); + pointer_to_member_function_tests(); + test_overloaded_pointer_to_member(); + return 0; +} + diff --git a/src/boost/libs/phoenix/test/bll_compatibility/operator_tests_simple.cpp b/src/boost/libs/phoenix/test/bll_compatibility/operator_tests_simple.cpp new file mode 100644 index 00000000..34711fbb --- /dev/null +++ b/src/boost/libs/phoenix/test/bll_compatibility/operator_tests_simple.cpp @@ -0,0 +1,431 @@ +// operator_tests_simple.cpp -- The Boost Lambda Library --------------- +// +// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) +// +// 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) +// +// For more information, see www.boost.org + +// ----------------------------------------------------------------------- + + + +#include <boost/test/minimal.hpp> // see "Header Implementation Option" + +#include "boost/lambda/lambda.hpp" + +#include "boost/lambda/detail/suppress_unused.hpp" + +#include <boost/shared_ptr.hpp> + +#include <vector> +#include <map> +#include <set> +#include <string> + +#include <iostream> + +#ifndef BOOST_NO_STRINGSTREAM +#include <sstream> +#endif + +using namespace std; +using namespace boost; + +using namespace boost::lambda; + + +class unary_plus_tester {}; +unary_plus_tester operator+(const unary_plus_tester& a) { return a; } + +void cout_tests() +{ +#ifndef BOOST_NO_STRINGSTREAM + using std::cout; + ostringstream os; + int i = 10; + (os << _1)(i); + + (os << constant("FOO"))(); + + BOOST_CHECK(os.str() == std::string("10FOO")); + + + istringstream is("ABC 1"); + std::string s; + int k; + + is >> s; + is >> k; + + BOOST_CHECK(s == std::string("ABC")); + BOOST_CHECK(k == 1); + // test for constant, constant_ref and var + i = 5; + constant_type<int>::type ci(constant(i)); + var_type<int>::type vi(var(i)); + + (vi = _1)(make_const(100)); + BOOST_CHECK((ci)() == 5); + BOOST_CHECK(i == 100); + + int a; + constant_ref_type<int>::type cr(constant_ref(i)); + (++vi, var(a) = cr)(); + BOOST_CHECK(i == 101); +#endif +} + +void arithmetic_operators() { + int i = 1; int j = 2; int k = 3; + + using namespace std; + using namespace boost::lambda; + + BOOST_CHECK((_1 + 1)(i)==2); + BOOST_CHECK(((_1 + 1) * _2)(i, j)==4); + BOOST_CHECK((_1 - 1)(i)==0); + + BOOST_CHECK((_1 * 2)(j)==4); + BOOST_CHECK((_1 / 2)(j)==1); + + BOOST_CHECK((_1 % 2)(k)==1); + + BOOST_CHECK((-_1)(i) == -1); + BOOST_CHECK((+_1)(i) == 1); + + // test that unary plus really does something + unary_plus_tester u; + unary_plus_tester up = (+_1)(u); + + boost::lambda::detail::suppress_unused_variable_warnings(up); +} + +void bitwise_operators() { + unsigned int ui = 2; + + BOOST_CHECK((_1 << 1)(ui)==(2 << 1)); + BOOST_CHECK((_1 >> 1)(ui)==(2 >> 1)); + + BOOST_CHECK((_1 & 1)(ui)==(2 & 1)); + BOOST_CHECK((_1 | 1)(ui)==(2 | 1)); + BOOST_CHECK((_1 ^ 1)(ui)==(2 ^ 1)); + BOOST_CHECK((~_1)(ui)==~2u); +} + +void comparison_operators() { + int i = 0, j = 1; + + BOOST_CHECK((_1 < _2)(i, j) == true); + BOOST_CHECK((_1 <= _2)(i, j) == true); + BOOST_CHECK((_1 == _2)(i, j) == false); + BOOST_CHECK((_1 != _2)(i, j) == true); + BOOST_CHECK((_1 > _2)(i, j) == false); + BOOST_CHECK((_1 >= _2)(i, j) == false); + + BOOST_CHECK((!(_1 < _2))(i, j) == false); + BOOST_CHECK((!(_1 <= _2))(i, j) == false); + BOOST_CHECK((!(_1 == _2))(i, j) == true); + BOOST_CHECK((!(_1 != _2))(i, j) == false); + BOOST_CHECK((!(_1 > _2))(i, j) == true); + BOOST_CHECK((!(_1 >= _2))(i, j) == true); +} + +void logical_operators() { + + bool t = true, f = false; + BOOST_CHECK((_1 && _2)(t, t) == true); + BOOST_CHECK((_1 && _2)(t, f) == false); + BOOST_CHECK((_1 && _2)(f, t) == false); + BOOST_CHECK((_1 && _2)(f, f) == false); + + BOOST_CHECK((_1 || _2)(t, t) == true); + BOOST_CHECK((_1 || _2)(t, f) == true); + BOOST_CHECK((_1 || _2)(f, t) == true); + BOOST_CHECK((_1 || _2)(f, f) == false); + + BOOST_CHECK((!_1)(t) == false); + BOOST_CHECK((!_1)(f) == true); + + // test short circuiting + int i=0; + + (false && ++_1)(i); + BOOST_CHECK(i==0); + i = 0; + + (true && ++_1)(i); + BOOST_CHECK(i==1); + i = 0; + + (false || ++_1)(i); + BOOST_CHECK(i==1); + i = 0; + + (true || ++_1)(i); + BOOST_CHECK(i==0); + i = 0; +} + +void unary_incs_and_decs() { + int i = 0; + + BOOST_CHECK(_1++(i) == 0); + BOOST_CHECK(i == 1); + i = 0; + + BOOST_CHECK(_1--(i) == 0); + BOOST_CHECK(i == -1); + i = 0; + + BOOST_CHECK((++_1)(i) == 1); + BOOST_CHECK(i == 1); + i = 0; + + BOOST_CHECK((--_1)(i) == -1); + BOOST_CHECK(i == -1); + i = 0; + + // the result of prefix -- and ++ are lvalues + (++_1)(i) = 10; + BOOST_CHECK(i==10); + i = 0; + + (--_1)(i) = 10; + BOOST_CHECK(i==10); + i = 0; +} + +void compound_operators() { + + int i = 1; + + // normal variable as the left operand + (i += _1)(make_const(1)); + BOOST_CHECK(i == 2); + + (i -= _1)(make_const(1)); + BOOST_CHECK(i == 1); + + (i *= _1)(make_const(10)); + BOOST_CHECK(i == 10); + + (i /= _1)(make_const(2)); + BOOST_CHECK(i == 5); + + (i %= _1)(make_const(2)); + BOOST_CHECK(i == 1); + + // lambda expression as a left operand + (_1 += 1)(i); + BOOST_CHECK(i == 2); + + (_1 -= 1)(i); + BOOST_CHECK(i == 1); + + (_1 *= 10)(i); + BOOST_CHECK(i == 10); + + (_1 /= 2)(i); + BOOST_CHECK(i == 5); + + (_1 %= 2)(i); + BOOST_CHECK(i == 1); + + // lambda expression as a left operand with rvalue on RHS + (_1 += (0 + 1))(i); + BOOST_CHECK(i == 2); + + (_1 -= (0 + 1))(i); + BOOST_CHECK(i == 1); + + (_1 *= (0 + 10))(i); + BOOST_CHECK(i == 10); + + (_1 /= (0 + 2))(i); + BOOST_CHECK(i == 5); + + (_1 %= (0 + 2))(i); + BOOST_CHECK(i == 1); + + // shifts + unsigned int ui = 2; + (_1 <<= 1)(ui); + BOOST_CHECK(ui==(2 << 1)); + + ui = 2; + (_1 >>= 1)(ui); + BOOST_CHECK(ui==(2 >> 1)); + + ui = 2; + (ui <<= _1)(make_const(1)); + BOOST_CHECK(ui==(2 << 1)); + + ui = 2; + (ui >>= _1)(make_const(1)); + BOOST_CHECK(ui==(2 >> 1)); + + // and, or, xor + ui = 2; + (_1 &= 1)(ui); + BOOST_CHECK(ui==(2 & 1)); + + ui = 2; + (_1 |= 1)(ui); + BOOST_CHECK(ui==(2 | 1)); + + ui = 2; + (_1 ^= 1)(ui); + BOOST_CHECK(ui==(2 ^ 1)); + + ui = 2; + (ui &= _1)(make_const(1)); + BOOST_CHECK(ui==(2 & 1)); + + ui = 2; + (ui |= _1)(make_const(1)); + BOOST_CHECK(ui==(2 | 1)); + + ui = 2; + (ui ^= _1)(make_const(1)); + BOOST_CHECK(ui==(2 ^ 1)); + +} + +void assignment_and_subscript() { + + // assignment and subscript need to be defined as member functions. + // Hence, if you wish to use a normal variable as the left hand argument, + // you must wrap it with var to turn it into a lambda expression + + using std::string; + string s; + + (_1 = "one")(s); + BOOST_CHECK(s == string("one")); + + (var(s) = "two")(); + BOOST_CHECK(s == string("two")); + + BOOST_CHECK((var(s)[_1])(make_const(2)) == 'o'); + BOOST_CHECK((_1[2])(s) == 'o'); + BOOST_CHECK((_1[_2])(s, make_const(2)) == 'o'); + + // subscript returns lvalue + (var(s)[_1])(make_const(1)) = 'o'; + BOOST_CHECK(s == "too"); + + (_1[1])(s) = 'a'; + BOOST_CHECK(s == "tao"); + + (_1[_2])(s, make_const(0)) = 'm'; + BOOST_CHECK(s == "mao"); + + // TODO: tests for vector, set, map, multimap +} + +class A {}; + +void address_of_and_dereference() { + + A a; int i = 42; + + BOOST_CHECK((&_1)(a) == &a); + BOOST_CHECK((*&_1)(i) == 42); + + std::vector<int> vi; vi.push_back(1); + std::vector<int>::iterator it = vi.begin(); + + (*_1 = 7)(it); + BOOST_CHECK(vi[0] == 7); + const std::vector<int>::iterator cit(it); + (*_1 = 8)(cit); + BOOST_CHECK(vi[0] == 8); + + // TODO: Add tests for more complex iterator types + + boost::shared_ptr<int> ptr(new int(0)); + (*_1 = 7)(ptr); + BOOST_CHECK(*ptr == 7); + const boost::shared_ptr<int> cptr(ptr); + (*_1 = 8)(cptr); + BOOST_CHECK(*ptr == 8); +} + + + +void comma() { + + int i = 100; + BOOST_CHECK((_1 = 10, 2 * _1)(i) == 20); + + // TODO: that the return type is the exact type of the right argument + // (that r/l valueness is preserved) + +} + +void pointer_arithmetic() { + + int ia[4] = { 1, 2, 3, 4 }; + int* ip = ia; + int* ia_last = &ia[3]; + + const int cia[4] = { 1, 2, 3, 4 }; + const int* cip = cia; + const int* cia_last = &cia[3]; + + + // non-const array + BOOST_CHECK((*(_1 + 1))(ia) == 2); + + // non-const pointer + BOOST_CHECK((*(_1 + 1))(ip) == 2); + + BOOST_CHECK((*(_1 - 1))(ia_last) == 3); + + // const array + BOOST_CHECK((*(_1 + 1))(cia) == 2); + // const pointer + BOOST_CHECK((*(_1 + 1))(cip) == 2); + BOOST_CHECK((*(_1 - 1))(cia_last) == 3); + + // pointer arithmetic should not make non-consts const + (*(_1 + 2))(ia) = 0; + (*(_1 + 3))(ip) = 0; + + BOOST_CHECK(ia[2] == 0); + BOOST_CHECK(ia[3] == 0); + + // pointer - pointer + BOOST_CHECK((_1 - _2)(ia_last, ia) == 3); + BOOST_CHECK((_1 - _2)(cia_last, cia) == 3); + BOOST_CHECK((ia_last - _1)(ia) == 3); + BOOST_CHECK((cia_last - _1)(cia) == 3); + BOOST_CHECK((cia_last - _1)(cip) == 3); + +} + +int test_main(int, char *[]) { + + arithmetic_operators(); + bitwise_operators(); + comparison_operators(); + logical_operators(); + unary_incs_and_decs(); + compound_operators(); + assignment_and_subscript(); + address_of_and_dereference(); + comma(); + pointer_arithmetic(); + cout_tests(); + return 0; +} + + + + + + diff --git a/src/boost/libs/phoenix/test/bll_compatibility/phoenix_control_structures.cpp b/src/boost/libs/phoenix/test/bll_compatibility/phoenix_control_structures.cpp new file mode 100644 index 00000000..722a74f9 --- /dev/null +++ b/src/boost/libs/phoenix/test/bll_compatibility/phoenix_control_structures.cpp @@ -0,0 +1,148 @@ +// phoenix_style_control_structures.cpp -- The Boost Lambda Library ------ +// +// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) +// +// 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) +// +// For more information, see www.boost.org + +// ----------------------------------------------------------------------- + + +#include <boost/test/minimal.hpp> // see "Header Implementation Option" + +#include "boost/lambda/lambda.hpp" +#include "boost/lambda/if.hpp" +#include "boost/lambda/loops.hpp" + +#include <iostream> +#include <vector> +#include <list> +#include <algorithm> +#include <cmath> +#include <cassert> +#include <functional> + + + +using namespace boost::lambda; +using namespace std; + + + +// If-else, while, do-while, for statements + + +int test_main(int, char *[]) { + + vector<int> v; + v.clear(); + v.push_back(1); + v.push_back(2); + v.push_back(3); + v.push_back(4); + v.push_back(5); + v.push_back(6); + v.push_back(7); + v.push_back(8); + v.push_back(9); + v.push_back(10); + + int sum = 0; + ////////////////////////////////// + for_each(v.begin(), v.end(), + if_(_1 > 3 && _1 <= 8) + [ + sum += _1 + ] + ); + + BOOST_CHECK(sum == 4+5+6+7+8); + + int gt = 0, eq = 0, lt = 0; + ////////////////////////////////// + for_each(v.begin(), v.end(), + if_(_1 > 5) + [ + ++var(gt) + ] + .else_ + [ + if_(_1 == 5) + [ + ++var(eq) + ] + .else_ + [ + ++var(lt) + ] + ] + ); + + BOOST_CHECK(lt==4); + BOOST_CHECK(eq==1); + BOOST_CHECK(gt==5); + + vector<int> t = v; + + int counta = 0; + int countb = 0; + ////////////////////////////////// + for_each(v.begin(), v.end(), + ( + while_(_1--) + [ + ++var(counta) + ], + ++var(countb) + ) + ); + + BOOST_CHECK(counta == 55); + BOOST_CHECK(countb == 10); + + + v = t; + + counta = 0; countb = 0; + ////////////////////////////////// + for_each(v.begin(), v.end(), + ( + do_ + [ + ++var(counta) + ] + .while_(_1--), + ++var(countb) + ) + ); + + BOOST_CHECK(counta == (2+11)*10/2); + BOOST_CHECK(countb == 10); + + + v = t; + counta = 0; countb = 0; + ////////////////////////////////// + int iii; + for_each(v.begin(), v.end(), + ( + for_(var(iii) = 0, var(iii) < _1, ++var(iii)) + [ + ++var(counta) + ], + ++var(countb) + ) + ); + + BOOST_CHECK(counta == (1+10)*10/2); + BOOST_CHECK(countb == 10); + + v = t; + + return 0; +} + diff --git a/src/boost/libs/phoenix/test/bll_compatibility/result_of_tests.cpp b/src/boost/libs/phoenix/test/bll_compatibility/result_of_tests.cpp new file mode 100644 index 00000000..9047f5bc --- /dev/null +++ b/src/boost/libs/phoenix/test/bll_compatibility/result_of_tests.cpp @@ -0,0 +1,314 @@ +// result_of_tests.cpp -- The Boost Lambda Library ------------------ +// +// Copyright (C) 2010 Steven Watanabe +// +// 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) +// +// For more information, see www.boost.org + +// ----------------------------------------------------------------------- + + +#include <boost/test/minimal.hpp> // see "Header Implementation Option" +#include <boost/lambda/bind.hpp> +#include <boost/lambda/lambda.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/type_traits/is_same.hpp> + +struct with_result_type { + typedef int result_type; + int operator()() const { return 0; } + int operator()(int) const { return 1; } + int operator()(int, int) const { return 2; } + int operator()(int, int, int) const { return 3; } + int operator()(int, int, int, int) const { return 4; } + int operator()(int, int, int, int, int) const { return 5; } + int operator()(int, int, int, int, int, int) const { return 6; } + int operator()(int, int, int, int, int, int, int) const { return 7; } + int operator()(int, int, int, int, int, int, int, int) const { return 8; } + int operator()(int, int, int, int, int, int, int, int, int) const { return 9; } +}; + +struct with_result_template_value { + template<class Sig> + struct result; + template<class This> + struct result<This()> { + typedef int type; + }; + template<class This, class A1> + struct result<This(A1)> { + BOOST_MPL_ASSERT((boost::is_same<A1, int>)); + typedef int type; + }; + template<class This, class A1, class A2> + struct result<This(A1, A2)> { + BOOST_MPL_ASSERT((boost::is_same<A1, int>)); + BOOST_MPL_ASSERT((boost::is_same<A2, int>)); + typedef int type; + }; + template<class This, class A1, class A2, class A3> + struct result<This(A1, A2, A3)> { + BOOST_MPL_ASSERT((boost::is_same<A1, int>)); + BOOST_MPL_ASSERT((boost::is_same<A2, int>)); + BOOST_MPL_ASSERT((boost::is_same<A3, int>)); + typedef int type; + }; + template<class This, class A1, class A2, class A3, class A4> + struct result<This(A1, A2, A3, A4)> { + BOOST_MPL_ASSERT((boost::is_same<A1, int>)); + BOOST_MPL_ASSERT((boost::is_same<A2, int>)); + BOOST_MPL_ASSERT((boost::is_same<A3, int>)); + BOOST_MPL_ASSERT((boost::is_same<A4, int>)); + typedef int type; + }; + template<class This, class A1, class A2, class A3, class A4, class A5> + struct result<This(A1, A2, A3, A4, A5)> { + BOOST_MPL_ASSERT((boost::is_same<A1, int>)); + BOOST_MPL_ASSERT((boost::is_same<A2, int>)); + BOOST_MPL_ASSERT((boost::is_same<A3, int>)); + BOOST_MPL_ASSERT((boost::is_same<A4, int>)); + BOOST_MPL_ASSERT((boost::is_same<A5, int>)); + typedef int type; + }; + template<class This, class A1, class A2, class A3, class A4, class A5, class A6> + struct result<This(A1, A2, A3, A4, A5, A6)> { + BOOST_MPL_ASSERT((boost::is_same<A1, int>)); + BOOST_MPL_ASSERT((boost::is_same<A2, int>)); + BOOST_MPL_ASSERT((boost::is_same<A3, int>)); + BOOST_MPL_ASSERT((boost::is_same<A4, int>)); + BOOST_MPL_ASSERT((boost::is_same<A5, int>)); + BOOST_MPL_ASSERT((boost::is_same<A6, int>)); + typedef int type; + }; + template<class This, class A1, class A2, class A3, class A4, class A5, class A6, class A7> + struct result<This(A1, A2, A3, A4, A5, A6, A7)> { + BOOST_MPL_ASSERT((boost::is_same<A1, int>)); + BOOST_MPL_ASSERT((boost::is_same<A2, int>)); + BOOST_MPL_ASSERT((boost::is_same<A3, int>)); + BOOST_MPL_ASSERT((boost::is_same<A4, int>)); + BOOST_MPL_ASSERT((boost::is_same<A5, int>)); + BOOST_MPL_ASSERT((boost::is_same<A6, int>)); + BOOST_MPL_ASSERT((boost::is_same<A7, int>)); + typedef int type; + }; + template<class This, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> + struct result<This(A1, A2, A3, A4, A5, A6, A7, A8)> { + BOOST_MPL_ASSERT((boost::is_same<A1, int>)); + BOOST_MPL_ASSERT((boost::is_same<A2, int>)); + BOOST_MPL_ASSERT((boost::is_same<A3, int>)); + BOOST_MPL_ASSERT((boost::is_same<A4, int>)); + BOOST_MPL_ASSERT((boost::is_same<A5, int>)); + BOOST_MPL_ASSERT((boost::is_same<A6, int>)); + BOOST_MPL_ASSERT((boost::is_same<A7, int>)); + BOOST_MPL_ASSERT((boost::is_same<A8, int>)); + typedef int type; + }; + template<class This, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> + struct result<This(A1, A2, A3, A4, A5, A6, A7, A8, A9)> { + BOOST_MPL_ASSERT((boost::is_same<A1, int>)); + BOOST_MPL_ASSERT((boost::is_same<A2, int>)); + BOOST_MPL_ASSERT((boost::is_same<A3, int>)); + BOOST_MPL_ASSERT((boost::is_same<A4, int>)); + BOOST_MPL_ASSERT((boost::is_same<A5, int>)); + BOOST_MPL_ASSERT((boost::is_same<A6, int>)); + BOOST_MPL_ASSERT((boost::is_same<A7, int>)); + BOOST_MPL_ASSERT((boost::is_same<A8, int>)); + BOOST_MPL_ASSERT((boost::is_same<A9, int>)); + typedef int type; + }; + + int operator()() const { return 0; } + int operator()(int) const { return 1; } + int operator()(int, int) const { return 2; } + int operator()(int, int, int) const { return 3; } + int operator()(int, int, int, int) const { return 4; } + int operator()(int, int, int, int, int) const { return 5; } + int operator()(int, int, int, int, int, int) const { return 6; } + int operator()(int, int, int, int, int, int, int) const { return 7; } + int operator()(int, int, int, int, int, int, int, int) const { return 8; } + int operator()(int, int, int, int, int, int, int, int, int) const { return 9; } +}; + +struct with_result_template_reference { + template<class Sig> + struct result; + template<class This> + struct result<This()> { + typedef int type; + }; + template<class This, class A1> + struct result<This(A1)> { + BOOST_MPL_ASSERT((boost::is_same<A1, int&>)); + typedef int type; + }; + template<class This, class A1, class A2> + struct result<This(A1, A2)> { + BOOST_MPL_ASSERT((boost::is_same<A1, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A2, int&>)); + typedef int type; + }; + template<class This, class A1, class A2, class A3> + struct result<This(A1, A2, A3)> { + BOOST_MPL_ASSERT((boost::is_same<A1, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A2, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A3, int&>)); + typedef int type; + }; + template<class This, class A1, class A2, class A3, class A4> + struct result<This(A1, A2, A3, A4)> { + BOOST_MPL_ASSERT((boost::is_same<A1, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A2, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A3, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A4, int&>)); + typedef int type; + }; + template<class This, class A1, class A2, class A3, class A4, class A5> + struct result<This(A1, A2, A3, A4, A5)> { + BOOST_MPL_ASSERT((boost::is_same<A1, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A2, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A3, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A4, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A5, int&>)); + typedef int type; + }; + template<class This, class A1, class A2, class A3, class A4, class A5, class A6> + struct result<This(A1, A2, A3, A4, A5, A6)> { + BOOST_MPL_ASSERT((boost::is_same<A1, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A2, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A3, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A4, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A5, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A6, int&>)); + typedef int type; + }; + template<class This, class A1, class A2, class A3, class A4, class A5, class A6, class A7> + struct result<This(A1, A2, A3, A4, A5, A6, A7)> { + BOOST_MPL_ASSERT((boost::is_same<A1, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A2, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A3, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A4, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A5, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A6, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A7, int&>)); + typedef int type; + }; + template<class This, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> + struct result<This(A1, A2, A3, A4, A5, A6, A7, A8)> { + BOOST_MPL_ASSERT((boost::is_same<A1, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A2, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A3, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A4, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A5, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A6, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A7, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A8, int&>)); + typedef int type; + }; + template<class This, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> + struct result<This(A1, A2, A3, A4, A5, A6, A7, A8, A9)> { + BOOST_MPL_ASSERT((boost::is_same<A1, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A2, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A3, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A4, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A5, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A6, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A7, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A8, int&>)); + BOOST_MPL_ASSERT((boost::is_same<A9, int&>)); + typedef int type; + }; + + int operator()() const { return 0; } + int operator()(int) const { return 1; } + int operator()(int, int) const { return 2; } + int operator()(int, int, int) const { return 3; } + int operator()(int, int, int, int) const { return 4; } + int operator()(int, int, int, int, int) const { return 5; } + int operator()(int, int, int, int, int, int) const { return 6; } + int operator()(int, int, int, int, int, int, int) const { return 7; } + int operator()(int, int, int, int, int, int, int, int) const { return 8; } + int operator()(int, int, int, int, int, int, int, int, int) const { return 9; } +}; + +template<class F> +typename boost::result_of<F()>::type apply0(F f) { + return f(); +} +template<class A, class F> +typename boost::result_of<F(A)>::type apply1(F f, A a) { + return f(a); +} +template<class A, class B, class F> +typename boost::result_of<F(A, B)>::type apply2(F f, A a, B b) { + return f(a, b); +} +template<class A, class B, class C, class F> +typename boost::result_of<F(A, B, C)>::type apply3(F f, A a, B b, C c) { + return f(a, b, c); +} + +using namespace boost::lambda; + +int test_main(int, char *[]) { + BOOST_CHECK(boost::lambda::bind(with_result_type())() == 0); + BOOST_CHECK(boost::lambda::bind(with_result_type(), 1)() == 1); + BOOST_CHECK(boost::lambda::bind(with_result_type(), 1, 2)() == 2); + BOOST_CHECK(boost::lambda::bind(with_result_type(), 1, 2, 3)() == 3); + BOOST_CHECK(boost::lambda::bind(with_result_type(), 1, 2, 3, 4)() == 4); + BOOST_CHECK(boost::lambda::bind(with_result_type(), 1, 2, 3, 4, 5)() == 5); + BOOST_CHECK(boost::lambda::bind(with_result_type(), 1, 2, 3, 4, 5, 6)() == 6); + BOOST_CHECK(boost::lambda::bind(with_result_type(), 1, 2, 3, 4, 5, 6, 7)() == 7); + BOOST_CHECK(boost::lambda::bind(with_result_type(), 1, 2, 3, 4, 5, 6, 7, 8)() == 8); + BOOST_CHECK(boost::lambda::bind(with_result_type(), 1, 2, 3, 4, 5, 6, 7, 8, 9)() == 9); + + // Nullary result_of fails + //BOOST_CHECK(boost::lambda::bind(with_result_template_value())() == 0); + BOOST_CHECK(boost::lambda::bind(with_result_template_value(), 1)() == 1); + BOOST_CHECK(boost::lambda::bind(with_result_template_value(), 1, 2)() == 2); + BOOST_CHECK(boost::lambda::bind(with_result_template_value(), 1, 2, 3)() == 3); + BOOST_CHECK(boost::lambda::bind(with_result_template_value(), 1, 2, 3, 4)() == 4); + BOOST_CHECK(boost::lambda::bind(with_result_template_value(), 1, 2, 3, 4, 5)() == 5); + BOOST_CHECK(boost::lambda::bind(with_result_template_value(), 1, 2, 3, 4, 5, 6)() == 6); + BOOST_CHECK(boost::lambda::bind(with_result_template_value(), 1, 2, 3, 4, 5, 6, 7)() == 7); + BOOST_CHECK(boost::lambda::bind(with_result_template_value(), 1, 2, 3, 4, 5, 6, 7, 8)() == 8); + BOOST_CHECK(boost::lambda::bind(with_result_template_value(), 1, 2, 3, 4, 5, 6, 7, 8, 9)() == 9); + + int one = 1, + two = 2, + three = 3, + four = 4, + five = 5, + six = 6, + seven = 7, + eight = 8, + nine = 9; + + // Nullary result_of fails + //BOOST_CHECK(boost::lambda::bind(with_result_template_reference())() == 0); + BOOST_CHECK(boost::lambda::bind(with_result_template_reference(), var(one))() == 1); + BOOST_CHECK(boost::lambda::bind(with_result_template_reference(), var(one), var(two))() == 2); + BOOST_CHECK(boost::lambda::bind(with_result_template_reference(), var(one), var(two), var(three))() == 3); + BOOST_CHECK(boost::lambda::bind(with_result_template_reference(), var(one), var(two), var(three), var(four))() == 4); + BOOST_CHECK(boost::lambda::bind(with_result_template_reference(), var(one), var(two), var(three), var(four), var(five))() == 5); + BOOST_CHECK(boost::lambda::bind(with_result_template_reference(), var(one), var(two), var(three), var(four), var(five), var(six))() == 6); + BOOST_CHECK(boost::lambda::bind(with_result_template_reference(), var(one), var(two), var(three), var(four), var(five), var(six), var(seven))() == 7); + BOOST_CHECK(boost::lambda::bind(with_result_template_reference(), var(one), var(two), var(three), var(four), var(five), var(six), var(seven), var(eight))() == 8); + BOOST_CHECK(boost::lambda::bind(with_result_template_reference(), var(one), var(two), var(three), var(four), var(five), var(six), var(seven), var(eight), var(nine))() == 9); + + // Check using result_of with lambda functors + //BOOST_CHECK(apply0(constant(0)) == 0); + BOOST_CHECK(apply1<int>(_1, one) == 1); + BOOST_CHECK(apply1<int&>(_1, one) == 1); + BOOST_CHECK(apply1<const int&>(_1, one) == 1); + BOOST_CHECK((apply2<int, int>(_1 + _2, one, two) == 3)); + BOOST_CHECK((apply2<int&, int&>(_1 + _2, one, two) == 3)); + BOOST_CHECK((apply2<const int&, const int&>(_1 + _2, one, two) == 3)); + BOOST_CHECK((apply3<int, int, int>(_1 + _2 + _3, one, two, three) == 6)); + BOOST_CHECK((apply3<int&, int&, int&>(_1 + _2 + _3, one, two, three) == 6)); + BOOST_CHECK((apply3<const int&, const int&, const int&>(_1 + _2 + _3, one, two, three) == 6)); + + return 0; +} diff --git a/src/boost/libs/phoenix/test/bll_compatibility/ret_test.cpp b/src/boost/libs/phoenix/test/bll_compatibility/ret_test.cpp new file mode 100644 index 00000000..82c947f0 --- /dev/null +++ b/src/boost/libs/phoenix/test/bll_compatibility/ret_test.cpp @@ -0,0 +1,53 @@ +// ret_test.cpp - The Boost Lambda Library ----------------------- +// +// Copyright (C) 2009 Steven Watanabe +// +// 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) +// +// For more information, see www.boost.org + +#include <boost/test/minimal.hpp> + +#include <boost/lambda/lambda.hpp> + +#include <boost/mpl/assert.hpp> +#include <boost/type_traits/is_same.hpp> + +template<class R, class F> +void test_ret(R r, F f) { + typename F::result_type x = f(); + BOOST_MPL_ASSERT((boost::is_same<R, typename F::result_type>)); + BOOST_CHECK(x == r); +} + +template<class R, class F, class T1> +void test_ret(R r, F f, T1& t1) { + typename F::result_type x = f(t1); + BOOST_MPL_ASSERT((boost::is_same<R, typename F::result_type>)); + BOOST_CHECK(x == r); +} + +class add_result { +public: + add_result(int i = 0) : value(i) {} + friend bool operator==(const add_result& lhs, const add_result& rhs) { + return(lhs.value == rhs.value); + } +private: + int value; +}; + +class addable {}; +add_result operator+(addable, addable) { + return add_result(7); +} + +int test_main(int, char*[]) { + addable test; + test_ret(add_result(7), boost::lambda::ret<add_result>(boost::lambda::_1 + test), test); + test_ret(8.0, boost::lambda::ret<double>(boost::lambda::constant(7) + 1)); + + return 0; +} diff --git a/src/boost/libs/phoenix/test/bll_compatibility/rvalue_test.cpp b/src/boost/libs/phoenix/test/bll_compatibility/rvalue_test.cpp new file mode 100644 index 00000000..37351855 --- /dev/null +++ b/src/boost/libs/phoenix/test/bll_compatibility/rvalue_test.cpp @@ -0,0 +1,57 @@ +// rvalue_test - test lambda function objects with rvalue arguments +// +// Copyright (c) 2007 Peter Dimov +// +// 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/lambda/lambda.hpp> +#include <boost/detail/lightweight_test.hpp> + +int main() +{ + using namespace boost::lambda; + + int x = 0; + int const y = 1; + int const z = 2; + + BOOST_TEST( _1( x ) == 0 ); + BOOST_TEST( _1( y ) == 1 ); + BOOST_TEST( _1( 2 ) == 2 ); + + BOOST_TEST( _2( x, x ) == 0 ); + BOOST_TEST( _2( x, y ) == 1 ); + BOOST_TEST( _2( x, 2 ) == 2 ); + + BOOST_TEST( _2( 4, x ) == 0 ); + BOOST_TEST( _2( 4, y ) == 1 ); + BOOST_TEST( _2( 4, 2 ) == 2 ); + + (_1 = _2)( x, y ); + BOOST_TEST( x == y ); + + (_1 = _2)( x, 3 ); + BOOST_TEST( x == 3 ); + + (_2 = _1)( z, x ); + BOOST_TEST( x == z ); + + (_2 = _1)( 4, x ); + BOOST_TEST( x == 4 ); + + BOOST_TEST( _3( x, x, x ) == x ); + BOOST_TEST( _3( x, x, y ) == y ); + BOOST_TEST( _3( x, x, 2 ) == 2 ); + + BOOST_TEST( _3( x, 5, x ) == x ); + BOOST_TEST( _3( x, 5, y ) == y ); + BOOST_TEST( _3( x, 5, 2 ) == 2 ); + + BOOST_TEST( _3( 9, 5, x ) == x ); + BOOST_TEST( _3( 9, 5, y ) == y ); + BOOST_TEST( _3( 9, 5, 2 ) == 2 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/bll_compatibility/switch_construct.cpp b/src/boost/libs/phoenix/test/bll_compatibility/switch_construct.cpp new file mode 100644 index 00000000..a0599fe1 --- /dev/null +++ b/src/boost/libs/phoenix/test/bll_compatibility/switch_construct.cpp @@ -0,0 +1,392 @@ +// switch_test.cpp -- The Boost Lambda Library -------------------------- +// +// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) +// +// 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) +// +// For more information, see www.boost.org + +// ----------------------------------------------------------------------- + + +#include <boost/test/minimal.hpp> // see "Header Implementation Option" + + +#include "boost/lambda/lambda.hpp" +#include "boost/lambda/if.hpp" +#include "boost/lambda/switch.hpp" + +#include <iostream> +#include <algorithm> +#include <vector> +#include <string> + + + +// Check that elements 0 -- index are 1, and the rest are 0 +bool check(const std::vector<int>& v, int index) { + using namespace boost::lambda; + int counter = 0; + std::vector<int>::const_iterator + result = std::find_if(v.begin(), v.end(), + ! if_then_else_return( + var(counter)++ <= index, + _1 == 1, + _1 == 0) + ); + return result == v.end(); +} + + + +void do_switch_no_defaults_tests() { + + using namespace boost::lambda; + + int i = 0; + std::vector<int> v,w; + + // elements from 0 to 9 + std::generate_n(std::back_inserter(v), + 10, + var(i)++); + std::fill_n(std::back_inserter(w), 10, 0); + + // --- + std::for_each(v.begin(), v.end(), + switch_statement( + _1, + case_statement<0>(++var(w[0])) + ) + ); + + BOOST_CHECK(check(w, 0)); + std::fill_n(w.begin(), 10, 0); + + // --- + std::for_each(v.begin(), v.end(), + switch_statement( + _1, + case_statement<0>(++var(w[0])), + case_statement<1>(++var(w[1])) + ) + ); + + BOOST_CHECK(check(w, 1)); + std::fill_n(w.begin(), 10, 0); + + // --- + std::for_each(v.begin(), v.end(), + switch_statement( + _1, + case_statement<0>(++var(w[0])), + case_statement<1>(++var(w[1])), + case_statement<2>(++var(w[2])) + ) + ); + + BOOST_CHECK(check(w, 2)); + std::fill_n(w.begin(), 10, 0); + + // --- + std::for_each(v.begin(), v.end(), + switch_statement( + _1, + case_statement<0>(++var(w[0])), + case_statement<1>(++var(w[1])), + case_statement<2>(++var(w[2])), + case_statement<3>(++var(w[3])) + ) + ); + + BOOST_CHECK(check(w, 3)); + std::fill_n(w.begin(), 10, 0); + + // --- + std::for_each(v.begin(), v.end(), + switch_statement( + _1, + case_statement<0>(++var(w[0])), + case_statement<1>(++var(w[1])), + case_statement<2>(++var(w[2])), + case_statement<3>(++var(w[3])), + case_statement<4>(++var(w[4])) + ) + ); + + BOOST_CHECK(check(w, 4)); + std::fill_n(w.begin(), 10, 0); + + // --- + std::for_each(v.begin(), v.end(), + switch_statement( + _1, + case_statement<0>(++var(w[0])), + case_statement<1>(++var(w[1])), + case_statement<2>(++var(w[2])), + case_statement<3>(++var(w[3])), + case_statement<4>(++var(w[4])), + case_statement<5>(++var(w[5])) + ) + ); + + BOOST_CHECK(check(w, 5)); + std::fill_n(w.begin(), 10, 0); + + // --- + std::for_each(v.begin(), v.end(), + switch_statement( + _1, + case_statement<0>(++var(w[0])), + case_statement<1>(++var(w[1])), + case_statement<2>(++var(w[2])), + case_statement<3>(++var(w[3])), + case_statement<4>(++var(w[4])), + case_statement<5>(++var(w[5])), + case_statement<6>(++var(w[6])) + ) + ); + + BOOST_CHECK(check(w, 6)); + std::fill_n(w.begin(), 10, 0); + + // --- + std::for_each(v.begin(), v.end(), + switch_statement( + _1, + case_statement<0>(++var(w[0])), + case_statement<1>(++var(w[1])), + case_statement<2>(++var(w[2])), + case_statement<3>(++var(w[3])), + case_statement<4>(++var(w[4])), + case_statement<5>(++var(w[5])), + case_statement<6>(++var(w[6])), + case_statement<7>(++var(w[7])) + ) + ); + + BOOST_CHECK(check(w, 7)); + std::fill_n(w.begin(), 10, 0); + + // --- + std::for_each(v.begin(), v.end(), + switch_statement( + _1, + case_statement<0>(++var(w[0])), + case_statement<1>(++var(w[1])), + case_statement<2>(++var(w[2])), + case_statement<3>(++var(w[3])), + case_statement<4>(++var(w[4])), + case_statement<5>(++var(w[5])), + case_statement<6>(++var(w[6])), + case_statement<7>(++var(w[7])), + case_statement<8>(++var(w[8])) + ) + ); + + BOOST_CHECK(check(w, 8)); + std::fill_n(w.begin(), 10, 0); + +} + + +void do_switch_yes_defaults_tests() { + + using namespace boost::lambda; + + int i = 0; + std::vector<int> v,w; + + // elements from 0 to 9 + std::generate_n(std::back_inserter(v), + 10, + var(i)++); + std::fill_n(std::back_inserter(w), 10, 0); + + int default_count; + // --- + default_count = 0; + std::for_each(v.begin(), v.end(), + switch_statement( + _1, + default_statement(++var(default_count)) + ) + ); + + BOOST_CHECK(check(w, -1)); + BOOST_CHECK(default_count == 10); + std::fill_n(w.begin(), 10, 0); + + // --- + default_count = 0; + std::for_each(v.begin(), v.end(), + switch_statement( + _1, + case_statement<0>(++var(w[0])), + default_statement(++var(default_count)) + ) + ); + + BOOST_CHECK(check(w, 0)); + BOOST_CHECK(default_count == 9); + std::fill_n(w.begin(), 10, 0); + + // --- + default_count = 0; + std::for_each(v.begin(), v.end(), + switch_statement( + _1, + case_statement<0>(++var(w[0])), + case_statement<1>(++var(w[1])), + default_statement(++var(default_count)) + ) + ); + + BOOST_CHECK(check(w, 1)); + BOOST_CHECK(default_count == 8); + std::fill_n(w.begin(), 10, 0); + + // --- + default_count = 0; + std::for_each(v.begin(), v.end(), + switch_statement( + _1, + case_statement<0>(++var(w[0])), + case_statement<1>(++var(w[1])), + case_statement<2>(++var(w[2])), + default_statement(++var(default_count)) + ) + ); + + BOOST_CHECK(check(w, 2)); + BOOST_CHECK(default_count == 7); + std::fill_n(w.begin(), 10, 0); + + // --- + default_count = 0; + std::for_each(v.begin(), v.end(), + switch_statement( + _1, + case_statement<0>(++var(w[0])), + case_statement<1>(++var(w[1])), + case_statement<2>(++var(w[2])), + case_statement<3>(++var(w[3])), + default_statement(++var(default_count)) + ) + ); + + BOOST_CHECK(check(w, 3)); + BOOST_CHECK(default_count == 6); + std::fill_n(w.begin(), 10, 0); + + // --- + default_count = 0; + std::for_each(v.begin(), v.end(), + switch_statement( + _1, + case_statement<0>(++var(w[0])), + case_statement<1>(++var(w[1])), + case_statement<2>(++var(w[2])), + case_statement<3>(++var(w[3])), + case_statement<4>(++var(w[4])), + default_statement(++var(default_count)) + ) + ); + + BOOST_CHECK(check(w, 4)); + BOOST_CHECK(default_count == 5); + std::fill_n(w.begin(), 10, 0); + + // --- + default_count = 0; + std::for_each(v.begin(), v.end(), + switch_statement( + _1, + case_statement<0>(++var(w[0])), + case_statement<1>(++var(w[1])), + case_statement<2>(++var(w[2])), + case_statement<3>(++var(w[3])), + case_statement<4>(++var(w[4])), + case_statement<5>(++var(w[5])), + default_statement(++var(default_count)) + ) + ); + + BOOST_CHECK(check(w, 5)); + BOOST_CHECK(default_count == 4); + std::fill_n(w.begin(), 10, 0); + + // --- + default_count = 0; + std::for_each(v.begin(), v.end(), + switch_statement( + _1, + case_statement<0>(++var(w[0])), + case_statement<1>(++var(w[1])), + case_statement<2>(++var(w[2])), + case_statement<3>(++var(w[3])), + case_statement<4>(++var(w[4])), + case_statement<5>(++var(w[5])), + case_statement<6>(++var(w[6])), + default_statement(++var(default_count)) + ) + ); + + BOOST_CHECK(check(w, 6)); + BOOST_CHECK(default_count == 3); + std::fill_n(w.begin(), 10, 0); + + // --- + default_count = 0; + std::for_each(v.begin(), v.end(), + switch_statement( + _1, + case_statement<0>(++var(w[0])), + case_statement<1>(++var(w[1])), + case_statement<2>(++var(w[2])), + case_statement<3>(++var(w[3])), + case_statement<4>(++var(w[4])), + case_statement<5>(++var(w[5])), + case_statement<6>(++var(w[6])), + case_statement<7>(++var(w[7])), + default_statement(++var(default_count)) + ) + ); + + BOOST_CHECK(check(w, 7)); + BOOST_CHECK(default_count == 2); + std::fill_n(w.begin(), 10, 0); + +} + +void test_empty_cases() { + + using namespace boost::lambda; + + // --- + switch_statement( + _1, + default_statement() + )(make_const(1)); + + switch_statement( + _1, + case_statement<1>() + )(make_const(1)); + +} + +int test_main(int, char* []) { + + do_switch_no_defaults_tests(); + do_switch_yes_defaults_tests(); + + test_empty_cases(); + + return EXIT_SUCCESS; + +} + diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_and_or_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_and_or_test.cpp new file mode 100644 index 00000000..e0f5767d --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_and_or_test.cpp @@ -0,0 +1,77 @@ +/*============================================================================== + Copyright (c) 2008 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/operator.hpp> + +#include <iostream> +#include <boost/detail/lightweight_test.hpp> + +bool +f(bool x) +{ + return x; +} + +bool +g(bool x) +{ + return !x; +} + +bool +h() +{ + BOOST_ERROR("Short-circuit evaluation failure"); + return false; +} + +template <typename F, typename A1, typename A2, typename R> +void +tester(F f, A1 a1, A2 a2, R r) +{ + BOOST_TEST(f(a1, a2) == r); +} + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + using boost::phoenix::placeholders::_2; + + // && + + tester(bind(f, true) && bind(g, true), false, false, f(true) && g(true)); + tester(bind(f, true) && bind(g, false), false, false, f(true) && g(false)); + + tester(bind(f, false) && bind(h), false, false, f(false) && h()); + + tester(bind(f, _1) && bind(g, _2), true, true, f(true) && g(true)); + tester(bind(f, _1) && bind(g, _2), true, false, f(true) && g(false)); + + tester(bind(f, _1) && bind(h), false, false, f(false) && h()); + + // || + + tester(bind(f, false) || bind(g, true), false, false, f(false) || g(true)); + + tester(bind(f, false) || bind(g, false), false, false, f(false) || g(false)); + + tester(bind(f, true) || bind(h), false, false, f(true) || h()); + + tester(bind(f, _1) || bind(g, _2), false, true, f(false) || g(true)); + tester(bind(f, _1) || bind(g, _2), false, false, f(false) || g(false)); + + tester(bind(f, _1) || bind(h), true, false, f(true) || h()); + + // + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_cdecl_mf_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_cdecl_mf_test.cpp new file mode 100644 index 00000000..79e7577d --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_cdecl_mf_test.cpp @@ -0,0 +1,146 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/detail/lightweight_test.hpp> + +#include <boost/ref.hpp> + +struct X +{ + mutable unsigned int hash; + + X(): hash(0) {} + + int __cdecl f0() { f1(17); return 0; } + int __cdecl g0() const { g1(17); return 0; } + + int __cdecl f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; } + int __cdecl g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; } + + int __cdecl f2(int a1, int a2) { f1(a1); f1(a2); return 0; } + int __cdecl g2(int a1, int a2) const { g1(a1); g1(a2); return 0; } + + int __cdecl f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; } + int __cdecl g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; } + + int __cdecl f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; } + int __cdecl g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; } + + int __cdecl f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; } + int __cdecl g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; } + + int __cdecl f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } + int __cdecl g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } + + int __cdecl f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } + int __cdecl g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } + + int __cdecl f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } + int __cdecl g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } +}; + +void member_function_test() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + + X x; + + // 0 + + bind(&X::f0, &x)(); + bind(&X::f0, ref(x))(); + + bind(&X::g0, &x)(); + bind(&X::g0, x)(); + bind(&X::g0, ref(x))(); + + // 1 + + bind(&X::f1, &x, 1)(); + bind(&X::f1, ref(x), 1)(); + + bind(&X::g1, &x, 1)(); + bind(&X::g1, x, 1)(); + bind(&X::g1, ref(x), 1)(); + + // 2 + + bind(&X::f2, &x, 1, 2)(); + bind(&X::f2, ref(x), 1, 2)(); + + bind(&X::g2, &x, 1, 2)(); + bind(&X::g2, x, 1, 2)(); + bind(&X::g2, ref(x), 1, 2)(); + + // 3 + + bind(&X::f3, &x, 1, 2, 3)(); + bind(&X::f3, ref(x), 1, 2, 3)(); + + bind(&X::g3, &x, 1, 2, 3)(); + bind(&X::g3, x, 1, 2, 3)(); + bind(&X::g3, ref(x), 1, 2, 3)(); + + // 4 + + bind(&X::f4, &x, 1, 2, 3, 4)(); + bind(&X::f4, ref(x), 1, 2, 3, 4)(); + + bind(&X::g4, &x, 1, 2, 3, 4)(); + bind(&X::g4, x, 1, 2, 3, 4)(); + bind(&X::g4, ref(x), 1, 2, 3, 4)(); + + // 5 + + bind(&X::f5, &x, 1, 2, 3, 4, 5)(); + bind(&X::f5, ref(x), 1, 2, 3, 4, 5)(); + + bind(&X::g5, &x, 1, 2, 3, 4, 5)(); + bind(&X::g5, x, 1, 2, 3, 4, 5)(); + bind(&X::g5, ref(x), 1, 2, 3, 4, 5)(); + + // 6 + + bind(&X::f6, &x, 1, 2, 3, 4, 5, 6)(); + bind(&X::f6, ref(x), 1, 2, 3, 4, 5, 6)(); + + bind(&X::g6, &x, 1, 2, 3, 4, 5, 6)(); + bind(&X::g6, x, 1, 2, 3, 4, 5, 6)(); + bind(&X::g6, ref(x), 1, 2, 3, 4, 5, 6)(); + + // 7 + + bind(&X::f7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + bind(&X::g7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + // 8 + + bind(&X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + bind(&X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + BOOST_TEST( x.hash == 23558 ); +} + +int main() +{ + member_function_test(); + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_const_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_const_test.cpp new file mode 100644 index 00000000..7c1daabc --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_const_test.cpp @@ -0,0 +1,184 @@ +/*============================================================================== + Copyright (c) 2001-2004 Peter Dimov and Multi Media Ltd. + Copyright (c) 2001 David Abrahams + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +// + +long f_0() +{ + return 17041L; +} + +long f_1(long a) +{ + return a; +} + +long f_2(long a, long b) +{ + return a + 10 * b; +} + +long f_3(long a, long b, long c) +{ + return a + 10 * b + 100 * c; +} + +long f_4(long a, long b, long c, long d) +{ + return a + 10 * b + 100 * c + 1000 * d; +} + +long f_5(long a, long b, long c, long d, long e) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e; +} + +long f_6(long a, long b, long c, long d, long e, long f) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f; +} + +long f_7(long a, long b, long c, long d, long e, long f, long g) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; +} + +long f_8(long a, long b, long c, long d, long e, long f, long g, long h) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; +} + +long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +long global_result; + +void fv_0() +{ + global_result = 17041L; +} + +void fv_1(long a) +{ + global_result = a; +} + +void fv_2(long a, long b) +{ + global_result = a + 10 * b; +} + +void fv_3(long a, long b, long c) +{ + global_result = a + 10 * b + 100 * c; +} + +void fv_4(long a, long b, long c, long d) +{ + global_result = a + 10 * b + 100 * c + 1000 * d; +} + +void fv_5(long a, long b, long c, long d, long e) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e; +} + +void fv_6(long a, long b, long c, long d, long e, long f) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f; +} + +void fv_7(long a, long b, long c, long d, long e, long f, long g) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; +} + +void fv_8(long a, long b, long c, long d, long e, long f, long g, long h) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; +} + +void fv_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +template<class F, class A> long tester(F const & f, A const & a) +{ + return f(a); +} + +template<class F, class A> long testerv(F const & f, A const & a) +{ + f(a); + return global_result; +} + +void function_test() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + + int const i = 1; + + BOOST_TEST( tester( bind(f_0), i ) == 17041L ); + BOOST_TEST( tester( bind(f_1, _1), i ) == 1L ); + BOOST_TEST( tester( bind(f_2, _1, 2), i ) == 21L ); + BOOST_TEST( tester( bind(f_3, _1, 2, 3), i ) == 321L ); + BOOST_TEST( tester( bind(f_4, _1, 2, 3, 4), i ) == 4321L ); + BOOST_TEST( tester( bind(f_5, _1, 2, 3, 4, 5), i ) == 54321L ); + BOOST_TEST( tester( bind(f_6, _1, 2, 3, 4, 5, 6), i ) == 654321L ); + BOOST_TEST( tester( bind(f_7, _1, 2, 3, 4, 5, 6, 7), i ) == 7654321L ); + BOOST_TEST( tester( bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8), i ) == 87654321L ); + BOOST_TEST( tester( bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9), i ) == 987654321L ); + + BOOST_TEST( testerv( bind(fv_0), i ) == 17041L ); + BOOST_TEST( testerv( bind(fv_1, _1), i ) == 1L ); + BOOST_TEST( testerv( bind(fv_2, _1, 2), i ) == 21L ); + BOOST_TEST( testerv( bind(fv_3, _1, 2, 3), i ) == 321L ); + BOOST_TEST( testerv( bind(fv_4, _1, 2, 3, 4), i ) == 4321L ); + BOOST_TEST( testerv( bind(fv_5, _1, 2, 3, 4, 5), i ) == 54321L ); + BOOST_TEST( testerv( bind(fv_6, _1, 2, 3, 4, 5, 6), i ) == 654321L ); + BOOST_TEST( testerv( bind(fv_7, _1, 2, 3, 4, 5, 6, 7), i ) == 7654321L ); + BOOST_TEST( testerv( bind(fv_8, _1, 2, 3, 4, 5, 6, 7, 8), i ) == 87654321L ); + BOOST_TEST( testerv( bind(fv_9, _1, 2, 3, 4, 5, 6, 7, 8, 9), i ) == 987654321L ); +} + +int main() +{ + function_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_cv_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_cv_test.cpp new file mode 100644 index 00000000..6a332637 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_cv_test.cpp @@ -0,0 +1,165 @@ +/*============================================================================== + Copyright (c) 2004 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + typedef int result_type; + + int operator()() + { + return 17041; + } + + int operator()() const + { + return -17041; + } + + int operator()(int x1) + { + return x1; + } + + int operator()(int x1) const + { + return -x1; + } + + int operator()(int x1, int x2) + { + return x1+x2; + } + + int operator()(int x1, int x2) const + { + return -(x1+x2); + } + + int operator()(int x1, int x2, int x3) + { + return x1+x2+x3; + } + + int operator()(int x1, int x2, int x3) const + { + return -(x1+x2+x3); + } + + int operator()(int x1, int x2, int x3, int x4) + { + return x1+x2+x3+x4; + } + + int operator()(int x1, int x2, int x3, int x4) const + { + return -(x1+x2+x3+x4); + } + + int operator()(int x1, int x2, int x3, int x4, int x5) + { + return x1+x2+x3+x4+x5; + } + + int operator()(int x1, int x2, int x3, int x4, int x5) const + { + return -(x1+x2+x3+x4+x5); + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6) + { + return x1+x2+x3+x4+x5+x6; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6) const + { + return -(x1+x2+x3+x4+x5+x6); + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7) + { + return x1+x2+x3+x4+x5+x6+x7; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7) const + { + return -(x1+x2+x3+x4+x5+x6+x7); + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8) + { + return x1+x2+x3+x4+x5+x6+x7+x8; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8) const + { + return -(x1+x2+x3+x4+x5+x6+x7+x8); + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9) + { + return x1+x2+x3+x4+x5+x6+x7+x8+x9; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9) const + { + return -(x1+x2+x3+x4+x5+x6+x7+x8+x9); + } +}; + +template<class F> void test(F f, int r) +{ + F const & cf = f; + BOOST_TEST( cf() == -r ); + BOOST_TEST( f() == r ); + +} + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + using boost::phoenix::cref; + + test( bind(X()), 17041); + test( bind(X(), 1), 1); + test( bind(X(), 1, 2), 1+2); + test( bind(X(), 1, 2, 3), 1+2+3); + test( bind(X(), 1, 2, 3, 4), 1+2+3+4); + test( bind(X(), 1, 2, 3, 4, 5), 1+2+3+4+5); + test( bind(X(), 1, 2, 3, 4, 5, 6), 1+2+3+4+5+6); + test( bind(X(), 1, 2, 3, 4, 5, 6, 7), 1+2+3+4+5+6+7); + test( bind(X(), 1, 2, 3, 4, 5, 6, 7, 8), 1+2+3+4+5+6+7+8); + test( bind(X(), 1, 2, 3, 4, 5, 6, 7, 8, 9), 1+2+3+4+5+6+7+8+9); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm1_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm1_test.cpp new file mode 100644 index 00000000..68f50c07 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm1_test.cpp @@ -0,0 +1,77 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + int m; +}; + +X f( int v ) +{ + X r = { v }; + return r; +} + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + using boost::phoenix::placeholders::_1; + + X x = { 17041 }; + X * px = &x; + + BOOST_TEST( bind( &X::m, _1 )( x ) == 17041 ); + BOOST_TEST( bind( &X::m, _1 )( px ) == 17041 ); + + BOOST_TEST( bind( &X::m, x )() == 17041 ); + BOOST_TEST( bind( &X::m, px )() == 17041 ); + BOOST_TEST( bind( &X::m, ref(x) )() == 17041 ); + + + X const cx = x; + X const * pcx = &cx; + + BOOST_TEST( bind( &X::m, _1 )( cx ) == 17041 ); + BOOST_TEST( bind( &X::m, _1 )( pcx ) == 17041 ); + + BOOST_TEST( bind( &X::m, cx )() == 17041 ); + BOOST_TEST( bind( &X::m, pcx )() == 17041 ); + BOOST_TEST( bind( &X::m, ref(cx) )() == 17041 ); + + int const v = 42; + // Change bind_dm_test.cpp to bind to _1 twice. + BOOST_TEST( bind( &X::m, _1)( bind( f, _1 )( v ) ) == v ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm2_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm2_test.cpp new file mode 100644 index 00000000..43680def --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm2_test.cpp @@ -0,0 +1,74 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> +#include <string> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + int m; +}; + +struct Y +{ + char m[ 64 ]; +}; + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + using boost::phoenix::placeholders::_1; + + X x = { 0 }; + X * px = &x; + + bind( &X::m, _1 )( px ) = 42; + + BOOST_TEST( x.m == 42 ); + + bind( &X::m, ref(x) )() = 17041; + + BOOST_TEST( x.m == 17041 ); + + X const * pcx = &x; + + BOOST_TEST( bind( &X::m, _1 )( pcx ) == 17041L ); + BOOST_TEST( bind( &X::m, pcx )() == 17041L ); + + Y y = { "test" }; + std::string v( "test" ); + + BOOST_TEST( bind( &Y::m, &y )() == v ); + BOOST_TEST( bind( &Y::m, &y )() == v ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm3_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm3_test.cpp new file mode 100644 index 00000000..d50a4eaf --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm3_test.cpp @@ -0,0 +1,55 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> +#include <utility> + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + + typedef std::pair<int, int> pair_type; + + pair_type pair( 10, 20 ); + +#if defined(BOOST_MSVC) && (BOOST_MSVC >= 1600) && (BOOST_MSVC < 1700) +// bind is being confused with 'std::tr1::_Bind' to be found here +// C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxbind1(485) + int const & x = boost::phoenix::bind( &pair_type::first, _1 )( pair ); +#else + int const & x = bind( &pair_type::first, _1 )( pair ); +#endif + + BOOST_TEST( &pair.first == &x ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm_test.cpp new file mode 100644 index 00000000..5de4fc02 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_dm_test.cpp @@ -0,0 +1,88 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + int m; +}; + +X f( int v ) +{ + X r = { v }; + return r; +} + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + using boost::phoenix::placeholders::_1; + + X x = { 17041 }; + X * px = &x; + + BOOST_TEST( bind( &X::m, _1 )( x ) == 17041 ); + BOOST_TEST( bind( &X::m, _1 )( px ) == 17041 ); + + BOOST_TEST( bind( &X::m, x )() == 17041 ); + BOOST_TEST( bind( &X::m, px )() == 17041 ); + BOOST_TEST( bind( &X::m, ref(x) )() == 17041 ); + + + X const cx = x; + X const * pcx = &cx; + + BOOST_TEST( bind( &X::m, _1 )( cx ) == 17041 ); + BOOST_TEST( bind( &X::m, _1 )( pcx ) == 17041 ); + + BOOST_TEST( bind( &X::m, cx )() == 17041 ); + BOOST_TEST( bind( &X::m, pcx )() == 17041 ); + BOOST_TEST( bind( &X::m, ref(cx) )() == 17041 ); + + int const v = 42; + +// NOTE: The second case does not work with compiler optimization. +// This is a bug which has not yet been fixed. +// The current test for gcc 4.7.3 does use -O2 but does not +// satisfy this first part of the test for some unknown reason. +// So this is set to run the first case for all gcc 4.7 +#if (defined(__OPTIMIZE__) && __OPTIMIZE__) || \ + defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 40700) && (BOOST_GCC_VERSION < 40800) + // Change bind_dm_test.cpp to bind to _1 twice. + BOOST_TEST( bind( &X::m, _1)( bind( f, _1 )( v ) ) == v ); +#else + BOOST_TEST( bind( &X::m, bind( f, _1 ) )( v ) == v ); +#endif + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_eq2_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_eq2_test.cpp new file mode 100644 index 00000000..b7203f49 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_eq2_test.cpp @@ -0,0 +1,52 @@ +/*============================================================================== + Copyright (c) 2004, 2005, 2009 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/function_equal.hpp> +#include <boost/detail/lightweight_test.hpp> + +void f( int ) +{ +} + +int g( int i ) +{ + return i + 5; +} + +template< class F > void test_self_equal( F f ) +{ +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP + using boost::function_equal; +#endif + + BOOST_TEST( function_equal( f, f ) ); +} + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + + test_self_equal( bind( f, _1 ) ); + test_self_equal( bind( g, _1 ) ); + test_self_equal( bind( f, bind( g, _1 ) ) ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_eq3_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_eq3_test.cpp new file mode 100644 index 00000000..7340b63c --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_eq3_test.cpp @@ -0,0 +1,48 @@ +/*============================================================================== + Copyright (c) 2004, 2005, 2009 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/function_equal.hpp> +#include <boost/weak_ptr.hpp> +#include <boost/detail/lightweight_test.hpp> + +int f( boost::weak_ptr<void> wp ) +{ + return wp.use_count(); +} + +template< class F > void test_self_equal( F f ) +{ +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP + using boost::function_equal; +#endif + + BOOST_TEST( function_equal( f, f ) ); +} + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + + test_self_equal( bind( f, _1 ) ); + test_self_equal( bind( f, boost::weak_ptr<void>() ) ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_eq_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_eq_test.cpp new file mode 100644 index 00000000..ba33d531 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_eq_test.cpp @@ -0,0 +1,438 @@ +/*============================================================================== + Copyright (c) 2004, 2005, 2009 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP +# include <boost/function_equal.hpp> +#endif + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + int i_; + + explicit X(int i): i_(i) + { + } + + bool operator==(X const & rhs) const + { + return i_ == rhs.i_; + } +}; + +// f_* + +int f_0() +{ + return 0; +} + +int f_1(X) +{ + return 0; +} + +int f_2(X, X) +{ + return 0; +} + +int f_3(X, X, X) +{ + return 0; +} + +int f_4(X, X, X, X) +{ + return 0; +} + +int f_5(X, X, X, X, X) +{ + return 0; +} + +int f_6(X, X, X, X, X, X) +{ + return 0; +} + +int f_7(X, X, X, X, X, X, X) +{ + return 0; +} + +int f_8(X, X, X, X, X, X, X, X) +{ + return 0; +} + +int f_9(X, X, X, X, X, X, X, X, X) +{ + return 0; +} + +// fv_* + +void fv_0() +{ +} + +void fv_1(X) +{ +} + +void fv_2(X, X) +{ +} + +void fv_3(X, X, X) +{ +} + +void fv_4(X, X, X, X) +{ +} + +void fv_5(X, X, X, X, X) +{ +} + +void fv_6(X, X, X, X, X, X) +{ +} + +void fv_7(X, X, X, X, X, X, X) +{ +} + +void fv_8(X, X, X, X, X, X, X, X) +{ +} + +void fv_9(X, X, X, X, X, X, X, X, X) +{ +} + +template<class F> void test_eq(F f1, F f2) +{ +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP + + using boost::function_equal; + +#endif + + BOOST_TEST( function_equal( f1, f2 ) ); +} + +template<class F> void test_ne(F f1, F f2) +{ +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP + + using boost::function_equal; + +#endif + + BOOST_TEST( !function_equal( f1, f2 ) ); +} + +using boost::phoenix::bind; +using boost::phoenix::ref; +using boost::phoenix::placeholders::_1; +using boost::phoenix::placeholders::_2; +using boost::phoenix::placeholders::_3; +using boost::phoenix::placeholders::_4; +using boost::phoenix::placeholders::_5; +using boost::phoenix::placeholders::_6; +using boost::phoenix::placeholders::_7; +using boost::phoenix::placeholders::_8; +using boost::phoenix::placeholders::_9; + +// 0 + +template<class F> void test_0(F f) +{ + test_eq( bind(f), bind(f) ); +} + +// 1 + +template<class F, class V> void test_1_(F f, V v1, V v2) +{ + test_eq( bind(f, v1), bind(f, v1) ); + test_ne( bind(f, v1), bind(f, v2) ); +} + +template<class F> void test_1(F f) +{ + test_eq( bind(f, _1), bind(f, _1) ); + + test_1_( f, X(1), X(2) ); + + X a(0), b(0); + test_1_( f, ref(a), ref(b) ); +} + +// 2 + +template<class F, class V> void test_2_(F f, V v1, V v2) +{ + test_eq( bind(f, v1, v1), bind(f, v1, v1) ); + test_ne( bind(f, v1, v1), bind(f, v1, v2) ); + test_ne( bind(f, v1, v1), bind(f, v2, v1) ); +} + +template<class F> void test_2(F f) +{ + test_eq( bind(f, _1, _2), bind(f, _1, _2) ); + + test_2_( f, X(1), X(2) ); + + X a(0), b(0); + test_2_( f, ref(a), ref(b) ); +} + +// 3 + +template<class F, class V> void test_3_(F f, V v1, V v2) +{ + test_eq( bind(f, v1, v1, v1), bind(f, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1), bind(f, v1, v1, v2) ); + test_ne( bind(f, v1, v1, v1), bind(f, v1, v2, v1) ); + test_ne( bind(f, v1, v1, v1), bind(f, v2, v1, v1) ); +} + +template<class F> void test_3(F f) +{ + test_eq( bind(f, _1, _2, _3), bind(f, _1, _2, _3) ); + + test_3_( f, X(1), X(2) ); + + X a(0), b(0); + test_3_( f, ref(a), ref(b) ); +} + +// 4 + +template<class F, class V> void test_4_(F f, V v1, V v2) +{ + test_eq( bind(f, v1, v1, v1, v1), bind(f, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1), bind(f, v1, v1, v1, v2) ); + test_ne( bind(f, v1, v1, v1, v1), bind(f, v1, v1, v2, v1) ); + test_ne( bind(f, v1, v1, v1, v1), bind(f, v1, v2, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1), bind(f, v2, v1, v1, v1) ); +} + +template<class F> void test_4(F f) +{ + test_eq( bind(f, _1, _2, _3, _4), bind(f, _1, _2, _3, _4) ); + + test_4_( f, X(1), X(2) ); + + X a(0), b(0); + test_4_( f, ref(a), ref(b) ); +} + +// 5 + +template<class F, class V> void test_5_(F f, V v1, V v2) +{ + test_eq( bind(f, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v2) ); + test_ne( bind(f, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v2, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1), bind(f, v1, v1, v2, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1), bind(f, v1, v2, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1), bind(f, v2, v1, v1, v1, v1) ); +} + +template<class F> void test_5(F f) +{ + test_eq( bind(f, _1, _2, _3, _4, _5), bind(f, _1, _2, _3, _4, _5) ); + + test_5_( f, X(1), X(2) ); + + X a(0), b(0); + test_5_( f, ref(a), ref(b) ); +} + +// 6 + +template<class F, class V> void test_6_(F f, V v1, V v2) +{ + test_eq( bind(f, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v2) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v2, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v2, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v2, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1), bind(f, v1, v2, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1), bind(f, v2, v1, v1, v1, v1, v1) ); +} + +template<class F> void test_6(F f) +{ + test_eq( bind(f, _1, _2, _3, _4, _5, _6), bind(f, _1, _2, _3, _4, _5, _6) ); + + test_6_( f, X(1), X(2) ); + + X a(0), b(0); + test_6_( f, ref(a), ref(b) ); +} + +// 7 + +template<class F, class V> void test_7_(F f, V v1, V v2) +{ + test_eq( bind(f, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1, v2) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v2, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v2, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v2, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v2, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v2, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1), bind(f, v2, v1, v1, v1, v1, v1, v1) ); +} + +template<class F> void test_7(F f) +{ + test_eq( bind(f, _1, _2, _3, _4, _5, _6, _7), bind(f, _1, _2, _3, _4, _5, _6, _7) ); + + test_7_( f, X(1), X(2) ); + + X a(0), b(0); + test_7_( f, ref(a), ref(b) ); +} + +// 8 + +template<class F, class V> void test_8_(F f, V v1, V v2) +{ + test_eq( bind(f, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1, v1, v2) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1, v2, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v2, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v2, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v2, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v2, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v2, v1, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v2, v1, v1, v1, v1, v1, v1, v1) ); +} + +template<class F> void test_8(F f) +{ + test_eq( bind(f, _1, _2, _3, _4, _5, _6, _7, _8), bind(f, _1, _2, _3, _4, _5, _6, _7, _8) ); + + test_8_( f, X(1), X(2) ); + + X a(0), b(0); + test_8_( f, ref(a), ref(b) ); +} + +// 9 + +template<class F, class V> void test_9_(F f, V v1, V v2) +{ + test_eq( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v2) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1, v1, v2, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v1, v2, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v1, v2, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v1, v2, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v1, v2, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v1, v2, v1, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v1, v2, v1, v1, v1, v1, v1, v1, v1) ); + test_ne( bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), bind(f, v2, v1, v1, v1, v1, v1, v1, v1, v1) ); +} + +template<class F> void test_9(F f) +{ + test_eq( bind(f, _1, _2, _3, _4, _5, _6, _7, _8, _9), bind(f, _1, _2, _3, _4, _5, _6, _7, _8, _9) ); + + test_9_( f, X(1), X(2) ); + + X a(0), b(0); + test_9_( f, ref(a), ref(b) ); +} + +int main() +{ + // 0 + + test_0( f_0 ); + test_0( fv_0 ); + + // 1 + + test_1( f_1 ); + test_1( fv_1 ); + + // 2 + + test_2( f_2 ); + test_2( fv_2 ); + + // 3 + + test_3( f_3 ); + test_3( fv_3 ); + + // 4 + + test_4( f_4 ); + test_4( fv_4 ); + + // 5 + + test_5( f_5 ); + test_5( fv_5 ); + + // 6 + + test_6( f_6 ); + test_6( fv_6 ); + + // 7 + + test_7( f_7 ); + test_7( fv_7 ); + + // 8 + + test_8( f_8 ); + test_8( fv_8 ); + + // 9 + + test_9( f_9 ); + test_9( fv_9 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fastcall_mf_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fastcall_mf_test.cpp new file mode 100644 index 00000000..1c7a6baa --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fastcall_mf_test.cpp @@ -0,0 +1,165 @@ +/*============================================================================== + Copyright (c) 2001 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#define BOOST_MEM_FN_ENABLE_FASTCALL + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + mutable unsigned int hash; + + X(): hash(0) {} + + void __fastcall f0() { f1(17); } + void __fastcall g0() const { g1(17); } + + void __fastcall f1(int a1) { hash = (hash * 17041 + a1) % 32768; } + void __fastcall g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; } + + void __fastcall f2(int a1, int a2) { f1(a1); f1(a2); } + void __fastcall g2(int a1, int a2) const { g1(a1); g1(a2); } + + void __fastcall f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); } + void __fastcall g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); } + + void __fastcall f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); } + void __fastcall g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); } + + void __fastcall f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); } + void __fastcall g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); } + + void __fastcall f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); } + void __fastcall g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); } + + void __fastcall f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); } + void __fastcall g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); } + + void __fastcall f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); } + void __fastcall g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); } +}; + +void member_function_test() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + + X x; + + // 0 + + bind(&X::f0, &x)(); + bind(&X::f0, ref(x))(); + + bind(&X::g0, &x)(); + bind(&X::g0, x)(); + bind(&X::g0, ref(x))(); + + // 1 + + bind(&X::f1, &x, 1)(); + bind(&X::f1, ref(x), 1)(); + + bind(&X::g1, &x, 1)(); + bind(&X::g1, x, 1)(); + bind(&X::g1, ref(x), 1)(); + + // 2 + + bind(&X::f2, &x, 1, 2)(); + bind(&X::f2, ref(x), 1, 2)(); + + bind(&X::g2, &x, 1, 2)(); + bind(&X::g2, x, 1, 2)(); + bind(&X::g2, ref(x), 1, 2)(); + + // 3 + + bind(&X::f3, &x, 1, 2, 3)(); + bind(&X::f3, ref(x), 1, 2, 3)(); + + bind(&X::g3, &x, 1, 2, 3)(); + bind(&X::g3, x, 1, 2, 3)(); + bind(&X::g3, ref(x), 1, 2, 3)(); + + // 4 + + bind(&X::f4, &x, 1, 2, 3, 4)(); + bind(&X::f4, ref(x), 1, 2, 3, 4)(); + + bind(&X::g4, &x, 1, 2, 3, 4)(); + bind(&X::g4, x, 1, 2, 3, 4)(); + bind(&X::g4, ref(x), 1, 2, 3, 4)(); + + // 5 + + bind(&X::f5, &x, 1, 2, 3, 4, 5)(); + bind(&X::f5, ref(x), 1, 2, 3, 4, 5)(); + + bind(&X::g5, &x, 1, 2, 3, 4, 5)(); + bind(&X::g5, x, 1, 2, 3, 4, 5)(); + bind(&X::g5, ref(x), 1, 2, 3, 4, 5)(); + + // 6 + + bind(&X::f6, &x, 1, 2, 3, 4, 5, 6)(); + bind(&X::f6, ref(x), 1, 2, 3, 4, 5, 6)(); + + bind(&X::g6, &x, 1, 2, 3, 4, 5, 6)(); + bind(&X::g6, x, 1, 2, 3, 4, 5, 6)(); + bind(&X::g6, ref(x), 1, 2, 3, 4, 5, 6)(); + + // 7 + + bind(&X::f7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + bind(&X::g7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + // 8 + + bind(&X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + bind(&X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + BOOST_TEST( x.hash == 23558 ); +} + +int main() +{ + member_function_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fastcall_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fastcall_test.cpp new file mode 100644 index 00000000..14033a5c --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fastcall_test.cpp @@ -0,0 +1,110 @@ +/*============================================================================== + Copyright (c) 2002 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#define BOOST_BIND_ENABLE_FASTCALL + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +// + +long __fastcall f_0() +{ + return 17041L; +} + +long __fastcall f_1(long a) +{ + return a; +} + +long __fastcall f_2(long a, long b) +{ + return a + 10 * b; +} + +long __fastcall f_3(long a, long b, long c) +{ + return a + 10 * b + 100 * c; +} + +long __fastcall f_4(long a, long b, long c, long d) +{ + return a + 10 * b + 100 * c + 1000 * d; +} + +long __fastcall f_5(long a, long b, long c, long d, long e) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e; +} + +long __fastcall f_6(long a, long b, long c, long d, long e, long f) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f; +} + +long __fastcall f_7(long a, long b, long c, long d, long e, long f, long g) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; +} + +long __fastcall f_8(long a, long b, long c, long d, long e, long f, long g, long h) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; +} + +long __fastcall f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +void function_test() +{ + using boost::phoenix::bind; + + int const i = 1; + + BOOST_TEST( bind(f_0)(i) == 17041L ); + BOOST_TEST( bind(f_1, _1)(i) == 1L ); + BOOST_TEST( bind(f_2, _1, 2)(i) == 21L ); + BOOST_TEST( bind(f_3, _1, 2, 3)(i) == 321L ); + BOOST_TEST( bind(f_4, _1, 2, 3, 4)(i) == 4321L ); + BOOST_TEST( bind(f_5, _1, 2, 3, 4, 5)(i) == 54321L ); + BOOST_TEST( bind(f_6, _1, 2, 3, 4, 5, 6)(i) == 654321L ); + BOOST_TEST( bind(f_7, _1, 2, 3, 4, 5, 6, 7)(i) == 7654321L ); + BOOST_TEST( bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8)(i) == 87654321L ); + BOOST_TEST( bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i) == 987654321L ); +} + +int main() +{ + function_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fn2_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fn2_test.cpp new file mode 100644 index 00000000..8bb3cfe2 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fn2_test.cpp @@ -0,0 +1,171 @@ +/*============================================================================== + Copyright (c) 2005, 2008 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +long global_result; + +// long + +long f_0() +{ + return global_result = 17041L; +} + +long f_1(long a) +{ + return global_result = a; +} + +long f_2(long a, long b) +{ + return global_result = a + 10 * b; +} + +long f_3(long a, long b, long c) +{ + return global_result = a + 10 * b + 100 * c; +} + +long f_4(long a, long b, long c, long d) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d; +} + +long f_5(long a, long b, long c, long d, long e) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e; +} + +long f_6(long a, long b, long c, long d, long e, long f) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f; +} + +long f_7(long a, long b, long c, long d, long e, long f, long g) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; +} + +long f_8(long a, long b, long c, long d, long e, long f, long g, long h) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; +} + +long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +// void + +void fv_0() +{ + global_result = 17041L; +} + +void fv_1(long a) +{ + global_result = a; +} + +void fv_2(long a, long b) +{ + global_result = a + 10 * b; +} + +void fv_3(long a, long b, long c) +{ + global_result = a + 10 * b + 100 * c; +} + +void fv_4(long a, long b, long c, long d) +{ + global_result = a + 10 * b + 100 * c + 1000 * d; +} + +void fv_5(long a, long b, long c, long d, long e) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e; +} + +void fv_6(long a, long b, long c, long d, long e, long f) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f; +} + +void fv_7(long a, long b, long c, long d, long e, long f, long g) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; +} + +void fv_8(long a, long b, long c, long d, long e, long f, long g, long h) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; +} + +void fv_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +void function_test() +{ + using boost::phoenix::bind; + + bind( f_0 )(); BOOST_TEST( global_result == 17041L ); + bind( f_1, 1 )(); BOOST_TEST( global_result == 1L ); + bind( f_2, 1, 2 )(); BOOST_TEST( global_result == 21L ); + bind( f_3, 1, 2, 3 )(); BOOST_TEST( global_result == 321L ); + bind( f_4, 1, 2, 3, 4 )(); BOOST_TEST( global_result == 4321L ); + bind( f_5, 1, 2, 3, 4, 5 )(); BOOST_TEST( global_result == 54321L ); + bind( f_6, 1, 2, 3, 4, 5, 6 )(); BOOST_TEST( global_result == 654321L ); + bind( f_7, 1, 2, 3, 4, 5, 6, 7 )(); BOOST_TEST( global_result == 7654321L ); + bind( f_8, 1, 2, 3, 4, 5, 6, 7, 8 )(); BOOST_TEST( global_result == 87654321L ); + bind( f_9, 1, 2, 3, 4, 5, 6, 7, 8, 9 )(); BOOST_TEST( global_result == 987654321L ); + + bind( fv_0 )(); BOOST_TEST( global_result == 17041L ); + bind( fv_1, 1 )(); BOOST_TEST( global_result == 1L ); + bind( fv_2, 1, 2 )(); BOOST_TEST( global_result == 21L ); + bind( fv_3, 1, 2, 3 )(); BOOST_TEST( global_result == 321L ); + bind( fv_4, 1, 2, 3, 4 )(); BOOST_TEST( global_result == 4321L ); + bind( fv_5, 1, 2, 3, 4, 5 )(); BOOST_TEST( global_result == 54321L ); + bind( fv_6, 1, 2, 3, 4, 5, 6 )(); BOOST_TEST( global_result == 654321L ); + bind( fv_7, 1, 2, 3, 4, 5, 6, 7 )(); BOOST_TEST( global_result == 7654321L ); + bind( fv_8, 1, 2, 3, 4, 5, 6, 7, 8 )(); BOOST_TEST( global_result == 87654321L ); + bind( fv_9, 1, 2, 3, 4, 5, 6, 7, 8, 9 )(); BOOST_TEST( global_result == 987654321L ); +} + +int main() +{ + function_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fnobj2_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fnobj2_test.cpp new file mode 100644 index 00000000..c03b3e93 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_fnobj2_test.cpp @@ -0,0 +1,79 @@ +/*============================================================================== + Copyright (c) 2005, 2008 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + mutable unsigned int hash; + + typedef int result_type; + + X(): hash(0) {} + + int operator()() const { operator()(17); return 0; } + int operator()(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; } + int operator()(int a1, int a2) const { operator()(a1); operator()(a2); return 0; } + int operator()(int a1, int a2, int a3) const { operator()(a1, a2); operator()(a3); return 0; } + int operator()(int a1, int a2, int a3, int a4) const { operator()(a1, a2, a3); operator()(a4); return 0; } + int operator()(int a1, int a2, int a3, int a4, int a5) const { operator()(a1, a2, a3, a4); operator()(a5); return 0; } + int operator()(int a1, int a2, int a3, int a4, int a5, int a6) const { operator()(a1, a2, a3, a4, a5); operator()(a6); return 0; } + int operator()(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { operator()(a1, a2, a3, a4, a5, a6); operator()(a7); return 0; } + int operator()(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { operator()(a1, a2, a3, a4, a5, a6, a7); operator()(a8); return 0; } + int operator()(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9) const { operator()(a1, a2, a3, a4, a5, a6, a7, a8); operator()(a9); return 0; } +}; + +void function_object_test() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + + X x; + + bind(ref(x) )(); + bind(ref(x), 1 )(); + bind(ref(x), 1, 2 )(); + bind(ref(x), 1, 2, 3 )(); + bind(ref(x), 1, 2, 3, 4 )(); + bind(ref(x), 1, 2, 3, 4, 5 )(); + bind(ref(x), 1, 2, 3, 4, 5, 6 )(); + bind(ref(x), 1, 2, 3, 4, 5, 6, 7)(); + bind(ref(x), 1, 2, 3, 4, 5, 6, 7, 8 )(); + bind(ref(x), 1, 2, 3, 4, 5, 6, 7, 8, 9 )(); + + BOOST_TEST( x.hash == 9932 ); +} + +int main() +{ + function_object_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_function_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_function_test.cpp new file mode 100644 index 00000000..1e9c4425 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_function_test.cpp @@ -0,0 +1,79 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/detail/lightweight_test.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> +#include <boost/function.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +int f( int x ) +{ + return x; +} + +int g( int x ) +{ + return x + 1; +} + +int main() +{ + using boost::phoenix::bind; + + boost::function0<int> fn; + + BOOST_TEST( !fn.contains( bind( f, 1 ) ) ); + BOOST_TEST( !fn.contains( bind( f, 2 ) ) ); + BOOST_TEST( !fn.contains( bind( g, 1 ) ) ); + + fn = bind( f, 1 ); + + BOOST_TEST( fn() == 1 ); + + BOOST_TEST( fn.contains( bind( f, 1 ) ) ); + BOOST_TEST( !fn.contains( bind( f, 2 ) ) ); + BOOST_TEST( !fn.contains( bind( g, 1 ) ) ); + + fn = bind( f, 2 ); + + BOOST_TEST( fn() == 2 ); + + BOOST_TEST( !fn.contains( bind( f, 1 ) ) ); + BOOST_TEST( fn.contains( bind( f, 2 ) ) ); + BOOST_TEST( !fn.contains( bind( g, 1 ) ) ); + + fn = bind( g, 1 ); + + BOOST_TEST( fn() == 2 ); + + BOOST_TEST( !fn.contains( bind( f, 1 ) ) ); + BOOST_TEST( !fn.contains( bind( f, 2 ) ) ); + BOOST_TEST( fn.contains( bind( g, 1 ) ) ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_interoperation_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_interoperation_test.cpp new file mode 100644 index 00000000..fdce19a5 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_interoperation_test.cpp @@ -0,0 +1,142 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/function.hpp> +#include <boost/bind.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/detail/lightweight_test.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> +#include <boost/function.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +int f1( int x ) +{ + return x; +} + +int f2( int x, int y ) +{ + return x + y; +} + +struct X +{ + mutable int n; + + X() : n(0) {} + + int f0() { n += f1(17); return n; } + int g0() const { n += g1(17); return n; } + + + int f1(int a1) { return a1; } + int g1(int a1) const { return a1; } +}; + +struct Y +{ + int m; +}; + +namespace phx = boost::phoenix; +using phx::placeholders::arg1; +using phx::placeholders::arg2; +using boost::phoenix::ref; + +void member_test() +{ + Y y = { 17041 }; + Y * py = &y; + + BOOST_TEST( boost::bind( &Y::m, _1 )( y ) == 17041 ); + BOOST_TEST( boost::bind( &Y::m, _1 )( py ) == 17041 ); + + BOOST_TEST( phx::bind( &Y::m, _1 )( y ) == 17041 ); + BOOST_TEST( phx::bind( &Y::m, _1 )( py ) == 17041 ); + + BOOST_TEST( phx::bind( &Y::m, arg1 )( y ) == 17041 ); + BOOST_TEST( phx::bind( &Y::m, arg1 )( py ) == 17041 ); + + BOOST_TEST( boost::bind( &Y::m, y )() == 17041 ); + BOOST_TEST( boost::bind( &Y::m, py )() == 17041 ); + //BOOST_TEST( boost::bind( &Y::m, ref(y) )() == 17041 ); + + BOOST_TEST( phx::bind( &Y::m, y )() == 17041 ); + BOOST_TEST( phx::bind( &Y::m, py )() == 17041 ); + BOOST_TEST( phx::bind( &Y::m, ref(y) )() == 17041 ); + + return; +} + +void member_function_test() +{ + + X x; + + // 0 + + BOOST_TEST(boost::bind(&X::f0, &x )() == 17); + //boost::bind(&X::f0, ref(x) )(); boost::bind does not work with phx::ref. + + BOOST_TEST(boost::bind(&X::g0, &x )() == 34); + BOOST_TEST(boost::bind(&X::g0, x )() == 51); + //boost::bind(&X::g0, ref(x) )(); + + BOOST_TEST(phx::bind(&X::f0, &x )() == 51); + BOOST_TEST(phx::bind(&X::f0, ref(x) )() == 68); + + BOOST_TEST(phx::bind(&X::g0, &x )() == 85); + BOOST_TEST(phx::bind(&X::g0, x )() == 102); + BOOST_TEST(phx::bind(&X::g0, ref(x) )() == 102); + + return; +} + +int main() +{ + + boost::function<int (int)> fun1_f1(boost::bind ( &f1, _1) ); + boost::function<int (int)> fun2_f1( phx::bind ( &f1, _1) ); + boost::function<int (int)> fun3_f1( phx::bind ( &f1, arg1) ); + + BOOST_TEST( fun1_f1(1) == 1 ); + BOOST_TEST( fun2_f1(2) == 2 ); + BOOST_TEST( fun3_f1(3) == 3 ); + + boost::function<int (int, int)> fun1_f2(boost::bind ( &f2, _1, _2) ); + boost::function<int (int, int)> fun2_f2( phx::bind ( &f2, _1, _2) ); + boost::function<int (int, int)> fun3_f2( phx::bind ( &f2, arg1, arg2) ); + + BOOST_TEST( fun1_f2(1,2) == 3 ); + BOOST_TEST( fun2_f2(2,3) == 5 ); + BOOST_TEST( fun3_f2(3,4) == 7 ); + + member_function_test(); + member_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_lookup_problem_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_lookup_problem_test.cpp new file mode 100644 index 00000000..a0e23de5 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_lookup_problem_test.cpp @@ -0,0 +1,42 @@ +/*============================================================================== + Copyright (c) 2005 Markus Schoepflin + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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.hpp> +#include <boost/phoenix/bind.hpp> + +template<class T> void value(); + +void f0() { } +void f1(int) { } +void f2(int, int) { } +void f3(int, int, int) { } +void f4(int, int, int, int) { } +void f5(int, int, int, int, int) { } +void f6(int, int, int, int, int, int) { } +void f7(int, int, int, int, int, int, int) { } +void f8(int, int, int, int, int, int, int, int) { } +void f9(int, int, int, int, int, int, int, int, int) { } + +int main() +{ + using boost::phoenix::bind; + + bind(f0); + bind(f1, 0); + bind(f2, 0, 0); + bind(f3, 0, 0, 0); + bind(f4, 0, 0, 0, 0); + bind(f5, 0, 0, 0, 0, 0); + bind(f6, 0, 0, 0, 0, 0, 0); + bind(f7, 0, 0, 0, 0, 0, 0, 0); + bind(f8, 0, 0, 0, 0, 0, 0, 0, 0); + bind(f9, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + return 0; +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_mf2_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_mf2_test.cpp new file mode 100644 index 00000000..178bd6e1 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_mf2_test.cpp @@ -0,0 +1,163 @@ +/*============================================================================== + Copyright (c) 2005, 2008 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + mutable unsigned int hash; + + X(): hash(0) {} + + int f0() { f1(17); return 0; } + int g0() const { g1(17); return 0; } + + int f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; } + int g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; } + + int f2(int a1, int a2) { f1(a1); f1(a2); return 0; } + int g2(int a1, int a2) const { g1(a1); g1(a2); return 0; } + + int f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; } + int g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; } + + int f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; } + int g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; } + + int f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; } + int g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; } + + int f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } + int g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } + + int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } + int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } + + int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } + int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } +}; + +void member_function_test() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + + X x; + + // 0 + + bind(&X::f0, &x )(); + bind(&X::f0, ref(x) )(); + + bind(&X::g0, &x )(); + bind(&X::g0, x )(); + bind(&X::g0, ref(x) )(); + + // 1 + + bind(&X::f1, &x, 1 )(); + bind(&X::f1, ref(x), 1 )(); + + bind(&X::g1, &x, 1 )(); + bind(&X::g1, x, 1 )(); + bind(&X::g1, ref(x), 1 )(); + + // 2 + + bind(&X::f2, &x, 1, 2 )(); + bind(&X::f2, ref(x), 1, 2 )(); + + bind(&X::g2, &x, 1, 2 )(); + bind(&X::g2, x, 1, 2 )(); + bind(&X::g2, ref(x), 1, 2 )(); + + // 3 + + bind(&X::f3, &x, 1, 2, 3 )(); + bind(&X::f3, ref(x), 1, 2, 3 )(); + + bind(&X::g3, &x, 1, 2, 3 )(); + bind(&X::g3, x, 1, 2, 3 )(); + bind(&X::g3, ref(x), 1, 2, 3 )(); + + // 4 + + bind(&X::f4, &x, 1, 2, 3, 4 )(); + bind(&X::f4, ref(x), 1, 2, 3, 4 )(); + + bind(&X::g4, &x, 1, 2, 3, 4 )(); + bind(&X::g4, x, 1, 2, 3, 4 )(); + bind(&X::g4, ref(x), 1, 2, 3, 4 )(); + + // 5 + + bind(&X::f5, &x, 1, 2, 3, 4, 5 )(); + bind(&X::f5, ref(x), 1, 2, 3, 4, 5 )(); + + bind(&X::g5, &x, 1, 2, 3, 4, 5 )(); + bind(&X::g5, x, 1, 2, 3, 4, 5 )(); + bind(&X::g5, ref(x), 1, 2, 3, 4, 5 )(); + + // 6 + + bind(&X::f6, &x, 1, 2, 3, 4, 5, 6 )(); + bind(&X::f6, ref(x), 1, 2, 3, 4, 5, 6 )(); + + bind(&X::g6, &x, 1, 2, 3, 4, 5, 6 )(); + bind(&X::g6, x, 1, 2, 3, 4, 5, 6 )(); + bind(&X::g6, ref(x), 1, 2, 3, 4, 5, 6 )(); + + // 7 + + bind(&X::f7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + bind(&X::g7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + // 8 + + bind(&X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8 )(); + bind(&X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8 )(); + + bind(&X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8 )(); + bind(&X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8 )(); + bind(&X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8 )(); + + BOOST_TEST( x.hash == 23558 ); +} + +int main() +{ + member_function_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_not_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_not_test.cpp new file mode 100644 index 00000000..e4998069 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_not_test.cpp @@ -0,0 +1,61 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/operator.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +template<class F, class A1, class R> void tester( F f, A1 a1, R r ) +{ + BOOST_TEST( f(a1) == r ); +} + +bool f( bool v ) +{ + return v; +} + +int g( int v ) +{ + return v; +} + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + + tester( !bind( f, true ), 0, !f( true ) ); + tester( !bind( g, _1 ), 5, !g( 5 ) ); + tester( bind( f, !bind( f, true ) ), 0, f( !f( true ) ) ); + tester( bind( f, !bind( f, _1 ) ), true, f( !f( true ) ) ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_placeholder_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_placeholder_test.cpp new file mode 100644 index 00000000..817805b6 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_placeholder_test.cpp @@ -0,0 +1,87 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined( BOOST_MSVC ) + +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed + +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +// + +long f( long a, long b, long c, long d, long e, long f, long g, long h, long i ) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +template< int I > struct custom_placeholder + : boost::mpl::int_<I> +{ +}; + +namespace boost +{ + +template< int I > struct is_placeholder< custom_placeholder< I > > +{ + enum { value = I + 1}; +}; + +} // namespace boost + +int main() +{ + using boost::phoenix::bind; + + int const x1 = 1; + int const x2 = 2; + int const x3 = 3; + int const x4 = 4; + int const x5 = 5; + int const x6 = 6; + int const x7 = 7; + int const x8 = 8; + int const x9 = 9; + + custom_placeholder<0> p1; + custom_placeholder<1> p2; + custom_placeholder<2> p3; + custom_placeholder<3> p4; + custom_placeholder<4> p5; + custom_placeholder<5> p6; + custom_placeholder<6> p7; + custom_placeholder<7> p8; + custom_placeholder<8> p9; + + BOOST_TEST( + bind( f, p1, p2, p3, p4, p5, p6, p7, p8, p9 ) + ( x1, x2, x3, x4, x5, x6, x7, x8, x9 ) == 987654321L ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_ref_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_ref_test.cpp new file mode 100644 index 00000000..486028be --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_ref_test.cpp @@ -0,0 +1,38 @@ +/*============================================================================== + Copyright (c) 2009 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/ref.hpp> +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + int f( int x ) + { + return x; + } + + int g( int x ) const + { + return -x; + } +}; + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + X x; + + BOOST_TEST( bind( &X::f, _1, 1 )( boost::ref( x ) ) == 1 ); + BOOST_TEST( bind( &X::g, _1, 2 )( boost::cref( x ) ) == -2 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rel_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rel_test.cpp new file mode 100644 index 00000000..63d3c66a --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rel_test.cpp @@ -0,0 +1,102 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/operator.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +int f( int x ) +{ + return x + x; +} + +int g( int x ) +{ + return 2 * x; +} + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + using boost::phoenix::placeholders::_1; + using boost::phoenix::placeholders::_2; + + int x = 4; + int y = x + x; + + // bind op value + + BOOST_TEST( ( bind( f, _1 ) == y )( x ) ); + BOOST_TEST( !( ( bind( f, _1 ) != y )( x ) ) ); + + BOOST_TEST( !( ( bind( f, _1 ) < y )( x ) ) ); + BOOST_TEST( ( bind( f, _1 ) < y + 1 )( x ) ); + + BOOST_TEST( !( ( bind( f, _1 ) > y )( x ) ) ); + BOOST_TEST( ( bind( f, _1 ) > y - 1 )( x ) ); + + BOOST_TEST( !( ( bind( f, _1 ) <= y - 1 )( x ) ) ); + BOOST_TEST( ( bind( f, _1 ) <= y )( x ) ); + BOOST_TEST( ( bind( f, _1 ) <= y + 1 )( x ) ); + + BOOST_TEST( !( ( bind( f, _1 ) >= y + 1 )( x ) ) ); + BOOST_TEST( ( bind( f, _1 ) >= y )( x ) ); + BOOST_TEST( ( bind( f, _1 ) >= y - 1 )( x ) ); + + // bind op ref + + BOOST_TEST( ( bind( f, _1 ) == ref( y ) )( x ) ); + BOOST_TEST( !( ( bind( f, _1 ) != ref( y ) )( x ) ) ); + BOOST_TEST( !( ( bind( f, _1 ) < ref( y ) )( x ) ) ); + BOOST_TEST( !( ( bind( f, _1 ) > ref( y ) )( x ) ) ); + BOOST_TEST( ( bind( f, _1 ) <= ref( y ) )( x ) ); + BOOST_TEST( ( bind( f, _1 ) >= ref( y ) )( x ) ); + + // bind op placeholder + + BOOST_TEST( ( bind( f, _1 ) == _2 )( x, y ) ); + BOOST_TEST( !( ( bind( f, _1 ) != _2 )( x, y ) ) ); + BOOST_TEST( !( ( bind( f, _1 ) < _2 )( x, y ) ) ); + BOOST_TEST( !( ( bind( f, _1 ) > _2 )( x, y ) ) ); + BOOST_TEST( ( bind( f, _1 ) <= _2 )( x, y ) ); + BOOST_TEST( ( bind( f, _1 ) >= _2 )( x, y ) ); + + // bind op bind + + BOOST_TEST( ( bind( f, _1 ) == bind( g, _1 ) )( x ) ); + BOOST_TEST( !( ( bind( f, _1 ) != bind( g, _1 ) )( x ) ) ); + BOOST_TEST( !( ( bind( f, _1 ) < bind( g, _1 ) )( x ) ) ); + BOOST_TEST( ( bind( f, _1 ) <= bind( g, _1 ) )( x ) ); + BOOST_TEST( !( ( bind( f, _1 ) > bind( g, _1 ) )( x ) ) ); + BOOST_TEST( ( bind( f, _1 ) >= bind( g, _1 ) )( x ) ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp1_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp1_test.cpp new file mode 100644 index 00000000..a276014c --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp1_test.cpp @@ -0,0 +1,68 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> +#include <boost/shared_ptr.hpp> + +struct X +{ + int v_; + + X( int v ): v_( v ) + { + } + + int f() + { + return v_; + } +}; + +struct Y +{ + boost::shared_ptr<X> f() + { + return boost::shared_ptr<X>( new X( 42 ) ); + } +}; + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + + Y y; + + // Change bind_rv_sp_test.cpp to bind to _1. + BOOST_TEST( bind( &X::f, _1) ( bind( &Y::f, &y )()) == 42 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp2_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp2_test.cpp new file mode 100644 index 00000000..ca505f25 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp2_test.cpp @@ -0,0 +1,68 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> +#include <boost/shared_ptr.hpp> + +struct X +{ + int v_; + + X( int v ): v_( v ) + { + } + + int f() + { + return v_; + } +}; + +struct Y +{ + boost::shared_ptr<X> f() + { + return boost::shared_ptr<X>( new X( 42 ) ); + } +}; + +int main() +{ + using boost::phoenix::bind; + //using boost::phoenix::placeholders::_1; + + Y y; + + // Simplify Change bind_rv_sp_test.cpp to bind to _1. + BOOST_TEST( (*bind( &Y::f, &y )()).f() == 42 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp3_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp3_test.cpp new file mode 100644 index 00000000..2aff70a6 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp3_test.cpp @@ -0,0 +1,68 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> +#include <boost/shared_ptr.hpp> + +struct X +{ + int v_; + + X( int v ): v_( v ) + { + } + + int f() + { + return v_; + } +}; + +struct Y +{ + boost::shared_ptr<X> g() + { + return boost::shared_ptr<X>( new X( 42 ) ); + } +}; + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + + Y y; + + // Change bind_rv_sp_test.cpp to bind to _1. Renamed f to g in y + BOOST_TEST( bind( &X::f, _1) ( bind( &Y::g, &y )()) == 42 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp4_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp4_test.cpp new file mode 100644 index 00000000..1cd9a887 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp4_test.cpp @@ -0,0 +1,70 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> +#include <boost/shared_ptr.hpp> + +struct X +{ + int v_; + + X( int v ): v_( v ) + { + } + + int f() + { + return v_; + } +}; + +struct Y +{ + boost::shared_ptr<X> f() + { + return boost::shared_ptr<X>( new X( 42 ) ); + } +}; + +int main() +{ + using boost::phoenix::bind; + //using boost::phoenix::placeholders::_1; + + Y y; + + // Change bind_rv_sp_test.cpp to bind to _1. Renamed f to g in y + //BOOST_TEST( bind( &X::f, _1) ( bind( &Y::g, &y )()) == 42 ); + boost::shared_ptr<X> xp = bind( &Y::f, &y )(); + BOOST_TEST( bind( &X::f, xp)() == 42 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp5_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp5_test.cpp new file mode 100644 index 00000000..4d82a46d --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp5_test.cpp @@ -0,0 +1,70 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> +#include <boost/shared_ptr.hpp> + +struct X +{ + int v_; + + X( int v ): v_( v ) + { + } + + int f() + { + return v_; + } +}; + +struct Y +{ + boost::shared_ptr<X> f() + { + return boost::shared_ptr<X>( new X( 42 ) ); + } +}; + +int main() +{ + using boost::phoenix::bind; + //using boost::phoenix::placeholders::_1; + + Y y; + + // Change bind_rv_sp_test.cpp to bind to _1. Renamed f to g in y + //BOOST_TEST( bind( &X::f, _1) ( bind( &Y::g, &y )()) == 42 ); + boost::shared_ptr<X> xp = bind( &Y::f, &y )(); + //BOOST_TEST( bind( &X::f, xp)() == 42 ); + BOOST_TEST( (*xp).f() == 42 ); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp6_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp6_test.cpp new file mode 100644 index 00000000..446d17e7 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp6_test.cpp @@ -0,0 +1,71 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> +#include <boost/shared_ptr.hpp> + +struct X +{ + int v_; + + X( int v ): v_( v ) + { + } + + int f() + { + return v_; + } +}; + +struct Y +{ + boost::shared_ptr<X> f() + { + return boost::shared_ptr<X>( new X( 42 ) ); + } +}; + +int main() +{ + using boost::phoenix::bind; + //using boost::phoenix::placeholders::_1; + + Y y; + + // Change bind_rv_sp_test.cpp to bind to _1. Renamed f to g in y + //BOOST_TEST( bind( &X::f, _1) ( bind( &Y::g, &y )()) == 42 ); + //boost::shared_ptr<X> xp = bind( &Y::f, &y )(); + boost::shared_ptr<X> xp = y.f(); + BOOST_TEST( bind( &X::f, xp)() == 42 ); + //BOOST_TEST( (*xp).f() == 42 ); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp7_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp7_test.cpp new file mode 100644 index 00000000..7b050bf7 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp7_test.cpp @@ -0,0 +1,71 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> +#include <boost/shared_ptr.hpp> + +struct X +{ + int v_; + + X( int v ): v_( v ) + { + } + + int f() + { + return v_; + } +}; + +struct Y +{ + boost::shared_ptr<X> f() + { + return boost::shared_ptr<X>( new X( 42 ) ); + } +}; + +int main() +{ + using boost::phoenix::bind; + //using boost::phoenix::placeholders::_1; + + Y y; + + // Change bind_rv_sp_test.cpp to bind to _1. Renamed f to g in y + //BOOST_TEST( bind( &X::f, _1) ( bind( &Y::g, &y )()) == 42 ); + //boost::shared_ptr<X> xp = bind( &Y::f, &y )(); + boost::shared_ptr<X> xp = y.f(); + // BOOST_TEST( bind( &X::f, xp)() == 42 ); + BOOST_TEST( (*xp).f() == 42 ); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp_test.cpp new file mode 100644 index 00000000..3fe67c48 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rv_sp_test.cpp @@ -0,0 +1,75 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> +#include <boost/shared_ptr.hpp> + +struct X +{ + int v_; + + X( int v ): v_( v ) + { + } + + int f() + { + return v_; + } +}; + +struct Y +{ + boost::shared_ptr<X> f() + { + return boost::shared_ptr<X>( new X( 42 ) ); + } +}; + +int main() +{ + using boost::phoenix::bind; + + Y y; + + // MSVC 10,9 and 8 all give a COMDAT error with the full test. + // This also fails: + //boost::shared_ptr<X> xp = bind( &Y::f, &y )(); +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1700) + boost::shared_ptr<X> xp = y.f(); + BOOST_TEST( bind( &X::f, xp)() == 42 ); +#else + BOOST_TEST( bind( &X::f, bind( &Y::f, &y ) )() == 42 ); +#endif + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rvalue_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rvalue_test.cpp new file mode 100644 index 00000000..049e45e1 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_rvalue_test.cpp @@ -0,0 +1,93 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined( BOOST_MSVC ) + +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed + +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +// + +int f( int x ) +{ + return x; +} + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + using boost::phoenix::placeholders::_2; + using boost::phoenix::placeholders::_3; + using boost::phoenix::placeholders::_4; + using boost::phoenix::placeholders::_5; + using boost::phoenix::placeholders::_6; + using boost::phoenix::placeholders::_7; + using boost::phoenix::placeholders::_8; + using boost::phoenix::placeholders::_9; + + BOOST_TEST( + bind( f, _1 ) + ( 1 ) == 1 ); + + BOOST_TEST( + bind( f, _2 ) + ( 1, 2 ) == 2 ); + + BOOST_TEST( + bind( f, _3 ) + ( 1, 2, 3 ) == 3 ); + + BOOST_TEST( + bind( f, _4 ) + ( 1, 2, 3, 4 ) == 4 ); + + BOOST_TEST( + bind( f, _5 ) + ( 1, 2, 3, 4, 5 ) == 5 ); + + BOOST_TEST( + bind( f, _6 ) + ( 1, 2, 3, 4, 5, 6 ) == 6 ); + + BOOST_TEST( + bind( f, _7 ) + ( 1, 2, 3, 4, 5, 6, 7 ) == 7 ); + + BOOST_TEST( + bind( f, _8 ) + ( 1, 2, 3, 4, 5, 6, 7, 8 ) == 8 ); + + BOOST_TEST( + bind( f, _9 ) + ( 1, 2, 3, 4, 5, 6, 7, 8, 9 ) == 9 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_stateful_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_stateful_test.cpp new file mode 100644 index 00000000..fae0e9c6 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_stateful_test.cpp @@ -0,0 +1,301 @@ +/*============================================================================== + Copyright (c) 2004 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +class X +{ +private: + + mutable int state_; + +public: + + X(): state_(0) + { + } + + int state() const + { + return state_; + } + + typedef int result_type; + + int operator()() const + { + return state_ += 17041; + } + + int operator()(int x1) const + { + return state_ += x1; + } + + int operator()(int x1, int x2) const + { + return state_ += x1+x2; + } + + int operator()(int x1, int x2, int x3) const + { + return state_ += x1+x2+x3; + } + + int operator()(int x1, int x2, int x3, int x4) const + { + return state_ += x1+x2+x3+x4; + } + + int operator()(int x1, int x2, int x3, int x4, int x5) const + { + return state_ += x1+x2+x3+x4+x5; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6) const + { + return state_ += x1+x2+x3+x4+x5+x6; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7) const + { + return state_ += x1+x2+x3+x4+x5+x6+x7; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8) const + { + return state_ += x1+x2+x3+x4+x5+x6+x7+x8; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9) const + { + return state_ += x1+x2+x3+x4+x5+x6+x7+x8+x9; + } +}; + +class Y +{ +private: + + int state_; + +public: + + Y(): state_(0) + { + } + + int state() const + { + return state_; + } + + typedef int result_type; + + int operator()() + { + return state_ += 17041; + } + + int operator()(int x1) + { + return state_ += x1; + } + + int operator()(int x1, int x2) + { + return state_ += x1+x2; + } + + int operator()(int x1, int x2, int x3) + { + return state_ += x1+x2+x3; + } + + int operator()(int x1, int x2, int x3, int x4) + { + return state_ += x1+x2+x3+x4; + } + + int operator()(int x1, int x2, int x3, int x4, int x5) + { + return state_ += x1+x2+x3+x4+x5; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6) + { + return state_ += x1+x2+x3+x4+x5+x6; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7) + { + return state_ += x1+x2+x3+x4+x5+x6+x7; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8) + { + return state_ += x1+x2+x3+x4+x5+x6+x7+x8; + } + + int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9) + { + return state_ += x1+x2+x3+x4+x5+x6+x7+x8+x9; + } +}; + +int f0(int & state_) +{ + return state_ += 17041; +} + +int f1(int & state_, int x1) +{ + return state_ += x1; +} + +int f2(int & state_, int x1, int x2) +{ + return state_ += x1+x2; +} + +int f3(int & state_, int x1, int x2, int x3) +{ + return state_ += x1+x2+x3; +} + +int f4(int & state_, int x1, int x2, int x3, int x4) +{ + return state_ += x1+x2+x3+x4; +} + +int f5(int & state_, int x1, int x2, int x3, int x4, int x5) +{ + return state_ += x1+x2+x3+x4+x5; +} + +int f6(int & state_, int x1, int x2, int x3, int x4, int x5, int x6) +{ + return state_ += x1+x2+x3+x4+x5+x6; +} + +int f7(int & state_, int x1, int x2, int x3, int x4, int x5, int x6, int x7) +{ + return state_ += x1+x2+x3+x4+x5+x6+x7; +} + +int f8(int & state_, int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8) +{ + return state_ += x1+x2+x3+x4+x5+x6+x7+x8; +} + +template <typename> struct wrap {}; + +template<class F> void test(F f, int a, int b) +{ + BOOST_TEST( f() == a + b ); + BOOST_TEST( f() == a + 2*b ); + BOOST_TEST( f() == a + 3*b ); +} + +using boost::phoenix::bind; +using boost::phoenix::ref; + +void stateful_function_object_test() +{ + ::test( bind( X() ), 0, 17041 ); + ::test( bind( X(), 1 ), 0, 1 ); + ::test( bind( X(), 1, 2 ), 0, 1+2 ); + ::test( bind( X(), 1, 2, 3 ), 0, 1+2+3 ); + ::test( bind( X(), 1, 2, 3, 4 ), 0, 1+2+3+4 ); + ::test( bind( X(), 1, 2, 3, 4, 5 ), 0, 1+2+3+4+5 ); + ::test( bind( X(), 1, 2, 3, 4, 5, 6 ), 0, 1+2+3+4+5+6 ); + ::test( bind( X(), 1, 2, 3, 4, 5, 6, 7 ), 0, 1+2+3+4+5+6+7 ); + ::test( bind( X(), 1, 2, 3, 4, 5, 6, 7, 8 ), 0, 1+2+3+4+5+6+7+8 ); + ::test( bind( X(), 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 0, 1+2+3+4+5+6+7+8+9 ); + + Y y; + + int n = y.state(); + + ::test( bind( ref(y) ), n, 17041 ); + n += 3 * 17041; + + ::test( bind( ref(y), 1 ), n, 1 ); + n += 3*1; + + ::test( bind( ref(y), 1, 2 ), n, 1+2 ); + n += 3*(1+2); + + ::test( bind( ref(y), 1, 2, 3 ), n, 1+2+3 ); + n += 3*(1+2+3); + + ::test( bind( ref(y), 1, 2, 3, 4 ), n, 1+2+3+4 ); + n += 3*(1+2+3+4); + + ::test( bind( ref(y), 1, 2, 3, 4, 5 ), n, 1+2+3+4+5 ); + n += 3*(1+2+3+4+5); + + ::test( bind( ref(y), 1, 2, 3, 4, 5, 6 ), n, 1+2+3+4+5+6 ); + n += 3*(1+2+3+4+5+6); + + ::test( bind( ref(y), 1, 2, 3, 4, 5, 6, 7 ), n, 1+2+3+4+5+6+7 ); + n += 3*(1+2+3+4+5+6+7); + + ::test( bind( ref(y), 1, 2, 3, 4, 5, 6, 7, 8 ), n, 1+2+3+4+5+6+7+8 ); + n += 3*(1+2+3+4+5+6+7+8); + + ::test( bind( ref(y), 1, 2, 3, 4, 5, 6, 7, 8, 9 ), n, 1+2+3+4+5+6+7+8+9 ); + n += 3*(1+2+3+4+5+6+7+8+9); + + BOOST_TEST( y.state() == n ); +} + +void stateful_function_test() +{ + using boost::phoenix::ref; + + ::test( bind( f0, 0), 0, 17041 ); + ::test( bind( f1, 0, 1 ), 0, 1 ); + ::test( bind( f2, 0, 1, 2 ), 0, 1+2 ); + ::test( bind( f3, 0, 1, 2, 3 ), 0, 1+2+3 ); + ::test( bind( f4, 0, 1, 2, 3, 4 ), 0, 1+2+3+4 ); + ::test( bind( f5, 0, 1, 2, 3, 4, 5 ), 0, 1+2+3+4+5 ); + ::test( bind( f6, 0, 1, 2, 3, 4, 5, 6 ), 0, 1+2+3+4+5+6 ); + ::test( bind( f7, 0, 1, 2, 3, 4, 5, 6, 7 ), 0, 1+2+3+4+5+6+7 ); + ::test( bind( f8, 0, 1, 2, 3, 4, 5, 6, 7, 8 ), 0, 1+2+3+4+5+6+7+8 ); +} + +int main() +{ + stateful_function_object_test(); + stateful_function_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_stdcall_mf_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_stdcall_mf_test.cpp new file mode 100644 index 00000000..b7ecdd18 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_stdcall_mf_test.cpp @@ -0,0 +1,167 @@ +/*============================================================================== + Copyright (c) 2001 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#define BOOST_MEM_FN_ENABLE_STDCALL + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct X +{ + mutable unsigned int hash; + + X(): hash(0) {} + + int __stdcall f0() { f1(17); return 0; } + int __stdcall g0() const { g1(17); return 0; } + + int __stdcall f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; } + int __stdcall g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; } + + int __stdcall f2(int a1, int a2) { f1(a1); f1(a2); return 0; } + int __stdcall g2(int a1, int a2) const { g1(a1); g1(a2); return 0; } + + int __stdcall f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; } + int __stdcall g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; } + + int __stdcall f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; } + int __stdcall g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; } + + int __stdcall f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; } + int __stdcall g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; } + + int __stdcall f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } + int __stdcall g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } + + int __stdcall f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } + int __stdcall g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } + + int __stdcall f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } + int __stdcall g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } +}; + +void member_function_test() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + + X x; + + // 0 + + std::cout << typeid(typename boost::result_of<X::f0()>::type).name() << "\n"; + + bind(&X::f0, &x)(); + bind(&X::f0, ref(x))(); + + bind(&X::g0, &x)(); + bind(&X::g0, x)(); + bind(&X::g0, ref(x))(); + + // 1 + + bind(&X::f1, &x, 1)(); + bind(&X::f1, ref(x), 1)(); + + bind(&X::g1, &x, 1)(); + bind(&X::g1, x, 1)(); + bind(&X::g1, ref(x), 1)(); + + // 2 + + bind(&X::f2, &x, 1, 2)(); + bind(&X::f2, ref(x), 1, 2)(); + + bind(&X::g2, &x, 1, 2)(); + bind(&X::g2, x, 1, 2)(); + bind(&X::g2, ref(x), 1, 2)(); + + // 3 + + bind(&X::f3, &x, 1, 2, 3)(); + bind(&X::f3, ref(x), 1, 2, 3)(); + + bind(&X::g3, &x, 1, 2, 3)(); + bind(&X::g3, x, 1, 2, 3)(); + bind(&X::g3, ref(x), 1, 2, 3)(); + + // 4 + + bind(&X::f4, &x, 1, 2, 3, 4)(); + bind(&X::f4, ref(x), 1, 2, 3, 4)(); + + bind(&X::g4, &x, 1, 2, 3, 4)(); + bind(&X::g4, x, 1, 2, 3, 4)(); + bind(&X::g4, ref(x), 1, 2, 3, 4)(); + + // 5 + + bind(&X::f5, &x, 1, 2, 3, 4, 5)(); + bind(&X::f5, ref(x), 1, 2, 3, 4, 5)(); + + bind(&X::g5, &x, 1, 2, 3, 4, 5)(); + bind(&X::g5, x, 1, 2, 3, 4, 5)(); + bind(&X::g5, ref(x), 1, 2, 3, 4, 5)(); + + // 6 + + bind(&X::f6, &x, 1, 2, 3, 4, 5, 6)(); + bind(&X::f6, ref(x), 1, 2, 3, 4, 5, 6)(); + + bind(&X::g6, &x, 1, 2, 3, 4, 5, 6)(); + bind(&X::g6, x, 1, 2, 3, 4, 5, 6)(); + bind(&X::g6, ref(x), 1, 2, 3, 4, 5, 6)(); + + // 7 + + bind(&X::f7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + bind(&X::g7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + // 8 + + bind(&X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + bind(&X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + BOOST_TEST( x.hash == 23558 ); +} + +int main() +{ + member_function_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_stdcall_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_stdcall_test.cpp new file mode 100644 index 00000000..b3723a5d --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_stdcall_test.cpp @@ -0,0 +1,111 @@ +/*============================================================================== + Copyright (c) 2001 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#define BOOST_BIND_ENABLE_STDCALL + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +// + +long __stdcall f_0() +{ + return 17041L; +} + +long __stdcall f_1(long a) +{ + return a; +} + +long __stdcall f_2(long a, long b) +{ + return a + 10 * b; +} + +long __stdcall f_3(long a, long b, long c) +{ + return a + 10 * b + 100 * c; +} + +long __stdcall f_4(long a, long b, long c, long d) +{ + return a + 10 * b + 100 * c + 1000 * d; +} + +long __stdcall f_5(long a, long b, long c, long d, long e) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e; +} + +long __stdcall f_6(long a, long b, long c, long d, long e, long f) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f; +} + +long __stdcall f_7(long a, long b, long c, long d, long e, long f, long g) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; +} + +long __stdcall f_8(long a, long b, long c, long d, long e, long f, long g, long h) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; +} + +long __stdcall f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +void function_test() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + + int const i = 1; + + BOOST_TEST( bind(f_0)(i) == 17041L ); + BOOST_TEST( bind(f_1, _1)(i) == 1L ); + BOOST_TEST( bind(f_2, _1, 2)(i) == 21L ); + BOOST_TEST( bind(f_3, _1, 2, 3)(i) == 321L ); + BOOST_TEST( bind(f_4, _1, 2, 3, 4)(i) == 4321L ); + BOOST_TEST( bind(f_5, _1, 2, 3, 4, 5)(i) == 54321L ); + BOOST_TEST( bind(f_6, _1, 2, 3, 4, 5, 6)(i) == 654321L ); + BOOST_TEST( bind(f_7, _1, 2, 3, 4, 5, 6, 7)(i) == 7654321L ); + BOOST_TEST( bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8)(i) == 87654321L ); + BOOST_TEST( bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i) == 987654321L ); +} + +int main() +{ + function_test(); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_test.cpp new file mode 100644 index 00000000..1225b8ab --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_test.cpp @@ -0,0 +1,542 @@ +/*============================================================================== + Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. + Copyright (c) 2001 David Abrahams + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +// + +long f_0() +{ + return 17041L; +} + +long f_1(long a) +{ + return a; +} + +long f_2(long a, long b) +{ + return a + 10 * b; +} + +long f_3(long a, long b, long c) +{ + return a + 10 * b + 100 * c; +} + +long f_4(long a, long b, long c, long d) +{ + return a + 10 * b + 100 * c + 1000 * d; +} + +long f_5(long a, long b, long c, long d, long e) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e; +} + +long f_6(long a, long b, long c, long d, long e, long f) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f; +} + +long f_7(long a, long b, long c, long d, long e, long f, long g) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; +} + +long f_8(long a, long b, long c, long d, long e, long f, long g, long h) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; +} + +long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +{ + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +long global_result; + +void fv_0() +{ + global_result = 17041L; +} + +void fv_1(long a) +{ + global_result = a; +} + +void fv_2(long a, long b) +{ + global_result = a + 10 * b; +} + +void fv_3(long a, long b, long c) +{ + global_result = a + 10 * b + 100 * c; +} + +void fv_4(long a, long b, long c, long d) +{ + global_result = a + 10 * b + 100 * c + 1000 * d; +} + +void fv_5(long a, long b, long c, long d, long e) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e; +} + +void fv_6(long a, long b, long c, long d, long e, long f) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f; +} + +void fv_7(long a, long b, long c, long d, long e, long f, long g) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; +} + +void fv_8(long a, long b, long c, long d, long e, long f, long g, long h) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; +} + +void fv_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +{ + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +void function_test() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + + int const i = 1; + + BOOST_TEST( bind(f_0)(i) == 17041L ); + BOOST_TEST( bind(f_1, _1)(i) == 1L ); + BOOST_TEST( bind(f_2, _1, 2)(i) == 21L ); + BOOST_TEST( bind(f_3, _1, 2, 3)(i) == 321L ); + BOOST_TEST( bind(f_4, _1, 2, 3, 4)(i) == 4321L ); + BOOST_TEST( bind(f_5, _1, 2, 3, 4, 5)(i) == 54321L ); + BOOST_TEST( bind(f_6, _1, 2, 3, 4, 5, 6)(i) == 654321L ); + BOOST_TEST( bind(f_7, _1, 2, 3, 4, 5, 6, 7)(i) == 7654321L ); + BOOST_TEST( bind(f_8, _1, 2, 3, 4, 5, 6, 7, 8)(i) == 87654321L ); + BOOST_TEST( bind(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i) == 987654321L ); + + BOOST_TEST( (bind(fv_0)(i), (global_result == 17041L)) ); + BOOST_TEST( (bind(fv_1, _1)(i), (global_result == 1L)) ); + BOOST_TEST( (bind(fv_2, _1, 2)(i), (global_result == 21L)) ); + BOOST_TEST( (bind(fv_3, _1, 2, 3)(i), (global_result == 321L)) ); + BOOST_TEST( (bind(fv_4, _1, 2, 3, 4)(i), (global_result == 4321L)) ); + BOOST_TEST( (bind(fv_5, _1, 2, 3, 4, 5)(i), (global_result == 54321L)) ); + BOOST_TEST( (bind(fv_6, _1, 2, 3, 4, 5, 6)(i), (global_result == 654321L)) ); + BOOST_TEST( (bind(fv_7, _1, 2, 3, 4, 5, 6, 7)(i), (global_result == 7654321L)) ); + BOOST_TEST( (bind(fv_8, _1, 2, 3, 4, 5, 6, 7, 8)(i), (global_result == 87654321L)) ); + BOOST_TEST( (bind(fv_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i), (global_result == 987654321L)) ); +} + +// + +struct Y +{ + template <typename Sig> + struct result; + template <typename This, typename A0> + struct result<This(A0 &)> { typedef short type; }; + template <typename This, typename A0, typename A1> + struct result<This(A0, A1)> { typedef int type; }; + template <typename This, typename A0, typename A1, typename A2> + struct result<This(A0, A1, A2)> { typedef long type; }; + template <typename This, typename A0, typename A1, typename A2, typename A3> + struct result<This(A0, A1, A2, A3)> { typedef void type; }; + + short operator()(short & r) const { return ++r; } + int operator()(int a, int b) const { return a + 10 * b; } + long operator() (long a, long b, long c) const { return a + 10 * b + 100 * c; } + void operator() (long a, long b, long c, long d) const { global_result = a + 10 * b + 100 * c + 1000 * d; } +}; + +void function_object_test() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + using boost::phoenix::placeholders::_1; + + short i(6); + + int const k = 3; + + BOOST_TEST( bind(Y(), ref(i))() == 7 ); + BOOST_TEST( bind(Y(), ref(i))() == 8 ); + BOOST_TEST( bind(Y(), i, _1)(k) == 38 ); + BOOST_TEST( bind(Y(), i, _1, 9)(k) == 938 ); + +#if !defined(__MWERKS__) || (__MWERKS__ > 0x2407) // Fails for this version of the compiler. + + global_result = 0; + bind(Y(), i, _1, 9, 4)(k); + BOOST_TEST( global_result == 4938 ); + +#endif +} + +void function_object_test2() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + using boost::phoenix::placeholders::_1; + + short i(6); + + int const k = 3; + + BOOST_TEST( bind(Y(), ref(i))() == 7 ); + BOOST_TEST( bind(Y(), ref(i))() == 8 ); + BOOST_TEST( bind(Y(), i, _1)(k) == 38 ); + BOOST_TEST( bind(Y(), i, _1, 9)(k) == 938 ); + + global_result = 0; + bind(Y(), i, _1, 9, 4)(k); + BOOST_TEST( global_result == 4938 ); +} + +// + +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + +struct Z +{ + typedef int result_type; + int operator()(int a, int b) const { return a + 10 * b; } +}; + +void adaptable_function_object_test() +{ + using boost::phoenix::bind; + BOOST_TEST( bind(Z(), 7, 4)() == 47 ); +} + +#endif + +// + +struct X +{ + mutable unsigned int hash; + + X(): hash(0) {} + + int f0() { f1(17); return 0; } + int g0() const { g1(17); return 0; } + + int f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; } + int g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; } + + int f2(int a1, int a2) { f1(a1); f1(a2); return 0; } + int g2(int a1, int a2) const { g1(a1); g1(a2); return 0; } + + int f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; } + int g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; } + + int f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; } + int g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; } + + int f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; } + int g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; } + + int f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } + int g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } + + int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } + int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } + + int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } + int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } +}; + +struct V +{ + mutable unsigned int hash; + + V(): hash(0) {} + + void f0() { f1(17); } + void g0() const { g1(17); } + + void f1(int a1) { hash = (hash * 17041 + a1) % 32768; } + void g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; } + + void f2(int a1, int a2) { f1(a1); f1(a2); } + void g2(int a1, int a2) const { g1(a1); g1(a2); } + + void f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); } + void g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); } + + void f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); } + void g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); } + + void f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); } + void g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); } + + void f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); } + void g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); } + + void f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); } + void g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); } + + void f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); } + void g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); } +}; + +void member_function_test() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + + X x; + + // 0 + + bind(&X::f0, &x)(); + bind(&X::f0, ref(x))(); + + bind(&X::g0, &x)(); + bind(&X::g0, x)(); + bind(&X::g0, ref(x))(); + + // 1 + + bind(&X::f1, &x, 1)(); + bind(&X::f1, ref(x), 1)(); + + bind(&X::g1, &x, 1)(); + bind(&X::g1, x, 1)(); + bind(&X::g1, ref(x), 1)(); + + // 2 + + bind(&X::f2, &x, 1, 2)(); + bind(&X::f2, ref(x), 1, 2)(); + + bind(&X::g2, &x, 1, 2)(); + bind(&X::g2, x, 1, 2)(); + bind(&X::g2, ref(x), 1, 2)(); + + // 3 + + bind(&X::f3, &x, 1, 2, 3)(); + bind(&X::f3, ref(x), 1, 2, 3)(); + + bind(&X::g3, &x, 1, 2, 3)(); + bind(&X::g3, x, 1, 2, 3)(); + bind(&X::g3, ref(x), 1, 2, 3)(); + + // 4 + + bind(&X::f4, &x, 1, 2, 3, 4)(); + bind(&X::f4, ref(x), 1, 2, 3, 4)(); + + bind(&X::g4, &x, 1, 2, 3, 4)(); + bind(&X::g4, x, 1, 2, 3, 4)(); + bind(&X::g4, ref(x), 1, 2, 3, 4)(); + + // 5 + + bind(&X::f5, &x, 1, 2, 3, 4, 5)(); + bind(&X::f5, ref(x), 1, 2, 3, 4, 5)(); + + bind(&X::g5, &x, 1, 2, 3, 4, 5)(); + bind(&X::g5, x, 1, 2, 3, 4, 5)(); + bind(&X::g5, ref(x), 1, 2, 3, 4, 5)(); + + // 6 + + bind(&X::f6, &x, 1, 2, 3, 4, 5, 6)(); + bind(&X::f6, ref(x), 1, 2, 3, 4, 5, 6)(); + + bind(&X::g6, &x, 1, 2, 3, 4, 5, 6)(); + bind(&X::g6, x, 1, 2, 3, 4, 5, 6)(); + bind(&X::g6, ref(x), 1, 2, 3, 4, 5, 6)(); + + // 7 + + bind(&X::f7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + bind(&X::g7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, x, 1, 2, 3, 4, 5, 6, 7)(); + bind(&X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + // 8 + + bind(&X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + bind(&X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + BOOST_TEST( x.hash == 23558 ); +} + +void member_function_void_test() +{ + using boost::phoenix::bind; + using boost::phoenix::ref; + using boost::phoenix::placeholders::_1; + + V v; + + // 0 + + bind(&V::f0, &v)(); + bind(&V::f0, ref(v))(); + + bind(&V::g0, &v)(); + bind(&V::g0, v)(); + bind(&V::g0, ref(v))(); + + // 1 + + bind(&V::f1, &v, 1)(); + bind(&V::f1, ref(v), 1)(); + + bind(&V::g1, &v, 1)(); + bind(&V::g1, v, 1)(); + bind(&V::g1, ref(v), 1)(); + + // 2 + + bind(&V::f2, &v, 1, 2)(); + bind(&V::f2, ref(v), 1, 2)(); + + bind(&V::g2, &v, 1, 2)(); + bind(&V::g2, v, 1, 2)(); + bind(&V::g2, ref(v), 1, 2)(); + + // 3 + + bind(&V::f3, &v, 1, 2, 3)(); + bind(&V::f3, ref(v), 1, 2, 3)(); + + bind(&V::g3, &v, 1, 2, 3)(); + bind(&V::g3, v, 1, 2, 3)(); + bind(&V::g3, ref(v), 1, 2, 3)(); + + // 4 + + bind(&V::f4, &v, 1, 2, 3, 4)(); + bind(&V::f4, ref(v), 1, 2, 3, 4)(); + + bind(&V::g4, &v, 1, 2, 3, 4)(); + bind(&V::g4, v, 1, 2, 3, 4)(); + bind(&V::g4, ref(v), 1, 2, 3, 4)(); + + // 5 + + bind(&V::f5, &v, 1, 2, 3, 4, 5)(); + bind(&V::f5, ref(v), 1, 2, 3, 4, 5)(); + + bind(&V::g5, &v, 1, 2, 3, 4, 5)(); + bind(&V::g5, v, 1, 2, 3, 4, 5)(); + bind(&V::g5, ref(v), 1, 2, 3, 4, 5)(); + + // 6 + + bind(&V::f6, &v, 1, 2, 3, 4, 5, 6)(); + bind(&V::f6, ref(v), 1, 2, 3, 4, 5, 6)(); + + bind(&V::g6, &v, 1, 2, 3, 4, 5, 6)(); + bind(&V::g6, v, 1, 2, 3, 4, 5, 6)(); + bind(&V::g6, ref(v), 1, 2, 3, 4, 5, 6)(); + + // 7 + + bind(&V::f7, &v, 1, 2, 3, 4, 5, 6, 7)(); + bind(&V::f7, ref(v), 1, 2, 3, 4, 5, 6, 7)(); + + bind(&V::g7, &v, 1, 2, 3, 4, 5, 6, 7)(); + bind(&V::g7, v, 1, 2, 3, 4, 5, 6, 7)(); + bind(&V::g7, ref(v), 1, 2, 3, 4, 5, 6, 7)(); + + // 8 + + bind(&V::f8, &v, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&V::f8, ref(v), 1, 2, 3, 4, 5, 6, 7, 8)(); + + bind(&V::g8, &v, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&V::g8, v, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind(&V::g8, ref(v), 1, 2, 3, 4, 5, 6, 7, 8)(); + + BOOST_TEST( v.hash == 23558 ); +} + +void nested_bind_test() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + using boost::phoenix::placeholders::_2; + + int const x = 1; + int const y = 2; + + BOOST_TEST( bind(f_1, bind(f_1, _1))(x) == 1L ); + BOOST_TEST( bind(f_1, bind(f_2, _1, _2))(x, y) == 21L ); + BOOST_TEST( bind(f_2, bind(f_1, _1), bind(f_1, _1))(x) == 11L ); + BOOST_TEST( bind(f_2, bind(f_1, _1), bind(f_1, _2))(x, y) == 21L ); + BOOST_TEST( bind(f_1, bind(f_0))() == 17041L ); + + BOOST_TEST( (bind(fv_1, bind(f_1, _1))(x), (global_result == 1L)) ); + BOOST_TEST( (bind(fv_1, bind(f_2, _1, _2))(x, y), (global_result == 21L)) ); + BOOST_TEST( (bind(fv_2, bind(f_1, _1), bind(f_1, _1))(x), (global_result == 11L)) ); + BOOST_TEST( (bind(fv_2, bind(f_1, _1), bind(f_1, _2))(x, y), (global_result == 21L)) ); + BOOST_TEST( (bind(fv_1, bind(f_0))(), (global_result == 17041L)) ); +} + +int main() +{ + function_test(); + function_object_test(); + function_object_test2(); + +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + adaptable_function_object_test(); +#endif + + member_function_test(); + member_function_void_test(); + nested_bind_test(); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_unary_addr.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_unary_addr.cpp new file mode 100644 index 00000000..9a02a271 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_unary_addr.cpp @@ -0,0 +1,151 @@ +/*============================================================================== + Copyright (c) 2005 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +class X +{ +private: + + void operator& (); + void operator& () const; + +public: + + typedef void result_type; + + void operator()() + { + } + + void operator()() const + { + } + + void operator()(int) + { + } + + void operator()(int) const + { + } + + void operator()(int, int) + { + } + + void operator()(int, int) const + { + } + + void operator()(int, int, int) + { + } + + void operator()(int, int, int) const + { + } + + void operator()(int, int, int, int) + { + } + + void operator()(int, int, int, int) const + { + } + + void operator()(int, int, int, int, int) + { + } + + void operator()(int, int, int, int, int) const + { + } + + void operator()(int, int, int, int, int, int) + { + } + + void operator()(int, int, int, int, int, int) const + { + } + + void operator()(int, int, int, int, int, int, int) + { + } + + void operator()(int, int, int, int, int, int, int) const + { + } + + void operator()(int, int, int, int, int, int, int, int) + { + } + + void operator()(int, int, int, int, int, int, int, int) const + { + } + + void operator()(int, int, int, int, int, int, int, int, int) + { + } + + void operator()(int, int, int, int, int, int, int, int, int) const + { + } +}; + +template<class F> void test_const( F const & f ) +{ + f(); +} + +template<class F> void test( F f ) +{ + f(); + test_const( f ); +} + +int main() +{ + using boost::phoenix::bind; + + test( bind( X() ) ); + test( bind( X(), 1 ) ); + test( bind( X(), 1, 2 ) ); + test( bind( X(), 1, 2, 3 ) ); + test( bind( X(), 1, 2, 3, 4 ) ); + test( bind( X(), 1, 2, 3, 4, 5 ) ); + test( bind( X(), 1, 2, 3, 4, 5, 6 ) ); + test( bind( X(), 1, 2, 3, 4, 5, 6, 7 ) ); + test( bind( X(), 1, 2, 3, 4, 5, 6, 7, 8 ) ); + test( bind( X(), 1, 2, 3, 4, 5, 6, 7, 8, 9 ) ); + + return 0; +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_visit_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_visit_test.cpp new file mode 100644 index 00000000..2c518a4d --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_visit_test.cpp @@ -0,0 +1,76 @@ +/*============================================================================== + Copyright (c) 2006 Douglas Gregor <doug.gregor@gmail.com> + Copyright (c) 2006 Peter Dimov + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/config.hpp> + +#if defined(BOOST_MSVC) +# pragma warning(disable: 4786) // identifier truncated in debug info +# pragma warning(disable: 4710) // function not inlined +# pragma warning(disable: 4711) // function selected for automatic inline expansion +# pragma warning(disable: 4514) // unreferenced inline removed +# pragma warning(disable: 4100) // unreferenced formal parameter (it is referenced!) +#endif + + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/visit_each.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +# pragma warning(push, 3) +#endif + +#include <iostream> +#include <typeinfo> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +# pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +struct visitor +{ + int hash; + + visitor(): hash( 0 ) + { + } + + template<typename T> void operator()( T const & t ) + { + std::cout << "visitor::operator()( T ): " << typeid( t ).name() << std::endl; + } + + void operator()( int const & t ) + { + std::cout << "visitor::operator()( int ): " << t << std::endl; + hash = hash * 10 + t; + } +}; + +int f( int x, int y, int z ) +{ + return x + y + z; +} + +int main() +{ + using boost::phoenix::bind; + using boost::phoenix::placeholders::_1; + + visitor vis; + + boost::visit_each( vis, bind( f, 3, _1, 4 ) ); + + BOOST_TEST( vis.hash == 34 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_void_dm_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_void_dm_test.cpp new file mode 100644 index 00000000..5755fb65 --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_void_dm_test.cpp @@ -0,0 +1,73 @@ +/*============================================================================== + Copyright (c) 2006 Peter Dimov + Copyright (c) 2014 Agustin Berge + 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/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/ref.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +// + +struct Z +{ + int m; +}; + +void member_data_test() +{ + using boost::phoenix::bind; + + Z z = { 17041 }; + Z * pz = &z; + + bind<void>( &Z::m, _1 )( z ); + bind<void>( &Z::m, _1 )( pz ); + + bind<void>( &Z::m, z )(); + bind<void>( &Z::m, pz )(); + bind<void>( &Z::m, boost::ref(z) )(); + + + Z const cz = z; + Z const * pcz = &cz; + + bind<void>( &Z::m, _1 )( cz ); + bind<void>( &Z::m, _1 )( pcz ); + + bind<void>( &Z::m, cz )(); + bind<void>( &Z::m, pcz )(); + bind<void>( &Z::m, boost::ref(cz) )(); +} + +int main() +{ + member_data_test(); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_void_mf_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_void_mf_test.cpp new file mode 100644 index 00000000..62c2dcda --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_void_mf_test.cpp @@ -0,0 +1,171 @@ +#include <boost/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +// +// bind_void_mf_test.cpp - test for bind<void> with member functions +// +// Copyright (c) 2008 Peter Dimov +// Copyright (c) 2014 Agustin Berge +// +// 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/bind.hpp> +#include <boost/ref.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +// + +long global_result; + +// + +struct X +{ + mutable unsigned int hash; + + X(): hash(0) {} + + int f0() { f1(17); return 0; } + int g0() const { g1(17); return 0; } + + int f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; } + int g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; } + + int f2(int a1, int a2) { f1(a1); f1(a2); return 0; } + int g2(int a1, int a2) const { g1(a1); g1(a2); return 0; } + + int f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; } + int g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; } + + int f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; } + int g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; } + + int f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; } + int g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; } + + int f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } + int g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } + + int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } + int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } + + int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } + int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } +}; + +void member_function_test() +{ + using namespace boost; + + X x; + + // 0 + + bind<void>(&X::f0, &x)(); + bind<void>(&X::f0, ref(x))(); + + bind<void>(&X::g0, &x)(); + bind<void>(&X::g0, x)(); + bind<void>(&X::g0, ref(x))(); + + // 1 + + bind<void>(&X::f1, &x, 1)(); + bind<void>(&X::f1, ref(x), 1)(); + + bind<void>(&X::g1, &x, 1)(); + bind<void>(&X::g1, x, 1)(); + bind<void>(&X::g1, ref(x), 1)(); + + // 2 + + bind<void>(&X::f2, &x, 1, 2)(); + bind<void>(&X::f2, ref(x), 1, 2)(); + + bind<void>(&X::g2, &x, 1, 2)(); + bind<void>(&X::g2, x, 1, 2)(); + bind<void>(&X::g2, ref(x), 1, 2)(); + + // 3 + + bind<void>(&X::f3, &x, 1, 2, 3)(); + bind<void>(&X::f3, ref(x), 1, 2, 3)(); + + bind<void>(&X::g3, &x, 1, 2, 3)(); + bind<void>(&X::g3, x, 1, 2, 3)(); + bind<void>(&X::g3, ref(x), 1, 2, 3)(); + + // 4 + + bind<void>(&X::f4, &x, 1, 2, 3, 4)(); + bind<void>(&X::f4, ref(x), 1, 2, 3, 4)(); + + bind<void>(&X::g4, &x, 1, 2, 3, 4)(); + bind<void>(&X::g4, x, 1, 2, 3, 4)(); + bind<void>(&X::g4, ref(x), 1, 2, 3, 4)(); + + // 5 + + bind<void>(&X::f5, &x, 1, 2, 3, 4, 5)(); + bind<void>(&X::f5, ref(x), 1, 2, 3, 4, 5)(); + + bind<void>(&X::g5, &x, 1, 2, 3, 4, 5)(); + bind<void>(&X::g5, x, 1, 2, 3, 4, 5)(); + bind<void>(&X::g5, ref(x), 1, 2, 3, 4, 5)(); + + // 6 + + bind<void>(&X::f6, &x, 1, 2, 3, 4, 5, 6)(); + bind<void>(&X::f6, ref(x), 1, 2, 3, 4, 5, 6)(); + + bind<void>(&X::g6, &x, 1, 2, 3, 4, 5, 6)(); + bind<void>(&X::g6, x, 1, 2, 3, 4, 5, 6)(); + bind<void>(&X::g6, ref(x), 1, 2, 3, 4, 5, 6)(); + + // 7 + + bind<void>(&X::f7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind<void>(&X::f7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + bind<void>(&X::g7, &x, 1, 2, 3, 4, 5, 6, 7)(); + bind<void>(&X::g7, x, 1, 2, 3, 4, 5, 6, 7)(); + bind<void>(&X::g7, ref(x), 1, 2, 3, 4, 5, 6, 7)(); + + // 8 + + bind<void>(&X::f8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind<void>(&X::f8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + bind<void>(&X::g8, &x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind<void>(&X::g8, x, 1, 2, 3, 4, 5, 6, 7, 8)(); + bind<void>(&X::g8, ref(x), 1, 2, 3, 4, 5, 6, 7, 8)(); + + BOOST_TEST( x.hash == 23558 ); +} + +int main() +{ + member_function_test(); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_void_test.cpp b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_void_test.cpp new file mode 100644 index 00000000..bb1e80da --- /dev/null +++ b/src/boost/libs/phoenix/test/boost_bind_compatibility/bind_void_test.cpp @@ -0,0 +1,139 @@ +#include <boost/config.hpp> + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +// +// bind_void_test.cpp - test for bind<void> +// +// Copyright (c) 2008 Peter Dimov +// Copyright (c) 2014 Agustin Berge +// +// 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/bind.hpp> +#include <boost/ref.hpp> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include <iostream> + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include <boost/detail/lightweight_test.hpp> + +// + +long global_result; + +long f_0() +{ + return global_result = 17041L; +} + +long f_1(long a) +{ + return global_result = a; +} + +long f_2(long a, long b) +{ + return global_result = a + 10 * b; +} + +long f_3(long a, long b, long c) +{ + return global_result = a + 10 * b + 100 * c; +} + +long f_4(long a, long b, long c, long d) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d; +} + +long f_5(long a, long b, long c, long d, long e) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e; +} + +long f_6(long a, long b, long c, long d, long e, long f) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f; +} + +long f_7(long a, long b, long c, long d, long e, long f, long g) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; +} + +long f_8(long a, long b, long c, long d, long e, long f, long g, long h) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; +} + +long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +{ + return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; +} + +void function_test() +{ + using namespace boost; + + int const i = 1; + + BOOST_TEST( (bind<void>(f_0)(i), (global_result == 17041L)) ); + BOOST_TEST( (bind<void>(f_1, _1)(i), (global_result == 1L)) ); + BOOST_TEST( (bind<void>(f_2, _1, 2)(i), (global_result == 21L)) ); + BOOST_TEST( (bind<void>(f_3, _1, 2, 3)(i), (global_result == 321L)) ); + BOOST_TEST( (bind<void>(f_4, _1, 2, 3, 4)(i), (global_result == 4321L)) ); + BOOST_TEST( (bind<void>(f_5, _1, 2, 3, 4, 5)(i), (global_result == 54321L)) ); + BOOST_TEST( (bind<void>(f_6, _1, 2, 3, 4, 5, 6)(i), (global_result == 654321L)) ); + BOOST_TEST( (bind<void>(f_7, _1, 2, 3, 4, 5, 6, 7)(i), (global_result == 7654321L)) ); + BOOST_TEST( (bind<void>(f_8, _1, 2, 3, 4, 5, 6, 7, 8)(i), (global_result == 87654321L)) ); + BOOST_TEST( (bind<void>(f_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i), (global_result == 987654321L)) ); +} + +// + +struct Y +{ + short operator()(short & r) const { return global_result = ++r; } + int operator()(int a, int b) const { return global_result = a + 10 * b; } + long operator() (long a, long b, long c) const { return global_result = a + 10 * b + 100 * c; } + void operator() (long a, long b, long c, long d) const { global_result = a + 10 * b + 100 * c + 1000 * d; } +}; + +void function_object_test() +{ + using namespace boost; + + short i(6); + + int const k = 3; + + BOOST_TEST( (bind<void>(Y(), ref(i))(), (global_result == 7)) ); + BOOST_TEST( (bind<void>(Y(), ref(i))(), (global_result == 8)) ); + BOOST_TEST( (bind<void>(Y(), i, _1)(k), (global_result == 38)) ); + BOOST_TEST( (bind<void>(Y(), i, _1, 9)(k), (global_result == 938)) ); + BOOST_TEST( (bind<void>(Y(), i, _1, 9, 4)(k), (global_result == 4938)) ); +} + +int main() +{ + function_test(); + function_object_test(); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/container/container_tests.hpp b/src/boost/libs/phoenix/test/container/container_tests.hpp new file mode 100644 index 00000000..6dc6668e --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests.hpp @@ -0,0 +1,947 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + Copyright (c) 2017 Kohei Takahashi + + 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) +==============================================================================*/ +#if !defined(CONTAINER_TESTS_HPP) +#define CONTAINER_TESTS_HPP + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/stl/container/container.hpp> + +#include <iostream> +#include <typeinfo> +#include <deque> +#include <list> +#include <map> +#include <set> +#include <vector> +#include <utility> +#ifndef BOOST_NO_CXX11_HDR_UNORDERED_MAP +#include <unordered_map> +#endif +#ifndef BOOST_NO_CXX11_HDR_UNORDERED_SET +#include <unordered_set> +#endif + +#ifdef BOOST_MSVC +#pragma warning(disable : 4800) +#endif + +using std::cerr; +namespace phx = boost::phoenix; + +template <typename T> inline T const build_assoc(); + +std::deque<int> const build_deque(); +std::list<int> const build_list(); +std::map<int, int> const build_map(); +std::multimap<int, int> const build_multimap(); +std::vector<int> const build_vector(); +std::set<int> const build_set(); +std::multiset<int> const build_multiset(); +template <> inline std::map<int, int> const build_assoc() { return build_map(); } +template <> inline std::multimap<int, int> const build_assoc() { return build_multimap(); } +template <> inline std::set<int> const build_assoc() { return build_set(); } +template <> inline std::multiset<int> const build_assoc() { return build_multiset(); } +#ifndef BOOST_NO_CXX11_HDR_UNORDERED_MAP +std::unordered_map<int, int> const build_unordered_map(); +std::unordered_multimap<int, int> const build_unordered_multimap(); +template <> inline std::unordered_map<int, int> const build_assoc() { return build_unordered_map(); } +template <> inline std::unordered_multimap<int, int> const build_assoc() { return build_unordered_multimap(); } +#endif +#ifndef BOOST_NO_CXX11_HDR_UNORDERED_SET +std::unordered_set<int> const build_unordered_set(); +std::unordered_multiset<int> const build_unordered_multiset(); +template <> inline std::unordered_set<int> const build_assoc() { return build_unordered_set(); } +template <> inline std::unordered_multiset<int> const build_assoc() { return build_unordered_multiset(); } +#endif + +inline bool +test(bool fail) +{ + BOOST_TEST(!fail); + return fail; +} + +template <typename Container> +void test_assign(Container c) +{ + using phx::arg_names::arg1; + + typename Container::size_type count = 2; + typename Container::const_iterator first = c.begin(); + typename Container::const_iterator second = first; + typename Container::value_type value = *first; + + phx::assign(arg1, count, value)(c); + + // iterators may be invalidated! + first = c.begin(); + second = first; + + std::advance(second, 1); + if (test(*first != *second)) { + cerr << "Failed " << typeid(Container).name() << " test_assign 1\n"; + return; + } +#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST) + // Should not --- does not, Yay! --- compile. + Container const const_c = c; + phx::assign(const_c, count, value); +#endif +} + +template <typename Container> +void test_assign2(Container c) +{ + using phx::arg_names::arg1; + using phx::arg_names::arg2; + using phx::arg_names::arg3; + + Container c2 = c; + typename Container::const_iterator first = c2.begin(); + typename Container::const_iterator last = c2.end(); + typename Container::size_type size = c2.size(); + + c.clear(); + phx::assign(arg1, arg2, arg3)(c, first, last); + if (test(c.size() != size)) { + cerr << "Failed " << typeid(Container).name() + << " test_assign2 1\n" + << "size == " << c.size() << '\n'; + return; + } + +#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST) + // Should not --- does not, Yay! --- compile. + Container const const_c = c; + phx::assign(const_c, first, second); +#endif +} + +template <typename Container> +void test_at(Container c) +{ + using phx::arg_names::arg1; + using phx::at; + + typename Container::reference r1 = at(arg1, 0)(c); + if (test(r1 != c.at(0))) { + cerr << "Failed " << typeid(Container).name() << " test_at 1\n"; + return; + } + + typename Container::const_reference r2 = at(arg1, 0)(c); + if (test(r2 != c.at(0))) { + cerr << "Failed " << typeid(Container).name() << " test_at 2\n"; + return; + } + + Container const const_c = c; +#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST) + // Should not --- does not, Yay! --- compile. + typename Container::reference r3 = at(arg1, 0)(const_c); +#endif + + typename Container::const_reference r4 = at(arg1, 0)(const_c); + if (test(r4 != c.at(0))) { + cerr << "Failed " << typeid(Container).name() << " test_at 4\n"; + return; + } +} + +template <typename Container> +void test_back(Container c) +{ + using phx::arg_names::arg1; + using phx::back; + + typename Container::reference r1 = back(arg1)(c); + if (test(r1 != c.back())) { + cerr << "Failed " << typeid(Container).name() << " test_back 1\n"; + return; + } + typename Container::const_reference r2 = back(arg1)(c); + if (test(r2 != c.back())) { + cerr << "Failed " << typeid(Container).name() << " test_back 2\n"; + return; + } + + Container const const_c = c; +#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST) + // Should not --- does not, Yay! --- compile. + typename Container::reference r3 = back(arg1)(const_c); +#endif + + typename Container::const_reference r4 = back(arg1)(const_c); + if (test(r4 != c.back())) { + cerr << "Failed " << typeid(Container).name() << " test_back 4\n"; + return; + } +} + +template <typename Container> +void test_begin(Container c) +{ + using phx::arg_names::arg1; + using phx::begin; + + typename Container::iterator it1 = begin(arg1)(c); + if (test(it1 != c.begin())) { + cerr << "Failed " << typeid(Container).name() << " test_begin 1\n"; + return; + } + typename Container::const_iterator it2 = begin(arg1)(c); + if (test(it2 != c.begin())) { + cerr << "Failed " << typeid(Container).name() << " test_begin 2\n"; + return; + } + + Container const const_c = c; +#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST) + // Should not --- does not, Yay! --- compile. + typename Container::iterator it3 = begin(arg1)(const_c); +#endif + + typename Container::const_iterator it4 = begin(arg1)(const_c); + if (test(it4 != const_c.begin())) { + cerr << "Failed " << typeid(Container).name() << " test_begin 4\n"; + return; + } +} + +template <typename Container> +void test_capacity(Container c) +{ + using phx::arg_names::arg1; + using phx::capacity; + + typename Container::size_type s1 = capacity(arg1)(c); + if (test(s1 != c.capacity())) { + cerr << "Failed " << typeid(Container).name() << " test_capacity 1\n"; + return; + } + + Container const const_c = c; + typename Container::size_type s2 = capacity(arg1)(const_c); + if (test(s2 != const_c.capacity())) { + cerr << "Failed " << typeid(Container).name() << " test_capacity 2\n"; + return; + } +} + +template <typename Container> +void test_clear(Container c) +{ + using phx::arg_names::arg1; + using phx::clear; + + clear(arg1)(c); + if (test(!c.empty())) { + cerr << "Failed " << typeid(Container).name() << " test_clear 1\n"; + return; + } + +#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST) + Container const const_c = c; + clear(arg1)(const_c); +#endif +} + +template <typename Container> +void test_empty(Container c) +{ + using phx::arg_names::arg1; + using phx::empty; + + typename Container::size_type s1 = empty(arg1)(c); + if (test(bool(s1) != c.empty())) { + cerr << "Failed " << typeid(Container).name() << " test_empty 1\n"; + return; + } + + Container const const_c = c; + typename Container::size_type s2 = empty(arg1)(const_c); + if (test(bool(s2) != const_c.empty())) { + cerr << "Failed " << typeid(Container).name() << " test_empty 2\n"; + return; + } +} + +template <typename Container> +void test_end(Container c) +{ + using phx::arg_names::arg1; + using phx::end; + + typename Container::iterator it1 = end(arg1)(c); + if (test(it1 != c.end())) { + cerr << "Failed " << typeid(Container).name() << " test_end 1\n"; + return; + } + typename Container::const_iterator it2 = end(arg1)(c); + if (test(it2 != c.end())) { + cerr << "Failed " << typeid(Container).name() << " test_end 2\n"; + return; + } + + Container const const_c = c; +#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST) + // Should not --- does not, Yay! --- compile. + typename Container::iterator it3 = end(arg1)(const_c); +#endif + + typename Container::const_iterator it4 = end(arg1)(const_c); + if (test(it4 != const_c.end())) { + cerr << "Failed " << typeid(Container).name() << " test_end 4\n"; + return; + } +} + +template <typename Container> +void test_erase(Container c) +{ + using phx::arg_names::arg1; + using phx::arg_names::arg2; + using phx::arg_names::arg3; + using phx::erase; + + Container const const_c = c; + + typename Container::size_type size = c.size(); + typename Container::iterator c_begin = c.begin(); + erase(arg1, arg2)(c, c_begin); + if (test(c.size() + 1 != size)) { + cerr << "Failed " << typeid(Container).name() << " test_erase 1\n"; + return; + } + + c_begin = c.begin(); + typename Container::iterator c_end = c.end(); + erase(arg1, arg2, arg3)(c, c_begin, c_end); + if (test(!c.empty())) { + cerr << "Failed " << typeid(Container).name() << " test_erase 2\n"; + return; + } + +#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST) + erase(arg1, const_c.begin())(const_c); + erase(arg1, const_c.begin(), const_c.end())(const_c); +#endif +} + +template <typename Container> +void test_map_erase(Container c) +{ + test_erase(c); + if (boost::report_errors() != 0) + return; + + using phx::arg_names::arg1; + using phx::arg_names::arg2; + using phx::erase; + + typename Container::value_type const value = *c.begin(); + typename Container::key_type const key = value.first; + typename Container::size_type const removed = + erase(arg1, arg2)(c, key); + if (test(removed != 1)) { + cerr << "Failed " << typeid(Container).name() << " test_map_erase 1\n"; + return; + } +} + +template <typename Container> +void test_set_erase(Container c) +{ + test_erase(c); + if (boost::report_errors() != 0) + return; + + using phx::arg_names::arg1; + using phx::arg_names::arg2; + using phx::erase; + + typename Container::value_type const value = *c.begin(); + typename Container::key_type const key = value; + typename Container::size_type const removed = + erase(arg1, arg2)(c, key); + if (test(removed != 1)) { + cerr << "Failed " << typeid(Container).name() << " test_set_erase 1\n"; + return; + } +} + +template <typename Container> +void test_front(Container c) +{ + using phx::arg_names::arg1; + using phx::front; + + typename Container::reference r1 = front(arg1)(c); + if (test(r1 != c.front())) { + cerr << "Failed " << typeid(Container).name() << " test_front 1\n"; + return; + } + typename Container::const_reference r2 = front(arg1)(c); + if (test(r2 != c.front())) { + cerr << "Failed " << typeid(Container).name() << " test_front 2\n"; + return; + } + + Container const const_c = c; +#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST) + // Should not --- does not, Yay! --- compile. + typename Container::reference r3 = front(arg1)(const_c); +#endif + + typename Container::const_reference r4 = front(arg1)(const_c); + if (test(r4 != c.front())) { + cerr << "Failed " << typeid(Container).name() << " test_front 4\n"; + return; + } +} + +template <typename Container> +void test_get_allocator(Container c) +{ + using phx::arg_names::arg1; + using phx::get_allocator; + + Container const const_c = c; + + typename Container::allocator_type a1 = get_allocator(arg1)(c); + if (test(a1 != c.get_allocator())) { + cerr << "Failed " << typeid(Container).name() << " test_get_allocator 1\n"; + return; + } + + typename Container::allocator_type a2 = get_allocator(arg1)(const_c); + if (test(a2 != const_c.get_allocator())) { + cerr << "Failed " << typeid(Container).name() << " test_get_allocator 2\n"; + return; + } +} + +template <typename Container> +void test_insert(Container c) +{ + using phx::arg_names::arg1; + using phx::insert; + + typename Container::value_type const value = *c.begin(); + typename Container::iterator it = insert(arg1, c.begin(), value)(c); + if (test(it != c.begin() || *it != *(++it))) { + cerr << "Failed " << typeid(Container).name() << " test_insert 1\n"; + return; + } + + typename Container::size_type size = c.size(); + insert(arg1, c.begin(), 3, value)(c); + if (test(c.size() != size + 3)) { + cerr << "Failed " << typeid(Container).name() << " test_insert 2\n"; + return; + } + + Container const const_c = c; + size = c.size(); + insert(arg1, c.begin(), const_c.begin(), const_c.end())(c); + if (test(c.size() != 2 * size)) { + cerr << "Failed " << typeid(Container).name() << " test_insert 3\n"; + return; + } +} + +template <typename Map> +inline void test_map_insert(Map c) +{ + using phx::arg_names::arg1; + using phx::arg_names::arg2; + using phx::arg_names::arg3; + + typename Map::value_type const value = *c.begin(); + typename Map::iterator c_begin = c.begin(); + // wrapper for + // iterator insert(iterator where, const value_type& val); + typename Map::iterator it = + phx::insert(arg1, arg2, arg3)(c, c_begin, value); + + if (test(it != c.begin() /*|| *it != *(++it)*/)) { + cerr << "Failed " << typeid(Map).name() << " test_map_insert 1\n"; + return; + } + + // wrapper for + // pair<iterator, bool> insert(const value_type& val); + typename Map::value_type const value2(1400, 2200); + std::pair<typename Map::iterator, bool> result = + phx::insert(arg1, arg2)(c, value2); + if (test(!result.second)) { + cerr << "Failed " << typeid(Map).name() << " test_map_insert 2\n"; + return; + } + + // wrapper for + // template<class InIt> + // void insert(InIt first, InIt last); + Map const const_c = build_assoc<Map>(); + typename Map::size_type size = c.size(); + phx::insert(arg1, const_c.begin(), const_c.end())(c); + if (test(c.size() != size + const_c.size())) { + cerr << "Failed " << typeid(Map).name() << " test_map_insert 3\n"; + return; + } +} + +template <typename Multimap> +inline void test_multimap_insert(Multimap c) +{ + using phx::arg_names::arg1; + using phx::arg_names::arg2; + using phx::arg_names::arg3; + + typename Multimap::value_type const value = *c.begin(); + typename Multimap::iterator c_begin = c.begin(); + std::size_t old_size = c.size(); + // wrapper for + // iterator insert(iterator where, const value_type& val); + typename Multimap::iterator it = + phx::insert(arg1, arg2, arg3)(c, c_begin, value); + + if (test(*it != value || c.size() != old_size + 1)) { + cerr << "Failed " << typeid(Multimap).name() + << " test_multimap_insert 1\n"; + return; + } + + // wrapper for + // iterator insert(const value_type& val); + typename Multimap::value_type const value2(1400, 2200); + it = phx::insert(arg1, arg2)(c, value2); + if (test(it == c.end())) { + cerr << "Failed " << typeid(Multimap).name() + << " test_multimap_insert 2\n"; + return; + } + + // wrapper for + // template<class InIt> + // void insert(InIt first, InIt last); + Multimap const const_c = build_assoc<Multimap>(); + typename Multimap::size_type size = c.size(); + phx::insert(arg1, const_c.begin(), const_c.end())(c); + if (test(c.size() != size + const_c.size())) { + cerr << "Failed " << typeid(Multimap).name() + << " test_multimap_insert 3\n"; + return; + } +} + +template <typename Set> +inline void test_set_insert(Set c) +{ + using phx::arg_names::arg1; + using phx::arg_names::arg2; + using phx::arg_names::arg3; + + typename Set::value_type const value = *c.begin(); + typename Set::iterator c_begin = c.begin(); + // wrapper for + // iterator insert(iterator where, const value_type& val); + typename Set::iterator it = + phx::insert(arg1, arg2, arg3)(c, c_begin, value); + + if (test(it != c.begin() /*|| *it != *(++it)*/)) { + cerr << "Failed " << typeid(Set).name() << " test_set_insert 1\n"; + return; + } + + // wrapper for + // pair<iterator, bool> insert(const value_type& val); + typename Set::value_type const value2(1400); + std::pair<typename Set::iterator, bool> result = + phx::insert(arg1, arg2)(c, value2); + if (test(!result.second)) { + cerr << "Failed " << typeid(Set).name() << " test_set_insert 2\n"; + return; + } + + // wrapper for + // template<class InIt> + // void insert(InIt first, InIt last); + Set const const_c = build_assoc<Set>(); + typename Set::size_type size = c.size(); + phx::insert(arg1, const_c.begin(), const_c.end())(c); + if (test(c.size() != size + const_c.size())) { + cerr << "Failed " << typeid(Set).name() << " test_set_insert 3\n"; + return; + } +} + +template <typename Multiset> +inline void test_multiset_insert(Multiset c) +{ + using phx::arg_names::arg1; + using phx::arg_names::arg2; + using phx::arg_names::arg3; + + typename Multiset::value_type const value = *c.begin(); + typename Multiset::iterator c_begin = c.begin(); + std::size_t old_size = c.size(); + // wrapper for + // iterator insert(iterator where, const value_type& val); + typename Multiset::iterator it = + phx::insert(arg1, arg2, arg3)(c, c_begin, value); + + if (test(*it != value || c.size() != old_size + 1)) { + cerr << "Failed " << typeid(Multiset).name() + << " test_multiset_insert 1\n"; + return; + } + + // wrapper for + // iterator insert(const value_type& val); + typename Multiset::value_type const value2(1400); + it = phx::insert(arg1, arg2)(c, value2); + if (test(it == c.end())) { + cerr << "Failed " << typeid(Multiset).name() + << " test_multiset_insert 2\n"; + return; + } + + // wrapper for + // template<class InIt> + // void insert(InIt first, InIt last); + Multiset const const_c = build_assoc<Multiset>(); + typename Multiset::size_type size = c.size(); + phx::insert(arg1, const_c.begin(), const_c.end())(c); + if (test(c.size() != size + const_c.size())) { + cerr << "Failed " << typeid(Multiset).name() + << " test_multiset_insert 3\n"; + return; + } +} + +template <typename Container> +void test_key_comp(Container c) +{ + using phx::arg_names::arg1; + using phx::key_comp; + + typename Container::key_compare comp = key_comp(arg1)(c); + + Container const const_c = c; + comp = key_comp(arg1)(const_c); +} + +template <typename Container> +void test_max_size(Container c) +{ + using phx::arg_names::arg1; + using phx::max_size; + + Container const const_c = c; + + typename Container::size_type s1 = max_size(arg1)(c); + if (test(s1 != c.max_size())) { + cerr << "Failed " << typeid(Container).name() << " test_max_size 1\n"; + return; + } + + typename Container::size_type s2 = max_size(arg1)(const_c); + if (test(s2 != const_c.max_size())) { + cerr << "Failed " << typeid(Container).name() << " test_max_size 2\n"; + return; + } +} + +template <typename Container> +void test_pop_back(Container c) +{ + using phx::arg_names::arg1; + using phx::pop_back; + + Container const const_c = c; + + typename Container::size_type size = c.size(); + + pop_back(arg1)(c); + if (test(c.size() + 1 != size)) { + cerr << "Failed " << typeid(Container).name() << " test_pop_back 1\n"; + return; + } + +#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST) + pop_back(arg1)(const_c); +#endif +} + +template <typename Container> +void test_pop_front(Container c) +{ + using phx::arg_names::arg1; + using phx::pop_front; + + Container const const_c = c; + + typename Container::size_type size = c.size(); + + pop_front(arg1)(c); + if (test(c.size() + 1 != size)) { + cerr << "Failed " << typeid(Container).name() << " test_pop_front 1\n"; + return; + } +#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST) + pop_front(arg1)(const_c); +#endif +} + +template <typename Container> +void test_push_back(Container c) +{ + using phx::arg_names::arg1; + using phx::arg_names::arg2; + using phx::push_back; + + Container const const_c = c; + + typename Container::value_type data = *c.begin(); + typename Container::size_type size = c.size(); + push_back(arg1, arg2)(c, data); + if (test(c.size() != size + 1)) { + cerr << "Failed " << typeid(Container).name() << " test_push_back 1\n"; + return; + } +#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST) + push_back(arg1, arg2)(const_c, data); +#endif +} + +template <typename Container> +void test_push_front(Container c) +{ + using phx::arg_names::arg1; + using phx::arg_names::arg2; + using phx::push_front; + + Container const const_c = c; + + typename Container::value_type data = *c.begin(); + typename Container::size_type size = c.size(); + push_front(arg1, arg2)(c, data); + if (test(c.size() != size + 1)) { + cerr << "Failed " << typeid(Container).name() << " test_push_front 1\n"; + return; + } +#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST) + push_front(arg1, arg2)(const_c, data); +#endif +} + +template <typename Container> +void test_rbegin(Container c) +{ + using phx::arg_names::arg1; + using phx::rbegin; + + typename Container::reverse_iterator it1 = rbegin(arg1)(c); + typename Container::reverse_iterator it1_test = c.rbegin(); + if (test(it1 != it1_test)) { + cerr << "Failed " << typeid(Container).name() << " test_rbegin 1\n"; + return; + } + typename Container::const_reverse_iterator it2 = rbegin(arg1)(c); + typename Container::const_reverse_iterator it2_test = c.rbegin(); + if (test(it2 != it2_test)) { + cerr << "Failed " << typeid(Container).name() << " test_rbegin 2\n"; + return; + } + + Container const const_c = c; +#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST) + // Should not --- does not, Yay! --- compile. + typename Container::reverse_iterator it3 = rbegin(arg1)(const_c); +#endif + + typename Container::const_reverse_iterator it4 = rbegin(arg1)(const_c); + it2_test = const_c.rbegin(); + if (test(it4 != it2_test)) { + cerr << "Failed " << typeid(Container).name() << " test_rbegin 4\n"; + return; + } +} + +template <typename Container> +void test_rend(Container c) +{ + using phx::arg_names::arg1; + using phx::rend; + + typename Container::reverse_iterator it1 = rend(arg1)(c); + typename Container::reverse_iterator it1_test = c.rend(); + if (test(it1 != it1_test)) { + cerr << "Failed " << typeid(Container).name() << " test_rend 1\n"; + return; + } + typename Container::const_reverse_iterator it2 = rend(arg1)(c); + typename Container::const_reverse_iterator it2_test = c.rend(); + if (test(it2 != it2_test)) { + cerr << "Failed " << typeid(Container).name() << " test_rend 2\n"; + return; + } + + Container const const_c = c; +#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST) + // Should not --- does not, Yay! --- compile. + typename Container::reverse_iterator it3 = rend(arg1)(const_c); +#endif + + typename Container::const_reverse_iterator it4 = rend(arg1)(const_c); + it2_test = const_c.rend(); + if (test(it4 != it2_test)) { + cerr << "Failed " << typeid(Container).name() << " test_rend 4\n"; + return; + } +} + +template <typename Container> +void test_reserve(Container c) +{ + using phx::arg_names::arg1; + using phx::reserve; + + Container const const_c = c; + + typename Container::size_type count = 2 * c.size(); + reserve(arg1, count)(c); + if (test(c.capacity() < count)) { + cerr << "Failed " << typeid(Container).name() << " test_reserve 1\n"; + return; + } +#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST) + reserve(arg1, count)(const_c)(const_c); +#endif +} + +template <typename Container> +void test_resize(Container c) +{ + using phx::arg_names::arg1; + using phx::resize; + + Container const const_c = c; + + typename Container::size_type new_size = 2 * c.size(); + resize(arg1, new_size)(c); + if (test(c.size() != new_size)) { + cerr << "Failed " << typeid(Container).name() << " test_resize 1\n"; + return; + } + + new_size = 2 * c.size(); + typename Container::value_type value = *c.begin(); + resize(arg1, new_size, value)(c); + if (test(c.size() != new_size)) { + cerr << "Failed " << typeid(Container).name() << " test_resize 2\n"; + return; + } +#if defined(BOOST_PHOENIX_COMPILE_FAIL_TEST) + new_size = 2 * const_c.size(); + resize(arg1, new_size)(const_c); + + new_size = 2 * const_c.size(); + resize(arg1, new_size, value)(const_c); +#endif +} + +template <typename Container> +void test_size(Container c) +{ + using phx::arg_names::arg1; + using phx::size; + + Container const const_c = c; + + typename Container::size_type s1 = size(arg1)(c); + if (test(s1 != c.size())) { + cerr << "Failed " << typeid(Container).name() << " test_size 1\n"; + return; + } + + typename Container::size_type s2 = size(arg1)(const_c); + if (test(s2 != const_c.size())) { + cerr << "Failed " << typeid(Container).name() << " test_size 2\n"; + return; + } +} + +template <typename Container> +void test_splice(Container c) +{ + using phx::arg_names::arg1; + using phx::arg_names::arg2; + using phx::arg_names::arg3; + using phx::arg_names::arg4; + using phx::arg_names::arg5; + using phx::splice; + + typename Container::iterator c_end; + typename Container::iterator c2_begin; + typename Container::iterator c2_end; + typename Container::size_type size = c.size(); + + Container const copy = c; + Container const copy2 = build_list(); + Container c2 = copy2; + + size = c.size(); + c_end = c.end(); + splice(arg1, arg2, arg3)(c, c_end, c2); + if (test(c.size() != 2 * size)) { + cerr << "Failed " << typeid(Container).name() << " test_splice 1\n"; + return; + } + + c = copy; + c_end = c.end(); + c2 = copy2; + c2_begin = c2.begin(); + size = c.size() + 1; + splice(arg1, arg2, arg3, arg4)(c, c_end, c2, c2_begin); + if (test(c.size() != size)) { + cerr << "Failed " << typeid(Container).name() << " test_splice 2\n"; + return; + } + + c = copy; + c_end = c.end(); + c2 = copy2; + c2_begin = c2.begin(); + c2_end = c2.end(); + size = c.size() + c2.size(); + /* + splice(arg1, arg2, arg3, arg4, arg5)(c, c_end, c2, c2_begin, c2_end); + if (test(c.size() != size)) { + cerr << "Failed " << typeid(Container).name() << " test_splice 3\n"; + return; + } + */ +} + +template <typename Container> +void test_value_comp(Container c) +{ + using phx::arg_names::arg1; + using phx::value_comp; + + typename Container::value_compare comp = value_comp(arg1)(c); + + Container const const_c = c; + comp = value_comp(arg1)(const_c); +} + +#endif diff --git a/src/boost/libs/phoenix/test/container/container_tests10a.cpp b/src/boost/libs/phoenix/test/container/container_tests10a.cpp new file mode 100644 index 00000000..e7a06062 --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests10a.cpp @@ -0,0 +1,73 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + Copyright (c) 2017 Kohei Takahashi + + 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 "container_tests.hpp" +#include <boost/static_assert.hpp> + +std::unordered_map<int, int> const build_unordered_map() +{ + typedef std::unordered_map<int, int> int_map; + typedef std::vector<int> int_vector; + + int_map result; + int_vector const data = build_vector(); + int_vector::const_iterator it = data.begin(); + int_vector::const_iterator const end = data.end(); + for (; it != end; ++it) { + int const value = *it; + result[value] = 100 * value; + } + return result; +} + +std::unordered_multimap<int, int> const build_unordered_multimap() +{ + typedef std::unordered_map<int, int> int_map; + typedef std::unordered_multimap<int, int> int_multimap; + int_map const data = build_unordered_map(); + return int_multimap(data.begin(), data.end()); +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((phx::stl::has_mapped_type<std::unordered_multimap<int, int> >::value)); + BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::unordered_multimap<int, int> >::value)); + + std::unordered_multimap<int, int> const data = build_unordered_multimap(); + test_begin(data); + test_clear(data); + test_empty(data); + test_end(data); + test_map_erase(data); + test_get_allocator(data); + return boost::report_errors(); +} + + + + diff --git a/src/boost/libs/phoenix/test/container/container_tests10b.cpp b/src/boost/libs/phoenix/test/container/container_tests10b.cpp new file mode 100644 index 00000000..5ff194a9 --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests10b.cpp @@ -0,0 +1,74 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + Copyright (c) 2017 Kohei Takahashi + + 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 "container_tests.hpp" +#include <boost/static_assert.hpp> + +std::unordered_map<int, int> const build_unordered_map() +{ + typedef std::unordered_map<int, int> int_map; + typedef std::vector<int> int_vector; + + int_map result; + int_vector const data = build_vector(); + int_vector::const_iterator it = data.begin(); + int_vector::const_iterator const end = data.end(); + for (; it != end; ++it) { + int const value = *it; + result[value] = 100 * value; + } + return result; +} + +std::unordered_multimap<int, int> const build_unordered_multimap() +{ + typedef std::unordered_map<int, int> int_map; + typedef std::unordered_multimap<int, int> int_multimap; + int_map const data = build_unordered_map(); + return int_multimap(data.begin(), data.end()); +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((phx::stl::has_mapped_type<std::unordered_multimap<int, int> >::value)); + BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::unordered_multimap<int, int> >::value)); + + std::unordered_multimap<int, int> const data = build_unordered_multimap(); + test_multimap_insert(data); + //test_key_comp(data); + test_max_size(data); + //test_rbegin(data); + //test_rend(data); + test_size(data); + //test_value_comp(data); + return boost::report_errors(); +} + + + + diff --git a/src/boost/libs/phoenix/test/container/container_tests11a.cpp b/src/boost/libs/phoenix/test/container/container_tests11a.cpp new file mode 100644 index 00000000..b89c3c8f --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests11a.cpp @@ -0,0 +1,59 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + Copyright (c) 2017 Kohei Takahashi + + 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 "container_tests.hpp" +#include <boost/static_assert.hpp> + +std::unordered_set<int> const build_unordered_set() +{ + typedef std::unordered_set<int> int_set; + typedef std::vector<int> int_vector; + + int_set result; + int_vector const data = build_vector(); + int_vector::const_iterator it = data.begin(); + int_vector::const_iterator const end = data.end(); + result.insert(it, end); + return result; +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::unordered_set<int> >::value)); + BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::unordered_set<int> >::value)); + + std::unordered_set<int> const data = build_unordered_set(); + test_begin(data); + test_clear(data); + test_empty(data); + test_end(data); + test_set_erase(data); + test_get_allocator(data); + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/container/container_tests11b.cpp b/src/boost/libs/phoenix/test/container/container_tests11b.cpp new file mode 100644 index 00000000..53e2be9c --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests11b.cpp @@ -0,0 +1,60 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + Copyright (c) 2017 Kohei Takahashi + + 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 "container_tests.hpp" +#include <boost/static_assert.hpp> + +std::unordered_set<int> const build_unordered_set() +{ + typedef std::unordered_set<int> int_set; + typedef std::vector<int> int_vector; + + int_set result; + int_vector const data = build_vector(); + int_vector::const_iterator it = data.begin(); + int_vector::const_iterator const end = data.end(); + result.insert(it, end); + return result; +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::unordered_set<int> >::value)); + BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::unordered_set<int> >::value)); + + std::unordered_set<int> const data = build_unordered_set(); + test_set_insert(data); + //test_key_comp(data); + test_max_size(data); + //test_rbegin(data); + //test_rend(data); + test_size(data); + //test_value_comp(data); + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/container/container_tests12a.cpp b/src/boost/libs/phoenix/test/container/container_tests12a.cpp new file mode 100644 index 00000000..06c5d94e --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests12a.cpp @@ -0,0 +1,70 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + Copyright (c) 2017 Kohei Takahashi + + 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 "container_tests.hpp" +#include <boost/static_assert.hpp> + +std::unordered_set<int> const build_unordered_set() +{ + typedef std::unordered_set<int> int_set; + typedef std::vector<int> int_vector; + + int_set result; + int_vector const data = build_vector(); + int_vector::const_iterator it = data.begin(); + int_vector::const_iterator const end = data.end(); + result.insert(it, end); + return result; +} + +std::unordered_multiset<int> const build_unordered_multiset() +{ + typedef std::unordered_set<int> int_set; + typedef std::unordered_multiset<int> int_multiset; + int_set const data = build_unordered_set(); + return int_multiset(data.begin(), data.end()); +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::unordered_multiset<int> >::value)); + BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::unordered_multiset<int> >::value)); + + std::unordered_multiset<int> const data = build_unordered_multiset(); + test_begin(data); + test_clear(data); + test_empty(data); + test_end(data); + test_set_erase(data); + test_get_allocator(data); + return boost::report_errors(); +} + + + + diff --git a/src/boost/libs/phoenix/test/container/container_tests12b.cpp b/src/boost/libs/phoenix/test/container/container_tests12b.cpp new file mode 100644 index 00000000..63f167c4 --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests12b.cpp @@ -0,0 +1,71 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + Copyright (c) 2017 Kohei Takahashi + + 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 "container_tests.hpp" +#include <boost/static_assert.hpp> + +std::unordered_set<int> const build_unordered_set() +{ + typedef std::unordered_set<int> int_set; + typedef std::vector<int> int_vector; + + int_set result; + int_vector const data = build_vector(); + int_vector::const_iterator it = data.begin(); + int_vector::const_iterator const end = data.end(); + result.insert(it, end); + return result; +} + +std::unordered_multiset<int> const build_unordered_multiset() +{ + typedef std::unordered_set<int> int_set; + typedef std::unordered_multiset<int> int_multiset; + int_set const data = build_unordered_set(); + return int_multiset(data.begin(), data.end()); +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::unordered_multiset<int> >::value)); + BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::unordered_multiset<int> >::value)); + + std::unordered_multiset<int> const data = build_unordered_multiset(); + test_multiset_insert(data); + //test_key_comp(data); + test_max_size(data); + //test_rbegin(data); + //test_rend(data); + test_size(data); + //test_value_comp(data); + return boost::report_errors(); +} + + + + diff --git a/src/boost/libs/phoenix/test/container/container_tests1a.cpp b/src/boost/libs/phoenix/test/container/container_tests1a.cpp new file mode 100644 index 00000000..a4b1442b --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests1a.cpp @@ -0,0 +1,49 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + + 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 "container_tests.hpp" + +std::list<int> const build_list() +{ + std::vector<int> const data = build_vector(); + return std::list<int>(data.begin(), data.end()); +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::list<int> >::value)); + BOOST_STATIC_ASSERT((!phx::stl::has_key_type<std::list<int> >::value)); + + std::list<int> const data = build_list(); + test_assign(data); + test_assign2(data); + test_back(data); + test_begin(data); + test_clear(data); + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/container/container_tests1b.cpp b/src/boost/libs/phoenix/test/container/container_tests1b.cpp new file mode 100644 index 00000000..245fe0c3 --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests1b.cpp @@ -0,0 +1,51 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + + 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 "container_tests.hpp" + +std::list<int> const build_list() +{ + std::vector<int> const data = build_vector(); + return std::list<int>(data.begin(), data.end()); +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::list<int> >::value)); + BOOST_STATIC_ASSERT((!phx::stl::has_key_type<std::list<int> >::value)); + + std::list<int> const data = build_list(); + test_empty(data); + test_end(data); + test_erase(data); + test_front(data); + test_get_allocator(data); + test_insert(data); + test_max_size(data); + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/container/container_tests2a.cpp b/src/boost/libs/phoenix/test/container/container_tests2a.cpp new file mode 100644 index 00000000..757444a7 --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests2a.cpp @@ -0,0 +1,49 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + + 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 "container_tests.hpp" + +std::list<int> const build_list() +{ + std::vector<int> const data = build_vector(); + return std::list<int>(data.begin(), data.end()); +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::list<int> >::value)); + BOOST_STATIC_ASSERT((!phx::stl::has_key_type<std::list<int> >::value)); + + std::list<int> const data = build_list(); + test_pop_back(data); + test_pop_front(data); + test_push_back(data); + test_push_front(data); + return boost::report_errors(); +} + + diff --git a/src/boost/libs/phoenix/test/container/container_tests2b.cpp b/src/boost/libs/phoenix/test/container/container_tests2b.cpp new file mode 100644 index 00000000..c0e48190 --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests2b.cpp @@ -0,0 +1,50 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + + 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 "container_tests.hpp" + +std::list<int> const build_list() +{ + std::vector<int> const data = build_vector(); + return std::list<int>(data.begin(), data.end()); +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::list<int> >::value)); + BOOST_STATIC_ASSERT((!phx::stl::has_key_type<std::list<int> >::value)); + + std::list<int> const data = build_list(); + test_rbegin(data); + test_rend(data); + test_resize(data); + test_size(data); + test_splice(data); + return boost::report_errors(); +} + + diff --git a/src/boost/libs/phoenix/test/container/container_tests3a.cpp b/src/boost/libs/phoenix/test/container/container_tests3a.cpp new file mode 100644 index 00000000..348b6552 --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests3a.cpp @@ -0,0 +1,61 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + + 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 "container_tests.hpp" +#include <boost/static_assert.hpp> + +std::map<int, int> const build_map() +{ + typedef std::map<int, int> int_map; + typedef std::vector<int> int_vector; + + int_map result; + int_vector const data = build_vector(); + int_vector::const_iterator it = data.begin(); + int_vector::const_iterator const end = data.end(); + for (; it != end; ++it) { + int const value = *it; + result[value] = 100 * value; + } + return result; +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((phx::stl::has_mapped_type<std::map<int, int> >::value)); + BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::map<int, int> >::value)); + + std::map<int, int> const data = build_map(); + test_begin(data); + test_clear(data); + test_empty(data); + test_end(data); + test_map_erase(data); + test_get_allocator(data); + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/container/container_tests3b.cpp b/src/boost/libs/phoenix/test/container/container_tests3b.cpp new file mode 100644 index 00000000..98c3c65a --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests3b.cpp @@ -0,0 +1,62 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + + 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 "container_tests.hpp" +#include <boost/static_assert.hpp> + +std::map<int, int> const build_map() +{ + typedef std::map<int, int> int_map; + typedef std::vector<int> int_vector; + + int_map result; + int_vector const data = build_vector(); + int_vector::const_iterator it = data.begin(); + int_vector::const_iterator const end = data.end(); + for (; it != end; ++it) { + int const value = *it; + result[value] = 100 * value; + } + return result; +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((phx::stl::has_mapped_type<std::map<int, int> >::value)); + BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::map<int, int> >::value)); + + std::map<int, int> const data = build_map(); + test_map_insert(data); + test_key_comp(data); + test_max_size(data); + test_rbegin(data); + test_rend(data); + test_size(data); + test_value_comp(data); + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/container/container_tests4a.cpp b/src/boost/libs/phoenix/test/container/container_tests4a.cpp new file mode 100644 index 00000000..3d252d7c --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests4a.cpp @@ -0,0 +1,50 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + + 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 "container_tests.hpp" +#include <boost/static_assert.hpp> + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::vector<int> >::value)); + BOOST_STATIC_ASSERT((!phx::stl::has_key_type<std::vector<int> >::value)); + + std::vector<int> const data = build_vector(); + test_assign(data); + test_assign2(data); + test_at(data); + test_back(data); + test_begin(data); + test_capacity(data); + test_clear(data); + test_end(data); + test_empty(data); + test_erase(data); + test_front(data); + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/container/container_tests4b.cpp b/src/boost/libs/phoenix/test/container/container_tests4b.cpp new file mode 100644 index 00000000..07059b38 --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests4b.cpp @@ -0,0 +1,49 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + + 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 "container_tests.hpp" +#include <boost/static_assert.hpp> + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::vector<int> >::value)); + BOOST_STATIC_ASSERT((!phx::stl::has_key_type<std::vector<int> >::value)); + + std::vector<int> const data = build_vector(); + test_get_allocator(data); + test_insert(data); + test_max_size(data); + test_pop_back(data); + test_push_back(data); + test_rbegin(data); + test_rend(data); + test_reserve(data); + test_resize(data); + test_size(data); + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/container/container_tests5a.cpp b/src/boost/libs/phoenix/test/container/container_tests5a.cpp new file mode 100644 index 00000000..983913a4 --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests5a.cpp @@ -0,0 +1,56 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + + 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 "container_tests.hpp" + +std::deque<int> const build_deque() +{ + std::vector<int> const data = build_vector(); + return std::deque<int>(data.begin(), data.end()); +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::deque<int> >::value)); + BOOST_STATIC_ASSERT((!phx::stl::has_key_type<std::deque<int> >::value)); + + std::deque<int> const data = build_deque(); + test_assign(data); + test_assign2(data); + test_at(data); + test_back(data); + test_begin(data); + test_clear(data); + test_front(data); + test_empty(data); + test_end(data); + test_erase(data); + test_get_allocator(data); + return boost::report_errors(); +} + + diff --git a/src/boost/libs/phoenix/test/container/container_tests5b.cpp b/src/boost/libs/phoenix/test/container/container_tests5b.cpp new file mode 100644 index 00000000..d08a7016 --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests5b.cpp @@ -0,0 +1,55 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + + 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 "container_tests.hpp" + +std::deque<int> const build_deque() +{ + std::vector<int> const data = build_vector(); + return std::deque<int>(data.begin(), data.end()); +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::deque<int> >::value)); + BOOST_STATIC_ASSERT((!phx::stl::has_key_type<std::deque<int> >::value)); + + std::deque<int> const data = build_deque(); + test_insert(data); + test_max_size(data); + test_pop_back(data); + test_pop_front(data); + test_push_back(data); + test_push_front(data); + test_rbegin(data); + test_rend(data); + test_resize(data); + test_size(data); + return boost::report_errors(); +} + + diff --git a/src/boost/libs/phoenix/test/container/container_tests6a.cpp b/src/boost/libs/phoenix/test/container/container_tests6a.cpp new file mode 100644 index 00000000..62c8af18 --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests6a.cpp @@ -0,0 +1,72 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + + 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 "container_tests.hpp" +#include <boost/static_assert.hpp> + +std::map<int, int> const build_map() +{ + typedef std::map<int, int> int_map; + typedef std::vector<int> int_vector; + + int_map result; + int_vector const data = build_vector(); + int_vector::const_iterator it = data.begin(); + int_vector::const_iterator const end = data.end(); + for (; it != end; ++it) { + int const value = *it; + result[value] = 100 * value; + } + return result; +} + +std::multimap<int, int> const build_multimap() +{ + typedef std::map<int, int> int_map; + typedef std::multimap<int, int> int_multimap; + int_map const data = build_map(); + return int_multimap(data.begin(), data.end()); +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((phx::stl::has_mapped_type<std::multimap<int, int> >::value)); + BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::multimap<int, int> >::value)); + + std::multimap<int, int> const data = build_multimap(); + test_begin(data); + test_clear(data); + test_empty(data); + test_end(data); + test_map_erase(data); + test_get_allocator(data); + return boost::report_errors(); +} + + + + diff --git a/src/boost/libs/phoenix/test/container/container_tests6b.cpp b/src/boost/libs/phoenix/test/container/container_tests6b.cpp new file mode 100644 index 00000000..193f4bf4 --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests6b.cpp @@ -0,0 +1,73 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + + 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 "container_tests.hpp" +#include <boost/static_assert.hpp> + +std::map<int, int> const build_map() +{ + typedef std::map<int, int> int_map; + typedef std::vector<int> int_vector; + + int_map result; + int_vector const data = build_vector(); + int_vector::const_iterator it = data.begin(); + int_vector::const_iterator const end = data.end(); + for (; it != end; ++it) { + int const value = *it; + result[value] = 100 * value; + } + return result; +} + +std::multimap<int, int> const build_multimap() +{ + typedef std::map<int, int> int_map; + typedef std::multimap<int, int> int_multimap; + int_map const data = build_map(); + return int_multimap(data.begin(), data.end()); +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((phx::stl::has_mapped_type<std::multimap<int, int> >::value)); + BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::multimap<int, int> >::value)); + + std::multimap<int, int> const data = build_multimap(); + test_multimap_insert(data); + test_key_comp(data); + test_max_size(data); + test_rbegin(data); + test_rend(data); + test_size(data); + test_value_comp(data); + return boost::report_errors(); +} + + + + diff --git a/src/boost/libs/phoenix/test/container/container_tests7a.cpp b/src/boost/libs/phoenix/test/container/container_tests7a.cpp new file mode 100644 index 00000000..b82b4cf1 --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests7a.cpp @@ -0,0 +1,59 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + Copyright (c) 2017 Kohei Takahashi + + 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 "container_tests.hpp" +#include <boost/static_assert.hpp> + +std::set<int> const build_set() +{ + typedef std::set<int> int_set; + typedef std::vector<int> int_vector; + + int_set result; + int_vector const data = build_vector(); + int_vector::const_iterator it = data.begin(); + int_vector::const_iterator const end = data.end(); + result.insert(it, end); + return result; +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::set<int> >::value)); + BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::set<int> >::value)); + + std::set<int> const data = build_set(); + test_begin(data); + test_clear(data); + test_empty(data); + test_end(data); + test_set_erase(data); + test_get_allocator(data); + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/container/container_tests7b.cpp b/src/boost/libs/phoenix/test/container/container_tests7b.cpp new file mode 100644 index 00000000..a79be9e9 --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests7b.cpp @@ -0,0 +1,60 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + Copyright (c) 2017 Kohei Takahashi + + 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 "container_tests.hpp" +#include <boost/static_assert.hpp> + +std::set<int> const build_set() +{ + typedef std::set<int> int_set; + typedef std::vector<int> int_vector; + + int_set result; + int_vector const data = build_vector(); + int_vector::const_iterator it = data.begin(); + int_vector::const_iterator const end = data.end(); + result.insert(it, end); + return result; +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::set<int> >::value)); + BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::set<int> >::value)); + + std::set<int> const data = build_set(); + test_set_insert(data); + test_key_comp(data); + test_max_size(data); + test_rbegin(data); + test_rend(data); + test_size(data); + test_value_comp(data); + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/container/container_tests8a.cpp b/src/boost/libs/phoenix/test/container/container_tests8a.cpp new file mode 100644 index 00000000..95e85b83 --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests8a.cpp @@ -0,0 +1,70 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + Copyright (c) 2017 Kohei Takahashi + + 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 "container_tests.hpp" +#include <boost/static_assert.hpp> + +std::set<int> const build_set() +{ + typedef std::set<int> int_set; + typedef std::vector<int> int_vector; + + int_set result; + int_vector const data = build_vector(); + int_vector::const_iterator it = data.begin(); + int_vector::const_iterator const end = data.end(); + result.insert(it, end); + return result; +} + +std::multiset<int> const build_multiset() +{ + typedef std::set<int> int_set; + typedef std::multiset<int> int_multiset; + int_set const data = build_set(); + return int_multiset(data.begin(), data.end()); +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::multiset<int> >::value)); + BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::multiset<int> >::value)); + + std::multiset<int> const data = build_multiset(); + test_begin(data); + test_clear(data); + test_empty(data); + test_end(data); + test_set_erase(data); + test_get_allocator(data); + return boost::report_errors(); +} + + + + diff --git a/src/boost/libs/phoenix/test/container/container_tests8b.cpp b/src/boost/libs/phoenix/test/container/container_tests8b.cpp new file mode 100644 index 00000000..b20ed5d3 --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests8b.cpp @@ -0,0 +1,71 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + Copyright (c) 2017 Kohei Takahashi + + 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 "container_tests.hpp" +#include <boost/static_assert.hpp> + +std::set<int> const build_set() +{ + typedef std::set<int> int_set; + typedef std::vector<int> int_vector; + + int_set result; + int_vector const data = build_vector(); + int_vector::const_iterator it = data.begin(); + int_vector::const_iterator const end = data.end(); + result.insert(it, end); + return result; +} + +std::multiset<int> const build_multiset() +{ + typedef std::set<int> int_set; + typedef std::multiset<int> int_multiset; + int_set const data = build_set(); + return int_multiset(data.begin(), data.end()); +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::multiset<int> >::value)); + BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::multiset<int> >::value)); + + std::multiset<int> const data = build_multiset(); + test_multiset_insert(data); + test_key_comp(data); + test_max_size(data); + test_rbegin(data); + test_rend(data); + test_size(data); + test_value_comp(data); + return boost::report_errors(); +} + + + + diff --git a/src/boost/libs/phoenix/test/container/container_tests9a.cpp b/src/boost/libs/phoenix/test/container/container_tests9a.cpp new file mode 100644 index 00000000..5711c49d --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests9a.cpp @@ -0,0 +1,62 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + Copyright (c) 2017 Kohei Takahashi + + 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 "container_tests.hpp" +#include <boost/static_assert.hpp> + +std::unordered_map<int, int> const build_unordered_map() +{ + typedef std::unordered_map<int, int> int_map; + typedef std::vector<int> int_vector; + + int_map result; + int_vector const data = build_vector(); + int_vector::const_iterator it = data.begin(); + int_vector::const_iterator const end = data.end(); + for (; it != end; ++it) { + int const value = *it; + result[value] = 100 * value; + } + return result; +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((phx::stl::has_mapped_type<std::unordered_map<int, int> >::value)); + BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::unordered_map<int, int> >::value)); + + std::unordered_map<int, int> const data = build_unordered_map(); + test_begin(data); + test_clear(data); + test_empty(data); + test_end(data); + test_map_erase(data); + test_get_allocator(data); + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/container/container_tests9b.cpp b/src/boost/libs/phoenix/test/container/container_tests9b.cpp new file mode 100644 index 00000000..fcc2d56f --- /dev/null +++ b/src/boost/libs/phoenix/test/container/container_tests9b.cpp @@ -0,0 +1,63 @@ +/*============================================================================= + Copyright (c) 2004 Angus Leeming + Copyright (c) 2017 Kohei Takahashi + + 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 "container_tests.hpp" +#include <boost/static_assert.hpp> + +std::unordered_map<int, int> const build_unordered_map() +{ + typedef std::unordered_map<int, int> int_map; + typedef std::vector<int> int_vector; + + int_map result; + int_vector const data = build_vector(); + int_vector::const_iterator it = data.begin(); + int_vector::const_iterator const end = data.end(); + for (; it != end; ++it) { + int const value = *it; + result[value] = 100 * value; + } + return result; +} + +std::vector<int> const init_vector() +{ + typedef std::vector<int> int_vector; + int const data[] = { -4, -3, -2, -1, 0 }; + int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); + return int_vector(data, data + data_size); +} + +std::vector<int> const build_vector() +{ + typedef std::vector<int> int_vector; + static int_vector data = init_vector(); + int_vector::size_type const size = data.size(); + int_vector::iterator it = data.begin(); + int_vector::iterator const end = data.end(); + for (; it != end; ++it) + *it += size; + return data; +} + +int +main() +{ + BOOST_STATIC_ASSERT((phx::stl::has_mapped_type<std::unordered_map<int, int> >::value)); + BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::unordered_map<int, int> >::value)); + + std::unordered_map<int, int> const data = build_unordered_map(); + test_map_insert(data); + //test_key_comp(data); + test_max_size(data); + //test_rbegin(data); + //test_rend(data); + test_size(data); + //test_value_comp(data); + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/core/custom_terminal.cpp b/src/boost/libs/phoenix/test/core/custom_terminal.cpp new file mode 100644 index 00000000..e8b3a5d9 --- /dev/null +++ b/src/boost/libs/phoenix/test/core/custom_terminal.cpp @@ -0,0 +1,13 @@ +/*============================================================================= + Copyright (c) 2014 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/log/detail/custom_terminal_spec.hpp> + +int +main() +{ +} diff --git a/src/boost/libs/phoenix/test/core/intel_test.cpp b/src/boost/libs/phoenix/test/core/intel_test.cpp new file mode 100644 index 00000000..c2364c86 --- /dev/null +++ b/src/boost/libs/phoenix/test/core/intel_test.cpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> + +#include <boost/phoenix/core/argument.hpp> +#include <boost/phoenix/core/value.hpp> +#include <boost/detail/lightweight_test.hpp> + +using boost::phoenix::val; + +int +main() +{ +#ifndef BOOST_PHOENIX_NO_PREDEFINED_TERMINALS + using boost::phoenix::arg_names::_1; +#else + boost::phoenix::arg_names::_1_type _1; +#endif + + int i1 = 1; + + BOOST_TEST(val(_1)(i1) == i1); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/core/primitives_tests.cpp b/src/boost/libs/phoenix/test/core/primitives_tests.cpp new file mode 100644 index 00000000..c9813863 --- /dev/null +++ b/src/boost/libs/phoenix/test/core/primitives_tests.cpp @@ -0,0 +1,85 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <string> + +#include <boost/phoenix/core/argument.hpp> +#include <boost/phoenix/core/reference.hpp> +#include <boost/phoenix/core/value.hpp> +#include <boost/detail/lightweight_test.hpp> + +using boost::phoenix::cref; +using boost::phoenix::ref; +using boost::phoenix::val; + + +int +main() +{ +#ifndef BOOST_PHOENIX_NO_PREDEFINED_TERMINALS + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; +#else + boost::phoenix::arg_names::_1_type _1; + boost::phoenix::arg_names::arg1_type arg1; + boost::phoenix::arg_names::arg2_type arg2; +#endif + char c1 = '1'; + int i1 = 1, i2 = 2, i = 4; + const char* s2 = "2"; + + + + /////////////////////////////////////////////////////////////////////////// + // + // Values, references and arguments + // + /////////////////////////////////////////////////////////////////////////// + + // argument + BOOST_TEST(arg1(c1) == c1); + BOOST_TEST(arg1(i1, i2) == i1); + BOOST_TEST(arg2(i1, s2) == s2); + BOOST_TEST(&(arg1(c1)) == &c1); // must be an lvalue + + // value + val(' ')(); + val(" ")(); + std::cout << val("Hello,")() << val(' ')() << val("World")() << std::endl; + BOOST_TEST(val(3)() == 3); + BOOST_TEST(val("Hello, world")() == std::string("Hello, world")); + BOOST_TEST(val(_1)(i1) == i1); + + // should not compile: +#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST + &val(_1)(i1); // should return an rvalue +#endif + + // reference + BOOST_TEST(cref(i)() == ref(i)()); + BOOST_TEST(cref(i)() == 4); + BOOST_TEST(i == 4); + BOOST_TEST(ref(++i)() == 5); + BOOST_TEST(i == 5); + + // should not compile: +#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST + ref(arg1); +#endif + + // testing consts + int const ic = 123; + BOOST_TEST(arg1(ic) == 123); + + // should not compile: +#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST + arg1(); +#endif + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/function/adapt_function.cpp b/src/boost/libs/phoenix/test/function/adapt_function.cpp new file mode 100644 index 00000000..77cca41d --- /dev/null +++ b/src/boost/libs/phoenix/test/function/adapt_function.cpp @@ -0,0 +1,84 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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 <iostream> +#include <cmath> +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/function.hpp> + +namespace impl +{ + void + test() + { + std::cout << "Test adapting functions...\n"; + } + + int + negate(int n) + { + return -n; + } + + int + plus(int a, int b) + { + return a + b; + } + + template <typename T> + T + plus(T a, T b, T c) + { + return a + b + c; + } + + int + plus4(int a, int b, int c, int d) + { + return a + b + c + d; + } +} + +BOOST_PHOENIX_ADAPT_FUNCTION_NULLARY(void, test, impl::test) +BOOST_PHOENIX_ADAPT_FUNCTION(int, negate, impl::negate, 1) +BOOST_PHOENIX_ADAPT_FUNCTION(int, plus, impl::plus, 2) +BOOST_PHOENIX_ADAPT_FUNCTION( + typename boost::remove_reference<A0>::type + , plus + , impl::plus + , 3 +) +BOOST_PHOENIX_ADAPT_FUNCTION(int, plus4, impl::plus4, 4) + +// Test of solution to bug when using namespace +using namespace boost::phoenix; + +BOOST_PHOENIX_ADAPT_FUNCTION_NULLARY(void, test2, impl::test) +BOOST_PHOENIX_ADAPT_FUNCTION(int, negate2, impl::negate, 1) + + +int +main() +{ + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + + int a = 123; + int b = 256; + + test()(); + test2()(); + BOOST_TEST(::negate(arg1)(a) == -a); + BOOST_TEST(::negate2(arg1)(a) == -a); + BOOST_TEST(::plus(arg1, arg2)(a, b) == a+b); + BOOST_TEST(::plus(arg1, arg2, 3)(a, b) == a+b+3); + BOOST_TEST(plus4(arg1, arg2, 3, 4)(a, b) == a+b+3+4); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/function/function_tests.cpp b/src/boost/libs/phoenix/test/function/function_tests.cpp new file mode 100644 index 00000000..6f979faf --- /dev/null +++ b/src/boost/libs/phoenix/test/function/function_tests.cpp @@ -0,0 +1,140 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <cmath> +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> + +#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS +#include <boost/mpl/multiplies.hpp> +#undef BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS + +struct test_impl +{ + typedef void result_type; + void operator()() const + { + std::cout << "Test lazy functions...\n"; + } +}; + +boost::phoenix::function<test_impl> test; + +struct sqr_impl +{ + template <typename Signature> + struct result; + + template <typename This, typename Arg> + struct result<This(Arg)> + { + typedef typename boost::remove_reference<Arg>::type type; + }; + + template <typename Arg> + Arg + operator()(Arg n) const + { + return n * n; + } +}; + +boost::phoenix::function<sqr_impl> sqr; + +struct fact_impl +{ + template <typename Signature> + struct result; + + template <typename This, typename Arg> + struct result<This(Arg)> + { + typedef typename boost::remove_reference<Arg>::type type; + }; + + template <typename Arg> + Arg + operator()(Arg n) const + { + return (n <= 0) ? 1 : n * (*this)(n-1); + } +}; + +boost::phoenix::function<fact_impl> fact; + +struct pow_impl +{ + + template <typename Sig> + struct result; + + template <typename This, typename Arg1, typename Arg2> + struct result<This(Arg1, Arg2)> + { + typedef typename boost::remove_reference<Arg1>::type type; + }; + + template <typename Arg1, typename Arg2> + Arg1 + operator()(Arg1 a, Arg2 b) const + { + return std::pow(a, b); + } +}; + +boost::phoenix::function<pow_impl> power; + +struct add_impl +{ + template <typename Sig> + struct result; + + template <typename This, typename Arg1, typename Arg2, typename Arg3, typename Arg4> + struct result<This(Arg1, Arg2, Arg3, Arg4)> + { + typedef typename boost::remove_reference<Arg1>::type type; + }; + + template <typename Arg1, typename Arg2, typename Arg3, typename Arg4> + Arg1 + operator()(Arg1 a, Arg2 b, Arg3 c, Arg4 d) const + { + return a + b + c + d; + } +}; + +boost::phoenix::function<add_impl> add; + +int +main() +{ + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + + int i5 = 5; + double d5 = 5, d3 = 3; + + test()(); + BOOST_TEST(sqr(arg1)(i5) == (i5*i5)); + BOOST_TEST(fact(4)() == 24); + BOOST_TEST(fact(arg1)(i5) == 120); + BOOST_TEST((int)power(arg1, arg2)(d5, d3) == (int)std::pow(d5, d3)); + BOOST_TEST((sqr(arg1) + 5)(i5) == ((i5*i5)+5)); + BOOST_TEST(add(arg1, arg1, arg1, arg1)(i5) == (5+5+5+5)); + + // testing composition + BOOST_TEST(add(arg1, arg1, arg1, power(arg1, 2))(d5) == (5+5+5+25)); + + int const ic5 = 5; + // testing consts + BOOST_TEST(sqr(arg1)(ic5) == (ic5*ic5)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/function/function_tests_phx2.cpp b/src/boost/libs/phoenix/test/function/function_tests_phx2.cpp new file mode 100644 index 00000000..bff3a720 --- /dev/null +++ b/src/boost/libs/phoenix/test/function/function_tests_phx2.cpp @@ -0,0 +1,116 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <cmath> +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> + +using namespace boost::phoenix; +using namespace boost::phoenix::arg_names; +using namespace std; + + struct test_impl + { + typedef void result_type; + void operator()() const + { + cout << "Test lazy functions...\n"; + } + }; + + function<test_impl> test; + + struct sqr_impl + { + template <typename Arg> + struct result + { + typedef Arg type; + }; + + template <typename Arg> + Arg operator()(Arg n) const + { + return n * n; + } + }; + + function<sqr_impl> sqr; + + struct fact_impl + { + template <typename Arg> + struct result + { + typedef Arg type; + }; + + template <typename Arg> + Arg operator()(Arg n) const + { + return (n <= 0) ? 1 : n * (*this)(n-1); + } + }; + + function<fact_impl> fact; + + struct pow_impl + { + template <typename Arg1, typename Arg2> + struct result + { + typedef Arg1 type; + }; + + template <typename Arg1, typename Arg2> + Arg1 operator()(Arg1 a, Arg2 b) const + { + return pow(a, b); + } + }; + + function<pow_impl> power; + + struct add_impl + { + template <typename Arg1, typename Arg2, typename Arg3, typename Arg4> + struct result + { + typedef Arg1 type; + }; + + template <typename Arg1, typename Arg2, typename Arg3, typename Arg4> + Arg1 operator()(Arg1 a, Arg2 b, Arg3 c, Arg4 d) const + { + return a + b + c + d; + } + }; + + function<add_impl> add; + +int +main() +{ + int i5 = 5; + double d5 = 5, d3 = 3; + + test()(); + BOOST_TEST(sqr(arg1)(i5) == (i5*i5)); + BOOST_TEST(fact(4)() == 24); + BOOST_TEST(fact(arg1)(i5) == 120); + BOOST_TEST((int)power(arg1, arg2)(d5, d3) == (int)pow(d5, d3)); + BOOST_TEST((sqr(arg1) + 5)(i5) == ((i5*i5)+5)); + BOOST_TEST(add(arg1, arg1, arg1, arg1)(i5) == (5+5+5+5)); + + int const ic5 = 5; + // testing consts + BOOST_TEST(sqr(arg1)(ic5) == (ic5*ic5)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/function/lazy_argument_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_argument_tests.cpp new file mode 100644 index 00000000..a45f501f --- /dev/null +++ b/src/boost/libs/phoenix/test/function/lazy_argument_tests.cpp @@ -0,0 +1,53 @@ +//////////////////////////////////////////////////////////////////////////// +// lazy_argument_tests.cpp +// +// lazy argument tests passing lazy function as argument. +// +//////////////////////////////////////////////////////////////////////////// +/*============================================================================= + 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> + +namespace example { + struct G { + + template <typename Sig> + struct result; + + template <typename This, typename A0> + struct result<This(A0)> + : boost::remove_reference<A0> + {}; + + template <typename T> + T operator()(T t) const { return ++t; } + + }; +} + +typedef boost::phoenix::function<example::G> GG; +boost::phoenix::function<example::G> gg; + +template <typename F,typename T> +T h(F f, T const& t) +{ + return f(t)(); +} + +int main() +{ + BOOST_TEST( h(gg,1) == 2); + BOOST_TEST(( h<GG,int>(gg,1) == 2)); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/function/lazy_compose_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_compose_tests.cpp new file mode 100644 index 00000000..ea031e32 --- /dev/null +++ b/src/boost/libs/phoenix/test/function/lazy_compose_tests.cpp @@ -0,0 +1,40 @@ +//////////////////////////////////////////////////////////////////////////// +// lazy_compose_tests.cpp +// +// tests on compose +// +//////////////////////////////////////////////////////////////////////////// +/*============================================================================= + Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis + 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/lazy_prelude.hpp> + + +int main() +{ + namespace phx = boost::phoenix; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + using namespace phx; + + BOOST_TEST(compose(id,id)(arg1)(1) == 1); + BOOST_TEST(compose(id,id)(1)() == 1); + BOOST_TEST(compose(inc,inc)(arg1)(1) == 3); + BOOST_TEST(compose(inc,plus)(arg1,arg2)(2,3) == 6); + BOOST_TEST(compose(plus,inc,dec)(arg1)(1) == 2); + BOOST_TEST(compose(plus,plus,minus)(arg1,arg2)(3,1) == 6); + + + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/function/lazy_fold_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_fold_tests.cpp new file mode 100644 index 00000000..5c542575 --- /dev/null +++ b/src/boost/libs/phoenix/test/function/lazy_fold_tests.cpp @@ -0,0 +1,44 @@ +//////////////////////////////////////////////////////////////////////////// +// lazy_fold_tests.cpp +// +// tests on foldl foldr and compose +// +//////////////////////////////////////////////////////////////////////////// +/*============================================================================= + Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis + 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/lazy_prelude.hpp> + + +int main() +{ + namespace phx = boost::phoenix; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + using boost::phoenix::arg_names::arg3; + using namespace phx; + + list<int> l = enum_from(2); + list<int> evens = filter(even,l); + list<int> even4 = take(4,evens)(); + + BOOST_TEST(foldr(plus,0,even4)() == 20); + BOOST_TEST(foldr(multiplies,1,even4)() == 384); + BOOST_TEST(foldr1(plus,even4)() == 20 ); + BOOST_TEST(foldl(plus,arg1,even4)(0) == 20); + BOOST_TEST(foldl1(plus,even4)() == 20); + BOOST_TEST(compose(inc,foldr)(plus,0,even4)() == 21); + BOOST_TEST(compose(plus,foldl,foldr)(arg1,arg2,arg3)(plus,0,even4) == 40); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/function/lazy_list2_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_list2_tests.cpp new file mode 100644 index 00000000..c294a8f8 --- /dev/null +++ b/src/boost/libs/phoenix/test/function/lazy_list2_tests.cpp @@ -0,0 +1,42 @@ +//////////////////////////////////////////////////////////////////////////// +// lazy_list2_tests.cpp +// +// more tests on list<T> +// +//////////////////////////////////////////////////////////////////////////// +/*============================================================================= + Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis + 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/lazy_prelude.hpp> + + +int main() +{ + namespace phx = boost::phoenix; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + using namespace phx; + + list<int> l0; + list<int> l1 = list_with<>()(1,2,3,4,5); + list<int> l2 = all_but_last(l1)(); + + BOOST_TEST(null(l0)()); + BOOST_TEST(head(l1)() == 1); + BOOST_TEST(head(tail(l1))() == 2); + BOOST_TEST(last(l1)() == 5); + BOOST_TEST(last(l2)() == 4); + BOOST_TEST(head(drop(2,l2))() == 3); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/function/lazy_list3_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_list3_tests.cpp new file mode 100644 index 00000000..9e4bc6d0 --- /dev/null +++ b/src/boost/libs/phoenix/test/function/lazy_list3_tests.cpp @@ -0,0 +1,54 @@ +//////////////////////////////////////////////////////////////////////////// +// lazy_list3_tests.cpp +// +// more tests on list<T> +// +//////////////////////////////////////////////////////////////////////////// +/*============================================================================= + Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis + 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/lazy_prelude.hpp> + + +int main() +{ + namespace phx = boost::phoenix; + //using boost::phoenix::arg_names::arg1; + //using boost::phoenix::arg_names::arg2; + using namespace phx; + + list<int> l = enum_from(2); + list<int> ll = take(4,l); + list<int> lll = take(12,l); + list<int> l2 = enum_from_to(2,10); + list<int> ll2 = take(4,l2); + list<int> lll2 = take(12,l2); + list<int> evens = filter(even,l); + list<int> odds = filter(odd,l); + list<int> even4 = take(4,evens)(); + list<int> odd4 = take(4,odds)(); + list<int> itersome = take(4,iterate(dec,1))(); + list<int> repeatsome = take(4,repeat(1))(); + + BOOST_TEST(last(ll)() == 5); + BOOST_TEST(last(lll)() == 13); + BOOST_TEST(last(ll2)() == 5); + BOOST_TEST(last(lll2)() == 10); + BOOST_TEST(length(lll2)() == 9); + BOOST_TEST(at_(even4,3)() == 8); + BOOST_TEST(at_(odd4,2)() == 7); + BOOST_TEST(at_(itersome,3)() == -3); + BOOST_TEST(at_(repeatsome,3)() == 1); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/function/lazy_list_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_list_tests.cpp new file mode 100644 index 00000000..47caf649 --- /dev/null +++ b/src/boost/libs/phoenix/test/function/lazy_list_tests.cpp @@ -0,0 +1,78 @@ +//////////////////////////////////////////////////////////////////////////// +// lazy_list_tests.cpp +// +// tests on list<T> +// +//////////////////////////////////////////////////////////////////////////// +/*============================================================================= + Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis + 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/lazy_prelude.hpp> + + +int main() +{ + namespace phx = boost::phoenix; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + using phx::null; + using phx::list; + using phx::head; + using phx::tail; + using phx::cons; + using phx::cat; + using phx::take; + using phx::NIL; + + list<int> l0; + list<int> l1 = cons(1,l0); + list<int> l2 = cons(2,l1); + list<int> l3 = cons(3,l2); + list<int> l4 = cons(4,l3); + list<int> l5 = cons(5,NIL); + list<int> l6 = take(2,l4)(); + list<int> l7 = cons(7,take(2,l4)); + list<int> l8 = take(1,take(3,l4))(); + + BOOST_TEST(null(l0)()); + BOOST_TEST(null(arg1)(l0)); + BOOST_TEST(head(l1)() == 1); + BOOST_TEST(head(arg1)(l1) == 1); + BOOST_TEST(head(tail(l2))() == 1); + BOOST_TEST(head(tail(arg1))(l2) == 1); + BOOST_TEST(head(tail(tail(l3)))() == 1); + BOOST_TEST(head(tail(tail(arg1)))(l3) == 1); + BOOST_TEST(head(tail(tail(l4)))() == 2); + BOOST_TEST(head(tail(tail(arg1)))(l4) == 2); + BOOST_TEST(head(l5)() == 5); + BOOST_TEST(head(arg1)(l5) == 5); + BOOST_TEST(head(tail(l6))() == 3); + BOOST_TEST(head(tail(arg1))(l6) == 3); + BOOST_TEST(head(tail(l7))() == 4); + BOOST_TEST(head(tail(arg1))(l7) == 4); + BOOST_TEST(head(l8)() == 4); + BOOST_TEST(head(arg1)(l8) == 4); + + list<int> l9 = cat(l8,take(2,l4)); + list<int> l10 = cat(l8,NIL); + list<int> l11 = cat(l0,l7); + list<int> l12 = cat(l10,l8); + + BOOST_TEST(head(tail(l9))() == 4); + BOOST_TEST(head(l10)() == 4); + BOOST_TEST(head(arg1)(l11) == 7); + BOOST_TEST(head(l12)() == 4); + + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/function/lazy_make_pair_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_make_pair_tests.cpp new file mode 100644 index 00000000..09fccf5c --- /dev/null +++ b/src/boost/libs/phoenix/test/function/lazy_make_pair_tests.cpp @@ -0,0 +1,109 @@ +//////////////////////////////////////////////////////////////////////////// +// lazy_make_pair_tests.cpp +// +// lazy make_pair test solving the optimizer problem. +// +//////////////////////////////////////////////////////////////////////////// +/*============================================================================= + 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> + +namespace boost { + + namespace phoenix { + +#ifdef BOOST_RESULT_OF_USE_TR1 + + namespace result_of { + + template < + typename Arg1 + , typename Arg2 + > + class make_pair + { + public: + typedef typename boost::remove_reference<Arg1>::type Arg1Type; + typedef typename boost::remove_reference<Arg2>::type Arg2Type; + typedef std::pair<Arg1Type,Arg2Type> type; + }; + } +#endif + + namespace impl + { + + struct make_pair { + + +#ifdef BOOST_RESULT_OF_USE_TR1 + template <typename Sig> + struct result; + // This fails with -O2 unless refs are removed from A1 and A2. + template <typename This, typename A0, typename A1> + struct result<This(A0, A1)> + { + typedef typename result_of::make_pair<A0,A1>::type type; + }; +#else + template <typename Sig> + struct result; + + template <typename This, typename A0, typename A1> + struct result<This(A0, A1)> + : boost::remove_reference<std::pair<A0, A1> > + {}; + +#endif + + + template <typename A0, typename A1> +#ifdef BOOST_RESULT_OF_USE_TR1 + typename result<make_pair(A0,A1)>::type +#else + std::pair<A0, A1> +#endif + operator()(A0 const & a0, A1 const & a1) const + { + return std::make_pair(a0,a1); + } + + }; + } + +BOOST_PHOENIX_ADAPT_CALLABLE(make_pair, impl::make_pair, 2) + + } + +} + +int main() +{ + namespace phx = boost::phoenix; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + int a = 99; int b = 256; + + std::pair<int,int> ab1 = phx::make_pair(a,b)(); + //std::cout << ab1.first << "," << ab1.second << std::endl; + BOOST_TEST(ab1.first == 99 && ab1.second == 256); + std::pair<int,int> ab2 = phx::make_pair(arg1,b)(a); + //std::cout << ab2.first << "," << ab2.second << std::endl; + BOOST_TEST(ab2.first == 99 && ab2.second == 256); + std::pair<int,int> ab3 = phx::make_pair(arg1,arg2)(a,b); + //std::cout << ab3.first << "," << ab3.second << std::endl; + BOOST_TEST(ab3.first == 99 && ab3.second == 256); + + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/function/lazy_operator_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_operator_tests.cpp new file mode 100644 index 00000000..ef05717c --- /dev/null +++ b/src/boost/libs/phoenix/test/function/lazy_operator_tests.cpp @@ -0,0 +1,46 @@ +//////////////////////////////////////////////////////////////////////////// +// lazy_operator_tests.cpp +// +// lazy operator tests +// +//////////////////////////////////////////////////////////////////////////// +/*============================================================================= + Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis + 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/lazy_operator.hpp> + + +int main() +{ + using boost::phoenix::plus; + using boost::phoenix::minus; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + + int a = 123; + int b = 256; + + BOOST_TEST(plus(arg1, arg2)(a, b) == a+b); + BOOST_TEST(plus(arg1, arg2, 3)(a, b) == a+b+3); + BOOST_TEST(plus(arg1, b)(a) == a+b); + BOOST_TEST(plus(a, arg2)(a,b) == a+b); + BOOST_TEST(plus(a, arg1)(b) == a+b); + BOOST_TEST(plus(a, b)() == a+b); + BOOST_TEST(minus(a, b)() == a-b); + BOOST_TEST(plus(minus(a, b),b)() == a); + BOOST_TEST(plus(minus(arg1, b),b)(a) == a); + BOOST_TEST(plus(minus(arg1, arg2),b)(a,b) == a); + BOOST_TEST(plus(minus(arg1, arg2),arg2)(a,b) ==a); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/function/lazy_ptr_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_ptr_tests.cpp new file mode 100644 index 00000000..22b1f157 --- /dev/null +++ b/src/boost/libs/phoenix/test/function/lazy_ptr_tests.cpp @@ -0,0 +1,110 @@ +////////////////////////////////////////////////////////////////// +// +// lazy_ptr_tests.cpp +// +// Tests for ptr_to_fun, ptr_to_fun0 and ptr_to_mem_fun. +// +// +/*============================================================================= + Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis + 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 <iostream> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/phoenix/function/lazy_prelude.hpp> + +#include <boost/detail/lightweight_test.hpp> + +using namespace boost::phoenix; + +using std::cout; +using std::endl; + +namespace example { + + int footle() + { + return 0; + } + + int foobar(int x) + { + return 2*x; + } + + int foxy(int x,int y) + { + return x*y; + } + + int foxyz(int x,int y,int z) + { + return x*y + z; + } + + int fwxyz(int w,int x,int y,int z) + { + return w + x*y + z; + } + +} + +struct O { + int aa; + O( int a ) : aa(a) {} + int cf( int x ) const { return x+1; } + int f( int x ) { return ++aa + x; } + int a() const { return aa; } +}; + + +int main() { + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + using boost::phoenix::arg_names::arg3; + using boost::phoenix::arg_names::arg4; + + BOOST_TEST( ptr_to_fun0(&example::footle)()() == 0 ); + BOOST_TEST( ptr_to_fun(&example::foobar)(arg1)(1) == 2 ); + BOOST_TEST( ptr_to_fun(&example::foxy)(arg1,arg2)(2,3) == 6 ); + BOOST_TEST( ptr_to_fun(&example::foxyz)(arg1,arg2,arg3)(2,3,4) == 10 ); + BOOST_TEST( ptr_to_fun(&example::fwxyz)(arg1,arg2,arg3,arg4)(1,2,3,4) == 11); + + O o(1); + BOOST_TEST( ptr_to_mem_fun( &O::a )( &o )() == 1 ); + BOOST_TEST( ptr_to_mem_fun( &O::cf )( &o, 1 )() == 2 ); + BOOST_TEST( ptr_to_mem_fun( &O::f )( &o, 1 )() == 3 ); + BOOST_TEST( ptr_to_mem_fun( &O::f )( &o, 1 )() == 4 ); + BOOST_TEST( ptr_to_mem_fun( &O::cf )( &o, 1 )() == 2 ); + + O oo(1); + BOOST_TEST( ptr_to_mem_fun( &O::a )( arg1 )( &oo ) == 1 ); + BOOST_TEST( ptr_to_mem_fun( &O::cf )( &oo, arg1 )(1) == 2 ); + BOOST_TEST( ptr_to_mem_fun( &O::f )( &oo, arg1 )(1) == 3 ); + BOOST_TEST( ptr_to_mem_fun( &O::f )( &oo, arg1 )(1) == 4 ); + BOOST_TEST( ptr_to_mem_fun( &O::cf )( &oo, arg1 )(1) == 2 ); + + const O p(1); + BOOST_TEST( ptr_to_mem_fun( &O::a )( &p )() == 1 ); + BOOST_TEST( ptr_to_mem_fun( &O::cf )( &p, 1 )() == 2 ); + + boost::shared_ptr<O> r( new O(3) ); + BOOST_TEST( ptr_to_mem_fun( &O::a )( r )() == 3 ); + BOOST_TEST( ptr_to_mem_fun( &O::cf )( r, 1 )() == 2 ); + BOOST_TEST( ptr_to_mem_fun( &O::f )( r, 1 )() == 5 ); + BOOST_TEST( ptr_to_mem_fun( &O::f )( r, 1 )() == 6 ); + BOOST_TEST( ptr_to_mem_fun( &O::cf )( r, 1 )() == 2 ); + + boost::shared_ptr<const O> s( new O(3) ); + BOOST_TEST( ptr_to_mem_fun( &O::a )( s )() == 3 ); + BOOST_TEST( ptr_to_mem_fun( &O::cf )( s, 1 )() == 2 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/function/lazy_scan_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_scan_tests.cpp new file mode 100644 index 00000000..0567951b --- /dev/null +++ b/src/boost/libs/phoenix/test/function/lazy_scan_tests.cpp @@ -0,0 +1,56 @@ +//////////////////////////////////////////////////////////////////////////// +// lazy_scan_tests.cpp +// +// tests on scanl scanr map zip and zip_with +// +//////////////////////////////////////////////////////////////////////////// +/*============================================================================= + Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis + 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/lazy_prelude.hpp> + + +int main() +{ + namespace phx = boost::phoenix; + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + using boost::phoenix::arg_names::arg3; + using namespace phx; + + list<int> l = enum_from(2); + list<int> evens = filter(even,l); + list<int> odds = filter(odd,l); + list<int> even4 = take(4,evens)(); + list<int> odd4 = take(4,odds)(); + + BOOST_TEST(head(scanr(plus,0,even4))() == 20); + BOOST_TEST(last(scanl(plus,0,even4))() == 20); + BOOST_TEST(head(scanr1(plus,even4))() == 20); + BOOST_TEST(last(scanl1(plus,even4))() == 20); + + list<int> map_result = map(inc,even4)(); + list<int> zip_with_result = zip_with(plus,even4,odd4)(); + + BOOST_TEST(foldl1(plus,map_result)() == 24); + BOOST_TEST(last(zip_with_result)() == 17); + + typedef std::pair<int,int> pair_ii; + list<pair_ii> zip_result1 = zip_with(make_pair,even4,odd4)(); + list<pair_ii> zip_result2 = zip(even4,odd4)(); + + BOOST_TEST(head(zip_result1)().first == 2); + BOOST_TEST(last(zip_result2)().second == 9); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/function/lazy_templated_struct_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_templated_struct_tests.cpp new file mode 100644 index 00000000..b7c99043 --- /dev/null +++ b/src/boost/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(); +} diff --git a/src/boost/libs/phoenix/test/function/lazy_thunk_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_thunk_tests.cpp new file mode 100644 index 00000000..f44e991e --- /dev/null +++ b/src/boost/libs/phoenix/test/function/lazy_thunk_tests.cpp @@ -0,0 +1,48 @@ +////////////////////////////////////////////////////////////////// +// +// lazy_thunk_tests.cpp +// +// Tests for thunk functions. +// +// +/*============================================================================= + Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis + 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 <iostream> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/phoenix/function/lazy_prelude.hpp> + +#include <boost/detail/lightweight_test.hpp> + +using namespace boost::phoenix; + +using std::cout; +using std::endl; + + + +int main() { + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + + BOOST_TEST( thunk1(inc,1)()() == 2); + BOOST_TEST( thunk1(inc,arg1)(1)() == 2); + BOOST_TEST( thunk2(plus,1,2)()() == 3); + BOOST_TEST( thunk2(plus,arg1,arg2)(1,2)() == 3); + + list<int> l = enum_from_to(1,5); + list<int> l4 = take(4,l)(); + BOOST_TEST( foldl(plus,0,l4)() == 10); + BOOST_TEST( thunk3(foldl,plus,0,l4)()() == 10); + BOOST_TEST( thunk3(foldl,plus,arg1,l4)(0)() == 10); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/include/bind.cpp b/src/boost/libs/phoenix/test/include/bind.cpp new file mode 100644 index 00000000..a49d6381 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/bind.cpp @@ -0,0 +1,9 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/bind.hpp> + +int main() {} diff --git a/src/boost/libs/phoenix/test/include/bind/bind_member_function.cpp b/src/boost/libs/phoenix/test/include/bind/bind_member_function.cpp new file mode 100644 index 00000000..702854cb --- /dev/null +++ b/src/boost/libs/phoenix/test/include/bind/bind_member_function.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/bind/bind_member_function.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/bind/bind_member_variable.cpp b/src/boost/libs/phoenix/test/include/bind/bind_member_variable.cpp new file mode 100644 index 00000000..48af810a --- /dev/null +++ b/src/boost/libs/phoenix/test/include/bind/bind_member_variable.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/bind/bind_member_variable.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/core.cpp b/src/boost/libs/phoenix/test/include/core.cpp new file mode 100644 index 00000000..cb7d797d --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core.cpp @@ -0,0 +1,8 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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) +==============================================================================*/ +//#define BOOST_PHOENIX_NO_SPECIALIZE_CUSTOM_TERMINAL +#include <boost/phoenix/core.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/core/actor.cpp b/src/boost/libs/phoenix/test/include/core/actor.cpp new file mode 100644 index 00000000..45cb896b --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core/actor.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/actor.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/core/argument.cpp b/src/boost/libs/phoenix/test/include/core/argument.cpp new file mode 100644 index 00000000..7ea062c5 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core/argument.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/argument.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/core/arity.cpp b/src/boost/libs/phoenix/test/include/core/arity.cpp new file mode 100644 index 00000000..c4eb2a52 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core/arity.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/arity.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/core/bug7730.cpp b/src/boost/libs/phoenix/test/include/core/bug7730.cpp new file mode 100644 index 00000000..1baae29e --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core/bug7730.cpp @@ -0,0 +1,8 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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) +==============================================================================*/ +#define BOOST_PHOENIX_NO_SPECIALIZE_CUSTOM_TERMINAL +#include <boost/phoenix.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/core/call.cpp b/src/boost/libs/phoenix/test/include/core/call.cpp new file mode 100644 index 00000000..82d19273 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core/call.cpp @@ -0,0 +1,12 @@ +/*============================================================================== + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/call.hpp> + +int main() {} + diff --git a/src/boost/libs/phoenix/test/include/core/debug.cpp b/src/boost/libs/phoenix/test/include/core/debug.cpp new file mode 100644 index 00000000..fb2ec658 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core/debug.cpp @@ -0,0 +1,13 @@ +/*============================================================================== + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + Copyright (c) 2024 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/debug.hpp> + +int main() {} + diff --git a/src/boost/libs/phoenix/test/include/core/domain.cpp b/src/boost/libs/phoenix/test/include/core/domain.cpp new file mode 100644 index 00000000..3d356c7b --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core/domain.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/domain.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/core/environment.cpp b/src/boost/libs/phoenix/test/include/core/environment.cpp new file mode 100644 index 00000000..48fab108 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core/environment.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/environment.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/core/expression.cpp b/src/boost/libs/phoenix/test/include/core/expression.cpp new file mode 100644 index 00000000..ac83c4bf --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core/expression.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/expression.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/core/function_equal.cpp b/src/boost/libs/phoenix/test/include/core/function_equal.cpp new file mode 100644 index 00000000..b66e9d30 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core/function_equal.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/function_equal.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/core/is_actor.cpp b/src/boost/libs/phoenix/test/include/core/is_actor.cpp new file mode 100644 index 00000000..8a862522 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core/is_actor.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/is_actor.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/core/is_nullary.cpp b/src/boost/libs/phoenix/test/include/core/is_nullary.cpp new file mode 100644 index 00000000..c9f4e9b0 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core/is_nullary.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/is_nullary.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/core/limits.cpp b/src/boost/libs/phoenix/test/include/core/limits.cpp new file mode 100644 index 00000000..726c70e7 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core/limits.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/core/meta_grammar.cpp b/src/boost/libs/phoenix/test/include/core/meta_grammar.cpp new file mode 100644 index 00000000..9f3494d3 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core/meta_grammar.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/meta_grammar.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/core/nothing.cpp b/src/boost/libs/phoenix/test/include/core/nothing.cpp new file mode 100644 index 00000000..b905a9c4 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core/nothing.cpp @@ -0,0 +1,8 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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) +==============================================================================*/ +//#define BOOST_PHOENIX_NO_SPECIALIZE_CUSTOM_TERMINAL +#include <boost/phoenix/core/nothing.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/core/reference.cpp b/src/boost/libs/phoenix/test/include/core/reference.cpp new file mode 100644 index 00000000..d8a88619 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core/reference.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/reference.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/core/terminal.cpp b/src/boost/libs/phoenix/test/include/core/terminal.cpp new file mode 100644 index 00000000..5c710403 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core/terminal.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/terminal.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/core/value.cpp b/src/boost/libs/phoenix/test/include/core/value.cpp new file mode 100644 index 00000000..73318c4f --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core/value.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/value.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/core/visit_each.cpp b/src/boost/libs/phoenix/test/include/core/visit_each.cpp new file mode 100644 index 00000000..3bdab915 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/core/visit_each.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/visit_each.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/function.cpp b/src/boost/libs/phoenix/test/include/function.cpp new file mode 100644 index 00000000..4cc7acad --- /dev/null +++ b/src/boost/libs/phoenix/test/include/function.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/function.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/function/function.cpp b/src/boost/libs/phoenix/test/include/function/function.cpp new file mode 100644 index 00000000..48b20555 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/function/function.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/function/function.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/function/lazy_headers.cpp b/src/boost/libs/phoenix/test/include/function/lazy_headers.cpp new file mode 100644 index 00000000..8015d18b --- /dev/null +++ b/src/boost/libs/phoenix/test/include/function/lazy_headers.cpp @@ -0,0 +1,10 @@ +/*============================================================================= + Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2011 Thomas Heller + 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/function/lazy_prelude.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/fusion.cpp b/src/boost/libs/phoenix/test/include/fusion.cpp new file mode 100644 index 00000000..f55ec028 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/fusion.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/fusion.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/fusion/at.cpp b/src/boost/libs/phoenix/test/include/fusion/at.cpp new file mode 100644 index 00000000..acec69d0 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/fusion/at.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/fusion/at.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/fusion_at.cpp b/src/boost/libs/phoenix/test/include/fusion_at.cpp new file mode 100644 index 00000000..b35d3085 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/fusion_at.cpp @@ -0,0 +1,11 @@ +/*============================================================================= + Copyright (c) 2010 Thomas Heller + + 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) +==============================================================================*/ + +//Check if files are includable without errors +#include <boost/phoenix/fusion/at.hpp> + +int main() {} diff --git a/src/boost/libs/phoenix/test/include/object.cpp b/src/boost/libs/phoenix/test/include/object.cpp new file mode 100644 index 00000000..19b20ba4 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/object.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/object.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/object/const_cast.cpp b/src/boost/libs/phoenix/test/include/object/const_cast.cpp new file mode 100644 index 00000000..d440e944 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/object/const_cast.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/object/const_cast.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/object/construct.cpp b/src/boost/libs/phoenix/test/include/object/construct.cpp new file mode 100644 index 00000000..e5d386a0 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/object/construct.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/object/construct.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/object/delete.cpp b/src/boost/libs/phoenix/test/include/object/delete.cpp new file mode 100644 index 00000000..fdd297c9 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/object/delete.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/object/delete.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/object/dynamic_cast.cpp b/src/boost/libs/phoenix/test/include/object/dynamic_cast.cpp new file mode 100644 index 00000000..3f8b9dab --- /dev/null +++ b/src/boost/libs/phoenix/test/include/object/dynamic_cast.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/object/dynamic_cast.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/object/new.cpp b/src/boost/libs/phoenix/test/include/object/new.cpp new file mode 100644 index 00000000..48254583 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/object/new.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/object/new.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/object/reinterpret_cast.cpp b/src/boost/libs/phoenix/test/include/object/reinterpret_cast.cpp new file mode 100644 index 00000000..d21112d0 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/object/reinterpret_cast.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/object/reinterpret_cast.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/object/static_cast.cpp b/src/boost/libs/phoenix/test/include/object/static_cast.cpp new file mode 100644 index 00000000..ae9e834f --- /dev/null +++ b/src/boost/libs/phoenix/test/include/object/static_cast.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/object/static_cast.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/operator.cpp b/src/boost/libs/phoenix/test/include/operator.cpp new file mode 100644 index 00000000..b7aa27ea --- /dev/null +++ b/src/boost/libs/phoenix/test/include/operator.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/operator.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/operator/arithmetic.cpp b/src/boost/libs/phoenix/test/include/operator/arithmetic.cpp new file mode 100644 index 00000000..214600f0 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/operator/arithmetic.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/operator/arithmetic.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/operator/bitwise.cpp b/src/boost/libs/phoenix/test/include/operator/bitwise.cpp new file mode 100644 index 00000000..4caa3ca3 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/operator/bitwise.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/operator/bitwise.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/operator/comparison.cpp b/src/boost/libs/phoenix/test/include/operator/comparison.cpp new file mode 100644 index 00000000..49912bd9 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/operator/comparison.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/operator/comparison.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/operator/if_else.cpp b/src/boost/libs/phoenix/test/include/operator/if_else.cpp new file mode 100644 index 00000000..2ff9fc4f --- /dev/null +++ b/src/boost/libs/phoenix/test/include/operator/if_else.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/operator/if_else.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/operator/io.cpp b/src/boost/libs/phoenix/test/include/operator/io.cpp new file mode 100644 index 00000000..72069f0f --- /dev/null +++ b/src/boost/libs/phoenix/test/include/operator/io.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/operator/io.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/operator/logical.cpp b/src/boost/libs/phoenix/test/include/operator/logical.cpp new file mode 100644 index 00000000..35740be7 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/operator/logical.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/operator/logical.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/operator/member.cpp b/src/boost/libs/phoenix/test/include/operator/member.cpp new file mode 100644 index 00000000..6d3c2091 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/operator/member.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/operator/member.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/operator/self.cpp b/src/boost/libs/phoenix/test/include/operator/self.cpp new file mode 100644 index 00000000..204509f7 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/operator/self.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/operator/self.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/phoenix.cpp b/src/boost/libs/phoenix/test/include/phoenix.cpp new file mode 100644 index 00000000..f54aede0 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/phoenix.cpp @@ -0,0 +1,12 @@ +/*============================================================================== + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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/phoenix.hpp> + +int main() +{} diff --git a/src/boost/libs/phoenix/test/include/scope.cpp b/src/boost/libs/phoenix/test/include/scope.cpp new file mode 100644 index 00000000..dfd47d60 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/scope.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/scope.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/scope/dynamic.cpp b/src/boost/libs/phoenix/test/include/scope/dynamic.cpp new file mode 100644 index 00000000..e3eb1804 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/scope/dynamic.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/scope/dynamic.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/scope/lambda.cpp b/src/boost/libs/phoenix/test/include/scope/lambda.cpp new file mode 100644 index 00000000..aa08f758 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/scope/lambda.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/scope/lambda.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/scope/let.cpp b/src/boost/libs/phoenix/test/include/scope/let.cpp new file mode 100644 index 00000000..d0f6d11a --- /dev/null +++ b/src/boost/libs/phoenix/test/include/scope/let.cpp @@ -0,0 +1,8 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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) +==============================================================================*/ +#define BOOST_PHOENIX_NO_SPECIALIZE_CUSTOM_TERMINAL +#include <boost/phoenix/scope/let.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/scope/local_variable.cpp b/src/boost/libs/phoenix/test/include/scope/local_variable.cpp new file mode 100644 index 00000000..718f748d --- /dev/null +++ b/src/boost/libs/phoenix/test/include/scope/local_variable.cpp @@ -0,0 +1,8 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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) +==============================================================================*/ +#define BOOST_PHOENIX_NO_SPECIALIZE_CUSTOM_TERMINAL +#include <boost/phoenix/scope/local_variable.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/scope/scoped_environment.cpp b/src/boost/libs/phoenix/test/include/scope/scoped_environment.cpp new file mode 100644 index 00000000..56c1c0e7 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/scope/scoped_environment.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/scope/scoped_environment.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/scope/this.cpp b/src/boost/libs/phoenix/test/include/scope/this.cpp new file mode 100644 index 00000000..95b550c2 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/scope/this.cpp @@ -0,0 +1,8 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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) +==============================================================================*/ +#define BOOST_PHOENIX_NO_SPECIALIZE_CUSTOM_TERMINAL +#include <boost/phoenix/scope/this.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/spirit.cpp b/src/boost/libs/phoenix/test/include/spirit.cpp new file mode 100644 index 00000000..cea7d521 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/spirit.cpp @@ -0,0 +1,10 @@ +/*============================================================================= + Copyright (c) 2014 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) +==============================================================================*/ +// Cross check that I have not broken spirit +#include <boost/spirit/home/karma.hpp> +#include <boost/spirit/home/lex.hpp> +#include <boost/spirit/home/qi.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/spirit_no_specialize.cpp b/src/boost/libs/phoenix/test/include/spirit_no_specialize.cpp new file mode 100644 index 00000000..2ab7a58b --- /dev/null +++ b/src/boost/libs/phoenix/test/include/spirit_no_specialize.cpp @@ -0,0 +1,11 @@ +/*============================================================================= + Copyright (c) 2014 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) +==============================================================================*/ +// Cross check that I have not broken spirit +#define BOOST_PHOENIX_NO_SPECIALIZE_CUSTOM_TERMINAL +#include <boost/spirit/home/karma.hpp> +#include <boost/spirit/home/lex.hpp> +#include <boost/spirit/home/qi.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/statement.cpp b/src/boost/libs/phoenix/test/include/statement.cpp new file mode 100644 index 00000000..eb2d093b --- /dev/null +++ b/src/boost/libs/phoenix/test/include/statement.cpp @@ -0,0 +1,8 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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) +==============================================================================*/ +//#define BOOST_PHOENIX_NO_SPECIALIZE_CUSTOM_TERMINAL +#include <boost/phoenix/statement.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/statement/do_while.cpp b/src/boost/libs/phoenix/test/include/statement/do_while.cpp new file mode 100644 index 00000000..9f4aadbe --- /dev/null +++ b/src/boost/libs/phoenix/test/include/statement/do_while.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/statement/do_while.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/statement/for.cpp b/src/boost/libs/phoenix/test/include/statement/for.cpp new file mode 100644 index 00000000..a3d513e9 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/statement/for.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/statement/for.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/statement/if.cpp b/src/boost/libs/phoenix/test/include/statement/if.cpp new file mode 100644 index 00000000..3fae4b74 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/statement/if.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/statement/if.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/statement/sequence.cpp b/src/boost/libs/phoenix/test/include/statement/sequence.cpp new file mode 100644 index 00000000..56f49122 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/statement/sequence.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/statement/sequence.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/statement/switch.cpp b/src/boost/libs/phoenix/test/include/statement/switch.cpp new file mode 100644 index 00000000..e9218410 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/statement/switch.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/statement/switch.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/statement/throw.cpp b/src/boost/libs/phoenix/test/include/statement/throw.cpp new file mode 100644 index 00000000..5c506fed --- /dev/null +++ b/src/boost/libs/phoenix/test/include/statement/throw.cpp @@ -0,0 +1,8 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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) +==============================================================================*/ +//#define BOOST_PHOENIX_NO_SPECIALIZE_CUSTOM_TERMINAL +#include <boost/phoenix/statement/throw.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/statement/try_catch.cpp b/src/boost/libs/phoenix/test/include/statement/try_catch.cpp new file mode 100644 index 00000000..f743aeb5 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/statement/try_catch.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/statement/try_catch.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/statement/while.cpp b/src/boost/libs/phoenix/test/include/statement/while.cpp new file mode 100644 index 00000000..a99e9d22 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/statement/while.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/statement/while.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/stl.cpp b/src/boost/libs/phoenix/test/include/stl.cpp new file mode 100644 index 00000000..9b936d7e --- /dev/null +++ b/src/boost/libs/phoenix/test/include/stl.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/stl.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/stl/algorithm.cpp b/src/boost/libs/phoenix/test/include/stl/algorithm.cpp new file mode 100644 index 00000000..9f5da047 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/stl/algorithm.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/stl/algorithm.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/stl/algorithm/iteration.cpp b/src/boost/libs/phoenix/test/include/stl/algorithm/iteration.cpp new file mode 100644 index 00000000..67828987 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/stl/algorithm/iteration.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/stl/algorithm/iteration.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/stl/algorithm/querying.cpp b/src/boost/libs/phoenix/test/include/stl/algorithm/querying.cpp new file mode 100644 index 00000000..892cf92e --- /dev/null +++ b/src/boost/libs/phoenix/test/include/stl/algorithm/querying.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/stl/algorithm/querying.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/stl/algorithm/transformation.cpp b/src/boost/libs/phoenix/test/include/stl/algorithm/transformation.cpp new file mode 100644 index 00000000..9ac50699 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/stl/algorithm/transformation.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/stl/algorithm/transformation.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/stl/container.cpp b/src/boost/libs/phoenix/test/include/stl/container.cpp new file mode 100644 index 00000000..4a985a9c --- /dev/null +++ b/src/boost/libs/phoenix/test/include/stl/container.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/stl/container.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/stl/container/container.cpp b/src/boost/libs/phoenix/test/include/stl/container/container.cpp new file mode 100644 index 00000000..403547fd --- /dev/null +++ b/src/boost/libs/phoenix/test/include/stl/container/container.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/stl/container/container.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/support/iterate.cpp b/src/boost/libs/phoenix/test/include/support/iterate.cpp new file mode 100644 index 00000000..1c2781ad --- /dev/null +++ b/src/boost/libs/phoenix/test/include/support/iterate.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/support/iterate.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/support/preprocessor/round.cpp b/src/boost/libs/phoenix/test/include/support/preprocessor/round.cpp new file mode 100644 index 00000000..bc81c795 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/support/preprocessor/round.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/support/preprocessor/round.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/include/version.cpp b/src/boost/libs/phoenix/test/include/version.cpp new file mode 100644 index 00000000..e42703e3 --- /dev/null +++ b/src/boost/libs/phoenix/test/include/version.cpp @@ -0,0 +1,7 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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/version.hpp> +int main() {} diff --git a/src/boost/libs/phoenix/test/object/cast_tests.cpp b/src/boost/libs/phoenix/test/object/cast_tests.cpp new file mode 100644 index 00000000..11745269 --- /dev/null +++ b/src/boost/libs/phoenix/test/object/cast_tests.cpp @@ -0,0 +1,67 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <string> +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/object.hpp> + +using std::string; + +struct T +{ + string foo() { return "T"; } +}; + +struct U : T +{ + string foo() { return "U"; } +}; + +struct VT +{ + virtual string foo() { return "T"; } +}; + +struct VU : VT +{ + virtual string foo() { return "U"; } +}; + +int +main() +{ + using boost::phoenix::arg_names::arg1; + using boost::phoenix::const_cast_; + using boost::phoenix::dynamic_cast_; + using boost::phoenix::reinterpret_cast_; + using boost::phoenix::static_cast_; + + { + U u; + BOOST_TEST(arg1(u).foo() == "U"); + BOOST_TEST(static_cast_<T&>(arg1)(u).foo() == "T"); + } + + { + U const u = U(); + BOOST_TEST(const_cast_<U&>(arg1)(u).foo() == "U"); + } + + { + VU u; + VT* tp = &u; + BOOST_TEST(arg1(tp)->foo() == "U"); + BOOST_TEST(dynamic_cast_<VU*>(arg1)(tp) != 0); + } + + { + void* p = 0; + reinterpret_cast_<VU*>(arg1)(p); // compile test only + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/object/new_delete_tests.cpp b/src/boost/libs/phoenix/test/object/new_delete_tests.cpp new file mode 100644 index 00000000..a84168f4 --- /dev/null +++ b/src/boost/libs/phoenix/test/object/new_delete_tests.cpp @@ -0,0 +1,59 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <vector> +#include <algorithm> +#include <boost/shared_ptr.hpp> +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/object.hpp> +#include <boost/phoenix/operator.hpp> + +int n = 0; + +using std::cout; +using std::endl; + +struct X +{ + X(int, int, int) { cout << "new X(int, int, int)" << endl; ++n; } + X() { cout << "new X" << endl; ++n; } + ~X() { cout << "delete X" << endl; --n; } +}; + +int +main() +{ + using boost::phoenix::arg_names::arg1; + using boost::phoenix::construct; + using boost::phoenix::delete_; + using boost::phoenix::new_; + + using std::for_each; + using std::vector; + + { + vector<X*> v(10); + + for_each(v.begin(), v.end(), arg1 = new_<X>()); + for_each(v.begin(), v.end(), delete_(arg1)); + + for_each(v.begin(), v.end(), arg1 = new_<X>(1, 2, 3)); + for_each(v.begin(), v.end(), delete_(arg1)); + } + + { + using boost::shared_ptr; + vector<shared_ptr<X> > v(10); + for_each(v.begin(), v.end(), + arg1 = boost::phoenix::construct<shared_ptr<X> >(new_<X>()) + ); + } + + BOOST_TEST(n == 0); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/operator/arithmetic_tests.cpp b/src/boost/libs/phoenix/test/operator/arithmetic_tests.cpp new file mode 100644 index 00000000..7087e3dd --- /dev/null +++ b/src/boost/libs/phoenix/test/operator/arithmetic_tests.cpp @@ -0,0 +1,71 @@ +/*============================================================================= + 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/core/lightweight_test.hpp> + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> + +#include <boost/bind.hpp> + +namespace phoenix = boost::phoenix; + +int +main() +{ + using phoenix::ref; + using phoenix::val; + + { + int x = 123; + + BOOST_TEST((ref(x) += 456)() == (123 + 456)); + BOOST_TEST(x == 123 + 456); + BOOST_TEST((ref(x) -= 456)() == 123); + BOOST_TEST(x == 123); + BOOST_TEST((ref(x) *= 456)() == 123 * 456); + BOOST_TEST(x == 123 * 456); + BOOST_TEST((ref(x) /= 456)() == 123); + BOOST_TEST(x == 123); + + int& r1 = (ref(x) += 456)(); // should be an lvalue + int& r2 = (ref(x) -= 456)(); // should be an lvalue + int& r3 = (ref(x) *= 456)(); // should be an lvalue + int& r4 = (ref(x) /= 456)(); // should be an lvalue + BOOST_TEST(r1 == 123 && r2 == 123 && r3 == 123 && r4 == 123); + + BOOST_TEST((ref(x) %= 456)() == 123 % 456); + BOOST_TEST(x == 123 % 456); + } + + { + BOOST_TEST((-val(123))() == -123); + BOOST_TEST((val(123) + 456)() == 123 + 456); + BOOST_TEST((val(123) - 456)() == 123 - 456); + BOOST_TEST((val(123) * 456)() == 123 * 456); + BOOST_TEST((val(123) / 456)() == 123 / 456); + BOOST_TEST((val(123) % 456)() == 123 % 456); + + BOOST_TEST((123 + val(456))() == 123 + 456); + BOOST_TEST((123 - val(456))() == 123 - 456); + BOOST_TEST((123 * val(456))() == 123 * 456); + BOOST_TEST((123 / val(456))() == 123 / 456); + BOOST_TEST((123 % val(456))() == 123 % 456); + } + { + // Testcase contributed from Philipp Reh, failed in Phoenix V2 + using boost::phoenix::arg_names::arg1; + using boost::phoenix::arg_names::arg2; + + int x[2]; + + BOOST_TEST((&arg1 - &arg2)(x[0], x[1]) == &x[0] - &x[1]); + BOOST_TEST((arg1 - arg2)(&x[0], &x[1]) == &x[0] - &x[1]); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/operator/bitwise_tests.cpp b/src/boost/libs/phoenix/test/operator/bitwise_tests.cpp new file mode 100644 index 00000000..094bde68 --- /dev/null +++ b/src/boost/libs/phoenix/test/operator/bitwise_tests.cpp @@ -0,0 +1,76 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> + +namespace phoenix = boost::phoenix; + +int +main() +{ + using phoenix::ref; + using phoenix::val; + using phoenix::arg_names::arg1; + using std::cout; + + { + int x; + int y; + + x = 123; + y = 123; + (ref(x) &= 456)(); + y &= 456; + BOOST_TEST(x == y); + + x = 123; + y = 123; + (ref(x) |= 456)(); + y |= 456; + BOOST_TEST(x == y); + + x = 123; + y = 123; + (ref(x) ^= 456)(); + y ^= 456; + BOOST_TEST(x == y); + + x = 123; + y = 123; + (ref(x) <<= 4)(); + y <<= 4; + BOOST_TEST(x == y); + + x = 1230000; + y = 1230000; + (ref(x) >>= 4)(); + y >>= 4; + BOOST_TEST(x == y); + + int& r1 = (ref(x) &= 456)(); // should be an lvalue + int& r2 = (ref(x) |= 456)(); // should be an lvalue + int& r3 = (ref(x) ^= 456)(); // should be an lvalue + int& r4 = (ref(x) <<= 4)(); // should be an lvalue + int& r5 = (ref(x) >>= 4)(); // should be an lvalue + BOOST_TEST(&r1 == &r2 && &r2 == &r3 && &r3 == &r4 && &r4 == &r5); + } + + { + BOOST_TEST((val(123) & 456)() == (123 & 456)); + BOOST_TEST((val(123) | 456)() == (123 | 456)); + BOOST_TEST((val(123) ^ 456)() == (123 ^ 456)); + BOOST_TEST((val(123) << 4)() == (123 << 4)); + BOOST_TEST((val(1230000) >> 4)() == (1230000 >> 4)); + + char const* s = "Yabadabadoo!!!\n"; + (cout << arg1)(s); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/operator/comparison_tests.cpp b/src/boost/libs/phoenix/test/operator/comparison_tests.cpp new file mode 100644 index 00000000..cc799342 --- /dev/null +++ b/src/boost/libs/phoenix/test/operator/comparison_tests.cpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> + +namespace phoenix = boost::phoenix; + +int +main() +{ + using phoenix::val; + + { + BOOST_TEST(!(val(123) == 456)()); + BOOST_TEST((val(123) != 456)()); + BOOST_TEST(!(val(123) > 456)()); + BOOST_TEST((val(123) < 456)()); + BOOST_TEST(!(val(123) > 456)()); + BOOST_TEST((val(123) <= 123)()); + BOOST_TEST((val(123) >= 123)()); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/operator/if_else_tests.cpp b/src/boost/libs/phoenix/test/operator/if_else_tests.cpp new file mode 100644 index 00000000..f4d49f08 --- /dev/null +++ b/src/boost/libs/phoenix/test/operator/if_else_tests.cpp @@ -0,0 +1,36 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> + +namespace phoenix = boost::phoenix; + +int +main() +{ + //using phoenix::if_else; + using phoenix::ref; + using phoenix::val; + using phoenix::arg_names::arg1; + { + int x = 0; + int y = 0; + bool c = false; + + BOOST_TEST(phoenix::if_else(arg1, 1234, 5678)(c) == 5678); + BOOST_TEST(phoenix::if_else(arg1, 1234, 'x')(c) == 'x'); + + int& r = phoenix::if_else(arg1, ref(x), ref(y))(c); // should be an lvalue + BOOST_TEST(&y == &r); + + (phoenix::if_else(arg1, ref(x), ref(y)) = 986754321)(c); + BOOST_TEST(y == 986754321); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/operator/io_tests.cpp b/src/boost/libs/phoenix/test/operator/io_tests.cpp new file mode 100644 index 00000000..de4f1ea5 --- /dev/null +++ b/src/boost/libs/phoenix/test/operator/io_tests.cpp @@ -0,0 +1,61 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <vector> +#include <algorithm> +#include <sstream> +#include <string> +#include <algorithm> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> + +namespace phoenix = boost::phoenix; + +int +main() +{ + using phoenix::val; + using phoenix::arg_names::arg1; + using phoenix::arg_names::arg2; + using std::cout; + using std::endl; + using std::hex; + using std::for_each; + using std::string; + using std::stringstream; + using std::vector; + + int i100 = 100; + string hello = "hello"; + const char* world = " world"; + + int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + vector<int> v(init, init+10); + + char const* msg = "cout assert\n"; + (cout << arg1)(msg); + (cout << arg1 << endl)(hello); + (arg1 << hex)(cout); + (cout << val(hello))(); + + (cout << val(hello) << world << ", you da man!\n")(); + for_each(v.begin(), v.end(), cout << arg1 << ','); + (cout << arg1 + 1)(i100); + + (cout << arg1 << "this is it, shukz:" << hex << arg2 << endl << endl)(msg, i100); + + int in; + int out = 12345; + stringstream sstr; + (sstr << arg1)(out); + (sstr >> arg1)(in); + BOOST_TEST(in == out); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/operator/logical_tests.cpp b/src/boost/libs/phoenix/test/operator/logical_tests.cpp new file mode 100644 index 00000000..383db48f --- /dev/null +++ b/src/boost/libs/phoenix/test/operator/logical_tests.cpp @@ -0,0 +1,36 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> + +namespace phoenix = boost::phoenix; + +int +main() +{ + using phoenix::arg_names::arg1; + using phoenix::arg_names::arg2; + { + bool x = false; + bool y = true; + + BOOST_TEST((!arg1)(x) == true); + BOOST_TEST((!arg1)(y) == false); + BOOST_TEST((arg1 || arg2)(x, y) == true); + BOOST_TEST((arg1 && arg2)(x, y) == false); + + // short circuiting: + int i = 1234; + (arg1 || (arg2 = 4567))(y, i); + BOOST_TEST(i == 1234); + (arg1 && (arg2 = 4567))(y, i); + BOOST_TEST(i == 4567); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/operator/member.cpp b/src/boost/libs/phoenix/test/operator/member.cpp new file mode 100644 index 00000000..1abd22d3 --- /dev/null +++ b/src/boost/libs/phoenix/test/operator/member.cpp @@ -0,0 +1,108 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + Copyright (c) 2014 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.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/detail/lightweight_test.hpp> +//#include <boost/move/unique_ptr.hpp> + +#include <memory> + +#include <boost/shared_ptr.hpp> +#include <boost/scoped_ptr.hpp> + +namespace +{ + struct Test + { + int value; + + int func(int n) const { return n; } + int dunc() { return 10; } + int kunc() const { return 555; } + }; +} + +namespace phoenix = boost::phoenix; + +int main() +{ + using boost::scoped_ptr; + using boost::shared_ptr; + using phoenix::val; + using phoenix::ref; + using phoenix::arg_names::arg1; + using phoenix::arg_names::arg2; + + Test test = {1}; + const Test* cptr = &test; + Test* ptr = &test; + + BOOST_TEST((val(ptr)->*&Test::value)() == 1); + BOOST_TEST((val(cptr)->*&Test::value)() == 1); + BOOST_TEST((arg1->*&Test::value)(cptr) == 1); + + ((val(ptr)->*&Test::value) = 2)(); + BOOST_TEST(test.value == 2); + + + BOOST_TEST((val(ptr)->*&Test::func)(val(3))() == 3); + int i = 33; + BOOST_TEST((arg1->*&Test::func)(arg2)(cptr, i) == i); + //BOOST_TEST((val(cptr)->*&Test::func)(4)() == 4); + BOOST_TEST((val(ptr)->*&Test::dunc)()() == 10); + + BOOST_TEST((arg1->*&Test::func)(5)(ptr) == 5); + BOOST_TEST((arg1->*&Test::kunc)()(ptr)); + + shared_ptr<Test> sptr(new Test(test)); + + BOOST_TEST((arg1->*&Test::value)(sptr) == 2); + BOOST_TEST((arg1->*&Test::func)(6)(sptr) == 6); + + scoped_ptr<Test> scptr(new Test(test)); + + BOOST_TEST((arg1->*&Test::value)(scptr) == 2); + BOOST_TEST((arg1->*&Test::func)(7)(scptr) == 7); + + shared_ptr<const Test> csptr(new Test(test)); + + BOOST_TEST((arg1->*&Test::value)(csptr) == 2); + BOOST_TEST((arg1->*&Test::func)(8)(csptr) == 8); + + scoped_ptr<const Test> cscptr(new Test(test)); + + BOOST_TEST((arg1->*&Test::value)(cscptr) == 2); + BOOST_TEST((arg1->*&Test::func)(9)(cscptr) == 9); + +#ifdef BOOST_NO_CXX11_SMART_PTR + std::auto_ptr<Test> aptr(new Test(test)); +#else + std::unique_ptr<Test> aptr(new Test(test)); +#endif + + BOOST_TEST((arg1->*&Test::value)(aptr) == 2); + BOOST_TEST((arg1->*&Test::func)(10)(aptr) == 10); + +#ifdef BOOST_NO_CXX11_SMART_PTR + std::auto_ptr<const Test> captr(new Test(test)); +#else + std::unique_ptr<const Test> captr(new Test(test)); +#endif + + BOOST_TEST((arg1->*&Test::value)(captr) == 2); + BOOST_TEST((arg1->*&Test::func)(11)(captr) == 11); + + //boost::movelib::unique_ptr<Test> buptr(new Test(test)); + //BOOST_TEST((arg1->*&Test::value)(buptr) == 2); + //BOOST_TEST((arg1->*&Test::func)(12)(buptr) == 12); + + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/operator/misc_binary_tests.cpp b/src/boost/libs/phoenix/test/operator/misc_binary_tests.cpp new file mode 100644 index 00000000..468fed24 --- /dev/null +++ b/src/boost/libs/phoenix/test/operator/misc_binary_tests.cpp @@ -0,0 +1,104 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <string> +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> + +namespace phoenix = boost::phoenix; + +int +main() +{ + using phoenix::ref; + using phoenix::val; + using phoenix::arg_names::arg1; + using phoenix::arg_names::arg2; + using std::string; + { // From Phoenix 1.1 binary tests + + int i2 = 2, i3 = 3, i = 5; + const char* world = " world"; + + +#if !(defined(BOOST_MSVC) && (BOOST_MSVC >= 1900)) + BOOST_TEST((ref(i) = ref(i))() == 5); +#endif + BOOST_TEST((ref(i) = 3)() == 3); + BOOST_TEST(i == 3); + i = 5; + int x, y, z; + (ref(x) = ref(y) = ref(z) = 10)(); + BOOST_TEST(x == 10 && y == 10 && z == 10); + BOOST_TEST((val(world)[3])() == world[3]); + + BOOST_TEST((ref(i) += 5)() == 10); + BOOST_TEST((ref(i) -= 5)() == 5); + BOOST_TEST((ref(i) *= 5)() == 25); + BOOST_TEST((ref(i) /= 5)() == 5); + BOOST_TEST((ref(i) %= 2)() == 1); + + BOOST_TEST((ref(i) <<= 3)() == 8); + BOOST_TEST((ref(i) >>= 1)() == 4); + BOOST_TEST((ref(i) |= 0xFF)() == 0xFF); + BOOST_TEST((ref(i) &= 0xF0)() == 0xF0); + BOOST_TEST((ref(i) ^= 0xFFFFFFFF)() == int(0xFFFFFF0F)); + + BOOST_TEST((val(5) == val(5))()); + BOOST_TEST((val(5) == 5)()); + + BOOST_TEST((arg1 + arg2 )(i2, i3) == i2 + i3 ); + BOOST_TEST((arg1 - arg2)(i2, i3) == i2 - i3); + BOOST_TEST((arg1 * arg2)(i2, i3) == i2 * i3); + BOOST_TEST((arg1 / arg2)(i2, i3) == i2 / i3); + BOOST_TEST((arg1 % arg2)(i2, i3) == i2 % i3); + BOOST_TEST((arg1 & arg2)(i2, i3) == (i2 & i3)); + BOOST_TEST((arg1 | arg2)(i2, i3) == (i2 | i3)); + BOOST_TEST((arg1 ^ arg2)(i2, i3) == (i2 ^ i3)); + BOOST_TEST((arg1 << arg2)(i2, i3) == i2 << i3); + BOOST_TEST((arg1 >> arg2)(i2, i3) == i2 >> i3); + + BOOST_TEST((val(5) != val(6))()); + BOOST_TEST((val(5) < val(6))()); + BOOST_TEST(!(val(5) > val(6))()); + BOOST_TEST((val(5) < val(6))()); + BOOST_TEST((val(5) <= val(6))()); + BOOST_TEST((val(5) <= val(5))()); + BOOST_TEST((val(7) >= val(6))()); + BOOST_TEST((val(7) >= val(7))()); + + BOOST_TEST((val(false) && val(false))() == false); + BOOST_TEST((val(true) && val(false))() == false); + BOOST_TEST((val(false) && val(true))() == false); + BOOST_TEST((val(true) && val(true))() == true); + + BOOST_TEST((val(false) || val(false))() == false); + BOOST_TEST((val(true) || val(false))() == true); + BOOST_TEST((val(false) || val(true))() == true); + BOOST_TEST((val(true) || val(true))() == true); + } + + { // From Phoenix 1.1 mixed_binary tests + + int i1 = 1, i2 = 2, i50 = 50, i100 = 100; + double d2_5 = 2.5; + string hello = "hello"; + const char* world = " world"; + + BOOST_TEST((arg1 + arg2)(i100, i50) == (i100 + i50)); + BOOST_TEST((arg1 + 3)(i100) == (3 + i100)); + BOOST_TEST((arg1 + arg2)(hello, world) == "hello world"); + BOOST_TEST((arg1 + arg2)(i1, d2_5) == (i1 + d2_5)); + + BOOST_TEST((*(arg1 + arg2))(world, i2) == *(world + i2)); + BOOST_TEST((*(arg1 + arg2))(i2, world) == *(i2 + world)); + BOOST_TEST((*(val(world+i2) - arg1))(i2) == *world); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/operator/self_tests.cpp b/src/boost/libs/phoenix/test/operator/self_tests.cpp new file mode 100644 index 00000000..595ef692 --- /dev/null +++ b/src/boost/libs/phoenix/test/operator/self_tests.cpp @@ -0,0 +1,60 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <vector> +#include <string> +#include <map> +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> + +namespace phoenix = boost::phoenix; + +int +main() +{ + using phoenix::ref; + using phoenix::arg_names::arg1; + using phoenix::arg_names::arg2; + using std::map; + using std::string; + using std::vector; + + { + int x = 123; + BOOST_TEST((&arg1)(x) == &x); + //BOOST_TEST((*&arg1)(x) == 123); + + int y = 968; + (ref(x) = arg1)(y); + BOOST_TEST(x == y); + + (arg1 = 456)(x); + BOOST_TEST(x == 456); + int& r = (arg1 = 456)(x); // must be an lvalue + BOOST_TEST(&r == &x); + + int c[] = { 1, 2, 3, 4, 5 }; + BOOST_TEST((arg1[3])(c) == 4); + + int& r2 = (arg1[3])(c); // must be an lvalue + BOOST_TEST(&r2 == &c[3]); + + vector<string> v; + v.push_back("a"); + v.push_back("b"); + v.push_back("c"); + v.push_back("d"); + + BOOST_TEST((arg1[3])(v) == "d"); + + map<string, int> m; + (arg1["Kimpo"] = arg2)(m, x); + BOOST_TEST(m["Kimpo"] == x); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/operator/unary_tests.cpp b/src/boost/libs/phoenix/test/operator/unary_tests.cpp new file mode 100644 index 00000000..a5636e49 --- /dev/null +++ b/src/boost/libs/phoenix/test/operator/unary_tests.cpp @@ -0,0 +1,65 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> + +namespace phoenix = boost::phoenix; + +int +main() +{ + using phoenix::val; + using phoenix::ref; + using phoenix::arg_names::arg1; + { + BOOST_TEST((-val(123))() == -123); + BOOST_TEST((- -val(123))() == 123); + BOOST_TEST((+val(123))() == 123); + } + + { + int x = 123; + + BOOST_TEST((++ref(x))() == 124); + BOOST_TEST(x == 124); + BOOST_TEST((--ref(x))() == 123); + BOOST_TEST(x == 123); + + BOOST_TEST((ref(x)++)() == 123); + BOOST_TEST(x == 124); + BOOST_TEST((ref(x)--)() == 124); + BOOST_TEST(x == 123); + + int& r1 = (++ref(x))(); // should be an lvalue + int& r2 = (--ref(x))(); // should be an lvalue + BOOST_TEST(r1 == 123 && r2 == 123); + } + + { // From Phoenix 1.1 unary tests + + int i1 = 1, i = 5; + + BOOST_TEST((!val(true))() == false); + BOOST_TEST((-val(1))() == -1); + BOOST_TEST((+val(1))() == +1); + BOOST_TEST((~val(1))() == ~1); + BOOST_TEST(*(&arg1)(i1) == *(&i1)); + BOOST_TEST((&arg1)(i1) == &i1); + + BOOST_TEST((*val(&i1))() == *(&i1)); + BOOST_TEST((*&arg1)(i1) == *(&i1)); + BOOST_TEST((++ref(i))() == 6); + BOOST_TEST((--ref(i))() == 5); + BOOST_TEST((ref(i)++)() == 5); + BOOST_TEST(i == 6); + BOOST_TEST((ref(i)--)() == 6); + BOOST_TEST(i == 5); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/regression/actor_assignment.cpp b/src/boost/libs/phoenix/test/regression/actor_assignment.cpp new file mode 100644 index 00000000..9c0259c0 --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/actor_assignment.cpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2018 Nikita Kniazev + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix.hpp> +#include <boost/function.hpp> +#include <string> + +// Checks that rhs Phoenix actor is taken by value on assignment. +// The wrapper function is used to ensure that created temporaries are +// out of scope (as they will be created on the other stack frame). + +boost::function<void()> make_assignment_test(std::string & s) +{ + return boost::phoenix::ref(s) = "asd"; +} + +int main() +{ + std::string s; + make_assignment_test(s)(); + BOOST_TEST(s == "asd"); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/regression/bug4853.cpp b/src/boost/libs/phoenix/test/regression/bug4853.cpp new file mode 100644 index 00000000..09a875b1 --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug4853.cpp @@ -0,0 +1,79 @@ +/*============================================================================== + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + 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 <utility> // for std::forward used by boost/range in some cases. +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/range.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/make_shared.hpp> +#include <boost/range/adaptor/transformed.hpp> +#include <boost/range/adaptor/uniqued.hpp> +#include <boost/range/algorithm_ext/push_back.hpp> + +#include <vector> +#include <string> +#include <iostream> + + +namespace phoenix = boost::phoenix; + +struct Foo { + Foo(const std::string& name, int value) + : name_(name) + , value_(value) + { } + + std::string name_; int value_; +}; + +typedef boost::shared_ptr<Foo> FooPtr; + +int range_test_complex() { + typedef std::vector<FooPtr> V; + + V source; + + source.push_back(boost::make_shared<Foo>("Foo", 10)); + source.push_back(boost::make_shared<Foo>("Bar", 20)); + source.push_back(boost::make_shared<Foo>("Baz", 30)); + source.push_back(boost::make_shared<Foo>("Baz", 30)); //duplicate is here + + std::vector<std::string> result1; + std::vector<int> result2; + + using namespace boost::adaptors; + using phoenix::arg_names::arg1; + + // This is failing for gcc 4.4 and 4.5 - reason not identified. +#if ((BOOST_GCC_VERSION < 40400) || (BOOST_GCC_VERSION >= 40600)) + boost::push_back(result1, source | transformed(phoenix::bind(&Foo::name_, *arg1)) | uniqued); + + for(unsigned i = 0; i < result1.size(); ++i) + std::cout << result1[i] << "\n"; +#endif + +// This is failing for gcc 4.4 and 4.5 - reason not identified. +#if !(BOOST_GCC_VERSION < 40600) + boost::push_back(result2, source | transformed(phoenix::bind(&Foo::value_, *arg1)) | uniqued); + + for(unsigned i = 0; i < result2.size(); ++i) + std::cout << result2[i] << "\n"; +#endif + + return 0; + +} + +int main() +{ + return range_test_complex(); +} + diff --git a/src/boost/libs/phoenix/test/regression/bug5626.cpp b/src/boost/libs/phoenix/test/regression/bug5626.cpp new file mode 100644 index 00000000..6f277cab --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug5626.cpp @@ -0,0 +1,26 @@ +/*============================================================================== + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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 <utility> // for std::forward used by boost/range in some cases. +#include <boost/range.hpp> +#include <boost/range/irange.hpp> +#include <boost/range/adaptors.hpp> +#include <boost/phoenix.hpp> +#include <boost/detail/lightweight_test.hpp> + +using namespace boost::phoenix::arg_names; +using namespace boost::adaptors; + +int foo() { return 5; } + +int main() +{ + BOOST_TEST((*boost::begin(boost::irange(0,5) | transformed( arg1)) == 0)); + + boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/regression/bug5824.cpp b/src/boost/libs/phoenix/test/regression/bug5824.cpp new file mode 100644 index 00000000..43609904 --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug5824.cpp @@ -0,0 +1,25 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + Copyright (c) 2014 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) +==============================================================================*/ + +// Check for Bug5824 + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> + +#include <boost/core/lightweight_test.hpp> + +using namespace boost::phoenix::arg_names; + +int main() +{ + int a = 0; + (++arg1, ++arg1)(a); + BOOST_TEST(a == 2); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/regression/bug5875.cpp b/src/boost/libs/phoenix/test/regression/bug5875.cpp new file mode 100644 index 00000000..689c5808 --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug5875.cpp @@ -0,0 +1,23 @@ +/*============================================================================= + Copyright (c) 2014 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.hpp> +#include <vector> + +#include <boost/detail/lightweight_test.hpp> + +namespace phx = boost::phoenix; + +int main() +{ + std::vector<int> v = phx::let(phx::local_names::_a = std::vector<int>(3)) + [ + phx::local_names::_a + ] + (); + BOOST_TEST( v.size() == 3); +} diff --git a/src/boost/libs/phoenix/test/regression/bug5968.cpp b/src/boost/libs/phoenix/test/regression/bug5968.cpp new file mode 100644 index 00000000..113360a0 --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug5968.cpp @@ -0,0 +1,27 @@ +/*============================================================================== + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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.hpp> +#include <boost/signals2.hpp> + +struct s +{ + bool f(int, bool) { return true; } +}; + +int main() +{ + s s_obj; + boost::signals2::signal<bool (int, bool)> sig; + sig.connect( + boost::phoenix::bind( + &s::f, &s_obj, + boost::phoenix::placeholders::arg1, + boost::phoenix::placeholders::arg2)); +} + diff --git a/src/boost/libs/phoenix/test/regression/bug6040.cpp b/src/boost/libs/phoenix/test/regression/bug6040.cpp new file mode 100644 index 00000000..dce413cb --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug6040.cpp @@ -0,0 +1,22 @@ +/*============================================================================== + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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.hpp> +#include <vector> +#include <algorithm> +#include <sstream> + +int main() +{ + std::vector<unsigned char> data; + using boost::phoenix::arg_names::_1; + using boost::phoenix::static_cast_; + std::ostringstream oss; + oss << std::hex; + std::for_each(data.begin(),data.end(), static_cast_<unsigned int>(_1) ); +} diff --git a/src/boost/libs/phoenix/test/regression/bug6268.cpp b/src/boost/libs/phoenix/test/regression/bug6268.cpp new file mode 100644 index 00000000..978d1a0e --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug6268.cpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + Copyright (c) 2014 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/fusion/sequence/comparison.hpp> +#include <boost/fusion/sequence/sequence_facade.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/comparison.hpp> + +struct foo : boost::fusion::sequence_facade<foo, boost::fusion::random_access_traversal_tag> +{ + // Rest of the sequence_facade extension mechanism code omitted, + // as it is not needed to reproduce the error + + foo() : x(), y() {} + + int x; + int y; +}; + +int main() +{ + (void)(boost::phoenix::arg_names::arg1 < foo()); +} diff --git a/src/boost/libs/phoenix/test/regression/bug7165.cpp b/src/boost/libs/phoenix/test/regression/bug7165.cpp new file mode 100644 index 00000000..b7804559 --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug7165.cpp @@ -0,0 +1,15 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + Copyright (c) 2014-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) +==============================================================================*/ + +#define BOOST_PHOENIX_LIMIT 20 +#include <boost/phoenix/core/limits.hpp> + +int main() +{ +} diff --git a/src/boost/libs/phoenix/test/regression/bug7166.cpp b/src/boost/libs/phoenix/test/regression/bug7166.cpp new file mode 100644 index 00000000..1b3bc76b --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug7166.cpp @@ -0,0 +1,16 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + Copyright (c) 2014 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) +==============================================================================*/ + +#define BOOST_PROTO_MAX_ARITY 10 +#define BOOST_PHOENIX_LIMIT 20 +#include <boost/phoenix/core.hpp> + +int main() +{ +} diff --git a/src/boost/libs/phoenix/test/regression/bug7624.cpp b/src/boost/libs/phoenix/test/regression/bug7624.cpp new file mode 100644 index 00000000..f53c6bc5 --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/bug7624.cpp @@ -0,0 +1,31 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + Copyright (c) 2014 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.hpp> +#include <boost/range/as_literal.hpp> +#include <boost/core/lightweight_test.hpp> + +using namespace boost::phoenix::placeholders; +using namespace boost::phoenix; + +int main() +{ + char X('x'); + find(boost::as_literal("fox"), 'x')(); // works +#if !(defined (BOOST_NO_CXX11_DECLTYPE) || \ + defined (BOOST_INTEL_CXX_VERSION) || \ + (BOOST_GCC_VERSION < 40500) ) + const char *Y = find(boost::as_literal("fox"), arg1)('x'); // works for C++11 +#else + const char *Y = find(boost::as_literal("fox"), construct<char>(arg1))('x'); // works +#endif + BOOST_TEST(X == *Y); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/regression/from_array.cpp b/src/boost/libs/phoenix/test/regression/from_array.cpp new file mode 100644 index 00000000..b7da4830 --- /dev/null +++ b/src/boost/libs/phoenix/test/regression/from_array.cpp @@ -0,0 +1,60 @@ +/*============================================================================= + Copyright (c) 2017 Nikita Kniazev + + 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.hpp> +#include <boost/phoenix/object.hpp> +#include <boost/phoenix/scope.hpp> +#include <boost/phoenix/operator.hpp> + +#include <string> +#include <iostream> + +template <typename T, std::size_t N> +struct array_holder +{ + typedef T underlying_type[N]; + + array_holder(underlying_type const& x) + { + for (std::size_t i = 0; i < N; ++i) elems_[i] = x[i]; + } + + T elems_[N]; + + friend std::ostream& operator<<(std::ostream& os, array_holder const& x) + { + os << x.elems_[0]; + for (std::size_t i = 1; i < N; ++i) os << ", " << x.elems_[i]; + return os; + } +}; + +int main() +{ + using boost::phoenix::construct; + using boost::phoenix::let; + using boost::phoenix::arg_names::_1; + using boost::phoenix::local_names::_a; + + let(_a = construct<std::string>("str")) + [ + std::cout << _a << std::endl + ](); + + let(_a = construct<array_holder<char, 4> >("str")) + [ + std::cout << _a << std::endl + ](); + + int ints[] = { 1, 2, 3 }; + let(_a = construct<array_holder<int, sizeof(ints) / sizeof(ints[0])> >(ints) ) + [ + std::cout << _a << std::endl + ](); + + return 0; +} diff --git a/src/boost/libs/phoenix/test/scope/bug3289.cpp b/src/boost/libs/phoenix/test/scope/bug3289.cpp new file mode 100644 index 00000000..f54d5e1d --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/bug3289.cpp @@ -0,0 +1,37 @@ +/*============================================================================== + Copyright (c) 2005-2010 Joel de Guzman + Copyright (c) 2010 Thomas Heller + + 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 <algorithm> +#include <vector> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/scope.hpp> +#include <boost/phoenix/stl.hpp> + +namespace phx = boost::phoenix; +using namespace boost::phoenix; +using namespace boost::phoenix::arg_names; +using namespace boost::phoenix::local_names; + +int main() +{ + std::vector<int> u(11,1); + std::vector<int> w(11,2); + std::vector<int>::const_iterator it=w.begin(); + + boost::phoenix::generate(phx::ref(u), lambda(_a=*phx::ref(it)++)[_a*2])(); + + BOOST_TEST(std::accumulate(u.begin(), u.end(), 0) == 44); + + BOOST_TEST(lambda(_a=*phx::ref(it)++)[_a*2]()() == 4); + + return boost::report_errors(); +} + + diff --git a/src/boost/libs/phoenix/test/scope/bug8298.cpp b/src/boost/libs/phoenix/test/scope/bug8298.cpp new file mode 100644 index 00000000..42cd8ab6 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/bug8298.cpp @@ -0,0 +1,33 @@ +/*============================================================================= + Copyright (c) 2014 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.hpp> + +#include <boost/detail/lightweight_test.hpp> + +namespace phoenix = boost::phoenix; +using boost::phoenix::ref; +using namespace phoenix::local_names; +using boost::phoenix::arg_names::_1; + +int main(int argc, char *argv[]) +{ + int x = 17; + int y = phoenix::lambda(_a=ref(x)) + [ + _a = 18 + ]()(); + BOOST_TEST(y==18); + + int z = phoenix::lambda(_a=_1) + [ + _a = 18 + ](x)(); + std::cout << z << std::endl; + BOOST_TEST(y==18); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/bug8298f.cpp b/src/boost/libs/phoenix/test/scope/bug8298f.cpp new file mode 100644 index 00000000..ad7327ef --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/bug8298f.cpp @@ -0,0 +1,24 @@ +/*============================================================================= + Copyright (c) 2014 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.hpp> + +#include <boost/detail/lightweight_test.hpp> + +namespace phoenix = boost::phoenix; +using namespace phoenix::local_names; +using boost::phoenix::arg_names::_1; + +int main(int argc, char *argv[]) +{ + int y = phoenix::lambda(_a=_1) + [ + _a = 18 + ](17)(); + BOOST_TEST(y==18); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/bug_000008.cpp b/src/boost/libs/phoenix/test/scope/bug_000008.cpp new file mode 100644 index 00000000..58adf417 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/bug_000008.cpp @@ -0,0 +1,105 @@ +/*============================================================================= + Copyright (c) 2003 Martin Wille + 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) +=============================================================================*/ + + // see http://article.gmane.org/gmane.comp.parsers.spirit.general/4575 + // or https://sf.net/mailarchive/forum.php?thread_id=2692308&forum_id=1595 + // for a description of the bug being tested for by this program + // + // This code is borrowed from Spirit's bug_000008.cpp test for multithreads. + // Now modified to point to the Phoenix headers + // instead of the ones in Spirit. +#include <iostream> +#include <boost/config.hpp> +#include <boost/assert.hpp> +#include <boost/detail/lightweight_test.hpp> + // Testing problems in thread/future +//#include <boost/move/move.hpp> +//#include <boost/move/detail/type_traits.hpp> +//using boost::move_detail::is_copy_constructible; +#include <boost/phoenix/scope/dynamic.hpp> + +#if defined(DONT_HAVE_BOOST) \ + || !defined(BOOST_HAS_THREADS) \ + || defined(BOOST_DISABLE_THREADS) \ + || (defined(__GNUC__) && defined(__WIN32__)) // MinGW +#define SKIP_TEST +#endif + + +#if defined(SKIP_TEST) +// we end here if we can't do multithreading +static void skipped() +{ + std::cout << "skipped\n"; +} + +int +main() +{ + skipped(); + return boost::report_errors(); +} + +#else +// the real MT stuff + +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/scope.hpp> +#include <boost/thread.hpp> + +static const int number_of_calls_per_thread=20000; + +struct test_dynamic : boost::phoenix::dynamic<int> +{ + // test_dynamic() : b(*this) {} + test_dynamic() : b(init<0>(this)) {} + member1 b; +}; + +void +in_thread(void) +{ + test_dynamic s; // should now be a local + + for (int i = 0; i < number_of_calls_per_thread; ++i) + { + boost::phoenix::dynamic_frame<test_dynamic::self_type> frame(s); + (s.b = 123)(); + { + boost::phoenix::dynamic_frame<test_dynamic::self_type> frame(s); + (s.b = 456)(); + BOOST_ASSERT((s.b == 456)()); + } + BOOST_ASSERT((s.b == 123)()); + } +} + +void +bug_000008() +{ + boost::thread t1(in_thread); + boost::thread t2(in_thread); + boost::thread t3(in_thread); + boost::thread t4(in_thread); + + t1.join(); + t2.join(); + t3.join(); + t4.join(); +} + +int +main() +{ + bug_000008(); + return boost::report_errors(); +} + +#endif + diff --git a/src/boost/libs/phoenix/test/scope/dynamic_tests.cpp b/src/boost/libs/phoenix/test/scope/dynamic_tests.cpp new file mode 100644 index 00000000..8751d181 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/dynamic_tests.cpp @@ -0,0 +1,75 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <string> +#include <cmath> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/scope/dynamic.hpp> + +struct my_dynamic : ::boost::phoenix::dynamic<int, std::string, double> +{ + my_dynamic() : num(init<0>(this)), message(init<1>(this)), real(init<2>(this)) {} + + member1 num; + member2 message; + member3 real; +}; + +// You may also use the macro below to achieve the same as above: +// +//BOOST_PHOENIX_DYNAMIC( +// my_dynamic, +// (int, num) +// (std::string, message) +// (double, real) +//); + +int +main() +{ + using namespace boost::phoenix; + using namespace boost::phoenix::arg_names; + + my_dynamic clos; + + { // First stack frame + dynamic_frame<my_dynamic::self_type> frame(clos); + (clos.num = 123)(); + (clos.num += 456)(); + (clos.real = clos.num / 56.5)(); + (clos.message = "Hello " + std::string("World "))(); + + { // Second stack frame + dynamic_frame<my_dynamic::self_type> frame(clos); + (clos.num = 987)(); + (clos.message = std::string("Abracadabra "))(); + (clos.real = clos.num * 1e30)(); + + { // Third stack frame + boost::phoenix::vector3<int, std::string, double> init = {-1, "Direct Init ", 3.14}; + dynamic_frame<my_dynamic::self_type> frame(clos, init); + + (std::cout << clos.message << clos.num << ", " << clos.real << '\n')(); + BOOST_TEST(clos.num() == -1); + BOOST_TEST(clos.message() == "Direct Init "); + } + + (std::cout << clos.message << clos.num << ", " << clos.real << '\n')(); + BOOST_TEST(clos.num() == 987); + BOOST_TEST(clos.message() == "Abracadabra "); + } + + (std::cout << clos.message << clos.num << ", " << clos.real << '\n')(); + BOOST_TEST(clos.num() == 123+456); + BOOST_TEST(clos.message() == "Hello " + std::string("World ")); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests1.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests1.cpp new file mode 100644 index 00000000..4c3b4e7a --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests1.cpp @@ -0,0 +1,23 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahashi + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/scope/lambda.hpp> + +int main() +{ + using boost::phoenix::lambda; + using boost::phoenix::arg_names::_1; + + int x = 1; + int y = lambda[_1]()(x); + BOOST_TEST(x == y); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests10.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests10.cpp new file mode 100644 index 00000000..27b6f169 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests10.cpp @@ -0,0 +1,35 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahashi + + 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/config.hpp> +#include <boost/detail/workaround.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/self.hpp> +#include <boost/phoenix/scope/lambda.hpp> + +struct zzz {}; + +int main() +{ +#if defined(RUNNING_ON_APPVEYOR) && BOOST_WORKAROUND(BOOST_MSVC, == 1800) + // skip test +#else + using boost::phoenix::lambda; + using boost::phoenix::arg_names::_1; + using boost::phoenix::local_names::_a; + + int x = 1; + char const* y = "hello"; + zzz z; + BOOST_TEST(lambda(_a = _1)[lambda[_a]](x)(y)(z) == x); + + return boost::report_errors(); +#endif +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests11.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests11.cpp new file mode 100644 index 00000000..35fb8ce4 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests11.cpp @@ -0,0 +1,33 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahashi + + 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/config.hpp> +#include <boost/detail/workaround.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/self.hpp> +#include <boost/phoenix/scope/lambda.hpp> + +int main() +{ +#if defined(RUNNING_ON_APPVEYOR) && BOOST_WORKAROUND(BOOST_MSVC, == 1800) + // skip test +#else + using boost::phoenix::lambda; + using boost::phoenix::arg_names::_1; + using boost::phoenix::local_names::_a; + + int x = 1; + char const* y = "hello"; + int xx = 20; + BOOST_TEST(lambda(_a = _1)[lambda[_a]](x)(y)(xx) == x); + + return boost::report_errors(); +#endif +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests12.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests12.cpp new file mode 100644 index 00000000..f355b313 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests12.cpp @@ -0,0 +1,26 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahashi + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/arithmetic.hpp> +#include <boost/phoenix/operator/self.hpp> +#include <boost/phoenix/scope/lambda.hpp> + +int main() +{ + using boost::phoenix::lambda; + using boost::phoenix::arg_names::_1; + using boost::phoenix::local_names::_a; + + int x = 1; + char const* y = "hello"; + BOOST_TEST(lambda(_a = _1)[lambda[_a + _1]](x)(y)(x) == 2); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests13.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests13.cpp new file mode 100644 index 00000000..57c0a52e --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests13.cpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahashi + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/arithmetic.hpp> +#include <boost/phoenix/operator/self.hpp> +#include <boost/phoenix/scope/lambda.hpp> + +int main() +{ + using boost::phoenix::lambda; + using boost::phoenix::arg_names::_1; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + + int x = 1; + long x2 = 2; + short x3 = 3; + BOOST_TEST(lambda(_a = _1)[lambda(_b = _1)[_a + _b + _1]](x)(x2)(x3) == 6); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests14.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests14.cpp new file mode 100644 index 00000000..b504bf29 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests14.cpp @@ -0,0 +1,34 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahashi + + 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/config.hpp> +#include <boost/detail/workaround.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/self.hpp> +#include <boost/phoenix/operator/arithmetic.hpp> +#include <boost/phoenix/scope/lambda.hpp> + +int main() +{ +#if defined(RUNNING_ON_APPVEYOR) && BOOST_WORKAROUND(BOOST_MSVC, == 1800) + // skip test +#else + using boost::phoenix::lambda; + using boost::phoenix::arg_names::_1; + using boost::phoenix::local_names::_a; + + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda(_a = _1)[_a + lambda[_a + 2]])(x)(y)(y) == 1+1+1+2 + ); + + return boost::report_errors(); +#endif +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests15.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests15.cpp new file mode 100644 index 00000000..c2d08313 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests15.cpp @@ -0,0 +1,34 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahshi + + 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/config.hpp> +#include <boost/detail/workaround.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/self.hpp> +#include <boost/phoenix/operator/arithmetic.hpp> +#include <boost/phoenix/scope/lambda.hpp> + +int main() +{ +#if defined(RUNNING_ON_APPVEYOR) && BOOST_WORKAROUND(BOOST_MSVC, == 1800) + // skip test +#else + using boost::phoenix::lambda; + using boost::phoenix::arg_names::_1; + using boost::phoenix::local_names::_a; + + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda(_a = _1)[_a + lambda[_a + 2]])(x)()(x) == 1+1+1+2 + ); + + return boost::report_errors(); +#endif +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests16.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests16.cpp new file mode 100644 index 00000000..0ca0301f --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests16.cpp @@ -0,0 +1,25 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahashi + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/arithmetic.hpp> +#include <boost/phoenix/scope/lambda.hpp> + +int main() +{ + using boost::phoenix::lambda; + using boost::phoenix::arg_names::_1; + + int x = 1, y = 10; + BOOST_TEST( + (_1 + _1 + lambda[_1 + 2])(x)(y) == 1+1+10+2 + ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests17.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests17.cpp new file mode 100644 index 00000000..137bb95c --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests17.cpp @@ -0,0 +1,27 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahsahi + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/self.hpp> +#include <boost/phoenix/operator/arithmetic.hpp> +#include <boost/phoenix/scope/lambda.hpp> + +int main() +{ + using boost::phoenix::lambda; + using boost::phoenix::arg_names::_1; + using boost::phoenix::local_names::_a; + + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda(_a = _1)[_a + _1 + 2])(x)(y) == 1+1+10+2 + ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests18.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests18.cpp new file mode 100644 index 00000000..fc3b3025 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests18.cpp @@ -0,0 +1,36 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahsahi + + 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 <vector> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/self.hpp> +#include <boost/phoenix/operator/arithmetic.hpp> +#include <boost/phoenix/scope/lambda.hpp> +#include <boost/phoenix/stl/algorithm/iteration.hpp> +#include <boost/phoenix/stl/container.hpp> + +int main() +{ + using boost::phoenix::lambda; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + using boost::phoenix::for_each; + + int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + std::vector<int> v(init, init+10); + + int x = 0; + for_each(_1, lambda(_a = _2)[_a += _1])(v, x); + BOOST_TEST(x == 55); + + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests19.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests19.cpp new file mode 100644 index 00000000..c2002f6a --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests19.cpp @@ -0,0 +1,41 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahsahi + + 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 <vector> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/self.hpp> +#include <boost/phoenix/operator/arithmetic.hpp> +#include <boost/phoenix/scope/lambda.hpp> +#include <boost/phoenix/stl/algorithm/iteration.hpp> +#include <boost/phoenix/stl/container.hpp> + +int main() +{ + using boost::phoenix::lambda; + using boost::phoenix::ref; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + using boost::phoenix::placeholders::arg1; + + using boost::phoenix::for_each; + using boost::phoenix::push_back; + + int x = 10; + std::vector<std::vector<int> > v(10); + for_each(_1, lambda(_a = _2)[push_back(_1, _a)])(v, x); + + int y = 0; + for_each(arg1, lambda[ref(y) += _1[0]])(v); + BOOST_TEST(y == 100); + + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests2.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests2.cpp new file mode 100644 index 00000000..8c502992 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests2.cpp @@ -0,0 +1,25 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahashi + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/arithmetic.hpp> +#include <boost/phoenix/scope/lambda.hpp> + +int main() +{ + using boost::phoenix::lambda; + using boost::phoenix::arg_names::_1; + + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda[_1 + 2])(x)(y) == 1+10+2 + ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests20.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests20.cpp new file mode 100644 index 00000000..29e42ad3 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests20.cpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahashi + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/self.hpp> +#include <boost/phoenix/operator/arithmetic.hpp> +#include <boost/phoenix/scope/lambda.hpp> + +int main() +{ + using boost::phoenix::lambda; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + + int x = 1, y = 10, z = 13; + BOOST_TEST( + lambda(_a = _1, _b = _2)[_1 + _a + _b](x, z)(y) == x + y + z + ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests21.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests21.cpp new file mode 100644 index 00000000..493b1d3e --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests21.cpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahashi + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/self.hpp> +#include <boost/phoenix/scope/lambda.hpp> +#include <boost/phoenix/scope/let.hpp> + +int main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + + int i = 0; + int j = 2; + BOOST_TEST(lambda[let(_a = _1)[_a = _2]]()(i, j) == j); + BOOST_TEST(i == j); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests22.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests22.cpp new file mode 100644 index 00000000..859d2722 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests22.cpp @@ -0,0 +1,30 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahashi + + 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/config.hpp> +#include <boost/detail/workaround.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/self.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope/lambda.hpp> +#include <boost/phoenix/scope/let.hpp> + +int main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::local_names::_a; + + int x = (let(_a = lambda[val(1)])[bind(_a)])(); + BOOST_TEST(x == 1); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests23.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests23.cpp new file mode 100644 index 00000000..62d7f92c --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests23.cpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahashi + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/self.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope/lambda.hpp> +#include <boost/phoenix/scope/let.hpp> + +int main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::local_names::_a; + + int x = (let(_a = _1)[bind(_a)])(lambda[val(1)]()); + BOOST_TEST(x == 1); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests3.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests3.cpp new file mode 100644 index 00000000..dea0ccc3 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests3.cpp @@ -0,0 +1,25 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahashi + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/arithmetic.hpp> +#include <boost/phoenix/scope/lambda.hpp> + +int main() +{ + using boost::phoenix::lambda; + using boost::phoenix::arg_names::_1; + + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda[-_1])(x)(y) == 1+-10 + ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests4.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests4.cpp new file mode 100644 index 00000000..1e253569 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests4.cpp @@ -0,0 +1,33 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahashi + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/arithmetic.hpp> +#include <boost/phoenix/operator/self.hpp> +#include <boost/phoenix/scope/lambda.hpp> + +int main() +{ + using boost::phoenix::lambda; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + + int x = 1, y = 10, z = 13; + BOOST_TEST( + lambda(_a = _1, _b = _2) + [ + _1 + _a + _b + ] + (x, z)(y) == x + y + z + ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests5.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests5.cpp new file mode 100644 index 00000000..564980b4 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests5.cpp @@ -0,0 +1,27 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahashi + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/self.hpp> +#include <boost/phoenix/scope/lambda.hpp> + +int main() +{ + using boost::phoenix::lambda; + using boost::phoenix::arg_names::_1; + using boost::phoenix::local_names::_a; + + int x = 4; + int y = 5; + lambda(_a = _1)[_a = 555](x)(); + BOOST_TEST(x == 555); + (void)y; + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests6.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests6.cpp new file mode 100644 index 00000000..47535e65 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests6.cpp @@ -0,0 +1,27 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahashi + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/arithmetic.hpp> +#include <boost/phoenix/operator/self.hpp> +#include <boost/phoenix/scope/lambda.hpp> + +int main() +{ + using boost::phoenix::lambda; + using boost::phoenix::arg_names::_1; + using boost::phoenix::local_names::_a; + + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda(_a = _1)[_a + _1 + 2])(x)(y) == 1+1+10+2 + ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests7.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests7.cpp new file mode 100644 index 00000000..815485dd --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests7.cpp @@ -0,0 +1,34 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahashi + + 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/config.hpp> +#include <boost/detail/workaround.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/arithmetic.hpp> +#include <boost/phoenix/operator/self.hpp> +#include <boost/phoenix/scope/lambda.hpp> + +int main() +{ +#if defined(RUNNING_ON_APPVEYOR) && BOOST_WORKAROUND(BOOST_MSVC, == 1800) + // skip test +#else + using boost::phoenix::lambda; + using boost::phoenix::arg_names::_1; + using boost::phoenix::local_names::_a; + + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda(_a = _1)[_a + lambda[_a + 2]])(x)(y)(y) == 1+1+1+2 + ); + + return boost::report_errors(); +#endif +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests8.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests8.cpp new file mode 100644 index 00000000..6f0a2545 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests8.cpp @@ -0,0 +1,23 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahashi + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/scope/lambda.hpp> + +int main() +{ + using boost::phoenix::lambda; + using boost::phoenix::arg_names::_1; + + int x = 1; + char const* y = "hello"; + BOOST_TEST(lambda[_1](x)(y) == y); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests9.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests9.cpp new file mode 100644 index 00000000..bd7fe30b --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests9.cpp @@ -0,0 +1,25 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + Copyright (c) 2018 Kohei Takahashi + + 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/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator/self.hpp> +#include <boost/phoenix/scope/lambda.hpp> + +int main() +{ + using boost::phoenix::lambda; + using boost::phoenix::arg_names::_1; + using boost::phoenix::local_names::_a; + + int x = 1; + char const* y = "hello"; + BOOST_TEST(lambda(_a = _1)[_a](x)(y) == x); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/lambda_tests_phx2.cpp b/src/boost/libs/phoenix/test/scope/lambda_tests_phx2.cpp new file mode 100644 index 00000000..bdcce687 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/lambda_tests_phx2.cpp @@ -0,0 +1,91 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/scope.hpp> +#include <boost/phoenix/function.hpp> + +namespace boost { namespace phoenix +{ + struct for_each_impl + { + template <typename C, typename F> + struct result + { + typedef void type; + }; + + template <typename C, typename F> + void operator()(C& c, F f) const + { + std::for_each(c.begin(), c.end(), f); + } + }; + + function<for_each_impl> const for_each = for_each_impl(); + + struct push_back_impl + { + template <typename C, typename T> + struct result + { + typedef void type; + }; + + template <typename C, typename T> + void operator()(C& c, T& x) const + { + c.push_back(x); + } + }; + + function<push_back_impl> const push_back = push_back_impl(); +}} + +using namespace boost::phoenix; +using namespace boost::phoenix::arg_names; +using namespace boost::phoenix::local_names; +using namespace std; + +struct zzz {}; + +int +main() +{ + { + using boost::phoenix::for_each; + + int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + std::vector<int> v(init, init+10); + + int x = 0; + for_each(_1, lambda(_a = _2)[_a += _1])(v, x); + BOOST_TEST(x == 55); + } + + { + using boost::phoenix::for_each; + using boost::phoenix::push_back; + + int x = 10; + std::vector<std::vector<int> > v(10); + + for_each(_1, lambda(_a = _2)[push_back(_1, _a)])(v, x); + + int y = 0; + for_each(arg1, lambda[ref(y) += _1[0]])(v); + BOOST_TEST(y == 100); + } + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/scope/let_tests.cpp b/src/boost/libs/phoenix/test/scope/let_tests.cpp new file mode 100644 index 00000000..26fa916f --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/let_tests.cpp @@ -0,0 +1,204 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> +#include <boost/phoenix/object/construct.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::arg_names::_3; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + using boost::phoenix::local_names::_c; + using boost::phoenix::local_names::_d; + using boost::phoenix::local_names::_e; + using boost::phoenix::local_names::_x; + using boost::phoenix::local_names::_y; + using boost::phoenix::local_names::_z; + using boost::phoenix::placeholders::arg1; + + { + int x = 1; + BOOST_TEST( + let(_a = _1) + [ + _a + ] + (x) == x + ) + ; + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_a = _1, _b = _2) + [ + _a + _b + ] + (x, y) == x + y + ); + } + + { + int x = 1, y = 10, z = 13; + BOOST_TEST( + let(_x = _1, _y = _2) + [ + let(_z = _3) + [ + _x + _y + _z + ] + ] + (x, y, z) == x + y + z + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_x = _1) + [ + _x + + let(_x = _2) + [ + -_x + ] + ] + (x, y) == x + -y + ); + } + + { + int x = 999; + BOOST_TEST( + let(_x = _1) // _x is a reference to x + [ + _x += 888 + ] + (x) == 999 + 888 + ); + + BOOST_TEST(x == 888 + 999); + } + + { + int x = 999; + /* + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + _x += 888 + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + */ + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + val(_x += 888) + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + } + + { + BOOST_TEST( + let(_a = 1, _b = 2, _c = 3, _d = 4, _e = 5) + [ + _a + _b + _c + _d + _e + ] + () == 1 + 2 + 3 + 4 + 5 + ); + } + +#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST + { + // disallow this: + int i; + (_a + _b)(i); + } +#endif + + { + // show that we can return a local from an outer scope + int y = 0; +#if defined(__OPTIMIZE__) && __OPTIMIZE__ + int x = (let(_a = _2)[let(_b = _1)[ _a ]])(y,1); +#else + int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); +#endif + BOOST_TEST(x == 1); + } + + { + // show that this code returns an lvalue + int i = 1; + let(_a = arg1)[ _a ](i)++; + BOOST_TEST(i == 2); + } + + { + // show that what you put in is what you get out + int i = 1; + int& j = let(_a = arg1)[_a](i); + BOOST_TEST(&i == &j); + } + + { + // show that a let with a void result can compile + using boost::phoenix::construct; + + let(_a = 1)[ // need at least one expression here + construct<void>() // produce a void result + ](); + } + + { + using boost::phoenix::at_c; + + boost::fusion::tuple<int, int> t = boost::fusion::make_tuple(0, 1); + int i = let(_a = at_c<0>(_1))[_a](t); + + BOOST_TEST( i == 0 ); + } + + { + int i = 0; + let(_a = _1)[_a = _2](i, 2); + BOOST_TEST(i == 2); + } + + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/scope/let_tests_113.cpp b/src/boost/libs/phoenix/test/scope/let_tests_113.cpp new file mode 100644 index 00000000..c8ebea17 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/let_tests_113.cpp @@ -0,0 +1,204 @@ +/*============================================================================= + 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 <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::ref; + using boost::phoenix::arg_names::_1; + //using boost::phoenix::arg_names::_2; + //using boost::phoenix::arg_names::_3; + //using boost::phoenix::local_names::_a; + //using boost::phoenix::local_names::_b; + //using boost::phoenix::local_names::_c; + //using boost::phoenix::local_names::_d; + //using boost::phoenix::local_names::_e; + using boost::phoenix::local_names::_x; + //using boost::phoenix::local_names::_y; + //using boost::phoenix::local_names::_z; + //using boost::phoenix::placeholders::arg1; + /* + { + int x = 1; + BOOST_TEST( + let(_a = _1) + [ + _a + ] + (x) == x + ) + ; + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_a = _1, _b = _2) + [ + _a + _b + ] + (x, y) == x + y + ); + } + + { + int x = 1, y = 10, z = 13; + BOOST_TEST( + let(_x = _1, _y = _2) + [ + let(_z = _3) + [ + _x + _y + _z + ] + ] + (x, y, z) == x + y + z + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_x = _1) + [ + _x + + let(_x = _2) + [ + -_x + ] + ] + (x, y) == x + -y + ); + } + + { + int x = 999; + BOOST_TEST( + let(_x = _1) // _x is a reference to x + [ + _x += 888 + ] + (x) == 999 + 888 + ); + + BOOST_TEST(x == 888 + 999); + } + */ + { + int x = 999; + + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + val(_x += 888) // so use value here too. + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + /* + BOOST_TEST( + let(_x = ref(_1)) // _x holds x by reference + [ + _x += 888 + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + */ + + BOOST_TEST( + let( _x = _1 ) // _x holds x by reference + [ + _x += 888 + ] + (x) == 999 + 888 + ); + + BOOST_TEST(x == 888 + 999); + } + /* + { + BOOST_TEST( + let(_a = 1, _b = 2, _c = 3, _d = 4, _e = 5) + [ + _a + _b + _c + _d + _e + ] + () == 1 + 2 + 3 + 4 + 5 + ); + } + +#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST + { + // disallow this: + int i; + (_a + _b)(i); + } +#endif + + { + // show that we can return a local from an outer scope + int y = 0; + int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + + { + // show that this code returns an lvalue + int i = 1; + let(_a = arg1)[ _a ](i)++; + BOOST_TEST(i == 2); + } + + { + // show that what you put in is what you get out + int i = 1; + int& j = let(_a = arg1)[_a](i); + BOOST_TEST(&i == &j); + } + + { + using boost::phoenix::at_c; + + boost::fusion::tuple<int, int> t = boost::fusion::make_tuple(0, 1); + int i = let(_a = at_c<0>(_1))[_a](t); + + BOOST_TEST( i == 0 ); + } + + { + int i = 0; + let(_a = _1)[_a = _2](i, 2); + BOOST_TEST(i == 2); + } + */ + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/scope/let_tests_113a.cpp b/src/boost/libs/phoenix/test/scope/let_tests_113a.cpp new file mode 100644 index 00000000..6d84e484 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/let_tests_113a.cpp @@ -0,0 +1,192 @@ +/*============================================================================= + 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 <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + //using boost::phoenix::arg_names::_2; + //using boost::phoenix::arg_names::_3; + //using boost::phoenix::local_names::_a; + //using boost::phoenix::local_names::_b; + //using boost::phoenix::local_names::_c; + //using boost::phoenix::local_names::_d; + //using boost::phoenix::local_names::_e; + using boost::phoenix::local_names::_x; + //using boost::phoenix::local_names::_y; + //using boost::phoenix::local_names::_z; + //using boost::phoenix::placeholders::arg1; + /* + { + int x = 1; + BOOST_TEST( + let(_a = _1) + [ + _a + ] + (x) == x + ) + ; + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_a = _1, _b = _2) + [ + _a + _b + ] + (x, y) == x + y + ); + } + + { + int x = 1, y = 10, z = 13; + BOOST_TEST( + let(_x = _1, _y = _2) + [ + let(_z = _3) + [ + _x + _y + _z + ] + ] + (x, y, z) == x + y + z + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_x = _1) + [ + _x + + let(_x = _2) + [ + -_x + ] + ] + (x, y) == x + -y + ); + } + + { + int x = 999; + BOOST_TEST( + let(_x = _1) // _x is a reference to x + [ + _x += 888 + ] + (x) == 999 + 888 + ); + + BOOST_TEST(x == 888 + 999); + } + */ + { + int x = 999; + + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + val(_x += 888) + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + /* + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + val(_x += 888) + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); */ + } + /* + { + BOOST_TEST( + let(_a = 1, _b = 2, _c = 3, _d = 4, _e = 5) + [ + _a + _b + _c + _d + _e + ] + () == 1 + 2 + 3 + 4 + 5 + ); + } + +#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST + { + // disallow this: + int i; + (_a + _b)(i); + } +#endif + + { + // show that we can return a local from an outer scope + int y = 0; + int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + + { + // show that this code returns an lvalue + int i = 1; + let(_a = arg1)[ _a ](i)++; + BOOST_TEST(i == 2); + } + + { + // show that what you put in is what you get out + int i = 1; + int& j = let(_a = arg1)[_a](i); + BOOST_TEST(&i == &j); + } + + { + using boost::phoenix::at_c; + + boost::fusion::tuple<int, int> t = boost::fusion::make_tuple(0, 1); + int i = let(_a = at_c<0>(_1))[_a](t); + + BOOST_TEST( i == 0 ); + } + + { + int i = 0; + let(_a = _1)[_a = _2](i, 2); + BOOST_TEST(i == 2); + } + */ + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/scope/let_tests_157.cpp b/src/boost/libs/phoenix/test/scope/let_tests_157.cpp new file mode 100644 index 00000000..7979cea4 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/let_tests_157.cpp @@ -0,0 +1,194 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + //using boost::phoenix::arg_names::_3; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + //using boost::phoenix::local_names::_c; + //using boost::phoenix::local_names::_d; + //using boost::phoenix::local_names::_e; + //using boost::phoenix::local_names::_x; + //using boost::phoenix::local_names::_y; + //using boost::phoenix::local_names::_z; + //using boost::phoenix::placeholders::arg1; + /* + { + int x = 1; + BOOST_TEST( + let(_a = _1) + [ + _a + ] + (x) == x + ) + ; + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_a = _1, _b = _2) + [ + _a + _b + ] + (x, y) == x + y + ); + } + + { + int x = 1, y = 10, z = 13; + BOOST_TEST( + let(_x = _1, _y = _2) + [ + let(_z = _3) + [ + _x + _y + _z + ] + ] + (x, y, z) == x + y + z + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_x = _1) + [ + _x + + let(_x = _2) + [ + -_x + ] + ] + (x, y) == x + -y + ); + } + + { + int x = 999; + BOOST_TEST( + let(_x = _1) // _x is a reference to x + [ + _x += 888 + ] + (x) == 999 + 888 + ); + + BOOST_TEST(x == 888 + 999); + } + + { + int x = 999; + + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + _x += 888 + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + val(_x += 888) + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + } + + { + BOOST_TEST( + let(_a = 1, _b = 2, _c = 3, _d = 4, _e = 5) + [ + _a + _b + _c + _d + _e + ] + () == 1 + 2 + 3 + 4 + 5 + ); + } + +#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST + { + // disallow this: + int i; + (_a + _b)(i); + } +#endif + */ + { + // show that we can return a local from an outer scope + int y = 0; +#if defined(__OPTIMIZE__) && __OPTIMIZE__ + int x = (let(_a = _2)[let(_b = _1)[ _a ]])(y,1); +#else + int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); +#endif + BOOST_TEST(x == 1); + } + /* + { + // show that this code returns an lvalue + int i = 1; + let(_a = arg1)[ _a ](i)++; + BOOST_TEST(i == 2); + } + + { + // show that what you put in is what you get out + int i = 1; + int& j = let(_a = arg1)[_a](i); + BOOST_TEST(&i == &j); + } + + { + using boost::phoenix::at_c; + + boost::fusion::tuple<int, int> t = boost::fusion::make_tuple(0, 1); + int i = let(_a = at_c<0>(_1))[_a](t); + + BOOST_TEST( i == 0 ); + } + + { + int i = 0; + let(_a = _1)[_a = _2](i, 2); + BOOST_TEST(i == 2); + } + */ + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/scope/let_tests_157a.cpp b/src/boost/libs/phoenix/test/scope/let_tests_157a.cpp new file mode 100644 index 00000000..83dd33ac --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/let_tests_157a.cpp @@ -0,0 +1,191 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + //using boost::phoenix::arg_names::_3; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + //using boost::phoenix::local_names::_c; + //using boost::phoenix::local_names::_d; + //using boost::phoenix::local_names::_e; + //using boost::phoenix::local_names::_x; + //using boost::phoenix::local_names::_y; + //using boost::phoenix::local_names::_z; + //using boost::phoenix::placeholders::arg1; + /* + { + int x = 1; + BOOST_TEST( + let(_a = _1) + [ + _a + ] + (x) == x + ) + ; + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_a = _1, _b = _2) + [ + _a + _b + ] + (x, y) == x + y + ); + } + + { + int x = 1, y = 10, z = 13; + BOOST_TEST( + let(_x = _1, _y = _2) + [ + let(_z = _3) + [ + _x + _y + _z + ] + ] + (x, y, z) == x + y + z + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_x = _1) + [ + _x + + let(_x = _2) + [ + -_x + ] + ] + (x, y) == x + -y + ); + } + + { + int x = 999; + BOOST_TEST( + let(_x = _1) // _x is a reference to x + [ + _x += 888 + ] + (x) == 999 + 888 + ); + + BOOST_TEST(x == 888 + 999); + } + + { + int x = 999; + + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + _x += 888 + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + val(_x += 888) + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + } + + { + BOOST_TEST( + let(_a = 1, _b = 2, _c = 3, _d = 4, _e = 5) + [ + _a + _b + _c + _d + _e + ] + () == 1 + 2 + 3 + 4 + 5 + ); + } + +#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST + { + // disallow this: + int i; + (_a + _b)(i); + } +#endif + */ + { + // show that we can return a local from an outer scope + int y = 0; + int x = (let(_a = _2)[let(_b = _1)[ _a ]])(y,1); + + BOOST_TEST(x == 1); + } + /* + { + // show that this code returns an lvalue + int i = 1; + let(_a = arg1)[ _a ](i)++; + BOOST_TEST(i == 2); + } + + { + // show that what you put in is what you get out + int i = 1; + int& j = let(_a = arg1)[_a](i); + BOOST_TEST(&i == &j); + } + + { + using boost::phoenix::at_c; + + boost::fusion::tuple<int, int> t = boost::fusion::make_tuple(0, 1); + int i = let(_a = at_c<0>(_1))[_a](t); + + BOOST_TEST( i == 0 ); + } + + { + int i = 0; + let(_a = _1)[_a = _2](i, 2); + BOOST_TEST(i == 2); + } + */ + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/scope/let_tests_rest.cpp b/src/boost/libs/phoenix/test/scope/let_tests_rest.cpp new file mode 100644 index 00000000..9200d31d --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/let_tests_rest.cpp @@ -0,0 +1,192 @@ +/*============================================================================= + 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 <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::arg_names::_3; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + using boost::phoenix::local_names::_c; + using boost::phoenix::local_names::_d; + using boost::phoenix::local_names::_e; + using boost::phoenix::local_names::_x; + using boost::phoenix::local_names::_y; + using boost::phoenix::local_names::_z; + using boost::phoenix::placeholders::arg1; + + { + int x = 1; + BOOST_TEST( + let(_a = _1) + [ + _a + ] + (x) == x + ) + ; + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_a = _1, _b = _2) + [ + _a + _b + ] + (x, y) == x + y + ); + } + + { + int x = 1, y = 10, z = 13; + BOOST_TEST( + let(_x = _1, _y = _2) + [ + let(_z = _3) + [ + _x + _y + _z + ] + ] + (x, y, z) == x + y + z + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_x = _1) + [ + _x + + let(_x = _2) + [ + -_x + ] + ] + (x, y) == x + -y + ); + } + + { + int x = 999; + BOOST_TEST( + let(_x = _1) // _x is a reference to x + [ + _x += 888 + ] + (x) == 999 + 888 + ); + + BOOST_TEST(x == 888 + 999); + } + /* + { + int x = 999; + + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + _x += 888 + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + val(_x += 888) + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + } + */ + { + BOOST_TEST( + let(_a = 1, _b = 2, _c = 3, _d = 4, _e = 5) + [ + _a + _b + _c + _d + _e + ] + () == 1 + 2 + 3 + 4 + 5 + ); + } + +#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST + { + // disallow this: + int i; + (_a + _b)(i); + } +#endif + /* + { + // show that we can return a local from an outer scope + int y = 0; + int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + */ + { + // show that this code returns an lvalue + int i = 1; + let(_a = arg1)[ _a ](i)++; + BOOST_TEST(i == 2); + } + + { + // show that what you put in is what you get out + int i = 1; + int& j = let(_a = arg1)[_a](i); + BOOST_TEST(&i == &j); + } + + { + using boost::phoenix::at_c; + + boost::fusion::tuple<int, int> t = boost::fusion::make_tuple(0, 1); + int i = let(_a = at_c<0>(_1))[_a](t); + + BOOST_TEST( i == 0 ); + } + + { + int i = 0; + let(_a = _1)[_a = _2](i, 2); + BOOST_TEST(i == 2); + } + + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/scope/more_lambda_tests.cpp b/src/boost/libs/phoenix/test/scope/more_lambda_tests.cpp new file mode 100644 index 00000000..ea9209dc --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/more_lambda_tests.cpp @@ -0,0 +1,48 @@ +/*============================================================================= + Copyright (c) 2014 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/detail/lightweight_test.hpp> + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + //using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + // using boost::phoenix::local_names::_b; + //using boost::phoenix::placeholders::arg1; + + { + int x = 1; + int y = lambda[_1]()(x); + BOOST_TEST(x == y); + } + + { + int x = 1; + int y = lambda(_a = _1)[_a+1](x)(); + BOOST_TEST(x+1 == y); + } + + { + int x = lambda[val(1)]()(); + BOOST_TEST(x == 1); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/scope/more_let_tests.cpp b/src/boost/libs/phoenix/test/scope/more_let_tests.cpp new file mode 100644 index 00000000..5950e6ef --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/more_let_tests.cpp @@ -0,0 +1,156 @@ +/*============================================================================= + 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 <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + + { + // show that we can return a local from an outer scope + int y = 0; +#ifdef __OPTIMIZE__ + int x = (let(_a = 1)[let(_b = _1)[ _a + 0 ]])(y); +#else + int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); +#endif + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + int y = 1; + int x = (let(_a = 0)[let(_b = _1)[ _b ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an outer scope + //int y = 0; +#ifdef __OPTIMIZE__ + int x = (let(_a = 1)[let(_b = _a)[ _a + 0 ]])(); +#else + int x = (let(_a = 1)[let(_b = _a)[ _a ]])(); +#endif + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + //int y = 0; +#ifdef __OPTIMIZE__ + int x = (let(_a = 1)[let(_b = _a)[ _b + 0 ]])(); +#else + int x = (let(_a = 1)[let(_b = _a)[ _b ]])(); +#endif + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an outer scope + int y = 1; + int x = (let(_a = _1)[let(_b = _a)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + int y = 1; + int x = (let(_a = _1)[let(_b = _a)[ _b ]])(y); + + BOOST_TEST(x == 1); + } + + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // Be very careful. Some of these cases give a silly answer + // with clang 3.4 with C++03 and work for C++11. + // gcc 4.8.2 seems O.K. both ways. Oh dear. + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + { + int y = 0; +#ifdef __OPTIMIZE__ + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _a + 0 ]])(y); +#else + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _a ]])(y); +#endif + //std::cout << x << " P1A "; //clang - empty memory + BOOST_TEST(x == 1); + } + { + int y = 0; +#ifdef __OPTIMIZE__ + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _b + 0 ]])(y); +#else + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _b ]])(y); +#endif + //std::cout << x << " P1B "; //clang - 42 value- one step better + BOOST_TEST(x == 1); + } + { + int y = 0; +#ifdef __OPTIMIZE__ + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ val(_a) ]])(y); +#else + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _a ]])(y); +#endif + //std::cout << x << " P2A "; //clang - 42 value - one step better + BOOST_TEST(x == 1); + } + { + int y = 0; +#ifdef __OPTIMIZE__ + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ val(_b) ]])(y); +#else + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _b ]])(y); +#endif + //std::cout << x << " P2B "; //clang - 42 value - one step better + BOOST_TEST(x == 1); + } + { + int y = 1; + int x = (let(_a = _1, _b = val(2))[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P3 "; //clang - OK - one step better still + BOOST_TEST(x == 1); + } + + { + int y = 0; +#ifdef __OPTIMIZE__ + int x = (let(_a = 1, _b = 2)[let(_b = _1)[ _a + 0 ]])(y); +#else + int x = (let(_a = 1, _b = 2)[let(_b = _1)[ _a ]])(y); +#endif + // std::cout << x << " Q "; // clang 4201472 + BOOST_TEST(x == 1); + } + + + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/scope/more_let_tests1.cpp b/src/boost/libs/phoenix/test/scope/more_let_tests1.cpp new file mode 100644 index 00000000..d4dddf1e --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/more_let_tests1.cpp @@ -0,0 +1,136 @@ +/*============================================================================= + 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 <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + + { + // show that we can return a local from an outer scope + int y = 0; +#if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 50000) && __OPTIMIZE__ + int x = (let(_a = _2)[let(_b = _1)[ _a ]])(y,1); +#else + int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); +#endif + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + int y = 1; + int x = (let(_a = 0)[let(_b = _1)[ _b ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an outer scope + //int y = 0; +#if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 50000) && __OPTIMIZE__ + int x = (let(_a = 1)[let(_b = _a)[ _a ]])(); +#else + int x = (let(_a = _1)[let(_b = _a)[ _a ]])(1); +#endif + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + //int y = 0; +#if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 50000) && __OPTIMIZE__ + int x = (let(_a = _1)[let(_b = _a)[ _b ]])(1); +#else + int x = (let(_a = 1)[let(_b = _a)[ _b ]])(); +#endif + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an outer scope + int y = 1; + int x = (let(_a = _1)[let(_b = _a)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + int y = 1; + int x = (let(_a = _1)[let(_b = _a)[ _b ]])(y); + + BOOST_TEST(x == 1); + } + + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // Be very careful. Some of these cases give a silly answer + // with clang 3.4 with C++03 and work for C++11. + // gcc 4.8.2 seems O.K. both ways. Oh dear. + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + /* { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P1A "; //clang - empty memory + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _b ]])(y); + //std::cout << x << " P1B "; //clang - 42 value- one step better + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P2A "; //clang - 42 value - one step better + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _b ]])(y); + //std::cout << x << " P2B "; //clang - 42 value - one step better + BOOST_TEST(x == 1); + } + { + int y = 1; + int x = (let(_a = _1, _b = val(2))[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P3 "; //clang - OK - one step better still + BOOST_TEST(x == 1); + } + + { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _1)[ _a ]])(y); + // std::cout << x << " Q "; // clang 4201472 + BOOST_TEST(x == 1); + } + */ + + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/scope/more_let_tests2.cpp b/src/boost/libs/phoenix/test/scope/more_let_tests2.cpp new file mode 100644 index 00000000..fb3fff8c --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/more_let_tests2.cpp @@ -0,0 +1,125 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + /* + { + // show that we can return a local from an outer scope + int y = 0; + int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + int y = 1; + int x = (let(_a = 0)[let(_b = _1)[ _b ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an outer scope + //int y = 0; + int x = (let(_a = 1)[let(_b = _a)[ _a ]])(); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + //int y = 0; + int x = (let(_a = 1)[let(_b = _a)[ _b ]])(); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an outer scope + int y = 1; + int x = (let(_a = _1)[let(_b = _a)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + int y = 1; + int x = (let(_a = _1)[let(_b = _a)[ _b ]])(y); + + BOOST_TEST(x == 1); + } + */ + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // Be very careful. Some of these cases give a silly answer + // with clang 3.4 with C++03 and work for C++11. + // gcc 4.8.2 seems O.K. both ways. Oh dear. + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P1A "; //clang - empty memory + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _b ]])(y); + //std::cout << x << " P1B "; //clang - 42 value- one step better + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P2A "; //clang - 42 value - one step better + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _b ]])(y); + //std::cout << x << " P2B "; //clang - 42 value - one step better + BOOST_TEST(x == 1); + } + { + int y = 1; + int x = (let(_a = _1, _b = val(2))[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P3 "; //clang - OK - one step better still + BOOST_TEST(x == 1); + } + + { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _1)[ _a ]])(y); + // std::cout << x << " Q "; // clang 4201472 + BOOST_TEST(x == 1); + } + + + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/scope/more_let_tests2a.cpp b/src/boost/libs/phoenix/test/scope/more_let_tests2a.cpp new file mode 100644 index 00000000..9a4aca71 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/more_let_tests2a.cpp @@ -0,0 +1,126 @@ +/*============================================================================= + 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 <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + /* + { + // show that we can return a local from an outer scope + int y = 0; + int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + int y = 1; + int x = (let(_a = 0)[let(_b = _1)[ _b ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an outer scope + //int y = 0; + int x = (let(_a = 1)[let(_b = _a)[ _a ]])(); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + //int y = 0; + int x = (let(_a = 1)[let(_b = _a)[ _b ]])(); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an outer scope + int y = 1; + int x = (let(_a = _1)[let(_b = _a)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + int y = 1; + int x = (let(_a = _1)[let(_b = _a)[ _b ]])(y); + + BOOST_TEST(x == 1); + } + */ + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // Be very careful. Some of these cases give a silly answer + // with clang 3.4 with C++03 and work for C++11. + // gcc 4.8.2 seems O.K. both ways. Oh dear. + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P1A "; //clang - empty memory + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _b ]])(y); + //std::cout << x << " P1B "; //clang - 42 value- one step better + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P2A "; //clang - 42 value - one step better + BOOST_TEST(x == 1); + } + /* { + int y = 0; + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _b ]])(y); + //std::cout << x << " P2B "; //clang - 42 value - one step better + BOOST_TEST(x == 1); + } + { + int y = 1; + int x = (let(_a = _1, _b = val(2))[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P3 "; //clang - OK - one step better still + BOOST_TEST(x == 1); + } + + { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _1)[ _a ]])(y); + // std::cout << x << " Q "; // clang 4201472 + BOOST_TEST(x == 1); + } + */ + + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/scope/more_let_tests2b.cpp b/src/boost/libs/phoenix/test/scope/more_let_tests2b.cpp new file mode 100644 index 00000000..b6039f8f --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/more_let_tests2b.cpp @@ -0,0 +1,136 @@ +/*============================================================================= + 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 <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + /* + { + // show that we can return a local from an outer scope + int y = 0; + int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + int y = 1; + int x = (let(_a = 0)[let(_b = _1)[ _b ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an outer scope + //int y = 0; + int x = (let(_a = 1)[let(_b = _a)[ _a ]])(); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + //int y = 0; + int x = (let(_a = 1)[let(_b = _a)[ _b ]])(); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an outer scope + int y = 1; + int x = (let(_a = _1)[let(_b = _a)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + int y = 1; + int x = (let(_a = _1)[let(_b = _a)[ _b ]])(y); + + BOOST_TEST(x == 1); + } + */ + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // Be very careful. Some of these cases give a silly answer + // with clang 3.4 with C++03 and work for C++11. + // gcc 4.8.2 seems O.K. both ways. Oh dear. + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + /*{ + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P1A "; //clang - empty memory + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _b ]])(y); + //std::cout << x << " P1B "; //clang - 42 value- one step better + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P2A "; //clang - 42 value - one step better + BOOST_TEST(x == 1); + }*/ + { + int y = 0; +#if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 50000) && __OPTIMIZE__ + //int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _b ]])(y); +#else + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _b ]])(y); + //std::cout << x << " P2B "; //clang - 42 value - one step better + BOOST_TEST(x == 1); +#endif + } + { + int y = 1; + int x = (let(_a = _1, _b = val(2))[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P3 "; //clang - OK - one step better still + BOOST_TEST(x == 1); + } + + { + int y = 0; +#if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 50000) && __OPTIMIZE__ + int z = 2; + int x = (let(_a = _1, _b = _2)[let(_b = _1)[ _a ]])(y,z); +#else + int x = (let(_a = 1, _b = 2)[let(_b = _1)[ _a ]])(y); +#endif + // std::cout << x << " Q "; // clang 4201472 + BOOST_TEST(x == 1); + } + + + return boost::report_errors(); +} + diff --git a/src/boost/libs/phoenix/test/scope/this.cpp b/src/boost/libs/phoenix/test/scope/this.cpp new file mode 100644 index 00000000..2f9ae578 --- /dev/null +++ b/src/boost/libs/phoenix/test/scope/this.cpp @@ -0,0 +1,124 @@ +/*============================================================================= + Copyright (c) 2011 Thomas Heller + 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.hpp> +#include <boost/phoenix/statement.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/scope.hpp> +#include <iostream> +#include <boost/phoenix/scope/this.hpp> + + +template <typename T0> +void f(T0 t) +{ + std::cout << t(1) << "\n"; + std::cout << t(2) << "\n"; + std::cout << t(3) << "\n"; + std::cout << t(4) << "\n"; + std::cout << t(5) << "\n"; + std::cout << t(6) << "\n"; + std::cout << t(7) << "\n"; +} + +template <typename T0> +void f_2(T0 t) +{ + for(int i = 0; i < 10; ++i) + { + for(int j = 0; j < i; ++j) + { + std::cout << t(i, j) << " "; + } + std::cout << "\n"; + } +} + +int main() +{ + //using boost::phoenix::_this; + using boost::phoenix::if_; + using boost::phoenix::if_else; + using boost::phoenix::val; + using boost::phoenix::let; + using boost::phoenix::nothing; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + + f(( + if_(_1 == 0) + [ + std::cout << val("\n") + ] + .else_ + [ + std::cout << _1 << " " + , this_(_1 - 1) + ] + , val(0) + )); + +/* + f(( + if_else( + _1 == 0 + , _1 + ,this_(_1 - 1) + ) + )); +*/ + + f(( + if_else( + _1 != 0 + ,this_(_1 - 1) + , _1 + ) + )); +/* + + f(( // fac(n) = n * fac(n-1); fac(1) = 1 + if_else( + _1 <= 1 + , 1 + , _1 * _this(_1 - 1) + ) + )); + + f(( // fac(n) = n * fac(n-1); fac(1) = 1 + if_else( + _1 > 1 + , let(_a = _this(_1-1))[_1 * _a] + , 1 + ) + )); + + f(( // fib(n) = fib(n-1) + fib(n-2); fib(0) = 0; fib(1) = 1 + if_else( + _1 == 0 + , 0 + , if_else( + _1 == 1 + , 1 + , _this(_1 - 1) + _this(_1 - 2) + ) + ) + )); + + f_2(( // bin(n, k) = bin(n-1, k-1) + bin(n-1, k); bin(n, 0) = 1; bin(0, k) = 0 + if_else( + _1 == 0 + , 0 + , if_else( + _2 == 0 + , 1 + , _this(_1 - 1, _2 - 1) + _this(_1 - 1, _2) + ) + ) + )); +*/ +} diff --git a/src/boost/libs/phoenix/test/statement/bug5715.cpp b/src/boost/libs/phoenix/test/statement/bug5715.cpp new file mode 100644 index 00000000..4e99d928 --- /dev/null +++ b/src/boost/libs/phoenix/test/statement/bug5715.cpp @@ -0,0 +1,37 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-2007 Joel de Guzman + Copyright (c) 2014 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) +==============================================================================*/ + +// Check for Bug5715 + +#include <boost/phoenix/statement/sequence.hpp> +#include <boost/phoenix/bind.hpp> + +#include <boost/core/lightweight_test.hpp> + +namespace test +{ + int x = 0; + int y = 0; + int z = 0; + + void f() { ++x; ++y; } + void g() { --x; ++z; } + +} +int main() +{ + ( + boost::phoenix::bind(test::f), + boost::phoenix::bind(test::g) + )(); + BOOST_TEST(test::x == 0); + BOOST_TEST(test::y == 1); + BOOST_TEST(test::z == 1); + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/statement/exceptions.cpp b/src/boost/libs/phoenix/test/statement/exceptions.cpp new file mode 100644 index 00000000..d2584f1d --- /dev/null +++ b/src/boost/libs/phoenix/test/statement/exceptions.cpp @@ -0,0 +1,194 @@ +/*============================================================================= + Copyright (c) 2005-2007 Dan Marsden + Copyright (c) 2005-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 <stdexcept> +#include <string> + +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/statement.hpp> +#include <boost/phoenix/scope/local_variable.hpp> +#include <boost/phoenix/bind/bind_member_function.hpp> + +#include <boost/detail/lightweight_test.hpp> + +struct base_exception : std::exception +{ + explicit + base_exception(char const *msg) + : _sliced(true), _what(msg) + {} + + base_exception(base_exception const &other) + : _sliced(true), _what(other._what) + { + } + + char const *what() const BOOST_NOEXCEPT_OR_NOTHROW + { + if (_sliced) { return "sliced ..."; } + return _what; + } + + bool _sliced; + char const *_what; +}; + +struct extended_exception : base_exception +{ + explicit + extended_exception(char const *msg) + : base_exception(msg) + { + // mark as not sliced + _sliced = false; + } + + extended_exception(extended_exception const &other) + : base_exception(other) + { + // mark as not sliced + _sliced = false; + } +}; + +int main() +{ + using boost::phoenix::throw_; + using boost::phoenix::try_; + using boost::phoenix::ref; + using boost::phoenix::local_names::_e; + using boost::phoenix::bind; + using std::exception; + using std::string; + using std::runtime_error; + namespace phx = boost::phoenix; + + { + try + { + throw_(runtime_error("error"))(); + BOOST_ERROR("exception should have been thrown"); + } + catch(runtime_error& err) + { + BOOST_TEST(err.what() == string("error")); + } + } + + { + try + { + try + { + throw runtime_error("error"); + } + catch(exception&) + { + throw_()(); + BOOST_ERROR("exception should have been rethrown"); + } + } + catch(exception& err) + { + BOOST_TEST(err.what() == string("error")); + } + } + + { + bool caught_exception = false; + + try_ + [ throw_(runtime_error("error")) ] + .catch_<exception>(_e) // captured but unused + [ + ref(caught_exception) = true + ](); + + BOOST_TEST(caught_exception); + } + + { + bool caught_exception = false; + string what; + + try_ + [ throw_(runtime_error("error")) ] + .catch_<exception>(_e) + [ + ref(caught_exception) = true + // ambiguous with std::ref + , phx::ref(what) = phx::bind(&exception::what, _e) + ](); + + BOOST_TEST(caught_exception); + BOOST_TEST(what == string("error")); + } + + { + bool caught_exception = false; + string what; + + try_ + [ throw_(extended_exception("error")) ] + .catch_<base_exception>(_e) // A thrown object should not be copied due to slicing. + [ + ref(caught_exception) = true + // ambiguous with std::ref + , phx::ref(what) = phx::bind(&exception::what, _e) + ](); + + BOOST_TEST(caught_exception); + BOOST_TEST(what == string("error")); + } + + { + bool caught_exception = false; + + try_ + [ throw_(runtime_error("error")) ] + .catch_all + [ ref(caught_exception) = true ](); + BOOST_TEST(caught_exception); + } + + { + bool caught_correct_exception = false; + string what; + + try_ + [ throw_(runtime_error("error")) ] + .catch_<string>() + [ ref(caught_correct_exception) = false ] + .catch_<exception>(_e) + [ + ref(caught_correct_exception) = true + // ambiguous with std::ref + , phx::ref(what) = phx::bind(&exception::what, _e) + ](); + + BOOST_TEST(caught_correct_exception); + BOOST_TEST(what == string("error")); + } + + { + bool caught_correct_exception = false; + + try_ + [ throw_(runtime_error("error")) ] + .catch_<string>() + [ ref(caught_correct_exception) = false ] + .catch_all + [ ref(caught_correct_exception) = true](); + + BOOST_TEST(caught_correct_exception); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/statement/if_tests.cpp b/src/boost/libs/phoenix/test/statement/if_tests.cpp new file mode 100644 index 00000000..1828a49d --- /dev/null +++ b/src/boost/libs/phoenix/test/statement/if_tests.cpp @@ -0,0 +1,70 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <vector> +#include <algorithm> +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/statement.hpp> +#include <boost/phoenix/operator.hpp> + +int +main() +{ + using boost::phoenix::arg_names::arg1; + using boost::phoenix::if_; + using boost::phoenix::ref; + + int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + std::vector<int> v(init, init+10); + + std::cout << std::dec; + int x = 0; + + for_each(v.begin(), v.end(), + if_(arg1 > 3 && arg1 <= 8) + [ + std::cout << arg1 << ", ", + ref(x) += arg1 + ] + ); + + std::cout << std::endl; + BOOST_TEST(x == 4+5+6+7+8); + + x = 0; + int y = 0; + int z = 0; + + for_each(v.begin(), v.end(), + if_(arg1 > 5) + [ + std::cout << arg1 << " > 5\n", + ref(x) += arg1 + ] + .else_ + [ + if_(arg1 == 5) + [ + std::cout << arg1 << " == 5\n", + ref(z) += arg1 + ] + .else_ + [ + std::cout << arg1 << " < 5\n", + ref(y) += arg1 + ] + ] + ); + + std::cout << std::endl; + BOOST_TEST(x == 6+7+8+9+10); + BOOST_TEST(y == 1+2+3+4); + BOOST_TEST(z == 5); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/statement/loops_tests.cpp b/src/boost/libs/phoenix/test/statement/loops_tests.cpp new file mode 100644 index 00000000..f3f2743e --- /dev/null +++ b/src/boost/libs/phoenix/test/statement/loops_tests.cpp @@ -0,0 +1,85 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <vector> +#include <algorithm> +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/statement.hpp> +#include <boost/phoenix/operator.hpp> + +int +main() +{ + using boost::phoenix::arg_names::arg1; + using boost::phoenix::do_; + using boost::phoenix::ref; + using boost::phoenix::val; + + using std::cout; + using std::endl; + using std::for_each; + using std::vector; + + int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + vector<int> v(init, init+10); + vector<int> t = v; + cout << endl; + int x = 0; + + for_each(v.begin(), v.end(), + ( + while_(arg1--) + [ + cout << arg1 << ", ", + ++ref(x) + ], + cout << val("\n") + ) + ); + + BOOST_TEST(x == 1+2+3+4+5+6+7+8+9+10); + cout << endl; + v = t; + x = 0; + + for_each(v.begin(), v.end(), + ( + do_ + [ + cout << arg1 << ", ", + ++ref(x) + ] + .while_(arg1--), + cout << val("\n") + ) + ); + + BOOST_TEST(x == 2+3+4+5+6+7+8+9+10+11); + cout << endl; + v = t; + x = 0; + + int iii; + for_each(v.begin(), v.end(), + ( + for_(ref(iii) = 0, ref(iii) < arg1, ++ref(iii)) + [ + cout << arg1 << ", ", + ++ref(x) + ], + cout << val("\n") + ) + ); + + BOOST_TEST(x == 1+2+3+4+5+6+7+8+9+10); + cout << endl; + v = t; + x = 0; + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/statement/switch_tests.cpp b/src/boost/libs/phoenix/test/statement/switch_tests.cpp new file mode 100644 index 00000000..d7247982 --- /dev/null +++ b/src/boost/libs/phoenix/test/statement/switch_tests.cpp @@ -0,0 +1,76 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + 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 <iostream> +#include <vector> +#include <algorithm> +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/statement.hpp> +#include <boost/phoenix/operator.hpp> + +int +main() +{ + using boost::phoenix::arg_names::_1; + using boost::phoenix::case_; + using boost::phoenix::switch_; + using boost::phoenix::ref; + using boost::phoenix::val; + + using std::cout; + using std::endl; + using std::vector; + using std::for_each; + + int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + vector<int> v(init, init+10); + + for_each(v.begin(), v.end(), + switch_(_1) + [ + // wierd case, why not just use if(...), but valid, nonetheless + case_<4>(cout << val("<4>") << endl) + ] + ); + + cout << endl; + for_each(v.begin(), v.end(), + switch_(_1) + [ + // wierd case, but valid, nonetheless + default_(cout << val("<any...>") << endl) + ] + ); + + cout << endl; + + for_each(v.begin(), v.end(), + switch_(_1) + [ + case_<1>(cout << val("<1>") << endl), + case_<2>(cout << val("<2>") << endl), + case_<3>(cout << val("<3>") << endl), + case_<4>(cout << val("<4>") << endl) + ] + ); + + cout << endl; + + for_each(v.begin(), v.end(), + switch_(_1) + [ + case_<1>(cout << val("<1>") << endl), + case_<2>(cout << val("<2>") << endl), + case_<3>(cout << val("<3>") << endl), + case_<4>(cout << val("<4>") << endl), + default_(cout << val("<over 4>") << endl) + ] + ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/phoenix/test/stdlib/cmath.cpp b/src/boost/libs/phoenix/test/stdlib/cmath.cpp new file mode 100644 index 00000000..f4703c61 --- /dev/null +++ b/src/boost/libs/phoenix/test/stdlib/cmath.cpp @@ -0,0 +1,31 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 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 <cmath> +#include <boost/function.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/stl/cmath.hpp> +#include <boost/core/lightweight_test.hpp> + +int main() +{ + double eps = 0.000001; + using namespace boost::phoenix::arg_names; + boost::function<bool(double, double)> f = boost::phoenix::fabs(_1 - _2) < eps; + + double x = boost::phoenix::pow(_1,_2)(2.,2.); + double y = boost::phoenix::atan2(_1,_2)(1.,1.); + double z = boost::phoenix::tan(_1)(y); + + BOOST_TEST(f(0.0, 0 * eps)); + BOOST_TEST(!f(0.0, eps)); + BOOST_TEST(std::fabs(x-4.) < eps ); + BOOST_TEST(std::fabs(z-1.) < eps ); + return boost::report_errors(); +} |