diff options
author | bugaevskiy <bugaevskiy@yandex-team.com> | 2022-08-24 10:46:13 +0300 |
---|---|---|
committer | bugaevskiy <bugaevskiy@yandex-team.com> | 2022-08-24 10:46:13 +0300 |
commit | ebeeef7964fdf94b17cb0b178e74d2bc25632dad (patch) | |
tree | c9e6aae097d11577c6fff0382c61476272c76371 | |
parent | bc3c9823a956f2c1b75508bfb618626b163bb224 (diff) | |
download | ydb-ebeeef7964fdf94b17cb0b178e74d2bc25632dad.tar.gz |
Reimport boost/lockfree as a separate project
220 files changed, 38 insertions, 54820 deletions
diff --git a/CMakeLists.darwin.txt b/CMakeLists.darwin.txt index 9733a7a1915..517f73681e0 100644 --- a/CMakeLists.darwin.txt +++ b/CMakeLists.darwin.txt @@ -324,15 +324,16 @@ add_subdirectory(contrib/restricted/boost/logic) add_subdirectory(contrib/restricted/boost/io) add_subdirectory(contrib/restricted/boost/lambda) add_subdirectory(contrib/restricted/boost/lexical_cast) -add_subdirectory(contrib/restricted/boost/math) +add_subdirectory(contrib/restricted/boost/lockfree) add_subdirectory(contrib/restricted/boost/atomic) +add_subdirectory(contrib/restricted/boost/parameter) +add_subdirectory(contrib/restricted/boost/math) add_subdirectory(contrib/restricted/boost/mp11) add_subdirectory(contrib/restricted/boost/multi_array) add_subdirectory(contrib/restricted/boost/functional) add_subdirectory(contrib/restricted/boost/multiprecision) add_subdirectory(contrib/restricted/boost/random) add_subdirectory(contrib/restricted/boost/rational) -add_subdirectory(contrib/restricted/boost/parameter) add_subdirectory(contrib/restricted/boost/phoenix) add_subdirectory(contrib/restricted/boost/proto) add_subdirectory(contrib/restricted/boost/polygon) diff --git a/CMakeLists.linux.txt b/CMakeLists.linux.txt index a7458519ae7..af86c200ca5 100644 --- a/CMakeLists.linux.txt +++ b/CMakeLists.linux.txt @@ -327,15 +327,16 @@ add_subdirectory(contrib/restricted/boost/logic) add_subdirectory(contrib/restricted/boost/io) add_subdirectory(contrib/restricted/boost/lambda) add_subdirectory(contrib/restricted/boost/lexical_cast) -add_subdirectory(contrib/restricted/boost/math) +add_subdirectory(contrib/restricted/boost/lockfree) add_subdirectory(contrib/restricted/boost/atomic) +add_subdirectory(contrib/restricted/boost/parameter) +add_subdirectory(contrib/restricted/boost/math) add_subdirectory(contrib/restricted/boost/mp11) add_subdirectory(contrib/restricted/boost/multi_array) add_subdirectory(contrib/restricted/boost/functional) add_subdirectory(contrib/restricted/boost/multiprecision) add_subdirectory(contrib/restricted/boost/random) add_subdirectory(contrib/restricted/boost/rational) -add_subdirectory(contrib/restricted/boost/parameter) add_subdirectory(contrib/restricted/boost/phoenix) add_subdirectory(contrib/restricted/boost/proto) add_subdirectory(contrib/restricted/boost/polygon) diff --git a/contrib/restricted/boost/CMakeLists.txt b/contrib/restricted/boost/CMakeLists.txt index 7b89c14305c..9dbe212fbca 100644 --- a/contrib/restricted/boost/CMakeLists.txt +++ b/contrib/restricted/boost/CMakeLists.txt @@ -41,6 +41,7 @@ target_link_libraries(contrib-restricted-boost INTERFACE restricted-boost-iterator restricted-boost-lambda restricted-boost-lexical_cast + restricted-boost-lockfree restricted-boost-math restricted-boost-move restricted-boost-mp11 diff --git a/contrib/restricted/boost/boost/contract.hpp b/contrib/restricted/boost/boost/contract.hpp deleted file mode 100644 index 2ff9505f6bf..00000000000 --- a/contrib/restricted/boost/boost/contract.hpp +++ /dev/null @@ -1,44 +0,0 @@ - -#ifndef BOOST_CONTRACT_HPP_ -#define BOOST_CONTRACT_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -/** @file -Include all header files required by this library at once (for convenience). - -All header files <c>boost/contract/\*.hpp</c> are independent from one another -and can be included one-by-one to reduce the amount of code to compile from this -library in user code (but this was measured to not make an appreciable -difference in compile-time so <c>boost/contract.hpp</c> can be included directly -in most cases). -Instead the headers <c>boost/contract/core/\*.hpp</c> are not independent from -other library headers and they are automatically included by the -<c>boost/contract/\*.hpp</c> headers (so the <c>boost/contract/core/\*.hpp</c> -headers are usually not directly included by programmers). - -All files under the <c>boost/contract/detail/</c> directory, names within the -@c boost::contract::detail namespace, names prefixed with -@c boost_contract_detail... and @c BOOST_CONTRACT_DETAIL... (in any namesapce, -including user's code) are reserved for internal use of this library and should -never be used directly by programmers. - -@see @RefSect{getting_started, Getting Started} -*/ - -#include <boost/contract/assert.hpp> -#include <boost/contract/base_types.hpp> -#include <boost/contract/call_if.hpp> -#include <boost/contract/constructor.hpp> -#include <boost/contract/destructor.hpp> -#include <boost/contract/function.hpp> -#include <boost/contract/check.hpp> -#include <boost/contract/old.hpp> -#include <boost/contract/override.hpp> -#include <boost/contract/public_function.hpp> - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/assert.hpp b/contrib/restricted/boost/boost/contract/assert.hpp deleted file mode 100644 index e7c0ab34a49..00000000000 --- a/contrib/restricted/boost/boost/contract/assert.hpp +++ /dev/null @@ -1,136 +0,0 @@ - -#ifndef BOOST_CONTRACT_ASSERT_HPP_ -#define BOOST_CONTRACT_ASSERT_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -/** @file -Assert contract conditions. -*/ - -#include <boost/contract/core/config.hpp> -#include <boost/contract/detail/noop.hpp> - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Preferred way to assert contract conditions. - - Any exception thrown from within a contract (preconditions, postconditions, - exception guarantees, old value copies at body, class invariants, etc.) is - interpreted by this library as a contract failure. - Therefore, users can program contract assertions manually throwing an - exception when an asserted condition is checked to be @c false (this - library will then call the appropriate contract failure handler - @RefFunc{boost::contract::precondition_failure}, etc.). - However, it is preferred to use this macro because it expands to - code that throws @RefClass{boost::contract::assertion_failure} with the - correct assertion file name (using <c>__FILE__</c>), line number (using - <c>__LINE__</c>), and asserted condition code so to produce informative - error messages. - - @RefMacro{BOOST_CONTRACT_ASSERT}, @RefMacro{BOOST_CONTRACT_ASSERT_AUDIT}, - and @RefMacro{BOOST_CONTRACT_ASSERT_AXIOM} are the three assertion levels - predefined by this library. - - @see @RefSect{tutorial.preconditions, Preconditions}, - @RefSect{tutorial.postconditions, Postconditions}, - @RefSect{tutorial.exception_guarantees, Exceptions Guarantees}, - @RefSect{tutorial.class_invariants, Class Invariants} - - @param cond Boolean contract condition to check. - (This is not a variadic macro parameter so any comma it might - contain must be protected by round parenthesis, - @c BOOST_CONTRACT_ASSERT((cond)) will always work.) - */ - // This must be an expression (a trivial one so the compiler can optimize it - // away). It cannot an empty code block `{}`, etc. otherwise code like - // `if(...) ASSERT(...); else ASSERT(...);` won't work when NO_ALL. - #define BOOST_CONTRACT_ASSERT(cond) -#elif !defined(BOOST_CONTRACT_NO_ALL) - #include <boost/contract/detail/assert.hpp> - #define BOOST_CONTRACT_ASSERT(cond) \ - BOOST_CONTRACT_DETAIL_ASSERT(cond) /* no `;` here */ -#else - // This must be an expression (a trivial one so the compiler can optimize it - // away). It cannot an empty code block `{}`, etc. otherwise code like - // `if(...) ASSERT(...); else ASSERT(...);` won't work when NO_ALL. - #define BOOST_CONTRACT_ASSERT(cond) \ - BOOST_CONTRACT_DETAIL_NOOP -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Preferred way to assert contract conditions that are computationally - expensive, at least compared to the cost of executing the function body. - - The asserted condition will always be compiled and validated syntactically, - but it will not be checked at run-time unless - @RefMacro{BOOST_CONTRACT_AUDITS} is defined (undefined by default). - This macro is defined by code equivalent to: - - @code - #ifdef BOOST_CONTRACT_AUDITS - #define BOOST_CONTRACT_ASSERT_AUDIT(cond) \ - BOOST_CONTRACT_ASSERT(cond) - #else - #define BOOST_CONTRACT_ASSERT_AUDIT(cond) \ - BOOST_CONTRACT_ASSERT(true || cond) - #endif - @endcode - - @RefMacro{BOOST_CONTRACT_ASSERT}, @RefMacro{BOOST_CONTRACT_ASSERT_AUDIT}, - and @RefMacro{BOOST_CONTRACT_ASSERT_AXIOM} are the three assertion levels - predefined by this library. - If there is a need, programmers are free to implement their own assertion - levels defining macros similar to the one above. - - @see @RefSect{extras.assertion_levels, Assertion Levels} - - @param cond Boolean contract condition to check. - (This is not a variadic macro parameter so any comma it might - contain must be protected by round parenthesis, - @c BOOST_CONTRACT_ASSERT_AUDIT((cond)) will always work.) - */ - #define BOOST_CONTRACT_ASSERT_AUDIT(cond) -#elif defined(BOOST_CONTRACT_AUDITS) - #define BOOST_CONTRACT_ASSERT_AUDIT(cond) \ - BOOST_CONTRACT_ASSERT(cond) -#else - #define BOOST_CONTRACT_ASSERT_AUDIT(cond) \ - BOOST_CONTRACT_DETAIL_NOEVAL(cond) -#endif - -/** -Preferred way to assert contract conditions that are computationally -prohibitive, at least compared to the cost of executing the function body. - -The asserted condition will always be compiled and validated syntactically, but -it will never be checked at run-time. -This macro is defined by code equivalent to: - -@code - #define BOOST_CONTRACT_ASSERT_AXIOM(cond) \ - BOOST_CONTRACT_ASSERT(true || cond) -@endcode - -@RefMacro{BOOST_CONTRACT_ASSERT}, @RefMacro{BOOST_CONTRACT_ASSERT_AUDIT}, and -@RefMacro{BOOST_CONTRACT_ASSERT_AXIOM} are the three assertion levels predefined -by this library. -If there is a need, programmers are free to implement their own assertion levels -defining macros similar to the one above. - -@see @RefSect{extras.assertion_levels, Assertion Levels} - -@param cond Boolean contract condition to check. - (This is not a variadic macro parameter so any comma it might - contain must be protected by round parenthesis, - @c BOOST_CONTRACT_ASSERT_AXIOM((cond)) will always work.) -*/ -#define BOOST_CONTRACT_ASSERT_AXIOM(cond) \ - BOOST_CONTRACT_DETAIL_NOEVAL(cond) - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/base_types.hpp b/contrib/restricted/boost/boost/contract/base_types.hpp deleted file mode 100644 index 2ab47d6e8b9..00000000000 --- a/contrib/restricted/boost/boost/contract/base_types.hpp +++ /dev/null @@ -1,200 +0,0 @@ - -#ifndef BOOST_CONTRACT_BASE_TYPES_HPP_ -#define BOOST_CONTRACT_BASE_TYPES_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -/** @file -Specify inheritance form base classes (for subcontracting). -*/ - -// IMPORTANT: Included by contract_macro.hpp so must #if-guard all its includes. -#include <boost/contract/core/config.hpp> -#include <boost/preprocessor/config/config.hpp> - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - -/** -Used to program a @c typedef listing the bases of a derived class. - -In order to support subcontracting, a derived class that specifies contracts for -one or more overriding public function must declare a @c typedef named -@c base_types (or @RefMacro{BOOST_CONTRACT_BASES_TYPEDEF}) using this macro. - - @code - class u : - #define BASES public b, protected virtual w1, private w2 - BASES - { - friend class boost::contract:access; - - typedef BOOST_CONTRACT_BASES(BASES) base_types; - #undef BASES - - ... - }; - @endcode - -This @c typedef must be @c public if @RefClass{boost::contract::access} is not -used. - -@see @RefSect{tutorial.base_classes__subcontracting_, Base Classes} - -@param ... Comma separated list of base classes. - Each base must explicitly specify its access specifier @c public, - @c protected, or @c private, and also @c virtual when present - (this not always required in C++ instead). - There is a limit of about 20 maximum bases that can be listed - (because of similar limits in Boost.MPL internally used by this - library). - This is a variadic macro parameter, on compilers that do not support - variadic macros, the @c typedef for base classes can be programmed - manually without using this macro. -*/ -#define BOOST_CONTRACT_BASE_TYPES(...) - -#elif !BOOST_PP_VARIADICS - -#define BOOST_CONTRACT_BASE_TYPES \ -BOOST_CONTRACT_ERROR_macro_BASE_TYPES_requires_variadic_macros_otherwise_manually_program_base_types - -#elif !defined(BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS) - -#include <boost/mpl/vector.hpp> -#include <boost/contract/detail/preprocessor/keyword/virtual.hpp> -#include <boost/contract/detail/preprocessor/keyword/public.hpp> -#include <boost/contract/detail/preprocessor/keyword/protected.hpp> -#include <boost/contract/detail/preprocessor/keyword/private.hpp> -#include <boost/preprocessor/variadic/to_seq.hpp> -#include <boost/preprocessor/seq/fold_left.hpp> -#include <boost/preprocessor/seq/enum.hpp> -#include <boost/preprocessor/seq/push_back.hpp> -#include <boost/preprocessor/seq/size.hpp> -#include <boost/preprocessor/seq/seq.hpp> // For HEAD, TAIL, etc. -#include <boost/preprocessor/tuple/elem.hpp> -#include <boost/preprocessor/tuple/rem.hpp> -#include <boost/preprocessor/tuple/eat.hpp> -#include <boost/preprocessor/comparison/equal.hpp> -#include <boost/preprocessor/control/iif.hpp> -#include <boost/preprocessor/facilities/expand.hpp> - -/* PRIVATE */ - -#define BOOST_CONTRACT_BASE_TYPES_REMOVE_VIRTUAL_(base) \ - BOOST_PP_EXPAND( \ - BOOST_PP_IIF(BOOST_CONTRACT_DETAIL_PP_KEYWORD_IS_VIRTUAL(base), \ - BOOST_CONTRACT_DETAIL_PP_KEYWORD_REMOVE_VIRTUAL \ - , \ - BOOST_PP_TUPLE_REM(1) \ - )(base) \ - ) - -#define BOOST_CONTRACT_BASE_TYPES_PUSH_BACK_IF_(is_public, types_nilseq, base) \ - ( \ - is_public, \ - BOOST_PP_IIF(is_public, \ - BOOST_PP_SEQ_PUSH_BACK \ - , \ - types_nilseq BOOST_PP_TUPLE_EAT(2) \ - )(types_nilseq, base) \ - ) - -#define BOOST_CONTRACT_BASE_TYPES_SKIP_NOT_PUBLIC_(is_public, types_nilseq, \ - base) \ - (0, types_nilseq) - -// Precondition: base = `public [virtual] ...`. -#define BOOST_CONTRACT_BASE_TYPES_PUSH_BACK_PUBLIC_(is_public, types_nilseq, \ - base) \ - ( \ - 1, \ - BOOST_PP_SEQ_PUSH_BACK(types_nilseq, \ - BOOST_CONTRACT_BASE_TYPES_REMOVE_VIRTUAL_( \ - BOOST_CONTRACT_DETAIL_PP_KEYWORD_REMOVE_PUBLIC(base)) \ - ) \ - ) - -#define BOOST_CONTRACT_BASE_TYPES_ACCESS_(is_public, types_nilseq, base) \ - BOOST_PP_IIF(BOOST_CONTRACT_DETAIL_PP_KEYWORD_IS_PUBLIC(base), \ - BOOST_CONTRACT_BASE_TYPES_PUSH_BACK_PUBLIC_ \ - , BOOST_PP_IIF(BOOST_CONTRACT_DETAIL_PP_KEYWORD_IS_PROTECTED(base), \ - BOOST_CONTRACT_BASE_TYPES_SKIP_NOT_PUBLIC_ \ - , BOOST_PP_IIF(BOOST_CONTRACT_DETAIL_PP_KEYWORD_IS_PRIVATE(base), \ - BOOST_CONTRACT_BASE_TYPES_SKIP_NOT_PUBLIC_ \ - , \ - BOOST_CONTRACT_BASE_TYPES_PUSH_BACK_IF_ \ - )))(is_public, types_nilseq, base) - -#define BOOST_CONTRACT_BASE_TYPES_(s, public_types, base) \ - BOOST_CONTRACT_BASE_TYPES_ACCESS_( \ - BOOST_PP_TUPLE_ELEM(2, 0, public_types), \ - BOOST_PP_TUPLE_ELEM(2, 1, public_types), \ - BOOST_CONTRACT_BASE_TYPES_REMOVE_VIRTUAL_(base) \ - ) - -#define BOOST_CONTRACT_BASE_TYPES_RETURN_YES_(types_nilseq) \ - BOOST_PP_SEQ_ENUM(BOOST_PP_SEQ_TAIL(types_nilseq)) - -#define BOOST_CONTRACT_BASE_TYPES_RETURN_(types_nilseq) \ - BOOST_PP_IIF(BOOST_PP_EQUAL(BOOST_PP_SEQ_SIZE(types_nilseq), 1), \ - BOOST_PP_TUPLE_EAT(1) \ - , \ - BOOST_CONTRACT_BASE_TYPES_RETURN_YES_ \ - )(types_nilseq) - -#define BOOST_CONTRACT_BASE_TYPES_OK_(base_tuple, bases_seq) \ - boost::mpl::vector< \ - BOOST_CONTRACT_BASE_TYPES_RETURN_(BOOST_PP_TUPLE_ELEM(2, 1, \ - BOOST_PP_SEQ_FOLD_LEFT( \ - BOOST_CONTRACT_BASE_TYPES_, \ - (0, (BOOST_PP_NIL)), \ - bases_seq \ - ) \ - )) \ - > - -#define BOOST_CONTRACT_BASE_TYPES_ERR_(bases_tuple, bases_seq) \ - BOOST_CONTRACT_ERROR_all_bases_must_explicitly_specify_public_protected_or_private base_tuple - -#define BOOST_CONTRACT_BASE_TYPES_IS_ACCESS_(base) \ - BOOST_PP_IIF(BOOST_CONTRACT_DETAIL_PP_KEYWORD_IS_PUBLIC(base), \ - 1 \ - , BOOST_PP_IIF(BOOST_CONTRACT_DETAIL_PP_KEYWORD_IS_PROTECTED(base), \ - 1 \ - , BOOST_PP_IIF(BOOST_CONTRACT_DETAIL_PP_KEYWORD_IS_PRIVATE(base), \ - 1 \ - , \ - 0 \ - ))) - -// Cannot check that all base types have access specifiers (unless users have to -// specify bases using pp-seq, because user specified base list can have -// unwrapped commas between bases but also within a given base type, when base -// types are templates), but at least check the very first base type explicitly -// specifies access `[virtual] public | protected | private [virtual] ...`. -#define BOOST_CONTRACT_BASE_TYPES_CHECK_(bases_tuple, bases_seq) \ - BOOST_PP_IIF(BOOST_CONTRACT_BASE_TYPES_IS_ACCESS_( \ - BOOST_CONTRACT_BASE_TYPES_REMOVE_VIRTUAL_(BOOST_PP_SEQ_HEAD( \ - bases_seq))), \ - BOOST_CONTRACT_BASE_TYPES_OK_ \ - , \ - BOOST_CONTRACT_BASE_TYPES_ERR_ \ - )(bases_tuple, bases_seq) - -/* PUBLIC */ - -#define BOOST_CONTRACT_BASE_TYPES(...) \ - BOOST_CONTRACT_BASE_TYPES_CHECK_((__VA_ARGS__), \ - BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) - -#else - -#define BOOST_CONTRACT_BASE_TYPES(...) void /* dummy type for typedef */ - -#endif - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/call_if.hpp b/contrib/restricted/boost/boost/contract/call_if.hpp deleted file mode 100644 index 7d7586cbfbf..00000000000 --- a/contrib/restricted/boost/boost/contract/call_if.hpp +++ /dev/null @@ -1,617 +0,0 @@ - -#ifndef BOOST_CONTRACT_CALL_IF_HPP_ -#define BOOST_CONTRACT_CALL_IF_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -/** @file -Statically disable compilation and execution of functor calls. - -@note This facility allows to emulate C++17 <c>if constexpr</c> statements - when used together with functor templates (or C++14 generic lambdas). -*/ - -#include <boost/contract/detail/none.hpp> -#include <boost/make_shared.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/utility/enable_if.hpp> -#include <boost/config.hpp> - -/* PRIVATE */ - -/** @cond */ - -// Boost.ResultOf not always able to deduce lambda result type (on MSVC). -#ifndef BOOST_NO_CXX11_DECLTYPE - #include <boost/utility/declval.hpp> - #define BOOST_CONTRACT_CALL_IF_RESULT_OF_(F) \ - decltype(boost::declval<F>()()) -#else - #include <boost/utility/result_of.hpp> - #define BOOST_CONTRACT_CALL_IF_RESULT_OF_(F) \ - typename boost::result_of<F()>::type -#endif - -/** @endcond */ - -/* CODE */ - -namespace boost { namespace contract { - -/** -Select compilation and execution of functor template calls using a static -boolean predicate. - -This class template has no members because it is never used directly, it is only -used via its specializations. -Usually this class template is instantiated only via the return value of -@RefFunc{boost::contract::call_if} and @RefFunc{boost::contract::call_if_c}. - -@see @RefSect{extras.assertion_requirements__templates_, - Assertion Requirements} - -@tparam Pred Static boolean predicate that selects which functor template - call to compile and execute. -@tparam Then Type of the functor template to call if the static predicate - @c Pred is @c true. -@tparam ThenResult Return type of then-branch functor template call (this is - usually automatically deduced by this library so it is never explicitly - specified by the user, and that is why it is often marked as - @c internal_type in this documentation). -*/ -template<bool Pred, typename Then, typename ThenResult = - #ifndef BOOST_CONTRACT_DETAIL_DOXYGEN - boost::contract::detail::none - #else - internal_type - #endif -> -struct call_if_statement {}; // Empty so cannot be used (but copyable). - -/** -Template specialization to dispatch between then-branch functor template calls -that return void and the ones that return non-void. - -The base class is a call-if statement so the else and else-if statements can be -specified if needed. -Usually this class template is instantiated only via the return value of -@RefFunc{boost::contract::call_if} and @RefFunc{boost::contract::call_if_c}. - -@note The <c>result_of<Then()>::type</c> expression should be evaluated only - when the static predicate is already checked to be @c true (because - @c Then() is required to compile only in that case). - Thus, this template specialization introduces an extra level of - indirection necessary for proper lazy evaluation of this result-of - expression. - -@see @RefSect{extras.assertion_requirements__templates_, - Assertion Requirements} - -@tparam Then Type of functor template to call when the static predicate is - @c true (as it is for this template specialization). -*/ -template<typename Then> -struct call_if_statement<true, Then, - #ifndef BOOST_CONTRACT_DETAIL_DOXYGEN - boost::contract::detail::none - #else - internal_type - #endif -> : - call_if_statement<true, Then, - #ifndef BOOST_CONTRACT_DETAIL_DOXYGEN - BOOST_CONTRACT_CALL_IF_RESULT_OF_(Then) - #else - typename result_of<Then()>::type - #endif - > -{ // Copyable (as its base). - /** - Construct this object with the then-branch functor template. - - @param f Then-branch nullary functor template. - The functor template call @c f() is compiled and called for this - template specialization (because the if-statement static - predicate is @c true). - The return type of @c f() must be the same as (or implicitly - convertible to) the return type of all other functor template - calls specified for this call-if object. - */ - explicit call_if_statement(Then f) : call_if_statement<true, Then, - BOOST_CONTRACT_CALL_IF_RESULT_OF_(Then)>(f) {} -}; - -/** -Template specialization to handle static predicates that are @c true for -then-branch functor template calls that do not return void. - -Usually this class template is instantiated only via the return value of -@RefFunc{boost::contract::call_if} and @RefFunc{boost::contract::call_if_c}. - -@see @RefSect{extras.assertion_requirements__templates_, - Assertion Requirements} - -@tparam Then Type of functor template to call when the static predicate is - @c true (as it is for this template specialization). -@tparam ThenResult Non-void return type of the then-branch functor template - call. -*/ -template<typename Then, typename ThenResult> -struct call_if_statement<true, Then, ThenResult> { // Copyable (as *). - /** - Construct this object with the then-branch functor template. - - @param f Then-branch nullary functor template. - The functor template call @c f() is actually compiled and - executed for this template specialization (because the - if-statement static predicate is @c true). - The return type of @c f() must be the same as (or implicitly - convertible to) the @p ThenResult type. - */ - explicit call_if_statement(Then f) : - r_(boost::make_shared<ThenResult>(f())) {} - - /** - This implicit type conversion returns a copy of the value returned by the - call to the then-branch functor template. - */ - operator ThenResult() const { return *r_; } - - /** - Specify the else-branch functor template. - - @param f Else-branch nullary functor template. - The functor template call @c f() is never compiled and executed - for this template specialization (because the if-statement - static predicate is @c true). - The return type of @c f() must be the same as (or implicitly - convertible to) the @p ThenResult type. - - @return A copy of the value returned by the call to the then-branch functor - template (because the else-branch functor template call is not - executed). - */ - template<typename Else> - ThenResult else_(Else const& f) const { return *r_; } - - /** - Specify an else-if-branch functor template (using a static boolean - predicate). - - @param f Else-if-branch nullary functor template. - The functor template call @c f() is never compiled and executed - for this template specialization (because the if-statement - static predicate is @c true). - The return type of @c f() must be the same as (or implicitly - convertible to) the @p ThenResult type. - - @tparam ElseIfPred Static boolean predicate selecting which functor - template call to compile and execute. - - @return A call-if statement so the else statement and additional else-if - statements can be specified if needed. - Eventually, it will be the return value of the then-branch functor - template call for this template specialization (because the - if-statement static predicate is @c true). - */ - template<bool ElseIfPred, typename ElseIfThen> - call_if_statement<true, Then, ThenResult> else_if_c(ElseIfThen const& f) - const { return *this; } - - /** - Specify an else-if-branch functor template (using a nullary boolean - meta-function). - - @param f Else-if-branch nullary functor template. - The functor template call @c f() is never compiled and executed - for this template specialization (because the if-statement - static predicate is @c true). - The return type of @c f() must be the same as (or implicitly - convertible to) the @p ThenResult type. - - @tparam ElseIfPred Nullary boolean meta-function selecting which functor - template call to compile and execute. - - @return A call-if statement so the else statement and additional else-if - statements can be specified if needed. - Eventually, it will be the return value of the then-branch functor - template call for this template specialization (because the - if-statement static predicate is @c true). - */ - template<class ElseIfPred, typename ElseIfThen> - call_if_statement<true, Then, ThenResult> else_if(ElseIfThen const& f) - const { return *this; } - -private: - boost::shared_ptr<ThenResult> r_; -}; - -/** -Template specialization to handle static predicates that are @c true for -then-branch functor template calls that return void. - -Usually this class template is instantiated only via the return value of -@RefFunc{boost::contract::call_if} and @RefFunc{boost::contract::call_if_c}. - -@see @RefSect{extras.assertion_requirements__templates_, - Assertion Requirements} - -@tparam Then Type of functor template to call when the static predicate if - @c true (as it is for this template specialization). -*/ -template<typename Then> -struct call_if_statement<true, Then, void> { // Copyable (no data). - /** - Construct this object with the then-branch functor template. - - @param f Then-branch nullary functor template. - The functor template call @c f() is actually compiled and - executed for this template specialization (because the - if-statement static predicate is @c true). - The return type of @c f() must be @c void for this template - specialization (because the then-branch functor template calls - return void). - */ - explicit call_if_statement(Then f) { f(); } - - // Cannot provide `operator ThenResult()` here, because ThenResult is void. - - /** - Specify the else-branch functor template. - - @param f Else-branch nullary functor template. - The functor template call @c f() is never compiled and executed - for this template specialization (because the if-statement - static predicate is @c true). - The return type of @c f() must be @c void for this template - specialization (because the then-branch functor template calls - return void). - */ - template<typename Else> - void else_(Else const& f) const {} - - /** - Specify an else-if-branch functor template (using a static boolean - predicate). - - @param f Else-if-branch nullary functor template. - The functor template call @c f() is never compiled and executed - for this template specialization (because the if-statement - static predicate is @c true). - The return type of @c f() must be @c void for this template - specialization (because the then-branch functor template calls - return void). - - @tparam ElseIfPred Static boolean predicate selecting which functor - template call to compile and execute. - - @return A call-if statement so the else statement and additional else-if - statements can be specified if needed. - Eventually, it will return void for this template specialization - (because the then-branch functor template calls return void). - */ - template<bool ElseIfPred, typename ElseIfThen> - call_if_statement<true, Then, void> else_if_c(ElseIfThen const& f) const { - return *this; - } - - /** - Specify an else-if-branch functor template (using a nullary boolean - meta-function). - - @param f Else-if-branch nullary functor template. - The functor template call @c f() is never compiled and executed - for this template specialization (because the if-statement - static predicate is @c true). - The return type of @c f() must be @c void for this template - specialization (because the then-branch functor template calls - return void). - - @tparam ElseIfPred Nullary boolean meta-function selecting which functor - template call to compile and execute. - - @return A call-if statement so the else statement and additional else-if - statements can be specified if needed. - Eventually, it will return void for this template specialization - (because the then-branch functor template calls return void). - */ - template<class ElseIfPred, typename ElseIfThen> - call_if_statement<true, Then, void> else_if(ElseIfThen const& f) const { - return *this; - } -}; - -/** -Template specialization to handle static predicates that are @c false. - -This template specialization handles all else-branch functor template calls -(whether they return void or not). -Usually this class template is instantiated only via the return value of -@RefFunc{boost::contract::call_if} and @RefFunc{boost::contract::call_if_c}. - -@see @RefSect{extras.assertion_requirements__templates_, - Assertion Requirements} - -@tparam Then Type of functor template to call when the static predicate is - @c true (never the case for this template specialization). -*/ -template<typename Then> // Copyable (no data). -struct call_if_statement<false, Then, - #ifndef BOOST_CONTRACT_DETAIL_DOXYGEN - boost::contract::detail::none - #else - internal_type - #endif -> { - /** - Construct this object with the then-branch functor template. - - @param f Then-branch nullary functor template. - The functor template call @c f() is never compiled and executed - for this template specialization (because the if-statement - static predicate is @c false). - The return type of @c f() must be the same as (or implicitly - convertible to) the return type of all other functor template - calls specified for this call-if object. - */ - explicit call_if_statement(Then const& f) {} - - // Do not provide `operator result_type()` here, require else_ instead. - - /** - Specify the else-branch functor template. - - @note The <c>result_of<Else()>::type</c> expression should be evaluated - only when the static predicate is already checked to be @c false - (because @c Else() is required to compile only in that case). - Thus, this result-of expression is evaluated lazily only in - instantiations of this template specialization. - - @param f Else-branch nullary functor template. - The functor template call @c f() is actually compiled and - executed for this template specialization (because the - if-statement static predicate is @c false). - The return type of @c f() must be the same as (or implicitly - convertible to) the return type of all other functor template - calls specified for this call-if object. - - @return A copy of the value returned by the call to the else-branch functor - template @c f(). - */ - template<typename Else> - #ifndef BOOST_CONTRACT_DETAIL_DOXYGEN - BOOST_CONTRACT_CALL_IF_RESULT_OF_(Else) - #else - typename result_of<Else()>::type - #endif - else_(Else f) const { return f(); } - - /** - Specify an else-if-branch functor template (using a static boolean - predicate). - - @param f Else-if-branch nullary functor template. - The functor template call @c f() is actually compiled and - executed if and only if @c ElseIfPred is @c true (because the - if-statement static predicate is already @c false for this - template specialization). - The return type of @c f() must be the same as (or implicitly - convertible to) the return type of all other functor template - calls specified for this call-if object. - - @tparam ElseIfPred Static boolean predicate selecting which functor - template call to compile and execute. - - @return A call-if statement so the else statement and additional else-if - statements can be specified if needed. - Eventually, this will be the return value of the functor template - call being compiled and executed. - */ - template<bool ElseIfPred, typename ElseIfThen> - call_if_statement<ElseIfPred, ElseIfThen> else_if_c(ElseIfThen f) const { - return call_if_statement<ElseIfPred, ElseIfThen>(f); - } - - /** - Specify an else-if-branch functor template (using a nullary boolen - meta-function). - - @param f Else-if-branch nullary functor template. - The functor template call @c f() is actually compiled and - executed if and only if @c ElseIfPred::value is @c true (because - the if-statement static predicate is already @c false for this - template specialization). - The return type of @c f() must be the same as (or implicitly - convertible to) the return type of all other functor template - calls specified for this call-if object. - - @tparam ElseIfPred Nullary boolean meta-function selecting which functor - template call to compile and execute. - - @return A call-if statement so the else statement and additional else-if - statements can be specified if needed. - Eventually, this will be the return value of the functor template - call being compiled and executed. - */ - template<class ElseIfPred, typename ElseIfThen> - call_if_statement<ElseIfPred::value, ElseIfThen> else_if(ElseIfThen f) - const { - return call_if_statement<ElseIfPred::value, ElseIfThen>(f); - } -}; - -/** -Select compilation and execution of functor template calls using a static -boolean predicate. - -Create a call-if object with the specified then-branch functor template: - -@code -boost::contract::call_if_c<Pred1>( - then_functor_template1 -).template else_if_c<Pred2>( // Optional. - then_functor_template2 -) // Optionally, other `else_if_c` or -... // `else_if`. -.else_( // Optional for `void` functors, - else_functor_template // but required for non `void`. -) -@endcode - -Optional functor templates for else-if-branches and the else-branch can be -specified as needed (the else-branch function template is required if @c f -returns non-void). - -@see @RefSect{extras.assertion_requirements__templates_, - Assertion Requirements} - -@param f Then-branch nullary functor template. - The functor template call @c f() is compiled and executed if and - only if @c Pred is @c true. - The return type of other functor template calls specified for this - call-if statement (else-branch, else-if-branches, etc.) must be the - same as (or implicitly convertible to) the return type of - then-branch functor call @c f(). - -@tparam Pred Static boolean predicate selecting which functor template call - to compile and execute. - -@return A call-if statement so else and else-if statements can be specified if - needed. - Eventually, this will be the return value of the functor template call - being compiled and executed (which can also be @c void). -*/ -template<bool Pred, typename Then> -call_if_statement<Pred, Then> call_if_c(Then f) { - return call_if_statement<Pred, Then>(f); -} - -/** -Select compilation and execution of functor template calls using a nullary -boolean meta-function. - -This is equivalent to <c>boost::contract::call_if_c<Pred::value>(f)</c>. -Create a call-if object with the specified then-branch functor template: - -@code -boost::contract::call_if<Pred1>( - then_functor_template1 -).template else_if<Pred2>( // Optional. - then_functor_template2 -) // Optionally, other `else_if` or -... // `else_if_c`. -.else_( // Optional for `void` functors, - else_functor_template // but required for non `void`. -) -@endcode - -Optional functor templates for else-if-branches and the else-branch can be -specified as needed (the else-branch functor template is required if @c f -returns non-void). - -@see @RefSect{extras.assertion_requirements__templates_, - Assertion Requirements} - -@param f Then-branch nullary functor template. - The functor template call @c f() is compiled and executed if and - only if @c Pred::value is @c true. - The return type of other functor template calls specified for this - call-if statement (else-branch, else-if-branches, etc.) must be the - same as (or implicitly convertible to) the return type of - then-branch functor template call @c f(). - -@tparam Pred Nullary boolean meta-function selecting which functor template - call to compile and execute. - -@return A call-if statement so else and else-if statements can be specified if - needed. - Eventually, this will be the return value of the functor template call - being compiled and executed (which can also be @c void). -*/ -template<class Pred, typename Then> -call_if_statement<Pred::value, Then> call_if(Then f) { - return call_if_statement<Pred::value, Then>(f); -} - -/** -Select compilation and execution of a boolean functor template condition using a -static boolean predicate. - -Compile and execute the nullary boolean functor template call @c f() if and only -if the specified static boolean predicate @p Pred is @c true, otherwise -trivially return @p else_ (@c true by default) at run-time. - -A call to <c>boost::contract::condition_if_c<Pred>(f, else_)</c> is logically -equivalent to -<c>boost::contract::call_if_c<Pred>(f, [else_] { return else_; })</c> (but -its internal implementation is optimized and it does not actually use -@c call_if_c). - -@see @RefSect{extras.assertion_requirements__templates_, - Assertion Requirements} - -@param f Nullary boolean functor template. - The functor template call @c f() is compiled and executed if and - only if @c Pred is @c true. - -@tparam Pred Static boolean predicate selecting when the functor template - call @c f() should be compiled and executed. -@param else_ Boolean value to return when @c Pred is @c false (instead of - compiling and executing the functor template call @c f()). - -@return Boolean value returned by @c f() if the static predicate @c Pred is - @c true. Otherwise, trivially return @p else_. -*/ -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - template<bool Pred, typename Then> - bool condition_if_c(Then f, bool else_ = true); -#else - // NOTE: condition_if is a very simple special case of call_if so it can be - // trivially implemented using enable_if instead of call_if as done below. - - template<bool Pred, typename Then> - typename boost::enable_if_c<Pred, bool>::type - condition_if_c(Then f, bool else_ = true) { return f(); } - - template<bool Pred, typename Then> - typename boost::disable_if_c<Pred, bool>::type - condition_if_c(Then f, bool else_ = true) { return else_; } -#endif - -/** -Select compilation and execution of a boolean functor template condition using a -nullary boolean meta-function. - -This is equivalent to -<c>boost::contract::condition_if_c<Pred::value>(f, else_)</c>. -Compile and execute the nullary boolean functor template call @c f() if and only -if the specified nullary boolean meta-function @p Pred is @c true, otherwise -trivially return @p else_ (@c true by default) at run-time. - -@see @RefSect{extras.assertion_requirements__templates_, - Assertion Requirements} - -@param f Nullary boolean functor template. - The functor template call @c f() is compiled and executed if and - only if @c Pred::value is @c true. -@param else_ Boolean value to return when @c Pred::value is @c false (instead - of compiling and executing the functor template call @c f()). - -@tparam Pred Nullary boolean meta-function selecting when the functor - template call @c f() should be compiled and executed. - -@return Boolean value returned by @c f() if the static predicate @c Pred is - @c true. Otherwise, trivially return @p else_. -*/ -template<class Pred, typename Then> -bool condition_if(Then f, bool else_ = true) { - return condition_if_c<Pred::value>(f, else_); -} - -} } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/check.hpp b/contrib/restricted/boost/boost/contract/check.hpp deleted file mode 100644 index e7423ce9a8f..00000000000 --- a/contrib/restricted/boost/boost/contract/check.hpp +++ /dev/null @@ -1,347 +0,0 @@ - -#ifndef BOOST_CONTRACT_CHECK_HPP_ -#define BOOST_CONTRACT_CHECK_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -/** @file -RAII object that checks contracts. -*/ - -#include <boost/contract/core/config.hpp> -#include <boost/contract/core/check_macro.hpp> -#include <boost/contract/core/specify.hpp> -#include <boost/contract/core/exception.hpp> // For set_... (if always in code). -#if !defined(BOOST_CONTRACT_NO_CONDITIONS) || \ - defined(BOOST_CONTRACT_STATIC_LINK) - #include <boost/contract/detail/condition/cond_base.hpp> - #include <boost/contract/detail/auto_ptr.hpp> - #include <boost/contract/detail/debug.hpp> -#endif -#include <boost/contract/detail/check.hpp> -#include <boost/config.hpp> - -/* PRIVATE */ - -/** @cond */ - -#if !defined(BOOST_CONTRACT_NO_CONDITIONS) || \ - defined(BOOST_CONTRACT_STATIC_LINK) - #define BOOST_CONTRACT_CHECK_CTOR_DEF_(contract_type) \ - : cond_(const_cast<contract_type&>(contract).cond_.release()) \ - { \ - BOOST_CONTRACT_DETAIL_DEBUG(cond_); \ - cond_->initialize(); \ - } -#else - #define BOOST_CONTRACT_CHECK_CTOR_DEF_(contract_type) {} -#endif - -/** @endcond */ - -/* CODE */ - -namespace boost { namespace contract { - -/** -RAII object that checks the contracts. - -In general, when this object is constructed it checks class invariants at entry, -preconditions, and makes old value copies at body. -When it is destructed, it checks class invariants at exist, postconditions, and -exception guarantees. -This object enforces the following (see -@RefSect{contract_programming_overview, Contract Programming Overview}): - -@li Postconditions are checked only if the body does not throw an exception. -@li Exceptions guarantees are checked only if the body throws an exception. -@li Constructor entry never checks class invariants. -@li Destructor exit checks class invariants only if the body throws an -exception (even if destructors should usually not be programmed to throw -exceptions in C++). -@li Static invariants are always checked at entry and exit (and regardless of -the body throwing exceptions or not). - -When used this way, this object is usually constructed and initialized to the -return value of one of the contract functions -@RefFunc{boost::contract::function}, @RefFunc{boost::contract::constructor}, -@RefFunc{boost::contract::destructor}, or -@RefFunc{boost::contract::public_function}. -In addition, this object can be constructed from a nullary functor that is used -to program implementation checks. - -@see @RefSect{tutorial, Tutorial}, - @RefSect{advanced.implementation_checks, Implementation Checks} -*/ -class check { // Copy ctor only (as move via ptr release). -public: - // NOTE: Unfortunately, Apple compilers define a `check(...)` macro that - // clashes with the name of this class. In the following code, - // BOOST_PREVENT_MACRO_SUBSTITUTION is used to workaround these name - // clashes. In user code, `check c = ...` syntax is typically used also - // avoiding clashes. - - /** - Construct this object for implementation checks. - - This can be used to program checks within implementation code (body, etc.). - This constructor is not declared @c explicit so initializations can use - assignment syntax @c =. - - @b Throws: This can throw in case programmers specify contract failure - handlers that throw exceptions instead of terminating the - program (see - @RefSect{advanced.throw_on_failures__and__noexcept__, - Throw on Failure}). - - @param f Nullary functor that asserts implementation checks. @c f() will - be called as soon as this object is constructed at the point it - is declared within the implementation code (see - @RefSect{advanced.implementation_checks, - Implementation Checks}). - */ - template<typename F> // Cannot check `if(f) ...` as f can be a lambda. - // f must be a valid callable object (not null func ptr, empty ftor, etc. - /* implicit */ check - /** @cond **/ BOOST_PREVENT_MACRO_SUBSTITUTION /** @endcond */ ( - F const& f) { - BOOST_CONTRACT_DETAIL_CHECK({ f(); }) - } - - /** - Construct this object copying it from the specified one. - - This object will check the contract, the copied-from object will not (i.e., - contract check ownership is transferred from the copied object to the new - object being created by this constructor). - - @param other Copied-from object. - */ - check /** @cond **/ BOOST_PREVENT_MACRO_SUBSTITUTION /** @endcond */ ( - check const& other) - #if !defined(BOOST_CONTRACT_NO_CONDITIONS) || \ - defined(BOOST_CONTRACT_STATIC_LINK) - // Copy ctor moves cond_ pointer to dest. - : cond_(const_cast<check&>(other).cond_.release()) - #endif - {} - - /** - Construct this object to check the specified contract. - - This checks class invariants at entry (if those apply to the specified - contract). - This constructor is not declared @c explicit so initializations can use - assignment syntax @c =. - - @b Throws: This can throw in case programmers specify contract failure - handlers that throw exceptions instead of terminating the - program (see - @RefSect{advanced.throw_on_failures__and__noexcept__, - Throw on Failure}). - - @param contract Contract to be checked (usually the return value of - @RefFunc{boost::contract::function} or - @RefFunc{boost::contract::public_function}). - - @tparam VirtualResult Return type of the enclosing function declaring the - contract if that is either a virtual or an - overriding public function. - Otherwise, this is always @c void. - */ - template<typename VirtualResult> - /* implicit */ check - /** @cond */ BOOST_PREVENT_MACRO_SUBSTITUTION /** @endcond */ ( - specify_precondition_old_postcondition_except<VirtualResult> const& - contract - ) - #ifndef BOOST_CONTRACT_DETAIL_DOXYGEN - BOOST_CONTRACT_CHECK_CTOR_DEF_( - specify_precondition_old_postcondition_except<VirtualResult>) - #else - ; - #endif - - /** - Construct this object to check the specified contract. - - This checks class invariants at entry and preconditions (if any of those - apply to the specified contract). - This constructor is not declared @c explicit so initializations can use - assignment syntax @c =. - - @b Throws: This can throw in case programmers specify contract failure - handlers that throw exceptions instead of terminating the - program (see - @RefSect{advanced.throw_on_failures__and__noexcept__, - Throw on Failure}). - - @param contract Contract to be checked (usually the return value of - @RefFunc{boost::contract::function}, - @RefFunc{boost::contract::constructor}, - @RefFunc{boost::contract::destructor}, or - @RefFunc{boost::contract::public_function}). - - @tparam VirtualResult Return type of the enclosing function declaring the - contract if that is either a virtual or an - overriding public function. - Otherwise, this is always @c void. - */ - template<typename VirtualResult> - /* implicit */ check - /** @cond */ BOOST_PREVENT_MACRO_SUBSTITUTION /** @endcond */ ( - specify_old_postcondition_except<VirtualResult> const& contract) - #ifndef BOOST_CONTRACT_DETAIL_DOXYGEN - BOOST_CONTRACT_CHECK_CTOR_DEF_( - specify_old_postcondition_except<VirtualResult>) - #else - ; - #endif - - /** - Construct this object to check the specified contract. - - This checks class invariants at entry and preconditions then it makes old - value copies at body (if any of those apply to the specified contract). - This constructor is not declared @c explicit so initializations can use - assignment syntax @c =. - - @b Throws: This can throw in case programmers specify contract failure - handlers that throw exceptions instead of terminating te - program (see - @RefSect{advanced.throw_on_failures__and__noexcept__, - Throw on Failure}). - - @param contract Contract to be checked (usually the return value of - @RefFunc{boost::contract::function}, - @RefFunc{boost::contract::constructor}, - @RefFunc{boost::contract::destructor}, or - @RefFunc{boost::contract::public_function}). - - @tparam VirtualResult Return type of the enclosing function declaring the - contract if that is either a virtual or an - overriding public function. - Otherwise, this is always @c void. - */ - template<typename VirtualResult> - /* implicit */ check - /** @cond */ BOOST_PREVENT_MACRO_SUBSTITUTION /** @endcond */ ( - specify_postcondition_except<VirtualResult> const& contract) - #ifndef BOOST_CONTRACT_DETAIL_DOXYGEN - BOOST_CONTRACT_CHECK_CTOR_DEF_( - specify_postcondition_except<VirtualResult>) - #else - ; - #endif - - /** - Construct this object to check the specified contract. - - This checks class invariants at entry and preconditions then it makes old - value copies at body, plus the destructor of this object will check - postconditions in this case (if any of those apply to the specified - contract). - This constructor is not declared @c explicit so initializations can use - assignment syntax @c =. - - @b Throws: This can throw in case programmers specify contract failure - handlers that throw exceptions instead of terminating the - program (see - @RefSect{advanced.throw_on_failures__and__noexcept__, - Throw on Failure}). - - @param contract Contract to be checked (usually the return value of - @RefFunc{boost::contract::function}, - @RefFunc{boost::contract::constructor}, - @RefFunc{boost::contract::destructor}, or - @RefFunc{boost::contract::public_function}). - - @tparam VirtualResult Return type of the enclosing function declaring the - contract if that is either a virtual or an - overriding public function. - Otherwise, this is always @c void. - */ - /* implicit */ check - /** @cond */ BOOST_PREVENT_MACRO_SUBSTITUTION /** @endcond */ ( - specify_except const& contract) - #ifndef BOOST_CONTRACT_DETAIL_DOXYGEN - BOOST_CONTRACT_CHECK_CTOR_DEF_(specify_except) - #else - ; - #endif - - /** - Construct this object to check the specified contract. - - This checks class invariants at entry and preconditions then it makes old - value copies at body, plus the destructor of this object will check - postconditions and exception guarantees in this case (if any of those apply - to the specified contract). - This constructor is not declared @c explicit so initializations can use - assignment syntax @c =. - - @b Throws: This can throw in case programmers specify contract failure - handlers that throw exceptions instead of terminating the - program (see - @RefSect{advanced.throw_on_failures__and__noexcept__, - Throw on Failure}). - - @param contract Contract to be checked (usually the return value of - @RefFunc{boost::contract::function}, - @RefFunc{boost::contract::constructor}, - @RefFunc{boost::contract::destructor}, or - @RefFunc{boost::contract::public_function}). - - @tparam VirtualResult Return type of the enclosing function declaring the - contract if that is either a virtual or an - overriding public function. - Otherwise, this is always @c void. - */ - /* implicit */ check - /** @cond */ BOOST_PREVENT_MACRO_SUBSTITUTION /** @endcond */ ( - specify_nothing const& contract) - #ifndef BOOST_CONTRACT_DETAIL_DOXYGEN - BOOST_CONTRACT_CHECK_CTOR_DEF_(specify_nothing) - #else - ; - #endif - - /** - Destruct this object. - - This checks class invariants at exit and either postconditions when the - enclosing function body did not throw an exception, or exception guarantees - when the function body threw an exception (that is if class invariants, - postconditions, and exception guarantees respectively apply to the contract - parameter specified when constructing this object). - - @b Throws: This can throw in case programmers specify contract failure - handlers that throw exceptions instead of terminating the - program (see - @RefSect{advanced.throw_on_failures__and__noexcept__, - Throw on Failure}). - (This is declared @c noexcept(false) since C++11.) - */ - ~check /** @cond */ BOOST_PREVENT_MACRO_SUBSTITUTION /** @endcond */ () - BOOST_NOEXCEPT_IF(false) /* allow auto_ptr dtor to throw */ - {} - -/** @cond */ -private: - check& operator=(check const&); // Cannot copy outside of `check c = ...`. - - #if !defined(BOOST_CONTRACT_NO_CONDITIONS) || \ - defined(BOOST_CONTRACT_STATIC_LINK) - boost::contract::detail::auto_ptr<boost::contract::detail::cond_base> - cond_; - #endif -/** @endcond */ -}; - -} } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/constructor.hpp b/contrib/restricted/boost/boost/contract/constructor.hpp deleted file mode 100644 index 9dab3294a5b..00000000000 --- a/contrib/restricted/boost/boost/contract/constructor.hpp +++ /dev/null @@ -1,108 +0,0 @@ - -#ifndef BOOST_CONTRACT_CONSTRUCTOR_HPP_ -#define BOOST_CONTRACT_CONSTRUCTOR_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -/** @file -Program contracts for constructors. -*/ - -#include <boost/contract/core/config.hpp> -#include <boost/contract/core/specify.hpp> -#include <boost/contract/core/access.hpp> -#include <boost/contract/core/constructor_precondition.hpp> -#if !defined(BOOST_CONTRACT_NO_CONSTRUCTORS) || \ - !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \ - defined(BOOST_CONTRACT_STATIC_LINK) - #include <boost/contract/detail/operation/constructor.hpp> -#endif - -namespace boost { namespace contract { - -/** -Program contracts for constructors. - -This is used to specify postconditions, exception guarantees, old value copies -at body, and check class invariants for constructors (see -@RefClass{boost::contract::constructor_precondition} to specify preconditions -for constructors instead): - -@code -class u { - friend class boost::contract:access; - - void invariant() const { // Optional (as for static and volatile). - BOOST_CONTRACT_ASSERT(...); - ... - } - -public: - u(...) { - boost::contract::old_ptr<old_type> old_var; - boost::contract::check c = boost::contract::constructor(this) - // No `.precondition` (use `constructor_precondition` if needed). - .old([&] { // Optional. - old_var = BOOST_CONTRACT_OLDOF(old_expr); - ... - }) - .postcondition([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - .except([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - ; - - ... // Constructor body. - } - - ... -}; -@endcode - -For optimization, this can be omitted for constructors that do not have -postconditions and exception guarantees, within classes that have no invariants. - -@see @RefSect{tutorial.constructors, Constructors} - -@param obj The object @c this from the scope of the enclosing constructor - declaring the contract. - (Constructors check all class invariants, including static and - volatile invariants, see @RefSect{tutorial.class_invariants, - Class Invariants} and - @RefSect{extras.volatile_public_functions, - Volatile Public Functions}). - -@tparam Class The type of the class containing the constructor declaring the - contract. - (Usually this template parameter is automatically deduced by C++ - and it does not need to be explicitly specified by programmers.) - -@return The result of this function must be explicitly assigned to a variable of - type @RefClass{boost::contract::check} declared locally just before the - code of the constructor body (otherwise this library will generate a - run-time error, see @RefMacro{BOOST_CONTRACT_ON_MISSING_CHECK_DECL}). -*/ -template<class Class> -specify_old_postcondition_except<> constructor(Class* obj) { - // Must #if also on ..._PRECONDITIONS here because specify_... is generic. - #if !defined(BOOST_CONTRACT_NO_CONSTRUCTORS) || \ - !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \ - defined(BOOST_CONTRACT_STATIC_LINK) - return specify_old_postcondition_except<>( - new boost::contract::detail::constructor<Class>(obj)); - #else - return specify_old_postcondition_except<>(); - #endif -} - -} } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/core/access.hpp b/contrib/restricted/boost/boost/contract/core/access.hpp deleted file mode 100644 index ba8334ba0de..00000000000 --- a/contrib/restricted/boost/boost/contract/core/access.hpp +++ /dev/null @@ -1,183 +0,0 @@ - -#ifndef BOOST_CONTRACT_ACCESS_HPP_ -#define BOOST_CONTRACT_ACCESS_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -/** @file -Allow to declare invariants, base types, etc all as private members. -*/ - -// IMPORTANT: Included by contract_macro.hpp so must #if-guard all its includes. -#include <boost/contract/core/config.hpp> -#if !defined(BOOST_CONTRACT_NO_CONDITIONS) || \ - defined(BOOST_CONTRACT_STATIC_LINK) - #include <boost/contract/detail/decl.hpp> - #include <boost/contract/detail/type_traits/mirror.hpp> -#endif -#ifndef BOOST_CONTRACT_NO_INVARIANTS - #include <boost/contract/detail/debug.hpp> - #include <boost/function_types/property_tags.hpp> - #include <boost/mpl/vector.hpp> -#endif - -namespace boost { namespace contract { - -#if !defined(BOOST_CONTRACT_NO_CONDITIONS) || \ - defined(BOOST_CONTRACT_STATIC_LINK) - class virtual_; - - namespace detail { - BOOST_CONTRACT_DETAIL_DECL_DETAIL_COND_SUBCONTRACTING_Z(1, - /* is_friend = */ 0, OO, RR, FF, CC, AArgs); - } -#endif -#ifndef BOOST_CONTRACT_NO_INVARIANTS - namespace detail { - template<typename RR, class CC> - class cond_inv; - } -#endif - -/** -Friend this class to declare invariants and base types as private members. - -Declare this class a friend of the user-defined class specifying the contracts -in order to declare the invariant functions and the base types @c typedef as -non-public members: - -@code -class u : - #define BASES public b, private w - BASES -{ - friend class boost::contract::access; - - typedef BOOST_CONTRACT_BASES(BASES) base_types; // Private. - #undef BASES - - void invariant() const { ... } // Private. - -public: - ... -}; -@endcode - -In real code, programmers will likely chose to declare this class as friend so -to fully control public interfaces of their user-defined classes. -This class is not intended to be directly used by programmers a part from -declaring it @c friend (and that is why this class does not have any public -member and it is not copyable). - -@warning Not declaring this class friend of user-defined classes will cause - compiler errors on some compilers (e.g., MSVC) because the private - members needed to check the contracts will not be accessible. - On other compilers (e.g., GCC and CLang), the private access will - instead fail SFINAE and no compiler error will be reported while - invariants and subcontracting will be silently skipped at run-time. - Therefore, programmers must make sure to either declare this class - as friend (preferred) or to always declare invariant functions and - base types @c typedef as public members. - -@see @RefSect{advanced.access_specifiers, Access Specifiers} -*/ -class access { // Non-copyable (see below). -/** @cond */ -private: // No public APIs (so users cannot use it directly by mistake). - - access(); // Should never be constructed (not even internally). - ~access(); - - // No boost::noncopyable to avoid its overhead when contracts disabled. - access(access&); - access& operator=(access&); - - #if !defined(BOOST_CONTRACT_NO_CONDITIONS) || \ - defined(BOOST_CONTRACT_STATIC_LINK) - BOOST_CONTRACT_DETAIL_MIRROR_HAS_TYPE(has_base_types, - BOOST_CONTRACT_BASES_TYPEDEF) - - template<class C> - struct base_types_of { - typedef typename C::BOOST_CONTRACT_BASES_TYPEDEF type; - }; - #endif - - #ifndef BOOST_CONTRACT_NO_INVARIANTS - BOOST_CONTRACT_DETAIL_MIRROR_HAS_MEMBER_FUNCTION( - has_static_invariant_f, BOOST_CONTRACT_STATIC_INVARIANT_FUNC) - - BOOST_CONTRACT_DETAIL_MIRROR_HAS_STATIC_MEMBER_FUNCTION( - has_static_invariant_s, BOOST_CONTRACT_STATIC_INVARIANT_FUNC) - - template<class C> - struct has_static_invariant : has_static_invariant_s<C, void, - boost::mpl::vector<> > {}; - - template<class C> - static void static_invariant() { - C::BOOST_CONTRACT_STATIC_INVARIANT_FUNC(); - } - - template<class C> - class static_invariant_addr { // Class so to pass it as tparam. - typedef void (*func_ptr)(); - public: - static func_ptr apply() { - return &C::BOOST_CONTRACT_STATIC_INVARIANT_FUNC; - } - }; - - BOOST_CONTRACT_DETAIL_MIRROR_HAS_MEMBER_FUNCTION( - has_invariant_f, BOOST_CONTRACT_INVARIANT_FUNC) - - BOOST_CONTRACT_DETAIL_MIRROR_HAS_STATIC_MEMBER_FUNCTION( - has_invariant_s, BOOST_CONTRACT_INVARIANT_FUNC) - - template<class C> - struct has_cv_invariant : has_invariant_f<C, void, boost::mpl::vector<>, - boost::function_types::cv_qualified> {}; - - template<class C> - struct has_const_invariant : has_invariant_f<C, void, boost::mpl:: - vector<>, boost::function_types::const_qualified> {}; - - template<class C> - static void cv_invariant(C const volatile* obj) { - BOOST_CONTRACT_DETAIL_DEBUG(obj); - obj->BOOST_CONTRACT_INVARIANT_FUNC(); - } - - template<class C> - static void const_invariant(C const* obj) { - BOOST_CONTRACT_DETAIL_DEBUG(obj); - obj->BOOST_CONTRACT_INVARIANT_FUNC(); - } - #endif - - // Friends (used to limit library's public API). - // NOTE: Using friends here and in all other places in this library - // does not increase compilation times (I experimented replacing all - // friends with public and got the same compilation times). - #if !defined(BOOST_CONTRACT_NO_CONDITIONS) || \ - defined(BOOST_CONTRACT_STATIC_LINK) - BOOST_CONTRACT_DETAIL_DECL_DETAIL_COND_SUBCONTRACTING_Z(1, - /* is_friend = */ 1, OO, RR, FF, CC, AArgs); - - BOOST_CONTRACT_DETAIL_DECL_FRIEND_OVERRIDING_PUBLIC_FUNCTIONS_Z(1, - OO, RR, FF, CC, AArgs, vv, rr, ff, oobj, aargs) - #endif - #ifndef BOOST_CONTRACT_NO_INVARIANTS - template<typename RR, class CC> - friend class boost::contract::detail::cond_inv; - #endif -/** @endcond */ -}; - -} } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/core/check_macro.hpp b/contrib/restricted/boost/boost/contract/core/check_macro.hpp deleted file mode 100644 index 3ecc93ea826..00000000000 --- a/contrib/restricted/boost/boost/contract/core/check_macro.hpp +++ /dev/null @@ -1,133 +0,0 @@ - -#ifndef BOOST_CONTRACT_CHECK_MACRO_HPP_ -#define BOOST_CONTRACT_CHECK_MACRO_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -/** @file -Macros for implementation checks. -*/ - -// IMPORTANT: Included by contract_macro.hpp so must #if-guard all its includes. -#include <boost/contract/core/config.hpp> -#include <boost/contract/detail/noop.hpp> - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Preferred way to assert implementation check conditions. - - It is preferred to use this macro instead of programming implementation - checks in a nullary functor passed to @RefClass{boost::contract::check} - constructor because this macro will completely remove implementation checks - from the code when @RefMacro{BOOST_CONTRACT_NO_CHECKS} is defined: - - @code - void f() { - ... - BOOST_CONTRACT_CHECK(...); - ... - } - @endcode - - @RefMacro{BOOST_CONTRACT_CHECK}, @RefMacro{BOOST_CONTRACT_CHECK_AUDIT}, and - @RefMacro{BOOST_CONTRACT_CHECK_AXIOM} are the three assertion levels - predefined by this library for implementation checks. - - @see @RefSect{advanced.implementation_checks, Implementation Checks} - - @param cond Boolean condition to check within implementation code (function - body, etc.). - (This is not a variadic macro parameter so any comma it might - contain must be protected by round parenthesis, - @c BOOST_CONTRACT_CHECK((cond)) will always work.) - */ - #define BOOST_CONTRACT_CHECK(cond) -#elif !defined(BOOST_CONTRACT_NO_CHECKS) - #include <boost/contract/detail/check.hpp> - #include <boost/contract/detail/assert.hpp> - - #define BOOST_CONTRACT_CHECK(cond) \ - BOOST_CONTRACT_DETAIL_CHECK(BOOST_CONTRACT_DETAIL_ASSERT(cond)) -#else - #define BOOST_CONTRACT_CHECK(cond) /* nothing */ -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Preferred way to assert implementation check conditions that are - computationally expensive, at least compared to the cost of executing the - function body. - - The specified condition will always be compiled and validated - syntactically, but it will not be evaluated at run-time unless - @RefMacro{BOOST_CONTRACT_AUDITS} is defined (undefined by default). - This macro is defined by code equivalent to: - - @code - #ifdef BOOST_CONTRACT_AUDITS - #define BOOST_CONTRACT_CHECK_AUDIT(cond) \ - BOOST_CONTRACT_CHECK(cond) - #else - #define BOOST_CONTRACT_CHECK_AUDIT(cond) \ - BOOST_CONTRACT_CHECK(true || cond) - #endif - @endcode - - @RefMacro{BOOST_CONTRACT_CHECK}, @RefMacro{BOOST_CONTRACT_CHECK_AUDIT}, and - @RefMacro{BOOST_CONTRACT_CHECK_AXIOM} are the three assertion levels - predefined by this library for implementation checks. - If there is a need, programmers are free to implement their own assertion - levels defining macros similar to the one above. - - @see @RefSect{extras.assertion_levels, Assertion Levels} - - @param cond Boolean condition to check within implementation code (function - body, etc.). - (This is not a variadic macro parameter so any comma it might - contain must be protected by round parenthesis, - @c BOOST_CONTRACT_CHECK_AUDIT((cond)) will always work.) - */ - #define BOOST_CONTRACT_CHECK_AUDIT(cond) -#elif defined(BOOST_CONTRACT_AUDITS) - #define BOOST_CONTRACT_CHECK_AUDIT(cond) \ - BOOST_CONTRACT_CHECK(cond) -#else - #define BOOST_CONTRACT_CHECK_AUDIT(cond) \ - BOOST_CONTRACT_DETAIL_NOEVAL(cond) -#endif - -/** -Preferred way to assert implementation check conditions that are computationally -prohibitive, at least compared to the cost of executing the function body. - -The specified condition will always be compiled and validated -syntactically, but it will never be evaluated at run-time. -This macro is defined by code equivalent to: - -@code -#define BOOST_CONTRACT_CHECK_AXIOM(cond) \ - BOOST_CONTRACT_CHECK(true || cond) -@endcode - -@RefMacro{BOOST_CONTRACT_CHECK}, @RefMacro{BOOST_CONTRACT_CHECK_AUDIT}, and -@RefMacro{BOOST_CONTRACT_CHECK_AXIOM} are the three assertion levels predefined -by this library for implementation checks. -If there is a need, programmers are free to implement their own assertion levels -defining macros similar to the one above. - -@see @RefSect{extras.assertion_levels, Assertion Levels} - -@param cond Boolean condition to check within implementation code (function - body, etc.). - (This is not a variadic macro parameter so any comma it might - contain must be protected by round parenthesis, - @c BOOST_CONTRACT_CHECK_AXIOM((cond)) will always work.) -*/ -#define BOOST_CONTRACT_CHECK_AXIOM(cond) \ - BOOST_CONTRACT_DETAIL_NOEVAL(cond) - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/core/config.hpp b/contrib/restricted/boost/boost/contract/core/config.hpp deleted file mode 100644 index e33c2bff819..00000000000 --- a/contrib/restricted/boost/boost/contract/core/config.hpp +++ /dev/null @@ -1,797 +0,0 @@ - -#ifndef BOOST_CONTRACT_CONFIG_HPP_ -#define BOOST_CONTRACT_CONFIG_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -/** @file -Configure this library compile-time and run-time behaviours. -*/ - -// IMPORTANT: This header MUST NOT #include any other header of this lib. -// That way users can #include this header and not #include any of this lib -// headers after that depending on the contract 0/1 macros below ensuring no -// compilation overhead. - -// Export symbols when compiling as shared lib (for internal use only). (Named -// after similar macros in all Boost libs.) -// BOOST_CONTRACT_SOURCE - -// Disable automatic library selection for linking. (Named after similar macros -// in all Boost libs.) -// BOOST_CONTRACT_NO_LIB -// BOOST_ALL_NO_LIB - -#if (!defined(BOOST_CONTRACT_DYN_LINK) && defined(BOOST_ALL_DYN_LINK)) || \ - defined(BOOST_CONTRACT_DETAIL_DOXYGEN) - /** - Define this macro to compile this library as a shared library (recommended). - - If this macro is defined, this library is compiled so it can be linked - as a shared library (a.k.a., Dynamically Linked Library or DLL) to user - code. - Also, this library will automatically define this macro when Boost libraries - are built as dynamic libraries (e.g., defining @c BOOST_ALL_DYN_LINK). - - @warning In general this library will correctly check contracts at - run-time only when compiled as a shared library, unless user - code checks contracts in a single program unit (e.g., a single - program with only statically linked libraries that check - contracts). - Therefore, it is recommended to build and use this library as - a dynamic library by defining this macro (or equivalently by - building all Boost libraries as dynamic libraries and - @c BOOST_ALL_DYN_LINK is defined). - - @see @RefSect{getting_started.compilers_and_platforms, Compilers and - Platforms} - */ - #define BOOST_CONTRACT_DYN_LINK -#elif defined(BOOST_CONTRACT_DYN_LINK) && defined(BOOST_CONTRACT_STATIC_LINK) - #error "DYN_LINK defined with STATIC_LINK" -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Define this macro to compile this library as a static library (not - recommended). - - If this macro is defined, this library is compiled so it can be linked - statically to user code. - This library build scripts will automatically define this macro when Boost - libraries are being built as static libraries. - - @warning This library is not guaranteed to always work correctly at - run-time when this macro is defined (define - @RefMacro{BOOST_CONTRACT_DYN_LINK} or @c BOOST_ALL_DYN_LINK - instead). - However, this macro can be defined and this library can be - safely used as a static library for user code that checks - contracts in a single program unit (e.g., a single program with - only statically linked libraries that check contracts). - - @see @RefSect{getting_started.compilers_and_platforms, Compilers and - Platforms} - */ - #define BOOST_CONTRACT_STATIC_LINK -#elif defined(BOOST_CONTRACT_STATIC_LINK) && defined(BOOST_CONTRACT_DYN_LINK) - #error "STATIC_LINK defined with DYN_LINK" -#endif - -#ifdef BOOST_CONTRACT_HEADER_ONLY - #error "leave DYN_LINK and STATIC_LINK undefined instead" -#elif (!defined(BOOST_CONTRACT_DYN_LINK) && \ - !defined(BOOST_CONTRACT_STATIC_LINK)) || \ - defined(BOOST_CONTRACT_DETAIL_DOXYGEN) - /** - Automatically defined by this library when it is being used as a header-only - library (not recommended). - - This library will define this macro when users do not define - @RefMacro{BOOST_CONTRACT_DYN_LINK} (or @c BOOST_ALL_DYN_LINK) and - @RefMacro{BOOST_CONTRACT_STATIC_LINK} (this macro is not a configuration - macro and this library will generate a compile-time error if users try to - define it directly). - When used as a header-only library, this library code does not have to be - compiled separately from user code, this library headers are simply included - and compiled as part of the user program. - - @warning This library is not guaranteed to always work correctly at - run-time when this macro is defined (define - @RefMacro{BOOST_CONTRACT_DYN_LINK} or @c BOOST_ALL_DYN_LINK - instead). - However, this macro can be defined and this library can be - safely used as a header-only library for user code that checks - contracts in a single program unit (e.g., a single program with - only statically linked libraries that check contracts). - - @see @RefSect{getting_started.compilers_and_platforms, Compilers and - Platforms} - */ - #define BOOST_CONTRACT_HEADER_ONLY -#endif - -#if (!defined(BOOST_CONTRACT_DISABLE_THREADS) && \ - defined(BOOST_DISABLE_THREADS)) || \ - defined(BOOST_CONTRACT_DETAIL_DOXYGEN) - /** - Define this macro to not lock internal library data for thread safety - (undefined by default). - - Defining this macro will make the library implementation code not thread - safe so this macro should not be defined unless the library is being used by - single-threaded applications only. - This library will automatically define this macro when Boost libraries are - built without threads (e.g., defining @c BOOST_DISABLE_THREADS). - - @note When this macro is left undefined this library needs to internally - use some sort of global lock (to ensure contract checking is - globally disabled when other contracts are being checked and also to - safely access failure handler functors). - That could introduce an undesired amount of synchronization in some - multi-threaded applications. - - @see @RefSect{contract_programming_overview.assertions, Assertions} - */ - #define BOOST_CONTRACT_DISABLE_THREADS -#endif - -#ifndef BOOST_CONTRACT_MAX_ARGS - /** - Maximum number of arguments for public function overrides on compilers that - do not support variadic templates (default to @c 10). - - On compilers that do not support variadic templates, this macro is defined - to the maximum number of arguments that public function overrides can have - and pass to @RefFunc{boost::contract::public_function} (users can redefine - this macro to a different value). - On compilers that support variadic templates, this macro has no effect. - - @note Regardless of the value of this macro and of compiler support for - variadic templates, there is an intrinsic limit of about 18 - arguments for public function overrides (because of similar limits - in Boost.MPL and Boost.FunctionTypes internally used by this - library). - - @see @RefSect{extras.no_macros__and_no_variadic_macros_, No Macros} - */ - #define BOOST_CONTRACT_MAX_ARGS 10 -#endif - -#ifndef BOOST_CONTRACT_BASES_TYPEDEF - /** - Define the name of the base type @c typedef (@c base_types by default). - - This macro expands to the name of the @c typedef that lists the base - classes for subcontracting via @RefMacro{BOOST_CONTRACT_BASE_TYPES}: - - @code - class u : - #define BASES public b, private w - BASES - { - friend class boost::contract:access; - - typedef BOOST_CONTRACT_BASES(BASES) BOOST_CONTRACT_TYPEDEF; - #undef BASES - - ... - }; - @endcode - - Users can redefine this macro if the @c typedef must have a name different - from @c base_types (because of name clashes in user code, etc.). - - @see @RefSect{tutorial.base_classes__subcontracting_, Base Classes} - */ - #define BOOST_CONTRACT_BASES_TYPEDEF base_types -#endif - -#ifndef BOOST_CONTRACT_INVARIANT_FUNC - /** - Define the name of the class invariant member function (@c invariant by - default). - - This macro expands to the name of the @c const and <c>const volatile</c> - member functions that check class invariants and volatile class invariants - respectively: - - @code - class u { - friend class boost::contract::access; - - void BOOST_CONTRACT_INVARIANT_FUNC() const { - BOOST_CONTRACT_ASSERT(...); - ... - } - - void BOOST_CONTRACT_INVARIANT_FUNC() const volatile { - BOOST_CONTRACT_ASSERT(...); - ... - } - - ... - }; - @endcode - - Users can redefine this macro if the invariant functions must have a name - different from @c invariant (because of name clashes in user code, etc.). - - @note C++ does not allow to overload member functions based on the - @c static classifier, so this macro must always be defined to be - different than the function name defined for - @RefMacro{BOOST_CONTRACT_STATIC_INVARIANT_FUNC}. - - @see @RefSect{tutorial.class_invariants, Class Invariants}, - @RefSect{extras.volatile_public_functions, - Volatile Public Functions} - */ - #define BOOST_CONTRACT_INVARIANT_FUNC invariant -#endif - -#ifndef BOOST_CONTRACT_STATIC_INVARIANT_FUNC - /** - Define the name of the static invariant member function (@c static_invariant - by default). - - This macro expands to the name of the @c static member function that checks - static class invariants: - - @code - class u { - friend class boost::contract::access; - - static void BOOST_CONTRACT_STATIC_INVARIANT_FUNC() { - BOOST_CONTRACT_ASSERT(...); - ... - } - - ... - }; - @endcode - - Users can redefine this macro if the static invariant function must have a - name different from @c static_invariant (because of name clashes in user - code, etc.). - - @note C++ does not allow to overload member functions based on the - @c static classifier, so this macro must always be defined to be - different than the function name defined for - @RefMacro{BOOST_CONTRACT_INVARIANT_FUNC}. - - @see @RefSect{tutorial.class_invariants, Class Invariants} - */ - #define BOOST_CONTRACT_STATIC_INVARIANT_FUNC static_invariant -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Disable some compile-time errors generated by this library (undefined by - default). - - Defining this macro disables a number of static checks and related - compile-time errors generated by this library, for example: - - @li The static invariant member @c BOOST_CONTRACT_STATIC_INVARIANT_FUNC - function must be declared @c static. - @li Non-static invariant member functions @c BOOST_CONTRACT_INVARIANT_FUNC - must be declared either @c const, <c>const volatile</c>, or - <c>volatile const</c>. - @li Derived classes that program contracts for one or more public function - overrides via @RefFunc{boost::contract::public_function} must also - define the @RefMacro{BOOST_CONTRACT_BASE_TYPES} @c typedef. - - In general, it is not recommended to define this macro because these - compile-time checks can guard against misuses of this library. - - @see @RefSect{tutorial.class_invariants, Class Invariants}, - @RefSect{tutorial.base_classes__subcontracting_, Base Classes} - */ - #define BOOST_CONTRACT_PERMISSIVE -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Code block to execute if contracts are not assigned to a - @RefClass{boost::contract::check} variable (undefined by default and - executes @c BOOST_ASSERT(false)). - - In general, there is a logic error in the program when contracts are not - assigned to a local variable of type @RefClass{boost::contract::check} - (because that is a misuse of this library). - Therefore, by default (i.e., when this macro is not defined) this library - calls <c>BOOST_ASSERT(false)</c> in those cases. - If this macro is defined, this library will execute the code expanded by the - macro instead of calling @c BOOST_ASSERT(false) (if programmers prefer to - throw an exception, etc.). - - This macro can be defined to be any block of code (use empty curly brackets - @c {} to generate no error), for example (on GCC): - @code - -DBOOST_CONTRACT_ON_MISSING_CHECK_DECL='{ throw std::logic_error("missing contract check declaration"); }' - @endcode - - @see @RefSect{tutorial, Tutorial} - */ - #define BOOST_CONTRACT_ON_MISSING_CHECK_DECL -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Define this macro to not disable other assertions while checking - preconditions (undefined by default). - - Not disabling other assertions while checking preconditions can lead to - infinite recursion in user code so by default this macro is not defined. - - However, the @RefSect{bibliography, [1962]} proposal does not disable - assertions while checking preconditions because arguments can reach the - function body unchecked if assertions are disabled while checking - preconditions (e.g., when these same functions bodies are called to check - the preconditions in question). - This macro can be defined to obtain the behaviour specified in - @RefSect{bibliography, [1962]} (at the risk of infinite recursion). - - @see @RefSect{contract_programming_overview.feature_summary, - Feature Summary} - */ - #define BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Define this macro to not disable any assertion while checking other - assertions (undefined by default). - - Not disabling assertions while checking other assertions can lead to - infinite recursion in user code so by default this macro is not defined. - (Defining this macro automatically implies that other assertion checking is - disabled while checking preconditions as if - @RefMacro{BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION} was also - defined.) - - @see @RefSect{contract_programming_overview.feature_summary, - Feature Summary} - */ - #define BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Define this macro to evaluate and check audit assertions at run-time - (undefined by default). - - Audit assertions and implementation checks programmed via - @RefMacro{BOOST_CONTRACT_ASSERT_AUDIT} and - @RefMacro{BOOST_CONTRACT_CHECK_AUDIT} are always compiled and validated - syntactically. - However, they are not evaluated and checked at run-time unless - this macro is defined (because these conditions can be computationally - expensive, at least compared to the cost of executing the function body). - - @see @RefSect{extras.assertion_levels, Assertion Levels} - */ - #define BOOST_CONTRACT_AUDITS -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - If defined, this library does not perform implementation checks (undefined - by default). - - If this macro is defined, this library internal code is also optimized to - reduce compile-time (not just run-time) overhead associated with - implementation checks. - Users can manually program @c \#ifndef statements in their code using this - macro to completely disable compilation of implementation checks or use - @RefMacro{BOOST_CONTRACT_CHECK} (recommended). - - @see @RefSect{advanced.implementation_checks, - Implementation Checks}, - @RefSect{extras.disable_contract_checking, - Disable Contract Checking}, - @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation} - */ - #define BOOST_CONTRACT_NO_CHECKS -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - If defined, this library does not check preconditions (undefined by - default). - - If this macro is defined, this library internal code is also optimized to - reduce compile-time (not just run-time) overhead associated with - checking preconditions. - Users can manually program @c \#ifndef statements in their code using this - macro to completely disable compilation of preconditions or use the macros - defined in @c boost/contract_macro.hpp (recommended only for applications - where it is truly necessary to completely remove contract code compilation - from production code). - - @see @RefSect{tutorial.preconditions, Preconditions}, - @RefSect{extras.disable_contract_checking, - Disable Contract Checking}, - @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation} - */ - #define BOOST_CONTRACT_NO_PRECONDITIONS -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - If defined, this library does not check postconditions (undefined by - default). - - If this macro is defined, this library internal code is also optimized to - reduce compile-time (not just run-time) overhead associated with - checking postconditions. - Users can manually program @c \#ifndef statements in their code using this - macro to completely disable compilation of postconditions or use the macros - defined in @c boost/contract_macro.hpp (recommended only for applications - where it is truly necessary to completely remove contract code compilation - from production code). - - It is necessary to disable both postconditions and exception guarantees - defining @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS} and - @RefMacro{BOOST_CONTRACT_NO_EXCEPTS} in order to disable old value copies - (see @RefMacro{BOOST_CONTRACT_NO_OLDS}). - - @see @RefSect{tutorial.postconditions, Postconditions}, - @RefSect{extras.disable_contract_checking, - Disable Contract Checking}, - @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation} - */ - #define BOOST_CONTRACT_NO_POSTCONDITIONS -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - If defined, this library does not check exception guarantees (undefined by - default). - - If this macro is defined, this library internal code is also optimized to - reduce compile-time (not just run-time) overhead associated with - checking exception guarantees. - Users can manually program @c \#ifndef statements in their code using this - macro to completely disable compilation of exception guarantees or use the - macros defined in @c boost/contract_macro.hpp (recommended only for - applications where it is truly necessary to completely remove contract code - compilation from production code). - - It is necessary to disable both postconditions and exception guarantees - defining @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS} and - @RefMacro{BOOST_CONTRACT_NO_EXCEPTS} in order to disable old value copies - (see @RefMacro{BOOST_CONTRACT_NO_OLDS}). - - @see @RefSect{tutorial.exception_guarantees, Exception Guarantees}, - @RefSect{extras.disable_contract_checking, - Disable Contract Checking}, - @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation} - */ - #define BOOST_CONTRACT_NO_EXCEPTS -#endif - -#if defined(BOOST_CONTRACT_DETAIL_DOXYGEN) || \ - ( \ - !defined(BOOST_CONTRACT_NO_ENTRY_INVARIANTS) && \ - defined(BOOST_CONTRACT_NO_INVARIANTS) \ - ) - /** - If defined, this library does not check class invariants at entry (undefined - by default). - - If this macro is defined, this library internal code is also optimized to - reduce compile-time (not just run-time) overhead associated with - checking class invariants at entry. - Users can manually program @c \#ifndef statements in their code using this - macro to completely disable compilation of entry class invariants or use the - macros defined in @c boost/contract_macro.hpp (recommended only for - applications where it is truly necessary to completely remove contract code - compilation from production code). - - This macro is automatically defined when - @RefMacro{BOOST_CONTRACT_NO_INVARIANTS} is defined. - - @see @RefSect{tutorial.class_invariants, Class Invariants}, - @RefSect{extras.disable_contract_checking, - Disable Contract Checking}, - @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation} - */ - #define BOOST_CONTRACT_NO_ENTRY_INVARIANTS -#endif - -#if defined(BOOST_CONTRACT_DETAIL_DOXYGEN) || \ - ( \ - !defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) && \ - defined(BOOST_CONTRACT_NO_INVARIANTS) \ - ) - /** - If defined, this library does not check class invariants at exit (undefined - by default). - - If this macro is defined, this library internal code is also optimized to - reduce compile-time (not just run-time) overhead associated with - checking class invariants at exit. - Users can manually program @c \#ifndef statements in their code using this - macro to completely disable compilation of exit class invariants or use the - macros defined in @c boost/contract_macro.hpp (recommended only for - applications where it is truly necessary to completely remove contract code - compilation from production code). - - This macro is automatically defined when - @RefMacro{BOOST_CONTRACT_NO_INVARIANTS} is defined. - - @see @RefSect{tutorial.class_invariants, Class Invariants}, - @RefSect{extras.disable_contract_checking, - Disable Contract Checking}, - @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation} - */ - #define BOOST_CONTRACT_NO_EXIT_INVARIANTS -#endif - -#if !defined(BOOST_CONTRACT_NO_INVARIANTS) && \ - defined(BOOST_CONTRACT_NO_ENTRY_INVARIANTS) && \ - defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) - /** - If defined, this library does not check class invariants (undefined by - default). - - If this macro is defined, this library internal code is also optimized to - reduce compile-time (not just run-time) overhead associated with - checking class invariants. - Users can manually program @c \#ifndef statements in their code using this - macro to completely disable compilation of class invariants or use the - macros defined in @c boost/contract_macro.hpp (recommended only for - applications where it is truly necessary to completely remove contract code - compilation from production code). - - Defining this macro is equivalent to defining both - @RefMacro{BOOST_CONTRACT_NO_ENTRY_INVARIANTS} and - @RefMacro{BOOST_CONTRACT_NO_EXIT_INVARIANTS}. - - @see @RefSect{tutorial.class_invariants, Class Invariants}, - @RefSect{extras.disable_contract_checking, - Disable Contract Checking}, - @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation} - */ - #define BOOST_CONTRACT_NO_INVARIANTS -#endif - -#ifdef BOOST_CONTRACT_NO_OLDS - #error "define NO_POSTCONDITIONS and NO_EXCEPTS instead" -#elif defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \ - defined(BOOST_CONTRACT_NO_EXCEPTS) - /** - Automatically defined by this library when old value copies are not to be - performed. - - This library will define this macro when users define both - @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS} and - @RefMacro{BOOST_CONTRACT_NO_EXCEPTS} (this macro is not a configuration - macro and this library will generate a compile-time error if users try to - define it directly). - Users can manually program @c \#ifndef statements in their code using this - macro to completely disable compilation of old value copies or use the - macros defined in @c boost/contract_macro.hpp (recommended only for - applications where it is truly necessary to completely remove contract code - compilation from production code). - - @see @RefSect{tutorial.old_values, Old Values}, - @RefSect{advanced.old_value_copies_at_body, - Old Value Copies at Body}, - @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation} - */ - #define BOOST_CONTRACT_NO_OLDS -#endif - -// Ctor pre checked separately and outside RAII so not part of this #define. -#ifdef BOOST_CONTRACT_NO_CONSTRUCTORS - #error "define NO_INVARIANTS, NO_POSTCONDITIONS, and NO_EXCEPTS instead" -#elif defined(BOOST_CONTRACT_NO_INVARIANTS) && \ - defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \ - defined(BOOST_CONTRACT_NO_EXCEPTS) - /** - Automatically defined by this library when contracts are not checked for - constructors. - - This library will define this macro when users define all - @RefMacro{BOOST_CONTRACT_NO_INVARIANTS}, - @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and - @RefMacro{BOOST_CONTRACT_NO_EXCEPTS} (this macro is not a configuration - macro and this library will generate a compile-time error if users try to - define it directly). - Users can manually program @c \#ifndef statements in their code using this - macro to completely disable compilation of contracts for constructors or use - the macros defined in @c boost/contract_macro.hpp (recommended only for - applications where it is truly necessary to completely remove contract code - compilation from production code). - - @note Constructor preconditions are checked separately by - @RefClass{boost::contract::constructor_precondition} so they are - disabled by @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS} instead. - - @see @RefSect{tutorial.constructors, Constructors}, - @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation} - */ - #define BOOST_CONTRACT_NO_CONSTRUCTORS -#endif - -#ifdef BOOST_CONTRACT_NO_DESTRUCTORS - #error "define NO_INVARIANTS, NO_POSTCONDITIONS, and NO_EXCEPTS instead" -#elif defined(BOOST_CONTRACT_NO_INVARIANTS) && \ - defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \ - defined(BOOST_CONTRACT_NO_EXCEPTS) - /** - Automatically defined by this library when contracts are not checked for - destructors. - - This library will define this macro when users define all - @RefMacro{BOOST_CONTRACT_NO_INVARIANTS}, - @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and - @RefMacro{BOOST_CONTRACT_NO_EXCEPTS} (this macro is not a configuration - macro and this library will generate a compile-time error if users try to - define it directly). - Users can manually program @c \#ifndef statements in their code using this - macro to completely disable compilation of contracts for destructors or use - the macros defined in @c boost/contract_macro.hpp (recommended only for - applications where it is truly necessary to completely remove contract code - compilation from production code). - - @see @RefSect{tutorial.destructors, Destructors}, - @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation} - */ - #define BOOST_CONTRACT_NO_DESTRUCTORS -#endif - -#ifdef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS - #error "define NO_INVARIANTS, NO_PRECONDITIONS, NO_POSTCONDITIONS, and NO_EXCEPTS instead" -#elif defined(BOOST_CONTRACT_NO_INVARIANTS) && \ - defined(BOOST_CONTRACT_NO_PRECONDITIONS) && \ - defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \ - defined(BOOST_CONTRACT_NO_EXCEPTS) - /** - Automatically defined by this library when contracts are not checked for - public functions. - - This library will define this macro when users define all - @RefMacro{BOOST_CONTRACT_NO_INVARIANTS}, - @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS}, - @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and - @RefMacro{BOOST_CONTRACT_NO_EXCEPTS} (this macro is not a configuration - macro and this library will generate a compile-time error if users try to - define it directly). - Users can manually program @c \#ifndef statements in their code using this - macro to completely disable compilation of contracts for public functions or - use the macros defined in @c boost/contract_macro.hpp (recommended only for - applications where it is truly necessary to completely remove contract code - compilation from production code). - - @see @RefSect{tutorial.public_functions, Public Functions}, - @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation} - */ - #define BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS -#endif - -#ifdef BOOST_CONTRACT_NO_FUNCTIONS - #error "define NO_PRECONDITIONS, NO_POSTCONDITIONS, and NO_EXCEPTS instead" -#elif defined(BOOST_CONTRACT_NO_PRECONDITIONS) && \ - defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \ - defined(BOOST_CONTRACT_NO_EXCEPTS) - /** - Automatically defined by this library when contracts are not checked for - non-member, private and protected functions. - - This library will define this macro when users define all - @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS}, - @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, and - @RefMacro{BOOST_CONTRACT_NO_EXCEPTS} (this macro is not a configuration - macro and this library will generate a compile-time error if users try to - define it directly). - Users can manually program @c \#ifndef statements in their code using this - macro to completely disable compilation of contracts for non-member, - private and protected functions, or use the macros defined in - @c boost/contract_macro.hpp (recommended only for applications where it is - truly necessary to completely remove contract code compilation from - production code). - - This macro is also used when contracts are not checked for private and - protected functions, lambda functions, code blocks, loops, etc. - - @see @RefSect{tutorial.non_member_functions, Non-Member Functions}, - @RefSect{advanced.private_and_protected_functions, - Private and Protected Functions}, - @RefSect{advanced.lambdas__loops__code_blocks__and__constexpr__, - Lambdas\, Loops\, Code Blocks}, - @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation} - */ - #define BOOST_CONTRACT_NO_FUNCTIONS -#endif - -#ifdef BOOST_CONTRACT_NO_CONDITIONS - #error "define NO_INVARIANTS, NO_PRECONDITIONS, NO_POSTCONDITIONS, and NO_EXCEPTS instead" -#elif defined(BOOST_CONTRACT_NO_INVARIANTS) && \ - defined(BOOST_CONTRACT_NO_PRECONDITIONS) && \ - defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \ - defined(BOOST_CONTRACT_NO_EXCEPTS) - /** - Automatically defined by this library when contracts are not checked for - preconditions, postconditions, exceptions guarantees, and class invariants - (excluding implementation checks). - - This library will define this macro when users define all - @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS}, - @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, - @RefMacro{BOOST_CONTRACT_NO_EXCEPTS}, and - @RefMacro{BOOST_CONTRACT_NO_INVARIANTS} (this macro is not a configuration - macro and this library will generate a compile-time error if users try to - define it directly). - Users can manually program @c \#ifndef statements in their code using this - macro to completely disable compilation of contracts within specifications - or use the macros defined in @c boost/contract_macro.hpp (recommended only - for applications where it is truly necessary to completely remove contract - code compilation from production code). - - @see @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation} - */ - #define BOOST_CONTRACT_NO_CONDITIONS -#endif - -#ifdef BOOST_CONTRACT_NO_ALL - #error "define NO_INVARIANTS, NO_PRECONDITIONS, NO_POSTCONDITIONS, NO_EXCEPTS, and NO_CHECKS instead" -#elif defined(BOOST_CONTRACT_NO_INVARIANTS) && \ - defined(BOOST_CONTRACT_NO_PRECONDITIONS) && \ - defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \ - defined(BOOST_CONTRACT_NO_EXCEPTS) && \ - defined(BOOST_CONTRACT_NO_CHECKS) - /** - Automatically defined by this library when contracts are not checked at all. - - This library will define this macro when users define all - @RefMacro{BOOST_CONTRACT_NO_INVARIANTS}, - @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS}, - @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS}, - @RefMacro{BOOST_CONTRACT_NO_EXCEPTS}, and - @RefMacro{BOOST_CONTRACT_NO_CHECKS} (this macro is not a configuration - macro and this library will generate a compile-time error if users try to - define it directly). - For example, users can manually program @c \#ifndef statements in their code - using this macro to avoid including the @c boost/contract.hpp header all - together: - - @code - #include <boost/contract/core/config.hpp> - #ifndef BOOST_CONTRACT_NO_ALL - #include <boost/contract.hpp> - #endif - @endcode - - Or, use the @c boost/contract_macro.hpp header and related macros instead - (because the @c boost/contract_macro.hpp header is already optimized to not - include other headers from this library when contracts are not checked, but - recommended only for applications where it is truly necessary to completely - remove contract code compilation from production code). - - @see @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation} - */ - #define BOOST_CONTRACT_NO_ALL -#endif - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/core/constructor_precondition.hpp b/contrib/restricted/boost/boost/contract/core/constructor_precondition.hpp deleted file mode 100644 index 7a7fa753aae..00000000000 --- a/contrib/restricted/boost/boost/contract/core/constructor_precondition.hpp +++ /dev/null @@ -1,122 +0,0 @@ - -#ifndef BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION_HPP_ -#define BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -/** @file -Program preconditions for constructors. -*/ - -// IMPORTANT: Included by contract_macro.hpp so must #if-guard all its includes. -#include <boost/contract/core/config.hpp> -#ifndef BOOST_CONTRACT_NO_PRECONDITIONS - #include <boost/contract/core/exception.hpp> - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - #include <boost/contract/detail/checking.hpp> - #endif -#endif - -namespace boost { namespace contract { - -/** -Program preconditions for constructors. - -This class must be the very first base of the class declaring the -constructor for which preconditions are programmed (that way constructor -arguments can be checked by preconditions even before they are used to -initialize other base classes): - -@code - class u - #define BASES private boost::contract::constructor_precondition<u>, \ - public b - : BASES - { - ... - #undef BASES - - public: - explicit u(unsigned x) : - boost::contract::constructor_precondition<u>([&] { - BOOST_CONTRACT_ASSERT(x != 0); - ... - }), - b(1.0 / float(x)) - { - ... - } - - ... - }; -@endcode - -User-defined classes should inherit privately from this class (to not alter the -public interface of user-defined classes). -In addition, this class should never be declared as a virtual base (because -virtual bases are initialized only once across the entire inheritance hierarchy -preventing preconditions of other base classes from being checked). - -Unions cannot have base classes in C++ so this class can be used to declare a -local object within the constructor definition just before -@RefFunc{boost::contract::constructor} is used (see -@RefSect{extras.unions, Unions}). - -@see @RefSect{tutorial.constructors, Constructors} - -@tparam Class The class type of the constructor for which preconditions are - being programmed. -*/ -template<class Class> -class constructor_precondition { // Copyable (has no data). -public: - /** - Construct this object without specifying constructor preconditions. - - This is implicitly called for those constructors of the contracted class - that do not specify preconditions. - - @note Calling this default constructor should amount to negligible - compile-time and run-time overheads (likely to be optimized away - completely by most compilers). - */ - constructor_precondition() {} - - /** - Construct this object specifying constructor preconditions. - - @param f Nullary functor called by this library to check constructor - preconditions @c f(). - Assertions within this functor call are usually programmed - using @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown - by a call to this functor indicates a contract failure (and will - result in this library calling - @RefFunc{boost::contract::precondition_failure}). - This functor should capture variables by (constant) value, or - better by (constant) reference to avoid extra copies. - */ - template<typename F> - explicit constructor_precondition(F const& f) { - #ifndef BOOST_CONTRACT_NO_PRECONDITIONS - try { - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - if(boost::contract::detail::checking::already()) return; - #ifndef BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION - boost::contract::detail::checking k; - #endif - #endif - f(); - } catch(...) { precondition_failure(from_constructor); } - #endif - } - - // Default copy operations (so user's derived classes can be copied, etc.). -}; - -} } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/core/exception.hpp b/contrib/restricted/boost/boost/contract/core/exception.hpp deleted file mode 100644 index 2a1d144dd29..00000000000 --- a/contrib/restricted/boost/boost/contract/core/exception.hpp +++ /dev/null @@ -1,953 +0,0 @@ - -#ifndef BOOST_CONTRACT_EXCEPTION_HPP_ -#define BOOST_CONTRACT_EXCEPTION_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -/** @file -Handle contract assertion failures. -*/ - -// IMPORTANT: Included by contract_macro.hpp so trivial headers only. -#include <boost/contract/core/config.hpp> -#include <boost/contract/detail/declspec.hpp> // No compile-time overhead. -#include <boost/function.hpp> -#include <boost/config.hpp> -#include <exception> -#include <string> - -// NOTE: This code should not change (not even its impl) based on the -// CONTRACT_NO_... macros. For example, preconditions_failure() should still -// all the set precondition failure handler even when NO_PRECONDITIONS is -// #defined, because user code might explicitly call precondition_failure() -// (for whatever reason...). Otherwise, the public API of this lib will change. - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN -// Needed for `std::` prefix to show (but removed via `EXCLUDE_SYMBOLS=std`). -namespace std { - class exception {}; - class bad_cast {}; -} -#endif - -namespace boost { namespace contract { - -/** -Public base class for all exceptions directly thrown by this library. - -This class does not inherit from @c std::exception because exceptions deriving -from this class will do that (inheriting from @c std::exception, -@c std::bad_cast, etc.). - -@see @RefClass{boost::contract::assertion_failure}, - @RefClass{boost::contract::bad_virtual_result_cast}, - etc. -*/ -class BOOST_CONTRACT_DETAIL_DECLSPEC exception { -public: - /** - Destruct this object. - - @b Throws: This is declared @c noexcept (or @c throw() before C++11). - */ - virtual ~exception() /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */; -}; - -#ifdef BOOST_MSVC - #pragma warning(push) - #pragma warning(disable: 4275) // Bases w/o DLL spec (bad_cast, etc). - #pragma warning(disable: 4251) // Members w/o DLL spec (string for what_). -#endif - -/** -Exception thrown when inconsistent return values are passed to overridden -virtual public functions. - -This exception is internally thrown by this library when programmers specify -return values for public function overrides in derived classes that are not -consistent with the return types of the virtual public functions being -overridden in the base classes. -This allows this library to give more descriptive error messages in such cases. - -@see @RefSect{tutorial.public_function_overrides__subcontracting_, - Public Function Overrides} -*/ -class BOOST_CONTRACT_DETAIL_DECLSPEC bad_virtual_result_cast : // Copy (as str). - public std::bad_cast, public boost::contract::exception { -public: - /** - Construct this object with the name of the from- and to- result types. - - @param from_type_name Name of the from-type (source of the cast). - @param to_type_name Name of the to-type (destination of the cast). - */ - explicit bad_virtual_result_cast(char const* from_type_name, - char const* to_type_name); - - /** - Destruct this object. - - @b Throws: This is declared @c noexcept (or @c throw() before C++11). - */ - virtual ~bad_virtual_result_cast() - /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */; - - /** - Description for this error (containing both from- and to- type names). - - @b Throws: This is declared @c noexcept (or @c throw() before C++11). - */ - virtual char const* what() const - /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */; - -/** @cond */ -private: - std::string what_; -/** @endcond */ -}; - -/** -Exception typically used to report a contract assertion failure. - -This exception is thrown by code expanded by @RefMacro{BOOST_CONTRACT_ASSERT} -(but it can also be thrown by user code programmed manually without that macro). -This exception is typically used to report contract assertion failures because -it contains detailed information about the file name, line number, and source -code of the asserted condition (so it can be used by this library to provide -detailed error messages). -However, any other exception can be used to report a contract assertion failure -(including user-defined exceptions). - -This library will call the appropriate contract failure handler function -(@RefFunc{boost::contract::precondition_failure}, etc.) when this or any other -exception is thrown while checking contracts (by default, these failure handler -functions print an error message to @c std::cerr and terminate the program, but -they can be customized to take any other action). - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{extras.no_macros__and_no_variadic_macros_, No Macros} -*/ -class BOOST_CONTRACT_DETAIL_DECLSPEC assertion_failure : // Copy (as str, etc.). - public std::exception, public boost::contract::exception { -public: - /** - Construct this object with file name, line number, and source code text of - an assertion condition (all optional). - - This constructor can also be used to specify no information (default - constructor), or to specify only file name and line number but not source - code text (because of the parameter default values). - - @param file Name of the file containing the assertion (usually set using - <c>__FILE__</c>). - @param line Number of the line containing the assertion (usually set using - <c>__LINE__</c>). - @param code Text listing the source code of the assertion condition. - */ - explicit assertion_failure(char const* file = "", unsigned long line = 0, - char const* code = ""); - - /** - Construct this object only with the source code text of the assertion - condition. - @param code Text listing the source code of the assertion condition. - */ - explicit assertion_failure(char const* code); - - /** - Destruct this object. - - @b Throws: This is declared @c noexcept (or @c throw() before C++11). - */ - virtual ~assertion_failure() - /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */; - - /** - String describing the failed assertion. - - @b Throws: This is declared @c noexcept (or @c throw() before C++11). - - @return A string formatted similarly to the following: - <c>assertion "`code()`" failed: file "`file()`", line \`line()\`</c>. - File, line, and code will be omitted from this string if they were - not specified when constructing this object. - */ - virtual char const* what() const - /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */; - - /** - Name of the file containing the assertion. - - @return File name as specified at construction (or @c "" if no file was - specified). - */ - char const* file() const; - - /** - Number of the line containing the assertion. - - @return Line number as specified at construction (or @c 0 if no line number - was specified). - */ - unsigned long line() const; - - /** - Text listing the source code of the assertion condition. - - @return Assertion condition source code as specified at construction (or - @c "" if no source code text was specified). - */ - char const* code() const; - -/** @cond */ -private: - void init(); - - char const* file_; - unsigned long line_; - char const* code_; - std::string what_; -/** @endcond */ -}; - -#ifdef BOOST_MSVC - #pragma warning(pop) -#endif - -/** -Indicate the kind of operation where the contract assertion failed. - -This is passed as a parameter to the assertion failure handler functions. -For example, it might be necessary to know in which operation an assertion -failed to make sure exceptions are never thrown from destructors, not even -when contract failure handlers are programmed by users to throw exceptions -instead of terminating the program. - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure} -*/ -enum from { - /** Assertion failed when checking contracts for constructors. */ - from_constructor, - - /** Assertion failed when checking contracts for destructors . */ - from_destructor, - - /** - Assertion failed when checking contracts for functions (members or not). - */ - from_function -}; - -/** -Type of assertion failure handler functions (with @c from parameter). - -Assertion failure handler functions specified by this type must be functors -returning @c void and taking a single parameter of type -@RefEnum{boost::contract::from}. -For example, this is used to specify contract failure handlers for class -invariants, preconditions, postconditions, and exception guarantees. - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure} -*/ -typedef boost::function<void (from)> from_failure_handler; - -/** -Type of assertion failure handler functions (without @c from parameter). - -Assertion failure handler functions specified by this type must be nullary -functors returning @c void. -For example, this is used to specify contract failure handlers for -implementation checks. - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure} -*/ -typedef boost::function<void ()> failure_handler; - -/** @cond */ -namespace exception_ { - // Check failure. - - BOOST_CONTRACT_DETAIL_DECLSPEC - failure_handler const& set_check_failure_unlocked(failure_handler const& f) - BOOST_NOEXCEPT_OR_NOTHROW; - BOOST_CONTRACT_DETAIL_DECLSPEC - failure_handler const& set_check_failure_locked(failure_handler const& f) - BOOST_NOEXCEPT_OR_NOTHROW; - - BOOST_CONTRACT_DETAIL_DECLSPEC - failure_handler get_check_failure_unlocked() BOOST_NOEXCEPT_OR_NOTHROW; - BOOST_CONTRACT_DETAIL_DECLSPEC - failure_handler get_check_failure_locked() BOOST_NOEXCEPT_OR_NOTHROW; - - BOOST_CONTRACT_DETAIL_DECLSPEC - void check_failure_unlocked() /* can throw */; - BOOST_CONTRACT_DETAIL_DECLSPEC - void check_failure_locked() /* can throw */; - - // Precondition failure. - - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler const& set_pre_failure_unlocked( - from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler const& set_pre_failure_locked( - from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; - - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler get_pre_failure_unlocked() BOOST_NOEXCEPT_OR_NOTHROW; - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler get_pre_failure_locked() BOOST_NOEXCEPT_OR_NOTHROW; - - BOOST_CONTRACT_DETAIL_DECLSPEC - void pre_failure_unlocked(from where) /* can throw */; - BOOST_CONTRACT_DETAIL_DECLSPEC - void pre_failure_locked(from where) /* can throw */; - - // Postcondition failure. - - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler const& set_post_failure_unlocked( - from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler const& set_post_failure_locked( - from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; - - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler get_post_failure_unlocked() BOOST_NOEXCEPT_OR_NOTHROW; - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler get_post_failure_locked() BOOST_NOEXCEPT_OR_NOTHROW; - - BOOST_CONTRACT_DETAIL_DECLSPEC - void post_failure_unlocked(from where) /* can throw */; - BOOST_CONTRACT_DETAIL_DECLSPEC - void post_failure_locked(from where) /* can throw */; - - // Except failure. - - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler const& set_except_failure_unlocked( - from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler const& set_except_failure_locked( - from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; - - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler get_except_failure_unlocked() - BOOST_NOEXCEPT_OR_NOTHROW; - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler get_except_failure_locked() BOOST_NOEXCEPT_OR_NOTHROW; - - BOOST_CONTRACT_DETAIL_DECLSPEC - void except_failure_unlocked(from where) /* can throw */; - BOOST_CONTRACT_DETAIL_DECLSPEC - void except_failure_locked(from where) /* can throw */; - - // Old-copy failure. - - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler const& set_old_failure_unlocked( - from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler const& set_old_failure_locked( - from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; - - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler get_old_failure_unlocked() BOOST_NOEXCEPT_OR_NOTHROW; - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler get_old_failure_locked() BOOST_NOEXCEPT_OR_NOTHROW; - - BOOST_CONTRACT_DETAIL_DECLSPEC - void old_failure_unlocked(from where) /* can throw */; - BOOST_CONTRACT_DETAIL_DECLSPEC - void old_failure_locked(from where) /* can throw */; - - // Entry invariant failure. - - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler const& set_entry_inv_failure_unlocked( - from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler const& set_entry_inv_failure_locked( - from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; - - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler get_entry_inv_failure_unlocked() - BOOST_NOEXCEPT_OR_NOTHROW; - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler get_entry_inv_failure_locked() - BOOST_NOEXCEPT_OR_NOTHROW; - - BOOST_CONTRACT_DETAIL_DECLSPEC - void entry_inv_failure_unlocked(from where) /* can throw */; - BOOST_CONTRACT_DETAIL_DECLSPEC - void entry_inv_failure_locked(from where) /* can throw */; - - // Exit invariant failure. - - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler const& set_exit_inv_failure_unlocked( - from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler const&set_exit_inv_failure_locked( - from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; - - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler get_exit_inv_failure_unlocked() - BOOST_NOEXCEPT_OR_NOTHROW; - BOOST_CONTRACT_DETAIL_DECLSPEC - from_failure_handler get_exit_inv_failure_locked() - BOOST_NOEXCEPT_OR_NOTHROW; - - BOOST_CONTRACT_DETAIL_DECLSPEC - void exit_inv_failure_unlocked(from where) /* can throw */; - BOOST_CONTRACT_DETAIL_DECLSPEC - void exit_inv_failure_locked(from where) /* can throw */; -} -/** @endcond */ - -} } // namespace - -/** @cond */ -#ifdef BOOST_CONTRACT_HEADER_ONLY - // NOTE: This header must be included in the middle of this file (because - // its impl depends on both from and assert_failure types). This is not - // ideal, but it is better than splitting this file into multiple - // independent ones because all content in this file is logically related - // from the user prospective. - #include <boost/contract/detail/inlined/core/exception.hpp> -#endif -/** @endcond */ - -namespace boost { namespace contract { - -// Following must be inline for static linkage (no DYN_LINK and no HEADER_ONLY). - -/** -Set failure handler for implementation checks. - -Set a new failure handler and returns it. - -@b Throws: This is declared @c noexcept (or @c throw() before C++11). - -@param f New failure handler functor to set. - -@return Same failure handler functor @p f passed as parameter (e.g., for - concatenating function calls). - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{advanced.implementation_checks, Implementation Checks} -*/ -inline failure_handler const& set_check_failure(failure_handler const& f) - /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - return exception_::set_check_failure_locked(f); - #else - return exception_::set_check_failure_unlocked(f); - #endif -} - -/** -Return failure handler currently set for implementation checks. - -This is often called only internally by this library. - -@b Throws: This is declared @c noexcept (or @c throw() before C++11). - -@return A copy of the failure handler currently set. - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{advanced.implementation_checks, Implementation Checks} -*/ -inline failure_handler get_check_failure() - /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - return exception_::get_check_failure_locked(); - #else - return exception_::get_check_failure_unlocked(); - #endif -} - -/** -Call failure handler for implementation checks. - -This is often called only internally by this library. - -@b Throws: This can throw in case programmers specify a failure handler that - throws exceptions on implementation check failures (not the - default). - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{advanced.implementation_checks, Implementation Checks} -*/ -inline void check_failure() /* can throw */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - exception_::check_failure_locked(); - #else - exception_::check_failure_unlocked(); - #endif -} - -/** -Set failure handler for preconditions. - -Set a new failure handler and returns it. - -@b Throws: This is declared @c noexcept (or @c throw() before C++11). - -@param f New failure handler functor to set. - -@return Same failure handler functor @p f passed as parameter (e.g., for - concatenating function calls). - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{tutorial.preconditions, Preconditions} -*/ -inline from_failure_handler const& set_precondition_failure(from_failure_handler - const& f) /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - return exception_::set_pre_failure_locked(f); - #else - return exception_::set_pre_failure_unlocked(f); - #endif -} - -/** -Return failure handler currently set for preconditions. - -This is often called only internally by this library. - -@b Throws: This is declared @c noexcept (or @c throw() before C++11). - -@return A copy of the failure handler currently set. - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{tutorial.preconditions, Preconditions} -*/ -inline from_failure_handler get_precondition_failure() - /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - return exception_::get_pre_failure_locked(); - #else - return exception_::get_pre_failure_unlocked(); - #endif -} - -/** -Call failure handler for preconditions. - -This is often called only internally by this library. - -@b Throws: This can throw in case programmers specify a failure handler that - throws exceptions on contract assertion failures (not the default). - -@param where Operation that failed the contract assertion (when this function - is called by this library, this parameter will never be - @c from_destructor because destructors do not have - preconditions). - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{tutorial.preconditions, Preconditions} -*/ -inline void precondition_failure(from where) /* can throw */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - exception_::pre_failure_locked(where); - #else - exception_::pre_failure_unlocked(where); - #endif -} - -/** -Set failure handler for postconditions. - -Set a new failure handler and returns it. - -@b Throws: This is declared @c noexcept (or @c throw() before C++11). - -@param f New failure handler functor to set. - -@return Same failure handler functor @p f passed as parameter (e.g., fr - concatenating function calls). - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{tutorial.postconditions, Postconditions} -*/ -inline from_failure_handler const& set_postcondition_failure( - from_failure_handler const& f -) /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - return exception_::set_post_failure_locked(f); - #else - return exception_::set_post_failure_unlocked(f); - #endif -} - -/** -Return failure handler currently set for postconditions. - -This is often called only internally by this library. - -@b Throws: This is declared @c noexcept (or @c throw() before C++11). - -@return A copy of the failure handler currently set. - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{tutorial.postconditions, Postconditions} -*/ -inline from_failure_handler get_postcondition_failure() - /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - return exception_::get_post_failure_locked(); - #else - return exception_::get_post_failure_unlocked(); - #endif -} - -/** -Call failure handler for postconditions. - -This is often called only internally by this library. - -@b Throws: This can throw in case programmers specify a failure handler that - throws exceptions on contract assertion failures (not the default). - -@param where Operation that failed the contract assertion (e.g., this might - be useful to program failure handler functors that never throw - from destructors, not even when they are programmed by users to - throw exceptions instead of terminating the program). - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{tutorial.postconditions, Postconditions} -*/ -inline void postcondition_failure(from where) /* can throw */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - exception_::post_failure_locked(where); - #else - exception_::post_failure_unlocked(where); - #endif -} - -/** -Set failure handler for exception guarantees. - -Set a new failure handler and returns it. - -@b Throws: This is declared @c noexcept (or @c throw() before C++11). - -@param f New failure handler functor to set. - -@return Same failure handler functor @p f passed as parameter (e.g., for - concatenating function calls). - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{tutorial.exception_guarantees, Exception Guarantees} -*/ -inline from_failure_handler const& set_except_failure(from_failure_handler - const& f) /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - return exception_::set_except_failure_locked(f); - #else - return exception_::set_except_failure_unlocked(f); - #endif -} - -/** -Return failure handler currently set for exception guarantees. - -This is often called only internally by this library. - -@b Throws: This is declared @c noexcept (or @c throw() before C++11). - -@return A copy of the failure handler currently set. - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{tutorial.exception_guarantees, Exception Guarantees} -*/ -inline from_failure_handler get_except_failure() - /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - return exception_::get_except_failure_locked(); - #else - return exception_::get_except_failure_unlocked(); - #endif -} - -/** -Call failure handler for exception guarantees. - -This is often called only internally by this library. - -@b Throws: This can throw in case programmers specify a failure handler that - throws exceptions on contract assertion failures (not the default), - however: - -@warning When this failure handler is called there is already an active - exception (the one that caused the exception guarantees to be - checked in the first place). - Therefore, programming this failure handler to throw yet another - exception will force C++ to automatically terminate the program. - -@param where Operation that failed the contract assertion. - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{tutorial.exception_guarantees, Exception Guarantees} -*/ -inline void except_failure(from where) /* can throw */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - exception_::except_failure_locked(where); - #else - exception_::except_failure_unlocked(where); - #endif -} - -/** -Set failure handler for old value copies at body. - -Set a new failure handler and returns it. - -@b Throws: This is declared @c noexcept (or @c throw() before C++11). - -@param f New failure handler functor to set. - -@return Same failure handler functor @p f passed as parameter (e.g., for - concatenating function calls). - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{advanced.old_value_copies_at_body, Old Value Copies at Body} -*/ -inline from_failure_handler const& set_old_failure(from_failure_handler const& - f) /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - return exception_::set_old_failure_locked(f); - #else - return exception_::set_old_failure_unlocked(f); - #endif -} - -/** -Return failure handler currently set for old value copies at body. - -This is often called only internally by this library. - -@b Throws: This is declared @c noexcept (or @c throw() before C++11). - -@return A copy of the failure handler currently set. - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{advanced.old_value_copies_at_body, Old Value Copies at Body} -*/ -inline from_failure_handler get_old_failure() - /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - return exception_::get_old_failure_locked(); - #else - return exception_::get_old_failure_unlocked(); - #endif -} - -/** -Call failure handler for old value copies at body. - -This is often called only internally by this library. - -@b Throws: This can throw in case programmers specify a failure handler that - throws exceptions on contract assertion failures (not the default). - -@param where Operation that failed the old value copy (e.g., this might - be useful to program failure handler functors that never throw - from destructors, not even when they are programmed by users to - throw exceptions instead of terminating the program). - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{advanced.old_value_copies_at_body, Old Value Copies at Body} -*/ -inline void old_failure(from where) /* can throw */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - exception_::old_failure_locked(where); - #else - exception_::old_failure_unlocked(where); - #endif -} - -/** -Set failure handler for class invariants at entry. - -Set a new failure handler and returns it. - -@b Throws: This is declared @c noexcept (or @c throw() before C++11). - -@param f New failure handler functor to set. - -@return Same failure handler functor @p f passed as parameter (e.g., for - concatenating function calls). - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{tutorial.class_invariants, Class Invariants}, - @RefSect{extras.volatile_public_functions, - Volatile Public Functions} -*/ -inline from_failure_handler const& set_entry_invariant_failure( - from_failure_handler const& f -)/** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - return exception_::set_entry_inv_failure_locked(f); - #else - return exception_::set_entry_inv_failure_unlocked(f); - #endif -} - -/** -Return failure handler currently set for class invariants at entry. - -This is often called only internally by this library. - -@b Throws: This is declared @c noexcept (or @c throw() before C++11). - -@return A copy of the failure handler currently set. - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{tutorial.class_invariants, Class Invariants}, - @RefSect{extras.volatile_public_functions, - Volatile Public Functions} -*/ -inline from_failure_handler get_entry_invariant_failure() - /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - return exception_::get_entry_inv_failure_locked(); - #else - return exception_::get_entry_inv_failure_unlocked(); - #endif -} - -/** -Call failure handler for class invariants at entry. - -This is often called only internally by this library. - -@b Throws: This can throw in case programmers specify a failure handler that - throws exceptions on contract assertion failures (not the default). - -@param where Operation that failed the contract assertion (e.g., this might - be useful to program failure handler functors that never throw - from destructors, not even when they are programmed by users to - throw exceptions instead of terminating the program). - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{tutorial.class_invariants, Class Invariants}, - @RefSect{extras.volatile_public_functions, - Volatile Public Functions} -*/ -inline void entry_invariant_failure(from where) /* can throw */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - return exception_::entry_inv_failure_locked(where); - #else - return exception_::entry_inv_failure_unlocked(where); - #endif -} - -/** -Set failure handler for class invariants at exit. - -Set a new failure handler and returns it. - -@b Throws: This is declared @c noexcept (or @c throw() before C++11). - -@param f New failure handler functor to set. - -@return Same failure handler functor @p f passed as parameter (e.g., for - concatenating function calls). - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{tutorial.class_invariants, Class Invariants}, - @RefSect{extras.volatile_public_functions, - Volatile Public Functions} -*/ -inline from_failure_handler const& set_exit_invariant_failure( - from_failure_handler const& f -) /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - return exception_::set_exit_inv_failure_locked(f); - #else - return exception_::set_exit_inv_failure_unlocked(f); - #endif -} - -/** -Return failure handler currently set for class invariants at exit. - -This is often called only internally by this library. - -@b Throws: This is declared @c noexcept (or @c throw() before C++11). - -@return A copy of the failure handler currently set. - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{tutorial.class_invariants, Class Invariants}, - @RefSect{extras.volatile_public_functions, - Volatile Public Functions} -*/ -inline from_failure_handler get_exit_invariant_failure() - /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - return exception_::get_exit_inv_failure_locked(); - #else - return exception_::get_exit_inv_failure_unlocked(); - #endif -} - -/** -Call failure handler for class invariants at exit. - -This is often called only internally by this library. - -@b Throws: This can throw in case programmers specify a failure handler that - throws exceptions on contract assertion failures (not the default). - -@param where Operation that failed the contract assertion (e.g., this might - be useful to program failure handler functors that never throw - from destructors, not even when they are programmed by users to - throw exceptions instead of terminating the program). - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{tutorial.class_invariants, Class Invariants}, - @RefSect{extras.volatile_public_functions, - Volatile Public Functions} -*/ -inline void exit_invariant_failure(from where) /* can throw */ { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - exception_::exit_inv_failure_locked(where); - #else - exception_::exit_inv_failure_unlocked(where); - #endif -} - -/** -Set failure handler for class invariants (at both entry and exit). - -This is provided for convenience and it is equivalent to call both -@RefFunc{boost::contract::set_entry_invariant_failure} and -@RefFunc{boost::contract::set_exit_invariant_failure} with the same functor -parameter @p f. - -@b Throws: This is declared @c noexcept (or @c throw() before C++11). - -@param f New failure handler functor to set for both entry and exit invariants. - -@return Same failure handler functor @p f passed as parameter (e.g., for - concatenating function calls). - -@see @RefSect{advanced.throw_on_failures__and__noexcept__, Throw on Failure}, - @RefSect{tutorial.class_invariants, Class Invariants}, - @RefSect{extras.volatile_public_functions, - Volatile Public Functions} -*/ -/** @cond */ BOOST_CONTRACT_DETAIL_DECLSPEC /** @endcond */ -from_failure_handler const& set_invariant_failure(from_failure_handler const& f) - /** @cond */ BOOST_NOEXCEPT_OR_NOTHROW /** @endcond */; - -} } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/core/specify.hpp b/contrib/restricted/boost/boost/contract/core/specify.hpp deleted file mode 100644 index ef0bea9b099..00000000000 --- a/contrib/restricted/boost/boost/contract/core/specify.hpp +++ /dev/null @@ -1,650 +0,0 @@ - -#ifndef BOOST_CONTRACT_SPECIFY_HPP_ -#define BOOST_CONTRACT_SPECIFY_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -/** @file -Specify preconditions, old value copies at body, postconditions, and exception -guarantees - -Preconditions, old value copies at body, postconditions, and exception -guarantees are all optionals but, when they are specified, they need to be -specified in that order. -*/ - -#include <boost/contract/core/config.hpp> -#include <boost/contract/detail/decl.hpp> -#if !defined(BOOST_CONTRACT_NO_CONDITIONS) || \ - defined(BOOST_CONTRACT_STATIC_LINK) - #include <boost/contract/detail/condition/cond_base.hpp> - #include <boost/contract/detail/condition/cond_post.hpp> - #include <boost/contract/detail/auto_ptr.hpp> - #include <boost/contract/detail/none.hpp> -#endif -#if !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS) - #include <boost/contract/detail/debug.hpp> -#endif -#include <boost/config.hpp> - -// NOTE: No inheritance for faster run-times (macros to avoid duplicated code). - -/* PRIVATE */ - -/* @cond */ - -// NOTE: Private copy ops below will force compile-time error is `auto c = ...` -// is used instead of `check c = ...` but only up to C++17. C++17 strong copy -// elision on function return values prevents this lib from generating a -// compile-time error in those cases, but the lib will still generate a run-time -// error according with ON_MISSING_CHECK_DECL. -#if !defined(BOOST_CONTRACT_NO_CONDITIONS) || \ - defined(BOOST_CONTRACT_STATIC_LINK) - #define BOOST_CONTRACT_SPECIFY_CLASS_IMPL_(class_type, cond_type) \ - private: \ - boost::contract::detail::auto_ptr<cond_type > cond_; \ - explicit class_type(cond_type* cond) : cond_(cond) {} \ - class_type(class_type const& other) : cond_(other.cond_) {} \ - class_type& operator=(class_type const& other) { \ - cond_ = other.cond_; \ - return *this; \ - } - - #define BOOST_CONTRACT_SPECIFY_COND_RELEASE_ cond_.release() -#else - #define BOOST_CONTRACT_SPECIFY_CLASS_IMPL_(class_type, cond_type) \ - private: \ - class_type() {} \ - class_type(class_type const&) {} \ - class_type& operator=(class_type const&) { return *this; } - - #define BOOST_CONTRACT_SPECIFY_COND_RELEASE_ /* nothing */ -#endif - -#ifndef BOOST_CONTRACT_NO_PRECONDITIONS - #define BOOST_CONTRACT_SPECIFY_PRECONDITION_IMPL_ \ - BOOST_CONTRACT_DETAIL_DEBUG(cond_); \ - cond_->set_pre(f); \ - return specify_old_postcondition_except<VirtualResult>( \ - BOOST_CONTRACT_SPECIFY_COND_RELEASE_); -#else - #define BOOST_CONTRACT_SPECIFY_PRECONDITION_IMPL_ \ - return specify_old_postcondition_except<VirtualResult>( \ - BOOST_CONTRACT_SPECIFY_COND_RELEASE_); -#endif - -#ifndef BOOST_CONTRACT_NO_OLDS - #define BOOST_CONTRACT_SPECIFY_OLD_IMPL_ \ - BOOST_CONTRACT_DETAIL_DEBUG(cond_); \ - cond_->set_old(f); \ - return specify_postcondition_except<VirtualResult>( \ - BOOST_CONTRACT_SPECIFY_COND_RELEASE_); -#else - #define BOOST_CONTRACT_SPECIFY_OLD_IMPL_ \ - return specify_postcondition_except<VirtualResult>( \ - BOOST_CONTRACT_SPECIFY_COND_RELEASE_); -#endif - -#ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - #define BOOST_CONTRACT_SPECIFY_POSTCONDITION_IMPL_ \ - BOOST_CONTRACT_DETAIL_DEBUG(cond_); \ - cond_->set_post(f); \ - return specify_except(BOOST_CONTRACT_SPECIFY_COND_RELEASE_); -#else - #define BOOST_CONTRACT_SPECIFY_POSTCONDITION_IMPL_ \ - return specify_except(BOOST_CONTRACT_SPECIFY_COND_RELEASE_); -#endif - -#ifndef BOOST_CONTRACT_NO_EXCEPTS - #define BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_ \ - BOOST_CONTRACT_DETAIL_DEBUG(cond_); \ - cond_->set_except(f); \ - return specify_nothing(BOOST_CONTRACT_SPECIFY_COND_RELEASE_); -#else - #define BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_ \ - return specify_nothing(BOOST_CONTRACT_SPECIFY_COND_RELEASE_); -#endif - -/* @endcond */ - -/* CODE */ - -namespace boost { - namespace contract { - class virtual_; - - template<typename VR> - class specify_precondition_old_postcondition_except; - - template<typename VR> - class specify_old_postcondition_except; - - template<typename VR> - class specify_postcondition_except; - - class specify_except; - } -} - -namespace boost { namespace contract { - -/** -Used to prevent setting other contract conditions after exception guarantees. - -This class has no member function so it is used to prevent specifying additional -functors to check any other contract. -This object is internally constructed by this library when users specify -contracts calling @RefFunc{boost::contract::function} and similar functions -(that is why this class does not have a public constructor). - -@see @RefSect{tutorial, Tutorial} -*/ -class specify_nothing { // Privately copyable (as *). -public: - /** - Destruct this object. - - @b Throws: This can throw in case programmers specify failure handlers that - throw exceptions instead of terminating the program (see - @RefSect{advanced.throw_on_failures__and__noexcept__, - Throw on Failure}). - (This is declared @c noexcept(false) since C++11.) - */ - ~specify_nothing() BOOST_NOEXCEPT_IF(false) {} - - // No set member function here. - -/** @cond */ -private: - BOOST_CONTRACT_SPECIFY_CLASS_IMPL_(specify_nothing, - boost::contract::detail::cond_base) - - // Friends (used to limit library's public API). - - friend class check; - - template<typename VR> - friend class specify_precondition_old_postcondition_except; - - template<typename VR> - friend class specify_old_postcondition_except; - - template<typename VR> - friend class specify_postcondition_except; - - friend class specify_except; -/** @endcond */ -}; - -/** -Allow to specify exception guarantees. - -Allow to specify the functor this library will call to check exception -guarantees. -This object is internally constructed by this library when users specify -contracts calling @RefFunc{boost::contract::function} and similar functions -(that is why this class does not have a public constructor). - -@see @RefSect{tutorial.exception_guarantees, Exception Guarantees} -*/ -class specify_except { // Privately copyable (as *). -public: - /** - Destruct this object. - - @b Throws: This can throw in case programmers specify failure handlers that - throw exceptions instead of terminating the program (see - @RefSect{advanced.throw_on_failures__and__noexcept__, - Throw on Failure}). - (This is declared @c noexcept(false) since C++11.) - */ - ~specify_except() BOOST_NOEXCEPT_IF(false) {} - - /** - Allow to specify exception guarantees. - - @param f Nullary functor called by this library to check exception - guarantees @c f(). - Assertions within this functor are usually programmed using - @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a - call to this functor indicates a contract assertion failure (and - will result in this library calling - @RefFunc{boost::contract::except_failure}). - This functor should capture variables by (constant) references - (to access the values they will have at function exit). - - @return After exception guarantees have been specified, the object returned - by this function does not allow to specify any additional contract. - */ - template<typename F> - specify_nothing except(F const& f) { - BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_ - } - -/** @cond */ -private: - BOOST_CONTRACT_SPECIFY_CLASS_IMPL_(specify_except, - boost::contract::detail::cond_base) - - // Friends (used to limit library's public API). - - friend class check; - - template<typename VR> - friend class specify_precondition_old_postcondition_except; - - template<typename VR> - friend class specify_old_postcondition_except; - - template<typename VR> - friend class specify_postcondition_except; -/** @endcond */ -}; - -/** -Allow to specify postconditions or exception guarantees. - -Allow to specify functors this library will call to check postconditions or -exception guarantees. -This object is internally constructed by this library when users specify -contracts calling @RefFunc{boost::contract::function} and similar functions -(that is why this class does not have a public constructor). - -@see @RefSect{tutorial.postconditions, Postconditions}, - @RefSect{tutorial.exception_guarantees, Exception Guarantees} - -@tparam VirtualResult Return type of the enclosing function declaring the - contract if that function is either a virtual public - function or a public function override. - Otherwise, this type is always @c void. -*/ -template<typename VirtualResult = void> -class specify_postcondition_except { // Privately copyable (as *). -public: - /** - Destruct this object. - - @b Throws: This can throw in case programmers specify failure handlers that - throw exceptions instead of terminating the program (see - @RefSect{advanced.throw_on_failures__and__noexcept__, - Throw on Failure}). - (This is declared @c noexcept(false) since C++11.) - */ - ~specify_postcondition_except() BOOST_NOEXCEPT_IF(false) {} - - /** - Allow to specify postconditions. - - @param f Functor called by this library to check postconditions - @c f(...). - Assertions within this functor are usually programmed using - @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a - call to this functor indicates a contract assertion failure (and - will result in this library calling - @RefFunc{boost::contract::postcondition_failure}). - This functor should capture variables by (constant) references - (to access the values they will have at function exit). - This functor must be a nullary functor if @c VirtualResult is - @c void, otherwise it must be a unary functor accepting the - return value as a parameter of type <c>VirtualResult const&</c> - (to avoid extra copies of the return value, or of type - @c VirtualResult or <c>VirtualResult const</c> if extra copies - of the return value are irrelevant). - - @return After postconditions have been specified, the object returned by - this function allows to optionally specify exception guarantees. - */ - template<typename F> - specify_except postcondition(F const& f) { - BOOST_CONTRACT_SPECIFY_POSTCONDITION_IMPL_ - } - - /** - Allow to specify exception guarantees. - - @param f Nullary functor called by this library to check exception - guarantees @c f(). - Assertions within this functor are usually programmed using - @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a - call to this functor indicates a contract assertion failure (and - will result in this library calling - @RefFunc{boost::contract::except_failure}). - This functor should capture variables by (constant) references - (to access the values they will have at function exit). - - @return After exception guarantees have been specified, the object returned - by this function does not allow to specify any additional contract. - */ - template<typename F> - specify_nothing except(F const& f) { - BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_ - } - -/** @cond */ -private: - BOOST_CONTRACT_SPECIFY_CLASS_IMPL_( - specify_postcondition_except, - boost::contract::detail::cond_post<typename - boost::contract::detail::none_if_void<VirtualResult>::type> - ) - - // Friends (used to limit library's public API). - - friend class check; - friend class specify_precondition_old_postcondition_except<VirtualResult>; - friend class specify_old_postcondition_except<VirtualResult>; -/** @endcond */ -}; - -/** -Allow to specify old value copies at body, postconditions, and exception -guarantees. - -Allow to specify functors this library will call to copy old value at body, -check postconditions, and check exception guarantees. -This object is internally constructed by this library when users specify -contracts calling @RefFunc{boost::contract::function} and similar functions -(that is why this class does not have a public constructor). - -@see @RefSect{advanced.old_value_copies_at_body, Old Value Copies at Body}, - @RefSect{tutorial.postconditions, Postconditions}, - @RefSect{tutorial.exception_guarantees, Exception Guarantees} - -@tparam VirtualResult Return type of the enclosing function declaring the - contract if that function is either a virtual public - function or a public function override. - Otherwise, this type is always @c void. -*/ -template<typename VirtualResult = void> -class specify_old_postcondition_except { // Privately copyable (as *). -public: - /** - Destruct this object. - - @b Throws: This can throw in case programmers specify failure handlers that - throw exceptions instead of terminating the program (see - @RefSect{advanced.throw_on_failures__and__noexcept__, - Throw on Failure}). - (This is declared @c noexcept(false) since C++11.) - */ - ~specify_old_postcondition_except() BOOST_NOEXCEPT_IF(false) {} - - /** - Allow to specify old value copies at body. - - It should often be sufficient to initialize old value pointers as soon as - they are declared, without using this function (see - @RefSect{advanced.old_value_copies_at_body, Old Value Copies at Body}). - - @param f Nullary functor called by this library @c f() to assign old - value copies just before the body is executed but after entry - invariants (when they apply) and preconditions are checked. - Old value pointers within this functor call are usually assigned - using @RefMacro{BOOST_CONTRACT_OLDOF}. - Any exception thrown by a call to this functor will result in - this library calling @RefFunc{boost::contract::old_failure} - (because old values could not be copied to check postconditions - and exception guarantees). - This functor should capture old value pointers by references so - they can be assigned (all other variables needed to evaluate old - value expressions can be captured by (constant) value, or better - by (constant) reference to avoid extra copies). - - @return After old value copies at body have been specified, the object - returned by this function allows to optionally specify - postconditions and exception guarantees. - */ - template<typename F> - specify_postcondition_except<VirtualResult> old(F const& f) { - BOOST_CONTRACT_SPECIFY_OLD_IMPL_ - } - - /** - Allow to specify postconditions. - - @param f Functor called by this library to check postconditions - @c f(...). - Assertions within this functor are usually programmed using - @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a - call to this functor indicates a contract assertion failure (and - will result in this library calling - @RefFunc{boost::contract::postcondition_failure}). - This functor should capture variables by (constant) references - (to access the values they will have at function exit). - This functor must be a nullary functor if @c VirtualResult is - @c void, otherwise it must be a unary functor accepting the - return value as a parameter of type <c>VirtualResult const&</c> - (to avoid extra copies of the return value, or of type - @c VirtualResult or <c>VirtualResult const</c> if extra copies - of the return value are irrelevant). - - @return After postconditions have been specified, the object returned by - this function allows to optionally specify exception guarantees. - */ - template<typename F> - specify_except postcondition(F const& f) { - BOOST_CONTRACT_SPECIFY_POSTCONDITION_IMPL_ - } - - /** - Allow to specify exception guarantees. - - @param f Nullary functor called by this library to check exception - guarantees @c f(). - Assertions within this functor are usually programmed using - @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a - call to this functor indicates a contract assertion failure (and - will result in this library calling - @RefFunc{boost::contract::except_failure}). - This functor should capture variables by (constant) references - (to access the values they will have at function exit). - - @return After exception guarantees have been specified, the object returned - by this function does not allow to specify any additional contract. - */ - template<typename F> - specify_nothing except(F const& f) { - BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_ - } - -/** @cond */ -private: - BOOST_CONTRACT_SPECIFY_CLASS_IMPL_( - specify_old_postcondition_except, - boost::contract::detail::cond_post<typename - boost::contract::detail::none_if_void<VirtualResult>::type> - ) - - // Friends (used to limit library's public API). - - friend class check; - friend class specify_precondition_old_postcondition_except<VirtualResult>; - - template<class C> - friend specify_old_postcondition_except<> constructor(C*); - - template<class C> - friend specify_old_postcondition_except<> destructor(C*); -/** @endcond */ -}; - -/** -Allow to specify preconditions, old value copies at body, postconditions, and -exception guarantees. - -Allow to specify functors this library will call to check preconditions, copy -old values at body, check postconditions, and check exception guarantees. -This object is internally constructed by this library when users specify -contracts calling @RefFunc{boost::contract::function} and similar functions -(that is why this class does not have a public constructor). - -@see @RefSect{tutorial.preconditions, Preconditions}, - @RefSect{advanced.old_value_copies_at_body, Old Value Copies at Body}, - @RefSect{tutorial.postconditions, Postconditions}, - @RefSect{tutorial.exception_guarantees, Exception Guarantees} - -@tparam VirtualResult Return type of the enclosing function declaring the - contract if that function is either a virtual public - function or a public function override. - Otherwise, this type is always @c void. -*/ -template< - typename VirtualResult /* = void (already in fwd decl from decl.hpp) */ - #ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - = void - #endif -> -class specify_precondition_old_postcondition_except { // Priv. copyable (as *). -public: - /** - Destruct this object. - - @b Throws: This can throw in case programmers specify failure handlers that - throw exceptions instead of terminating the program (see - @RefSect{advanced.throw_on_failures__and__noexcept__, - Throw on Failure}). - (This is declared @c noexcept(false) since C++11.) - */ - ~specify_precondition_old_postcondition_except() BOOST_NOEXCEPT_IF(false) {} - - /** - Allow to specify preconditions. - - @param f Nullary functor called by this library to check preconditions - @c f(). - Assertions within this functor are usually programmed using - @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a - call to this functor indicates a contract assertion failure (and - will result in this library calling - @RefFunc{boost::contract::precondition_failure}). - This functor should capture variables by (constant) value, or - better by (constant) reference (to avoid extra copies). - - @return After preconditions have been specified, the object returned by this - function allows to optionally specify old value copies at body, - postconditions, and exception guarantees. - */ - template<typename F> - specify_old_postcondition_except<VirtualResult> precondition(F const& f) { - BOOST_CONTRACT_SPECIFY_PRECONDITION_IMPL_ - } - - /** - Allow to specify old value copies at body. - - It should often be sufficient to initialize old value pointers as soon as - they are declared, without using this function (see - @RefSect{advanced.old_value_copies_at_body, Old Value Copies at Body}). - - @param f Nullary functor called by this library @c f() to assign old - value copies just before the body is executed but after entry - invariants (when they apply) and preconditions are checked. - Old value pointers within this functor call are usually assigned - using @RefMacro{BOOST_CONTRACT_OLDOF}. - Any exception thrown by a call to this functor will result in - this library calling @RefFunc{boost::contract::old_failure} - (because old values could not be copied to check postconditions - and exception guarantees). - This functor should capture old value pointers by references so - they can be assigned (all other variables needed to evaluate old - value expressions can be captured by (constant) value, or better - by (constant) reference to avoid extra copies). - - @return After old value copies at body have been specified, the object - returned by this functions allows to optionally specify - postconditions and exception guarantees. - */ - template<typename F> - specify_postcondition_except<VirtualResult> old(F const& f) { - BOOST_CONTRACT_SPECIFY_OLD_IMPL_ - } - - /** - Allow to specify postconditions. - - @param f Functor called by this library to check postconditions - @c f(...). - Assertions within this functor are usually programmed using - @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a - call to this functor indicates a contract assertion failure (and - will result in this library calling - @RefFunc{boost::contract::postcondition_failure}). - This functor should capture variables by (constant) references - (to access the values they will have at function exit). - This functor must be a nullary functor if @c VirtualResult is - @c void, otherwise it must be a unary functor accepting the - return value as a parameter of type <c>VirtualResult const&</c> - (to avoid extra copies of the return value, or of type - @c VirtualResult or <c>VirtualResult const</c> if extra copies - of the return value are irrelevant). - - @return After postconditions have been specified, the object returned by - this function allows to optionally specify exception guarantees. - */ - template<typename F> - specify_except postcondition(F const& f) { - BOOST_CONTRACT_SPECIFY_POSTCONDITION_IMPL_ - } - - /** - Allow to specify exception guarantees. - - @param f Nullary functor called by this library to check exception - guarantees @c f(). - Assertions within this functor are usually programmed using - @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a - call to this functor indicates a contract assertion failure (and - will result in this library calling - @RefFunc{boost::contract::except_failure}). - This functor should capture variables by (constant) references - (to access the values they will have at function exit). - - @return After exception guarantees have been specified, the object returned - by this function does not allow to specify any additional contract. - */ - template<typename F> - specify_nothing except(F const& f) { - BOOST_CONTRACT_SPECIFY_EXCEPT_IMPL_ - } - -/** @cond */ -private: - BOOST_CONTRACT_SPECIFY_CLASS_IMPL_( - specify_precondition_old_postcondition_except, - boost::contract::detail::cond_post<typename - boost::contract::detail::none_if_void<VirtualResult>::type> - ) - - // Friends (used to limit library's public API). - - friend class check; - friend specify_precondition_old_postcondition_except<> function(); - - template<class C> - friend specify_precondition_old_postcondition_except<> public_function(); - - template<class C> - friend specify_precondition_old_postcondition_except<> public_function(C*); - - template<class C> - friend specify_precondition_old_postcondition_except<> public_function( - virtual_*, C*); - - template<typename VR, class C> - friend specify_precondition_old_postcondition_except<VR> public_function( - virtual_*, VR&, C*); - - BOOST_CONTRACT_DETAIL_DECL_FRIEND_OVERRIDING_PUBLIC_FUNCTIONS_Z(1, - O, VR, F, C, Args, v, r, f, obj, args) -/** @endcond */ -}; - -} } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/core/virtual.hpp b/contrib/restricted/boost/boost/contract/core/virtual.hpp deleted file mode 100644 index fcdd60555d2..00000000000 --- a/contrib/restricted/boost/boost/contract/core/virtual.hpp +++ /dev/null @@ -1,161 +0,0 @@ - -#ifndef BOOST_CONTRACT_VIRTUAL_HPP_ -#define BOOST_CONTRACT_VIRTUAL_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -/** @file -Handle virtual public functions with contracts (for subcontracting). -*/ - -// IMPORTANT: Included by contract_macro.hpp so must #if-guard all its includes. -#include <boost/contract/core/config.hpp> -#ifndef BOOST_CONTRACT_NO_CONDITIONS - #include <boost/contract/detail/decl.hpp> -#endif -#ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - #include <boost/any.hpp> -#endif -#ifndef BOOST_CONTRACT_NO_OLDS - #include <boost/shared_ptr.hpp> - #include <queue> -#endif - -namespace boost { namespace contract { - -#ifndef BOOST_CONTRACT_NO_CONDITIONS - namespace detail { - BOOST_CONTRACT_DETAIL_DECL_DETAIL_COND_SUBCONTRACTING_Z(1, - /* is_friend = */ 0, OO, RR, FF, CC, AArgs); - } -#endif - -/** -Type of extra function parameter to handle contracts for virtual public -functions (for subcontracting). - -Virtual public functions (and therefore also public function overrides) -declaring contracts using this library must specify an extra function parameter -at the very end of the parameter list. -This parameter must be a pointer to this class and it must have default value -@c 0 (i.e., @c nullptr). -(This extra parameter is often named @c v in this documentation, but any name -can be used.) - -In practice this extra parameter does not alter the calling interface of the -enclosing function declaring the contract because it is always the very last -parameter and it has a default value (so it can always be omitted when users -call the function). -This extra parameter must be passed to -@RefFunc{boost::contract::public_function}, @RefMacro{BOOST_CONTRACT_OLDOF}, and -all other operations of this library that accept a pointer to -@RefClass{boost::contract::virtual_}. -A part from that, this class is not intended to be directly used by programmers -(and that is why this class does not have any public member and it is not -copyable). - -@see @RefSect{tutorial.virtual_public_functions, Virtual Public Functions}, - @RefSect{tutorial.public_function_overrides__subcontracting_, - Public Function Overrides} -*/ -class virtual_ { // Non-copyable (see below) to avoid copy queue, stack, etc. -/** @cond */ -private: // No public API (so users cannot use it directly by mistake). - - // No boost::noncopyable to avoid its overhead when contracts disabled. - virtual_(virtual_&); - virtual_& operator=(virtual_&); - - #ifndef BOOST_CONTRACT_NO_CONDITIONS - enum action_enum { - // virtual_ always held/passed as ptr so nullptr used for user call. - no_action, - #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS - check_entry_inv, - #endif - #ifndef BOOST_CONTRACT_NO_PRECONDITIONS - check_pre, - #endif - #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS - check_exit_inv, - #endif - #ifndef BOOST_CONTRACT_NO_OLDS - // For outside .old(...). - push_old_init_copy, - // pop_old_init_copy as static function below. - // For inside .old(...). - call_old_ftor, - push_old_ftor_copy, - pop_old_ftor_copy, - #endif - #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - check_post, - #endif - #ifndef BOOST_CONTRACT_NO_EXCEPTS - check_except, - #endif - }; - #endif - - #ifndef BOOST_CONTRACT_NO_OLDS - // Not just an enum value because the logical combination of two values. - inline static bool pop_old_init_copy(action_enum a) { - return - #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - a == check_post - #endif - #if !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) && \ - !defined(BOOST_CONTRACT_NO_EXCEPTS) - || - #endif - #ifndef BOOST_CONTRACT_NO_EXCEPTS - a == check_except - #endif - ; - } - #endif - - #ifndef BOOST_CONTRACT_NO_CONDITIONS - explicit virtual_(action_enum a) : - action_(a) - , failed_(false) - #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - , result_type_name_() - , result_optional_() - #endif - {} - #endif - - #ifndef BOOST_CONTRACT_NO_CONDITIONS - action_enum action_; - bool failed_; - #endif - #ifndef BOOST_CONTRACT_NO_OLDS - std::queue<boost::shared_ptr<void> > old_init_copies_; - std::queue<boost::shared_ptr<void> > old_ftor_copies_; - #endif - #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - boost::any result_ptr_; // Result for virtual and overriding functions. - char const* result_type_name_; - bool result_optional_; - #endif - - // Friends (used to limit library's public API). - #ifndef BOOST_CONTRACT_NO_OLDS - friend bool copy_old(virtual_*); - friend class old_pointer; - #endif - #ifndef BOOST_CONTRACT_NO_CONDITIONS - BOOST_CONTRACT_DETAIL_DECL_DETAIL_COND_SUBCONTRACTING_Z(1, - /* is_friend = */ 1, OO, RR, FF, CC, AArgs); - #endif -/** @endcond */ -}; - -} } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/destructor.hpp b/contrib/restricted/boost/boost/contract/destructor.hpp deleted file mode 100644 index 28372c7d0b1..00000000000 --- a/contrib/restricted/boost/boost/contract/destructor.hpp +++ /dev/null @@ -1,107 +0,0 @@ - -#ifndef BOOST_CONTRACT_DESTRUCTOR_HPP_ -#define BOOST_CONTRACT_DESTRUCTOR_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -/** @file -Program contracts for destructors. -*/ - -#include <boost/contract/core/config.hpp> -#include <boost/contract/core/specify.hpp> -#include <boost/contract/core/access.hpp> -#if !defined(BOOST_CONTRACT_NO_DESTRUCTORS) || \ - !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \ - defined(BOOST_CONTRACT_STATIC_LINK) - #include <boost/contract/detail/operation/destructor.hpp> -#endif - -namespace boost { namespace contract { - -/** -Program contracts for destructors. - -This is used to specify postconditions, exception guarantees, old value copies -at body, and check class invariants for destructors (destructors cannot not have -preconditions, see -@RefSect{contract_programming_overview.destructor_calls, Destructor Calls}): - -@code -class u { - friend class boost::contract::access; - - void invariant() const { // Optional (as for static and volatile). - BOOST_CONTRACT_ASSERT(...); - ... - } - -public: - ~u() { - boost::contract::old_ptr<old_type> old_var; - boost::contract::check c = boost::contract::destructor(this) - // No `.precondition` (destructors have no preconditions). - .old([&] { // Optional. - old_var = BOOST_CONTRACT_OLDOF(old_expr); - ... - }) - .postcondition([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - .except([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - ; - - ... // Destructor body. - } - - ... -}; -@endcode - -For optimization, this can be omitted for destructors that do not have -postconditions and exception guarantees, within classes that have no invariants. - -@see @RefSect{tutorial.destructors, Destructors} - -@param obj The object @c this from the scope of the enclosing destructor - declaring the contract. - (Destructors check all class invariants, including static and - volatile invariants, see @RefSect{tutorial.class_invariants, - Class Invariants} and - @RefSect{extras.volatile_public_functions, - Volatile Public Functions}). - -@tparam Class The type of the class containing the destructor declaring the - contract. - (Usually this template parameter is automatically deduced by C++ - and it does not need to be explicitly specified by programmers.) - -@return The result of this function must be explicitly assigned to a variable of - type @RefClass{boost::contract::check} declared locally just before the - code of the destructor body (otherwise this library will generate a - run-time error, see @RefMacro{BOOST_CONTRACT_ON_MISSING_CHECK_DECL}). -*/ -template<class Class> -specify_old_postcondition_except<> destructor(Class* obj) { - // Must #if also on ..._PRECONDITIONS here because specify_... is generic. - #if !defined(BOOST_CONTRACT_NO_DESTRUCTORS) || \ - !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \ - defined(BOOST_CONTRACT_STATIC_LINK) - return specify_old_postcondition_except<>( - new boost::contract::detail::destructor<Class>(obj)); - #else - return specify_old_postcondition_except<>(); - #endif -} - -} } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/assert.hpp b/contrib/restricted/boost/boost/contract/detail/assert.hpp deleted file mode 100644 index e44726733eb..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/assert.hpp +++ /dev/null @@ -1,28 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_ASSERT_HPP_ -#define BOOST_CONTRACT_DETAIL_ASSERT_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/core/exception.hpp> -#include <boost/contract/detail/noop.hpp> -#include <boost/preprocessor/stringize.hpp> - -// In detail because used by both ASSERT and CHECK. -// Use ternary operator `?:` and no trailing `;` here to allow `if(...) ASSERT( -// ...); else ...` (won't compile if expands using an if statement instead even -// if wrapped by {}, and else won't compile if expands trailing `;`). -#define BOOST_CONTRACT_DETAIL_ASSERT(cond) \ - /* no if-statement here */ \ - ((cond) ? \ - BOOST_CONTRACT_DETAIL_NOOP \ - : \ - throw boost::contract::assertion_failure( \ - __FILE__, __LINE__, BOOST_PP_STRINGIZE(cond)) \ - ) /* no ; here */ - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/auto_ptr.hpp b/contrib/restricted/boost/boost/contract/detail/auto_ptr.hpp deleted file mode 100644 index e76945ce9cf..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/auto_ptr.hpp +++ /dev/null @@ -1,53 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_AUTO_PTR_HPP_ -#define BOOST_CONTRACT_DETAIL_AUTO_PTR_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/detail/operator_safe_bool.hpp> -#include <boost/contract/detail/debug.hpp> -#include <boost/config.hpp> - -namespace boost { namespace contract { namespace detail { - -// Using this instead of std::auto_ptr because std::auto_ptr will be removed in -// C++17 (this library always uses release() to avoid ownership issues). -template<typename T> -class auto_ptr { // Copyable (using default copy operations). -public: - explicit auto_ptr(T* ptr = 0) : ptr_(ptr) {} - - ~auto_ptr() BOOST_NOEXCEPT_IF(false) { delete ptr_; } - - T* release() { - T* ptr = ptr_; - ptr_ = 0; - return ptr; - } - - T& operator*() { - BOOST_CONTRACT_DETAIL_DEBUG(ptr_); - return *ptr_; - } - - T const& operator*() const { - BOOST_CONTRACT_DETAIL_DEBUG(ptr_); - return *ptr_; - } - - T* operator->() { return ptr_; } - T const* operator->() const { return ptr_; } - - BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL(auto_ptr<T>, !!ptr_) - -private: - T* ptr_; -}; - -} } } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/check.hpp b/contrib/restricted/boost/boost/contract/detail/check.hpp deleted file mode 100644 index 49006d92d7f..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/check.hpp +++ /dev/null @@ -1,48 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_CHECK_HPP_ -#define BOOST_CONTRACT_DETAIL_CHECK_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/core/config.hpp> -#ifndef BOOST_CONTRACT_NO_CHECKS - #include <boost/contract/core/exception.hpp> - - /* PRIVATE */ - - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - #include <boost/contract/detail/checking.hpp> - #include <boost/contract/detail/name.hpp> - - #define BOOST_CONTRACT_CHECK_IF_NOT_CHECKING_ALREADY_ \ - if(!boost::contract::detail::checking::already()) - #define BOOST_CONTRACT_CHECK_CHECKING_VAR_(guard) \ - /* this name somewhat unique to min var shadow warnings */ \ - boost::contract::detail::checking BOOST_CONTRACT_DETAIL_NAME2( \ - guard, __LINE__); - #else - #define BOOST_CONTRACT_CHECK_IF_NOT_CHECKING_ALREADY_ /* nothing */ - #define BOOST_CONTRACT_CHECK_CHECKING_VAR_(guard) /* nothing */ - #endif - - /* PUBLIC */ - - #define BOOST_CONTRACT_DETAIL_CHECK(assertion) \ - { \ - try { \ - BOOST_CONTRACT_CHECK_IF_NOT_CHECKING_ALREADY_ \ - { \ - BOOST_CONTRACT_CHECK_CHECKING_VAR_(k) \ - { assertion; } \ - } \ - } catch(...) { boost::contract::check_failure(); } \ - } -#else - #define BOOST_CONTRACT_DETAIL_CHECK(assertion) {} -#endif - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/checking.hpp b/contrib/restricted/boost/boost/contract/detail/checking.hpp deleted file mode 100644 index 765c04f4f85..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/checking.hpp +++ /dev/null @@ -1,80 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_CHECKING_HPP_ -#define BOOST_CONTRACT_DETAIL_CHECKING_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/core/config.hpp> -#include <boost/contract/detail/static_local_var.hpp> -#include <boost/contract/detail/declspec.hpp> -#include <boost/thread/mutex.hpp> -#include <boost/noncopyable.hpp> - -namespace boost { namespace contract { namespace detail { - -#ifdef BOOST_MSVC - #pragma warning(push) - #pragma warning(disable: 4251) // Member w/o DLL spec (mutex_ type). -#endif - -// RAII facility to disable assertions while checking other assertions. -class BOOST_CONTRACT_DETAIL_DECLSPEC checking : - private boost::noncopyable // Non-copyable resource (might use mutex, etc.). -{ -public: - explicit checking() { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - init_locked(); - #else - init_unlocked(); - #endif - } - - ~checking() { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - done_locked(); - #else - done_unlocked(); - #endif - } - - static bool already() { - #ifndef BOOST_CONTRACT_DISABLE_THREADS - return already_locked(); - #else - return already_unlocked(); - #endif - } - -private: - void init_unlocked(); - void init_locked(); - - void done_unlocked(); - void done_locked(); - - static bool already_unlocked(); - static bool already_locked(); - - struct mutex_tag; - typedef static_local_var<mutex_tag, boost::mutex> mutex; - - struct checking_tag; - typedef static_local_var_init<checking_tag, bool, bool, false> flag; -}; - -#ifdef BOOST_MSVC - #pragma warning(pop) -#endif - -} } } // namespace - -#ifdef BOOST_CONTRACT_HEADER_ONLY - #include <boost/contract/detail/inlined/detail/checking.hpp> -#endif - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/condition/cond_base.hpp b/contrib/restricted/boost/boost/contract/detail/condition/cond_base.hpp deleted file mode 100644 index c3f4090461f..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/condition/cond_base.hpp +++ /dev/null @@ -1,153 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_COND_BASE_HPP_ -#define BOOST_CONTRACT_DETAIL_COND_BASE_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -// NOTE: It seemed not possible to implement this library without inheritance -// here because some sort of base type needs to be used to hold contract objects -// in instances of boost::contract::check while polymorphically calling -// init and destructor functions to check contracts at entry and exit. This -// could be possible without inheritance only if boost::contract::check was made -// a template type but that would complicate user code. In any case, early -// experimentation with removing this base class and its virtual methods did not -// seem to reduce compilation and/or run time. - -#include <boost/contract/core/exception.hpp> -#include <boost/contract/core/config.hpp> -#if !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_OLDS) || \ - !defined(BOOST_CONTRACT_NO_EXEPTS) - #include <boost/function.hpp> -#endif -#include <boost/noncopyable.hpp> -#ifndef BOOST_CONTRACT_ON_MISSING_CHECK_DECL - #include <boost/assert.hpp> -#endif -#include <boost/config.hpp> - -namespace boost { namespace contract { namespace detail { - -class cond_base : // Base to hold all contract objects for RAII. - private boost::noncopyable // Avoid copying possible user's ftor captures. -{ -public: - explicit cond_base(boost::contract::from from) : - BOOST_CONTRACT_ERROR_missing_check_object_declaration(false) - , init_asserted_(false) - #ifndef BOOST_CONTRACT_NO_CONDITIONS - , from_(from) - , failed_(false) - #endif - {} - - // Can override for checking on exit, but should call assert_initialized(). - virtual ~cond_base() BOOST_NOEXCEPT_IF(false) { - // Catch error (but later) even if overrides miss assert_initialized(). - if(!init_asserted_) assert_initialized(); - } - - void initialize() { // Must be called by owner ctor (i.e., check class). - BOOST_CONTRACT_ERROR_missing_check_object_declaration = true; - this->init(); // So all inits (pre, old, post) done after owner decl. - } - - #ifndef BOOST_CONTRACT_NO_PRECONDITIONS - template<typename F> - void set_pre(F const& f) { pre_ = f; } - #endif - - #ifndef BOOST_CONTRACT_NO_OLDS - template<typename F> - void set_old(F const& f) { old_ = f; } - #endif - - #ifndef BOOST_CONTRACT_NO_EXCEPTS - template<typename F> - void set_except(F const& f) { except_ = f; } - #endif - -protected: - void assert_initialized() { // Derived dtors must assert this at entry. - init_asserted_ = true; - #ifdef BOOST_CONTRACT_ON_MISSING_CHECK_DECL - if(!BOOST_CONTRACT_ERROR_missing_check_object_declaration) { - BOOST_CONTRACT_ON_MISSING_CHECK_DECL; - } - #else - // Cannot use a macro instead of this ERROR_... directly here - // because assert will not expand it in the error message. - BOOST_ASSERT(BOOST_CONTRACT_ERROR_missing_check_object_declaration); - #endif - } - - virtual void init() {} // Override for checking on entry. - - // Return true if actually checked calling user ftor. - #ifndef BOOST_CONTRACT_NO_PRECONDITIONS - bool check_pre(bool throw_on_failure = false) { - if(failed()) return true; - try { if(pre_) pre_(); else return false; } - catch(...) { - // Subcontracted pre must throw on failure (instead of - // calling failure handler) so to be checked in logic-or. - if(throw_on_failure) throw; - fail(&boost::contract::precondition_failure); - } - return true; - } - #endif - - #ifndef BOOST_CONTRACT_NO_OLDS - void copy_old() { - if(failed()) return; - try { if(old_) old_(); } - catch(...) { fail(&boost::contract::old_failure); } - } - #endif - - #ifndef BOOST_CONTRACT_NO_EXCEPTS - void check_except() { - if(failed()) return; - try { if(except_) except_(); } - catch(...) { fail(&boost::contract::except_failure); } - } - #endif - - #ifndef BOOST_CONTRACT_NO_CONDITIONS - void fail(void (*h)(boost::contract::from)) { - failed(true); - if(h) h(from_); - } - - // Virtual so overriding pub func can use virtual_::failed_ instead. - virtual bool failed() const { return failed_; } - virtual void failed(bool value) { failed_ = value; } - #endif - -private: - bool BOOST_CONTRACT_ERROR_missing_check_object_declaration; - bool init_asserted_; // Avoid throwing twice from dtors (undef behavior). - #ifndef BOOST_CONTRACT_NO_CONDITIONS - boost::contract::from from_; - bool failed_; - #endif - // Following use Boost.Function to handle also lambdas, binds, etc. - #ifndef BOOST_CONTRACT_NO_PRECONDITIONS - boost::function<void ()> pre_; - #endif - #ifndef BOOST_CONTRACT_NO_OLDS - boost::function<void ()> old_; - #endif - #ifndef BOOST_CONTRACT_NO_EXCEPTS - boost::function<void ()> except_; - #endif -}; - -} } } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/condition/cond_inv.hpp b/contrib/restricted/boost/boost/contract/detail/condition/cond_inv.hpp deleted file mode 100644 index b4c6c03133b..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/condition/cond_inv.hpp +++ /dev/null @@ -1,232 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_COND_INV_HPP_ -#define BOOST_CONTRACT_DETAIL_COND_INV_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/core/exception.hpp> -#include <boost/contract/core/config.hpp> -#include <boost/contract/detail/condition/cond_post.hpp> -#ifndef BOOST_CONTRACT_NO_INVARIANTS - #include <boost/contract/core/access.hpp> - #include <boost/type_traits/add_pointer.hpp> - #include <boost/type_traits/is_volatile.hpp> - #include <boost/mpl/vector.hpp> - #include <boost/mpl/transform.hpp> - #include <boost/mpl/for_each.hpp> - #include <boost/mpl/copy_if.hpp> - #include <boost/mpl/eval_if.hpp> - #include <boost/mpl/not.hpp> - #include <boost/mpl/and.hpp> - #include <boost/mpl/placeholders.hpp> - #include <boost/utility/enable_if.hpp> - #ifndef BOOST_CONTRACT_PERMISSIVE - #include <boost/function_types/property_tags.hpp> - #include <boost/static_assert.hpp> - #endif -#endif - -namespace boost { namespace contract { namespace detail { - -template<typename VR, class C> -class cond_inv : public cond_post<VR> { // Non-copyable base. - #if !defined(BOOST_CONTRACT_NO_INVARIANTS) && \ - !defined(BOOST_CONTRACT_PERMISSIVE) - BOOST_STATIC_ASSERT_MSG( - (!boost::contract::access::has_static_invariant_f< - C, void, boost::mpl:: vector<> - >::value), - "static invariant member function cannot be mutable " - "(it must be static instead)" - ); - BOOST_STATIC_ASSERT_MSG( - (!boost::contract::access::has_static_invariant_f< - C, void, boost::mpl::vector<>, - boost::function_types::const_non_volatile - >::value), - "static invariant member function cannot be const qualified " - "(it must be static instead)" - ); - BOOST_STATIC_ASSERT_MSG( - (!boost::contract::access::has_static_invariant_f< - C, void, boost::mpl::vector<>, - boost::function_types::volatile_non_const - >::value), - "static invariant member function cannot be volatile qualified " - "(it must be static instead)" - ); - BOOST_STATIC_ASSERT_MSG( - (!boost::contract::access::has_static_invariant_f< - C, void, boost::mpl::vector<>, - boost::function_types::cv_qualified - >::value), - "static invariant member function cannot be const volatile " - "qualified (it must be static instead)" - ); - - BOOST_STATIC_ASSERT_MSG( - (!boost::contract::access::has_invariant_s< - C, void, boost::mpl::vector<> - >::value), - "non-static invariant member function cannot be static " - "(it must be either const or const volatile qualified instead)" - ); - BOOST_STATIC_ASSERT_MSG( - (!boost::contract::access::has_invariant_f< - C, void, boost::mpl::vector<>, - boost::function_types::non_cv - >::value), - "non-static invariant member function cannot be mutable " - "(it must be either const or const volatile qualified instead)" - ); - BOOST_STATIC_ASSERT_MSG( - (!boost::contract::access::has_invariant_f< - C, void, boost::mpl::vector<>, - boost::function_types::volatile_non_const - >::value), - "non-static invariant member function cannot be volatile qualified " - "(it must be const or const volatile qualified instead)" - ); - #endif - -public: - // obj can be 0 for static member functions. - explicit cond_inv(boost::contract::from from, C* obj) : - cond_post<VR>(from) - #ifndef BOOST_CONTRACT_NO_CONDITIONS - , obj_(obj) - #endif - {} - -protected: - #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS - void check_entry_inv() { check_inv(true, false, false); } - void check_entry_static_inv() { check_inv(true, true, false); } - void check_entry_all_inv() { check_inv(true, false, true); } - #endif - - #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS - void check_exit_inv() { check_inv(false, false, false); } - void check_exit_static_inv() { check_inv(false, true, false); } - void check_exit_all_inv() { check_inv(false, false, true); } - #endif - - #ifndef BOOST_CONTRACT_NO_CONDITIONS - C* object() { return obj_; } - #endif - -private: - #ifndef BOOST_CONTRACT_NO_INVARIANTS - // Static, cv, and const inv in that order as strongest qualifier first. - void check_inv(bool on_entry, bool static_only, bool const_and_cv) { - if(this->failed()) return; - try { - // Static members only check static inv. - check_static_inv<C>(); - if(!static_only) { - if(const_and_cv) { - check_cv_inv<C>(); - check_const_inv<C>(); - } else if(boost::is_volatile<C>::value) { - check_cv_inv<C>(); - } else { - check_const_inv<C>(); - } - } - } catch(...) { - if(on_entry) { - this->fail(&boost::contract::entry_invariant_failure); - } else this->fail(&boost::contract::exit_invariant_failure); - } - } - - template<class C_> - typename boost::disable_if< - boost::contract::access::has_const_invariant<C_> >::type - check_const_inv() {} - - template<class C_> - typename boost::enable_if< - boost::contract::access::has_const_invariant<C_> >::type - check_const_inv() { boost::contract::access::const_invariant(obj_); } - - template<class C_> - typename boost::disable_if< - boost::contract::access::has_cv_invariant<C_> >::type - check_cv_inv() {} - - template<class C_> - typename boost::enable_if< - boost::contract::access::has_cv_invariant<C_> >::type - check_cv_inv() { boost::contract::access::cv_invariant(obj_); } - - template<class C_> - typename boost::disable_if< - boost::contract::access::has_static_invariant<C_> >::type - check_static_inv() {} - - template<class C_> - typename boost::enable_if< - boost::contract::access::has_static_invariant<C_> >::type - check_static_inv() { - // SFINAE HAS_STATIC_... returns true even when member is inherited - // so extra run-time check here (not the same for non static). - if(!inherited<boost::contract::access::has_static_invariant, - boost::contract::access::static_invariant_addr>::apply()) { - boost::contract::access::static_invariant<C_>(); - } - } - - // Check if class's func is inherited from its base types or not. - template<template<class> class HasFunc, template<class> class FuncAddr> - struct inherited { - static bool apply() { - try { - boost::mpl::for_each< - // For now, no reason to deeply search inheritance tree - // (SFINAE HAS_STATIC_... already fails in that case). - typename boost::mpl::transform< - typename boost::mpl::copy_if< - typename boost::mpl::eval_if<boost::contract:: - access::has_base_types<C>, - typename boost::contract::access:: - base_types_of<C> - , - boost::mpl::vector<> - >::type, - HasFunc<boost::mpl::_1> - >::type, - boost::add_pointer<boost::mpl::_1> - >::type - >(compare_func_addr()); - } catch(signal_equal const&) { return true; } - return false; - } - - private: - class signal_equal {}; // Except. to stop for_each as soon as found. - - struct compare_func_addr { - template<typename B> - void operator()(B*) { - // Inherited func has same addr as in its base. - if(FuncAddr<C>::apply() == FuncAddr<B>::apply()) { - throw signal_equal(); - } - } - }; - }; - #endif - - #ifndef BOOST_CONTRACT_NO_CONDITIONS - C* obj_; - #endif -}; - -} } } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/condition/cond_post.hpp b/contrib/restricted/boost/boost/contract/detail/condition/cond_post.hpp deleted file mode 100644 index aa99a5b9fa0..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/condition/cond_post.hpp +++ /dev/null @@ -1,88 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_COND_POST_HPP_ -#define BOOST_CONTRACT_DETAIL_COND_POST_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/core/exception.hpp> -#include <boost/contract/core/config.hpp> -#include <boost/contract/detail/condition/cond_base.hpp> -#include <boost/contract/detail/none.hpp> -#ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - #include <boost/contract/detail/type_traits/optional.hpp> - #include <boost/optional.hpp> - #include <boost/function.hpp> - #include <boost/type_traits/remove_reference.hpp> - #include <boost/mpl/if.hpp> -#endif - -/* PRIVATE */ - -#define BOOST_CONTRACT_DETAIL_COND_POST_DEF_( \ - result_type, result_param, ftor_type, ftor_var, ftor_call) \ - public: \ - template<typename F> \ - void set_post(F const& f) { ftor_var = f; } \ - \ - protected: \ - void check_post(result_type const& result_param) { \ - if(failed()) return; \ - try { if(ftor_var) { ftor_call; } } \ - catch(...) { fail(&boost::contract::postcondition_failure); } \ - } \ - \ - private: \ - boost::function<ftor_type> ftor_var; /* Boost.Func for lambdas, etc. */ - -/* CODE */ - -namespace boost { namespace contract { namespace detail { - -template<typename VR> -class cond_post : public cond_base { // Non-copyable base. -public: - explicit cond_post(boost::contract::from from) : cond_base(from) {} - - #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - private: typedef typename boost::mpl::if_<is_optional<VR>, - boost::optional<typename boost::remove_reference<typename - optional_value_type<VR>::type>::type const&> const& - , - VR const& - >::type r_type; - - BOOST_CONTRACT_DETAIL_COND_POST_DEF_( - r_type, - r, - void (r_type), - // Won't raise this error if NO_POST (for optimization). - BOOST_CONTRACT_ERROR_postcondition_result_parameter_required, - BOOST_CONTRACT_ERROR_postcondition_result_parameter_required(r) - ) - #endif -}; - -template<> -class cond_post<none> : public cond_base { // Non-copyable base. -public: - explicit cond_post(boost::contract::from from) : cond_base(from) {} - - #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - BOOST_CONTRACT_DETAIL_COND_POST_DEF_( - none, - unused, - void (), - // Won't raise this error if NO_POST (for optimization). - BOOST_CONTRACT_ERROR_postcondition_result_parameter_not_allowed, - BOOST_CONTRACT_ERROR_postcondition_result_parameter_not_allowed() - ) - #endif -}; - -} } } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/condition/cond_subcontracting.hpp b/contrib/restricted/boost/boost/contract/detail/condition/cond_subcontracting.hpp deleted file mode 100644 index 17d7a6abaaf..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/condition/cond_subcontracting.hpp +++ /dev/null @@ -1,472 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_COND_SUBCONTRACTING_HPP_ -#define BOOST_CONTRACT_DETAIL_COND_SUBCONTRACTING_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/core/config.hpp> -#if !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS) - #include <boost/contract/core/exception.hpp> -#endif -#include <boost/contract/detail/condition/cond_inv.hpp> -#include <boost/contract/detail/decl.hpp> -#include <boost/contract/detail/tvariadic.hpp> -#ifndef BOOST_CONTRACT_NO_CONDITIONS - #include <boost/contract/core/virtual.hpp> - #include <boost/contract/core/access.hpp> - #include <boost/contract/detail/type_traits/optional.hpp> - #include <boost/contract/detail/type_traits/member_function_types.hpp> - #include <boost/contract/detail/debug.hpp> - #include <boost/contract/detail/none.hpp> - #include <boost/contract/detail/name.hpp> - #include <boost/type_traits/add_pointer.hpp> - #include <boost/mpl/fold.hpp> - #include <boost/mpl/contains.hpp> - #include <boost/mpl/empty.hpp> - #include <boost/mpl/push_back.hpp> - #include <boost/mpl/eval_if.hpp> - #include <boost/mpl/identity.hpp> - #include <boost/mpl/placeholders.hpp> - #ifndef BOOST_CONTRACT_PERMISSIVE - #include <boost/type_traits/is_same.hpp> - #include <boost/mpl/or.hpp> - #include <boost/mpl/not.hpp> - #include <boost/static_assert.hpp> - #endif - #include <boost/preprocessor/punctuation/comma_if.hpp> - #include <boost/config.hpp> -#endif -#include <boost/mpl/vector.hpp> -#if !defined(BOOST_CONTRACT_NO_INVARIANTS) || \ - !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS) - #include <boost/mpl/for_each.hpp> -#endif -#ifndef BOOST_CONTRACT_NO_PRECONDITIONS - #include <boost/mpl/pop_front.hpp> - #include <boost/mpl/front.hpp> -#endif -#if !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOSOT_CONTRACT_NO_EXCEPTS) - #include <boost/any.hpp> - #include <boost/optional.hpp> - #include <boost/type_traits/remove_reference.hpp> - #include <boost/utility/enable_if.hpp> - #include <typeinfo> -#endif - -namespace boost { namespace contract { namespace detail { - -namespace cond_subcontracting_ { - // Exception signals (must not inherit). - class signal_no_error {}; - class signal_not_checked {}; -} - -// O, VR, F, and Args-i can be none types (but C cannot). -BOOST_CONTRACT_DETAIL_DECL_DETAIL_COND_SUBCONTRACTING_Z(1, - /* is_friend = */ 0, O, VR, F, C, Args) : public cond_inv<VR, C> -{ // Non-copyable base. - #ifndef BOOST_CONTRACT_NO_CONDITIONS - template<class Class, typename Result = boost::mpl::vector<> > - class overridden_bases_of { - struct search_bases { - typedef typename boost::mpl::fold< - typename boost::contract::access::base_types_of<Class>:: - type, - Result, - // Fold: _1 = result, _2 = current base from base_types. - boost::mpl::eval_if<boost::mpl::contains<boost::mpl::_1, - boost::add_pointer<boost::mpl::_2> >, - boost::mpl::_1 // Base in result, do not add it again. - , - boost::mpl::eval_if< - typename O::template BOOST_CONTRACT_DETAIL_NAME1( - has_member_function)< - boost::mpl::_2, - typename member_function_types<C, F>:: - result_type, - typename member_function_types<C, F>:: - virtual_argument_types, - typename member_function_types<C, F>:: - property_tag - > - , - boost::mpl::push_back< - overridden_bases_of<boost::mpl::_2, - boost::mpl::_1>, - // Bases as * since for_each constructs them. - boost::add_pointer<boost::mpl::_2> - > - , - overridden_bases_of<boost::mpl::_2, boost::mpl::_1> - > - > - >::type type; - }; - public: - typedef typename boost::mpl::eval_if< - boost::contract::access::has_base_types<Class>, - search_bases - , - boost::mpl::identity<Result> // Return result (stop recursion). - >::type type; - }; - - typedef typename boost::mpl::eval_if<boost::is_same<O, none>, - boost::mpl::vector<> - , - overridden_bases_of<C> - >::type overridden_bases; - - #ifndef BOOST_CONTRACT_PERMISSIVE - BOOST_STATIC_ASSERT_MSG( - (boost::mpl::or_< - boost::is_same<O, none>, - boost::mpl::not_<boost::mpl::empty<overridden_bases> > - >::value), - "subcontracting function specified as 'override' but does not " - "override any contracted member function" - ); - #endif - #else - typedef boost::mpl::vector<> overridden_bases; - #endif - -public: - explicit cond_subcontracting( - boost::contract::from from, - boost::contract::virtual_* v, - C* obj, - VR& r - BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(BOOST_CONTRACT_MAX_ARGS) - BOOST_CONTRACT_DETAIL_TVARIADIC_FPARAMS_Z(1, - BOOST_CONTRACT_MAX_ARGS, Args, &, args) - ) : - cond_inv<VR, C>(from, obj) - #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - , r_(r) - #endif - #ifndef BOOST_CONTRACT_NO_CONDITIONS - BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(BOOST_CONTRACT_MAX_ARGS) - BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INIT_Z(1, - BOOST_CONTRACT_MAX_ARGS, args_, args) - #endif - { - #ifndef BOOST_CONTRACT_NO_CONDITIONS - if(v) { - base_call_ = true; - v_ = v; // Invariant: v_ never null if base_call_. - BOOST_CONTRACT_DETAIL_DEBUG(v_); - } else { - base_call_ = false; - if(!boost::mpl::empty<overridden_bases>::value) { - v_ = new boost::contract::virtual_( - boost::contract::virtual_::no_action); - #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - v_->result_ptr_ = &r_; - v_->result_type_name_ = typeid(VR).name(); - v_->result_optional_ = is_optional<VR>::value; - #endif - } else v_ = 0; - } - #endif - } - - #ifndef BOOST_CONTRACT_NO_CONDITIONS - virtual ~cond_subcontracting() BOOST_NOEXCEPT_IF(false) { - if(!base_call_) delete v_; - } - #endif - -protected: - #ifndef BOOST_CONTRACT_NO_OLDS - void init_subcontracted_old() { - // Old values of overloaded func on stack (so no `f` param here). - exec_and(boost::contract::virtual_::push_old_init_copy); - } - #endif - - #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS - void check_subcontracted_entry_inv() { - exec_and(boost::contract::virtual_::check_entry_inv, - &cond_subcontracting::check_entry_inv); - } - #endif - - #ifndef BOOST_CONTRACT_NO_PRECONDITIONS - void check_subcontracted_pre() { - exec_or( - boost::contract::virtual_::check_pre, - &cond_subcontracting::check_pre, - &boost::contract::precondition_failure - ); - } - #endif - - #ifndef BOOST_CONTRACT_NO_OLDS - void copy_subcontracted_old() { - exec_and(boost::contract::virtual_::call_old_ftor, - &cond_subcontracting::copy_virtual_old); - } - #endif - - #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS - void check_subcontracted_exit_inv() { - exec_and(boost::contract::virtual_::check_exit_inv, - &cond_subcontracting::check_exit_inv); - } - #endif - - #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - void check_subcontracted_post() { - exec_and(boost::contract::virtual_::check_post, - &cond_subcontracting::check_virtual_post); - } - #endif - - #ifndef BOOST_CONTRACT_NO_EXCEPTS - void check_subcontracted_except() { - exec_and(boost::contract::virtual_::check_except, - &cond_subcontracting::check_virtual_except); - } - #endif - - #ifndef BOOST_CONTRACT_NO_CONDITIONS - bool base_call() const { return base_call_; } - - bool failed() const /* override */ { - if(v_) return v_->failed_; - else return cond_base::failed(); - } - - void failed(bool value) /* override */ { - if(v_) v_->failed_ = value; - else cond_base::failed(value); - } - #endif - -private: - #ifndef BOOST_CONTRACT_NO_OLDS - void copy_virtual_old() { - boost::contract::virtual_::action_enum a; - if(base_call_) { - a = v_->action_; - v_->action_ = boost::contract::virtual_::push_old_ftor_copy; - } - this->copy_old(); - if(base_call_) v_->action_ = a; - } - - void pop_base_old() { - if(base_call_) { - boost::contract::virtual_::action_enum a = v_->action_; - v_->action_ = boost::contract::virtual_::pop_old_ftor_copy; - this->copy_old(); - v_->action_ = a; - } // Else, do nothing (for base calls only). - } - #endif - - #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - void check_virtual_post() { - pop_base_old(); - typedef typename boost::remove_reference<typename - optional_value_type<VR>::type>::type r_type; - boost::optional<r_type const&> r; // No result copy in this code. - if(!base_call_) r = optional_get(r_); - else if(v_->result_optional_) { - try { - r = **boost::any_cast<boost::optional<r_type>*>( - v_->result_ptr_); - } catch(boost::bad_any_cast const&) { - try { // Handle optional<...&>. - r = **boost::any_cast<boost::optional<r_type&>*>( - v_->result_ptr_); - } catch(boost::bad_any_cast const&) { - try { - throw boost::contract::bad_virtual_result_cast(v_-> - result_type_name_, typeid(r_type).name()); - } catch(...) { - this->fail(&boost::contract::postcondition_failure); - } - } - } - } else { - try { - r = *boost::any_cast<r_type*>(v_->result_ptr_); - } catch(boost::bad_any_cast const&) { - try { - throw boost::contract::bad_virtual_result_cast( - v_->result_type_name_, typeid(r_type).name()); - } catch(...) { - this->fail(&boost::contract::postcondition_failure); - } - } - } - check_virtual_post_with_result<VR>(r); - } - - template<typename R_, typename Result> - typename boost::enable_if<is_optional<R_> >::type - check_virtual_post_with_result(Result const& r) { - this->check_post(r); - } - - template<typename R_, typename Result> - typename boost::disable_if<is_optional<R_> >::type - check_virtual_post_with_result(Result const& r) { - BOOST_CONTRACT_DETAIL_DEBUG(r); - this->check_post(*r); - } - #endif - - #ifndef BOOST_CONTRACT_NO_EXCEPTS - void check_virtual_except() { - pop_base_old(); - this->check_except(); - } - #endif - - #if !defined(BOOST_CONTRACT_NO_INVARIANTS) || \ - !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS) - void exec_and( // Execute action in short-circuit logic-and with bases. - boost::contract::virtual_::action_enum a, - void (cond_subcontracting::* f)() = 0 - ) { - if(failed()) return; - if(!base_call_ || v_->action_ == a) { - if(!base_call_ && v_) { - v_->action_ = a; - boost::mpl::for_each<overridden_bases>(call_base(*this)); - } - if(f) (this->*f)(); - if(base_call_) { - throw cond_subcontracting_::signal_no_error(); - } - } - } - #endif - - #ifndef BOOST_CONTRACT_NO_PRECONDITIONS - void exec_or( // Execute action in short-circuit logic-or with bases. - boost::contract::virtual_::action_enum a, - bool (cond_subcontracting::* f)(bool) = 0, - void (*h)(boost::contract::from) = 0 - ) { - if(failed()) return; - if(!base_call_ || v_->action_ == a) { - if(!base_call_ && v_) { - v_->action_ = a; - try { - exec_or_bases<overridden_bases>(); - return; // A base checked with no error (done). - } catch(...) { - bool checked = f ? (this->*f)( - /* throw_on_failure = */ false) : false; - if(!checked) { - try { throw; } // Report latest exception found. - catch(...) { this->fail(h); } - } - return; // Checked and no exception (done). - } - } - bool checked = f ? - (this->*f)(/* throw_on_failure = */ base_call_) : false; - if(base_call_) { - if(!checked) { - throw cond_subcontracting_::signal_not_checked(); - } - throw cond_subcontracting_::signal_no_error(); - } - } - } - - template<typename Bases> - typename boost::enable_if<boost::mpl::empty<Bases>, bool>::type - exec_or_bases() { return false; } - - template<typename Bases> - typename boost::disable_if<boost::mpl::empty<Bases>, bool>::type - exec_or_bases() { - if(boost::mpl::empty<Bases>::value) return false; - try { - call_base(*this)(typename boost::mpl::front<Bases>::type()); - } catch(cond_subcontracting_::signal_not_checked const&) { - return exec_or_bases< - typename boost::mpl::pop_front<Bases>::type>(); - } catch(...) { - bool checked = false; - try { - checked = exec_or_bases< - typename boost::mpl::pop_front<Bases>::type>(); - } catch(...) { checked = false; } - if(!checked) throw; - } - return true; - } - #endif - - #ifndef BOOST_CONTRACT_NO_CONDITIONS - class call_base { // Copyable (as &). - public: - explicit call_base(cond_subcontracting& me) : me_(me) {} - - template<class B> - void operator()(B*) { - BOOST_CONTRACT_DETAIL_DEBUG(me_.object()); - BOOST_CONTRACT_DETAIL_DEBUG(me_.v_); - BOOST_CONTRACT_DETAIL_DEBUG(me_.v_->action_ != - boost::contract::virtual_::no_action); - try { - call<B>(BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INDEXES_OF( - Args)); - } catch(cond_subcontracting_::signal_no_error const&) { - // No error (do not throw). - } - } - - private: - template< - class B - // Can't use TVARIADIC_COMMA here. - BOOST_PP_COMMA_IF(BOOST_CONTRACT_DETAIL_TVARIADIC) - BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INDEXES_TPARAM(I) - > - void call( - BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INDEXES_FPARAM(I)) { - O::template BOOST_CONTRACT_DETAIL_NAME1(call_base)<B>( - me_.v_, - me_.object() - BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA( - BOOST_CONTRACT_MAX_ARGS) - BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_ELEMS_Z(1, - BOOST_CONTRACT_MAX_ARGS, I, me_.args_) - ); - } - - cond_subcontracting& me_; - }; - #endif - - #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - VR& r_; - #endif - #ifndef BOOST_CONTRACT_NO_CONDITIONS - boost::contract::virtual_* v_; - bool base_call_; - BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_Z(1, - BOOST_CONTRACT_MAX_ARGS, Args, &, args_) - #endif -}; - -} } } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/config.hpp b/contrib/restricted/boost/boost/contract/detail/config.hpp deleted file mode 100644 index 1bd106e6d08..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/config.hpp +++ /dev/null @@ -1,26 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_CONFIG_HPP_ -#define BOOST_CONTRACT_DETAIL_CONFIG_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/preprocessor/cat.hpp> - -// Turn off BOOST_ASSERT(...) in lib's implementation (always on by default). -// BOOST_CONTRACT_DETAIL_NDEBUG - -#ifndef BOOST_CONTRACT_DETAIL_NAME_INFIX - // Do not use underscore "_" to avoid generating reserved names with "__". - #define BOOST_CONTRACT_DETAIL_NAME_INFIX X -#endif - -#ifndef BOOST_CONTRACT_DETAIL_NAME_PREFIX - #define BOOST_CONTRACT_DETAIL_NAME_PREFIX \ - BOOST_PP_CAT(boost_contract_detail, BOOST_CONTRACT_DETAIL_NAME_INFIX) -#endif - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/debug.hpp b/contrib/restricted/boost/boost/contract/detail/debug.hpp deleted file mode 100644 index 9fa580a5f81..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/debug.hpp +++ /dev/null @@ -1,20 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_DEBUG_HPP_ -#define BOOST_CONTRACT_DETAIL_DEBUG_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -// Usually, never #defined (so "debug" assertions always in code). -#ifdef BOOST_CONTRACT_DETAIL_NDEBUG - #define BOOST_CONTRACT_DETAIL_DEBUG(cond) /* nothing */ -#else - #include <boost/assert.hpp> - // Extra parenthesis around BOOST_ASSERT to be safe because its is a macro. - #define BOOST_CONTRACT_DETAIL_DEBUG(cond) (BOOST_ASSERT(cond)) -#endif - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/decl.hpp b/contrib/restricted/boost/boost/contract/detail/decl.hpp deleted file mode 100644 index aa84e2e16de..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/decl.hpp +++ /dev/null @@ -1,129 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_DECL_HPP_ -#define BOOST_CONTRACT_DETAIL_DECL_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -// Cannot include core/*.hpp other than config.hpp here (avoid circular incl). -#include <boost/contract/detail/tvariadic.hpp> -#if !BOOST_CONTRACT_DETAIL_TVARIADIC - #include <boost/contract/core/config.hpp> - #include <boost/preprocessor/repetition/repeat.hpp> - #include <boost/preprocessor/tuple/elem.hpp> - #include <boost/preprocessor/arithmetic/inc.hpp> -#endif -#include <boost/preprocessor/control/expr_iif.hpp> -#include <boost/preprocessor/control/iif.hpp> -#include <boost/preprocessor/punctuation/comma_if.hpp> - -/* PUBLIC */ - -#define BOOST_CONTRACT_DETAIL_DECL_OVERRIDING_PUBLIC_FUNCTION_Z(z, \ - arity, is_friend, has_result, \ - O, VR, F, C, Args, \ - v, r, f, obj, args \ -) \ - template< \ - class O \ - BOOST_PP_COMMA_IF(has_result) \ - BOOST_PP_EXPR_IIF(has_result, typename VR) \ - , typename F \ - , class C \ - BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(arity) \ - BOOST_CONTRACT_DETAIL_TVARIADIC_TPARAMS_Z(z, arity, Args) \ - > \ - BOOST_PP_EXPR_IIF(is_friend, friend) \ - boost::contract::specify_precondition_old_postcondition_except< \ - BOOST_PP_EXPR_IIF(has_result, VR)> \ - /* no boost::contract:: here for friends (otherwise need fwd decl) */ \ - public_function( \ - boost::contract::virtual_* v \ - BOOST_PP_COMMA_IF(has_result) \ - BOOST_PP_EXPR_IIF(has_result, VR& r) \ - , F f \ - , C* obj \ - BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(arity) \ - BOOST_CONTRACT_DETAIL_TVARIADIC_FPARAMS_Z(z, arity, Args, &, args) \ - ) - -#if BOOST_CONTRACT_DETAIL_TVARIADIC - #define BOOST_CONTRACT_DETAIL_DECL_FRIEND_OVERRIDING_PUBLIC_FUNCTIONS_Z(z, \ - O, VR, F, C, Args, \ - v, r, f, obj, args \ - ) \ - BOOST_CONTRACT_DETAIL_DECL_OVERRIDING_PUBLIC_FUNCTION_Z(z, \ - ~, /* is_friend = */ 1, /* has_result = */ 0, \ - O, VR, F, C, Args, v, r, f, obj, args \ - ); \ - BOOST_CONTRACT_DETAIL_DECL_OVERRIDING_PUBLIC_FUNCTION_Z(z, \ - ~, /* is_friend = */ 1, /* has_result = */ 1, \ - O, VR, F, C, Args, v, r, f, obj, args \ - ); -#else - /* PRIVATE */ - #define BOOST_CONTRACT_DETAIL_DECL_FRIEND_OVERRIDING_PUBLIC_FUNCTION_( \ - z, n, result_O_R_F_C_Args_v_r_f_obj_args) \ - BOOST_CONTRACT_DETAIL_DECL_OVERRIDING_PUBLIC_FUNCTION_Z(z, \ - /* arity = */ n, \ - /* is_friend = */ 1, \ - BOOST_PP_TUPLE_ELEM(11, 0, result_O_R_F_C_Args_v_r_f_obj_args), \ - BOOST_PP_TUPLE_ELEM(11, 1, result_O_R_F_C_Args_v_r_f_obj_args), \ - BOOST_PP_TUPLE_ELEM(11, 2, result_O_R_F_C_Args_v_r_f_obj_args), \ - BOOST_PP_TUPLE_ELEM(11, 3, result_O_R_F_C_Args_v_r_f_obj_args), \ - BOOST_PP_TUPLE_ELEM(11, 4, result_O_R_F_C_Args_v_r_f_obj_args), \ - BOOST_PP_TUPLE_ELEM(11, 5, result_O_R_F_C_Args_v_r_f_obj_args), \ - BOOST_PP_TUPLE_ELEM(11, 6, result_O_R_F_C_Args_v_r_f_obj_args), \ - BOOST_PP_TUPLE_ELEM(11, 7, result_O_R_F_C_Args_v_r_f_obj_args), \ - BOOST_PP_TUPLE_ELEM(11, 8, result_O_R_F_C_Args_v_r_f_obj_args), \ - BOOST_PP_TUPLE_ELEM(11, 9, result_O_R_F_C_Args_v_r_f_obj_args), \ - BOOST_PP_TUPLE_ELEM(11, 10, result_O_R_F_C_Args_v_r_f_obj_args) \ - ); - - /* PUBLIC */ - #define BOOST_CONTRACT_DETAIL_DECL_FRIEND_OVERRIDING_PUBLIC_FUNCTIONS_Z(z, \ - O, VR, F, C, Args, \ - v, r, f, obj, args \ - ) \ - BOOST_PP_REPEAT_ ## z( \ - BOOST_PP_INC(BOOST_CONTRACT_MAX_ARGS), \ - BOOST_CONTRACT_DETAIL_DECL_FRIEND_OVERRIDING_PUBLIC_FUNCTION_, \ - (/* has_result = */ 0, O, VR, F, C, Args, v, r, f, obj, args) \ - ) \ - BOOST_PP_REPEAT_ ## z( \ - BOOST_PP_INC(BOOST_CONTRACT_MAX_ARGS), \ - BOOST_CONTRACT_DETAIL_DECL_FRIEND_OVERRIDING_PUBLIC_FUNCTION_, \ - (/* has_result = */ 1, O, VR, F, C, Args, v, r, f, obj, args) \ - ) -#endif - -#define BOOST_CONTRACT_DETAIL_DECL_DETAIL_COND_SUBCONTRACTING_Z( \ - z, is_friend, O, VR, F, C, Args) \ - template< \ - class O, typename VR, typename F, class C \ - BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(BOOST_CONTRACT_MAX_ARGS) \ - BOOST_CONTRACT_DETAIL_TVARIADIC_TPARAMS_Z(z, \ - BOOST_CONTRACT_MAX_ARGS, Args) \ - > \ - BOOST_PP_IIF(is_friend, \ - friend class boost::contract::detail:: \ - , \ - class \ - ) \ - cond_subcontracting - -/* CODE */ - -namespace boost { - namespace contract { - class virtual_; - - template<typename VR = void> - class specify_precondition_old_postcondition_except; - } -} - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/declspec.hpp b/contrib/restricted/boost/boost/contract/detail/declspec.hpp deleted file mode 100644 index a1bfb5ceda0..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/declspec.hpp +++ /dev/null @@ -1,51 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_DECLSPEC_HPP_ -#define BOOST_CONTRACT_DETAIL_DECLSPEC_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -// IMPORTANT: Indirectly included by contract_macro.hpp so trivial headers only. -#include <boost/contract/core/config.hpp> // No compile-time overhead. -#include <boost/config.hpp> - -/* PUBLIC */ - -// IMPORTANT: In general, this library should always and only be compiled and -// used as a shared library. Otherwise, lib's state won't be shared among -// different user programs and user libraries. However, this library can be -// safely compiled and used as a static or header-only library only when it is -// being used by a single program unit (e.g., a single program with only -// statically linked libraries that check contracts). - -#ifdef BOOST_CONTRACT_DYN_LINK - #ifdef BOOST_CONTRACT_SOURCE - #define BOOST_CONTRACT_DETAIL_DECLSPEC BOOST_SYMBOL_EXPORT - #else - #define BOOST_CONTRACT_DETAIL_DECLSPEC BOOST_SYMBOL_IMPORT - #endif -#else - #define BOOST_CONTRACT_DETAIL_DECLSPEC /* nothing */ -#endif - -#ifdef BOOST_CONTRACT_HEADER_ONLY - #define BOOST_CONTRACT_DETAIL_DECLINLINE inline -#else - #define BOOST_CONTRACT_DETAIL_DECLINLINE /* nothing */ - - // Automatically link this lib to correct build variant (for MSVC, etc.). - #if !defined(BOOST_ALL_NO_LIB) && \ - !defined(BOOST_CONTRACT_NO_LIB) && \ - !defined(BOOST_CONTRACT_SOURCE) - #define BOOST_LIB_NAME boost_contract // This lib (static or shared). - #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_CONTRACT_DYN_LINK) - #define BOOST_DYN_LINK // This lib as shared. - #endif - #include <boost/config/auto_link.hpp> // Also #undef BOOST_LIB_NAME. - #endif -#endif - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/inlined.hpp b/contrib/restricted/boost/boost/contract/detail/inlined.hpp deleted file mode 100644 index 06c7167f103..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/inlined.hpp +++ /dev/null @@ -1,15 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_INLINED_HPP_ -#define BOOST_CONTRACT_DETAIL_INLINED_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/detail/inlined/old.hpp> -#include <boost/contract/detail/inlined/core/exception.hpp> -#include <boost/contract/detail/inlined/detail/checking.hpp> - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/inlined/core/exception.hpp b/contrib/restricted/boost/boost/contract/detail/inlined/core/exception.hpp deleted file mode 100644 index 8c3eb3ff959..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/inlined/core/exception.hpp +++ /dev/null @@ -1,502 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_INLINED_EXCEPTION_HPP_ -#define BOOST_CONTRACT_DETAIL_INLINED_EXCEPTION_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -// IMPORTANT: Do NOT use config macros BOOST_CONTRACT_... in this file so lib -// .cpp does not need recompiling if config changes (recompile only user code). - -#include <boost/contract/core/exception.hpp> -#include <boost/contract/detail/static_local_var.hpp> -#include <boost/contract/detail/declspec.hpp> -#include <boost/thread/lock_guard.hpp> -#include <boost/thread/mutex.hpp> -#include <boost/exception/diagnostic_information.hpp> -#include <boost/config.hpp> -#include <string> -#include <sstream> -#include <iostream> -#include <exception> - -namespace boost { namespace contract { - -BOOST_CONTRACT_DETAIL_DECLINLINE -exception::~exception() BOOST_NOEXCEPT_OR_NOTHROW {} - -BOOST_CONTRACT_DETAIL_DECLINLINE -bad_virtual_result_cast::bad_virtual_result_cast(char const* from_type_name, - char const* to_type_name) { - std::ostringstream text; - text - << "incompatible contracted virtual function result type " - << "conversion from '" << from_type_name << "' to '" - << to_type_name << "'" - ; - what_ = text.str(); -} - -BOOST_CONTRACT_DETAIL_DECLINLINE -bad_virtual_result_cast::~bad_virtual_result_cast() BOOST_NOEXCEPT_OR_NOTHROW {} - -BOOST_CONTRACT_DETAIL_DECLINLINE -char const* bad_virtual_result_cast::what() const BOOST_NOEXCEPT_OR_NOTHROW { - return what_.c_str(); -} - -BOOST_CONTRACT_DETAIL_DECLINLINE -assertion_failure::assertion_failure(char const* const file, - unsigned long const line, char const* const code) : - file_(file), line_(line), code_(code) -{ init(); } - -BOOST_CONTRACT_DETAIL_DECLINLINE -assertion_failure::assertion_failure(char const* const code) : - file_(""), line_(0), code_(code) -{ init(); } - -BOOST_CONTRACT_DETAIL_DECLINLINE -assertion_failure::~assertion_failure() BOOST_NOEXCEPT_OR_NOTHROW {} - -BOOST_CONTRACT_DETAIL_DECLINLINE -char const* assertion_failure::what() const BOOST_NOEXCEPT_OR_NOTHROW { - return what_.c_str(); -} - -BOOST_CONTRACT_DETAIL_DECLINLINE -char const* assertion_failure::file() const { return file_; } - -BOOST_CONTRACT_DETAIL_DECLINLINE -unsigned long assertion_failure::line() const { return line_; } - -BOOST_CONTRACT_DETAIL_DECLINLINE -char const* assertion_failure::code() const { return code_; } - -BOOST_CONTRACT_DETAIL_DECLINLINE -void assertion_failure::init() { - std::ostringstream text; - text << "assertion"; - if(std::string(code_) != "") text << " \"" << code_ << "\""; - text << " failed"; - if(std::string(file_) != "") { - text << ": file \"" << file_ << "\""; - if(line_ != 0) text << ", line " << line_; - } - what_ = text.str(); -} - -namespace exception_ { - enum failure_key { - check_failure_key, - pre_failure_key, - post_failure_key, - except_failure_key, - old_failure_key, - entry_inv_failure_key, - exit_inv_failure_key - }; - - template<failure_key Key> - void default_handler() { - std::string k = ""; - switch(Key) { - case check_failure_key: k = "check "; break; - case pre_failure_key: k = "precondition "; break; - case post_failure_key: k = "postcondition "; break; - case except_failure_key: k = "except "; break; - case old_failure_key: k = "old copy "; break; - case entry_inv_failure_key: k = "entry invariant "; break; - case exit_inv_failure_key: k = "exit invariant "; break; - // No default (so compiler warning/error on missing enum case). - } - try { throw; } - catch(boost::contract::assertion_failure const& error) { - // what = "assertion '...' failed: ...". - std::cerr << k << error.what() << std::endl; - } catch(...) { // old_failure_key prints this, not above. - std::cerr << k << "threw following exception:" << std::endl - << boost::current_exception_diagnostic_information(); - } - std::terminate(); // Default handlers log and call terminate. - } - - template<failure_key Key> - void default_from_handler(from) { default_handler<Key>(); } - - // Check failure. - - struct check_failure_mutex_tag; - typedef boost::contract::detail::static_local_var<check_failure_mutex_tag, - boost::mutex> check_failure_mutex; - - struct check_failure_handler_tag; - typedef boost::contract::detail::static_local_var_init< - check_failure_handler_tag, - failure_handler, - void (*)(), - &default_handler<check_failure_key> - > check_failure_handler; - - BOOST_CONTRACT_DETAIL_DECLINLINE - failure_handler const& set_check_failure_unlocked(failure_handler const& f) - BOOST_NOEXCEPT_OR_NOTHROW { - check_failure_handler::ref() = f; - return f; - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - failure_handler const& set_check_failure_locked(failure_handler const& f) - BOOST_NOEXCEPT_OR_NOTHROW { - boost::lock_guard<boost::mutex> lock(check_failure_mutex::ref()); - return set_check_failure_unlocked(f); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - failure_handler get_check_failure_unlocked() BOOST_NOEXCEPT_OR_NOTHROW { - return check_failure_handler::ref(); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - failure_handler get_check_failure_locked() BOOST_NOEXCEPT_OR_NOTHROW { - boost::lock_guard<boost::mutex> lock(check_failure_mutex::ref()); - return get_check_failure_unlocked(); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - void check_failure_unlocked() /* can throw */ { - check_failure_handler::ref()(); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - void check_failure_locked() /* can throw */ { - boost::lock_guard<boost::mutex> lock(check_failure_mutex::ref()); - check_failure_unlocked(); - } - - // Precondition failure. - - struct pre_failure_mutex_tag; - typedef boost::contract::detail::static_local_var<pre_failure_mutex_tag, - boost::mutex> pre_failure_mutex; - - struct pre_failure_handler_tag; - typedef boost::contract::detail::static_local_var_init< - pre_failure_handler_tag, - from_failure_handler, - void (*)(from), - &default_from_handler<pre_failure_key> - > pre_failure_handler; - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler const& set_pre_failure_unlocked(from_failure_handler - const& f) BOOST_NOEXCEPT_OR_NOTHROW { - pre_failure_handler::ref() = f; - return f; - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler const& set_pre_failure_locked(from_failure_handler - const& f) BOOST_NOEXCEPT_OR_NOTHROW { - boost::lock_guard<boost::mutex> lock(pre_failure_mutex::ref()); - return set_pre_failure_unlocked(f); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler get_pre_failure_unlocked() BOOST_NOEXCEPT_OR_NOTHROW { - return pre_failure_handler::ref(); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler get_pre_failure_locked() BOOST_NOEXCEPT_OR_NOTHROW { - boost::lock_guard<boost::mutex> lock(pre_failure_mutex::ref()); - return get_pre_failure_unlocked(); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - void pre_failure_unlocked(from where) /* can throw */ { - pre_failure_handler::ref()(where); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - void pre_failure_locked(from where) /* can throw */ { - boost::lock_guard<boost::mutex> lock(pre_failure_mutex::ref()); - pre_failure_unlocked(where); - } - - // Postcondition failure. - - struct post_failure_mutex_tag; - typedef boost::contract::detail::static_local_var<post_failure_mutex_tag, - boost::mutex> post_failure_mutex; - - struct post_failure_handler_tag; - typedef boost::contract::detail::static_local_var_init< - post_failure_handler_tag, - from_failure_handler, - void (*)(from), - &default_from_handler<post_failure_key> - > post_failure_handler; - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler const& set_post_failure_unlocked(from_failure_handler - const& f) BOOST_NOEXCEPT_OR_NOTHROW { - post_failure_handler::ref() = f; - return f; - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler const& set_post_failure_locked(from_failure_handler - const& f) BOOST_NOEXCEPT_OR_NOTHROW { - boost::lock_guard<boost::mutex> lock(post_failure_mutex::ref()); - return set_post_failure_unlocked(f); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler get_post_failure_unlocked() BOOST_NOEXCEPT_OR_NOTHROW { - return post_failure_handler::ref(); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler get_post_failure_locked() BOOST_NOEXCEPT_OR_NOTHROW { - boost::lock_guard<boost::mutex> lock(post_failure_mutex::ref()); - return get_post_failure_unlocked(); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - void post_failure_unlocked(from where) /* can throw */ { - post_failure_handler::ref()(where); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - void post_failure_locked(from where) /* can throw */ { - boost::lock_guard<boost::mutex> lock(post_failure_mutex::ref()); - post_failure_unlocked(where); - } - - // Except failure. - - struct except_failure_mutex_tag; - typedef boost::contract::detail::static_local_var<except_failure_mutex_tag, - boost::mutex> except_failure_mutex; - - struct except_failure_handler_tag; - typedef boost::contract::detail::static_local_var_init< - except_failure_handler_tag, - from_failure_handler, - void (*)(from), - &default_from_handler<except_failure_key> - > except_failure_handler; - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler const& set_except_failure_unlocked(from_failure_handler - const& f) BOOST_NOEXCEPT_OR_NOTHROW { - except_failure_handler::ref() = f; - return f; - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler const& set_except_failure_locked(from_failure_handler - const& f) BOOST_NOEXCEPT_OR_NOTHROW { - boost::lock_guard<boost::mutex> lock(except_failure_mutex::ref()); - return set_except_failure_unlocked(f); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler get_except_failure_unlocked() - BOOST_NOEXCEPT_OR_NOTHROW { - return except_failure_handler::ref(); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler get_except_failure_locked() BOOST_NOEXCEPT_OR_NOTHROW { - boost::lock_guard<boost::mutex> lock(except_failure_mutex::ref()); - return get_except_failure_unlocked(); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - void except_failure_unlocked(from where) /* can throw */ { - except_failure_handler::ref()(where); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - void except_failure_locked(from where) /* can throw */ { - boost::lock_guard<boost::mutex> lock(except_failure_mutex::ref()); - except_failure_unlocked(where); - } - - // Old-copy failure. - - struct old_failure_mutex_tag; - typedef boost::contract::detail::static_local_var<old_failure_mutex_tag, - boost::mutex> old_failure_mutex; - - struct old_failure_handler_tag; - typedef boost::contract::detail::static_local_var_init< - old_failure_handler_tag, - from_failure_handler, - void (*)(from), - &default_from_handler<old_failure_key> - > old_failure_handler; - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler const& set_old_failure_unlocked(from_failure_handler - const& f) BOOST_NOEXCEPT_OR_NOTHROW { - old_failure_handler::ref() = f; - return f; - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler const& set_old_failure_locked(from_failure_handler - const& f) BOOST_NOEXCEPT_OR_NOTHROW { - boost::lock_guard<boost::mutex> lock(old_failure_mutex::ref()); - return set_old_failure_unlocked(f); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler get_old_failure_unlocked() BOOST_NOEXCEPT_OR_NOTHROW { - return old_failure_handler::ref(); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler get_old_failure_locked() BOOST_NOEXCEPT_OR_NOTHROW { - boost::lock_guard<boost::mutex> lock(old_failure_mutex::ref()); - return get_old_failure_unlocked(); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - void old_failure_unlocked(from where) /* can throw */ { - old_failure_handler::ref()(where); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - void old_failure_locked(from where) /* can throw */ { - boost::lock_guard<boost::mutex> lock(old_failure_mutex::ref()); - old_failure_unlocked(where); - } - - // Entry invariant failure. - - struct entry_inv_failure_mutex_tag; - typedef boost::contract::detail::static_local_var< - entry_inv_failure_mutex_tag, boost::mutex> entry_inv_failure_mutex; - - struct entry_inv_failure_handler_tag; - typedef boost::contract::detail::static_local_var_init< - entry_inv_failure_handler_tag, - from_failure_handler, - void (*)(from), - &default_from_handler<entry_inv_failure_key> - > entry_inv_failure_handler; - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler const& set_entry_inv_failure_unlocked( - from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW { - entry_inv_failure_handler::ref() = f; - return f; - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler const& set_entry_inv_failure_locked( - from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW { - boost::lock_guard<boost::mutex> lock(entry_inv_failure_mutex::ref()); - return set_entry_inv_failure_unlocked(f); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler get_entry_inv_failure_unlocked() - BOOST_NOEXCEPT_OR_NOTHROW { - return entry_inv_failure_handler::ref(); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler get_entry_inv_failure_locked() - BOOST_NOEXCEPT_OR_NOTHROW { - boost::lock_guard<boost::mutex> lock(entry_inv_failure_mutex::ref()); - return get_entry_inv_failure_unlocked(); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - void entry_inv_failure_unlocked(from where) /* can throw */ { - entry_inv_failure_handler::ref()(where); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - void entry_inv_failure_locked(from where) /* can throw */ { - boost::lock_guard<boost::mutex> lock(entry_inv_failure_mutex::ref()); - entry_inv_failure_unlocked(where); - } - - // Exit invariant failure. - - struct exit_inv_failure_mutex_tag; - typedef boost::contract::detail::static_local_var< - exit_inv_failure_mutex_tag, boost::mutex> exit_inv_failure_mutex; - - struct exit_inv_failure_handler_tag; - typedef boost::contract::detail::static_local_var_init< - exit_inv_failure_handler_tag, - from_failure_handler, - void (*)(from), - &default_from_handler<exit_inv_failure_key> - > exit_inv_failure_handler; - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler const& set_exit_inv_failure_unlocked( - from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW { - exit_inv_failure_handler::ref() = f; - return f; - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler const& set_exit_inv_failure_locked( - from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW { - boost::lock_guard<boost::mutex> lock(exit_inv_failure_mutex::ref()); - return set_exit_inv_failure_unlocked(f); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler get_exit_inv_failure_unlocked() - BOOST_NOEXCEPT_OR_NOTHROW { - return exit_inv_failure_handler::ref(); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - from_failure_handler get_exit_inv_failure_locked() - BOOST_NOEXCEPT_OR_NOTHROW { - boost::lock_guard<boost::mutex> lock(exit_inv_failure_mutex::ref()); - return get_exit_inv_failure_unlocked(); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - void exit_inv_failure_unlocked(from where) /* can throw */ { - exit_inv_failure_handler::ref()(where); - } - - BOOST_CONTRACT_DETAIL_DECLINLINE - void exit_inv_failure_locked(from where) /* can throw */ { - boost::lock_guard<boost::mutex> lock(exit_inv_failure_mutex::ref()); - exit_inv_failure_unlocked(where); - } -} - -from_failure_handler const& set_entry_invariant_failure( - from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; - -from_failure_handler const& set_exit_invariant_failure( - from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW; - -BOOST_CONTRACT_DETAIL_DECLINLINE -from_failure_handler const& set_invariant_failure( - from_failure_handler const& f) BOOST_NOEXCEPT_OR_NOTHROW { - set_entry_invariant_failure(f); - set_exit_invariant_failure(f); - return f; -} - -} } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/inlined/detail/checking.hpp b/contrib/restricted/boost/boost/contract/detail/inlined/detail/checking.hpp deleted file mode 100644 index c0557af48b4..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/inlined/detail/checking.hpp +++ /dev/null @@ -1,49 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_INLINED_DETAIL_CHECKING_HPP_ -#define BOOST_CONTRACT_DETAIL_INLINED_DETAIL_CHECKING_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -// IMPORTANT: Do NOT use config macros BOOST_CONTRACT_... in this file so lib -// .cpp does not need recompiling if config changes (recompile only user code). - -#include <boost/contract/detail/checking.hpp> -#include <boost/contract/detail/declspec.hpp> -#include <boost/thread/lock_guard.hpp> - -namespace boost { namespace contract { namespace detail { - -BOOST_CONTRACT_DETAIL_DECLINLINE -void checking::init_unlocked() { flag::ref() = true; } - -BOOST_CONTRACT_DETAIL_DECLINLINE -void checking::init_locked() { - boost::lock_guard<boost::mutex> lock(mutex::ref()); - init_unlocked(); -} - -BOOST_CONTRACT_DETAIL_DECLINLINE -void checking::done_unlocked() { flag::ref() = false; } - -BOOST_CONTRACT_DETAIL_DECLINLINE -void checking::done_locked() { - boost::lock_guard<boost::mutex> lock(mutex::ref()); - done_unlocked(); -} - -BOOST_CONTRACT_DETAIL_DECLINLINE -bool checking::already_unlocked() { return flag::ref(); } - -BOOST_CONTRACT_DETAIL_DECLINLINE -bool checking::already_locked() { - boost::lock_guard<boost::mutex> lock(mutex::ref()); - return already_unlocked(); -} - -} } } // namespace - -#endif - diff --git a/contrib/restricted/boost/boost/contract/detail/inlined/old.hpp b/contrib/restricted/boost/boost/contract/detail/inlined/old.hpp deleted file mode 100644 index aaa2fe7826b..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/inlined/old.hpp +++ /dev/null @@ -1,34 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_INLINED_OLD_HPP_ -#define BOOST_CONTRACT_DETAIL_INLINED_OLD_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -// IMPORTANT: Do NOT use config macros BOOST_CONTRACT_... in this file so lib -// .cpp does not need recompiling if config changes (recompile only user code). - -#include <boost/contract/old.hpp> -#include <boost/contract/detail/declspec.hpp> - -namespace boost { namespace contract { - -BOOST_CONTRACT_DETAIL_DECLINLINE -old_value null_old() { return old_value(); } - -BOOST_CONTRACT_DETAIL_DECLINLINE -old_pointer make_old(old_value const& old) { - return old_pointer(0, old); -} - -BOOST_CONTRACT_DETAIL_DECLINLINE -old_pointer make_old(virtual_* v, old_value const& old) { - return old_pointer(v, old); -} - -} } // namespacd - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/name.hpp b/contrib/restricted/boost/boost/contract/detail/name.hpp deleted file mode 100644 index 5327357e615..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/name.hpp +++ /dev/null @@ -1,26 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_NAME_HPP_ -#define BOOST_CONTRACT_DETAIL_NAME_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/detail/config.hpp> -#include <boost/preprocessor/cat.hpp> - -/* PUBLIC */ - -// NOTE: Explicitly list number of names to concatenate using ..._NAME-n -// (instead of using ..._SEQ_CAT or similar) for optimal speed and reentrancy. - -#define BOOST_CONTRACT_DETAIL_NAME1(name1) \ - BOOST_PP_CAT(BOOST_CONTRACT_DETAIL_NAME_PREFIX, name1) - -#define BOOST_CONTRACT_DETAIL_NAME2(name1, name2) \ - BOOST_PP_CAT(BOOST_CONTRACT_DETAIL_NAME_PREFIX, BOOST_PP_CAT(name1, \ - BOOST_PP_CAT(BOOST_CONTRACT_DETAIL_NAME_INFIX, name2))) - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/none.hpp b/contrib/restricted/boost/boost/contract/detail/none.hpp deleted file mode 100644 index afbd3024e8a..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/none.hpp +++ /dev/null @@ -1,28 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_NONE_HPP_ -#define BOOST_CONTRACT_DETAIL_NONE_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -namespace boost { namespace contract { namespace detail { - -// Tag for "no type". -struct none { - // Some lib code use this to avoid unused local var warnings on #if, etc. - static none& value() { - static none none_value; - return none_value; - } -}; - -// Transform `void` to `none` type (for convenience, instead of using MPL). -template<typename T> struct none_if_void { typedef T type; }; -template<> struct none_if_void<void> { typedef none type; }; - -} } } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/noop.hpp b/contrib/restricted/boost/boost/contract/detail/noop.hpp deleted file mode 100644 index f3beabe246f..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/noop.hpp +++ /dev/null @@ -1,19 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_NOOP_HPP_ -#define BOOST_CONTRACT_DETAIL_NOOP_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -// Following must be expressions, not statements (as used with if.., etc.). - -#define BOOST_CONTRACT_DETAIL_NOOP ((void)0) - -// Following always compiles but never evaluates cond (so check correct syntax). -#define BOOST_CONTRACT_DETAIL_NOEVAL(cond) \ - (true || (cond) ? BOOST_CONTRACT_DETAIL_NOOP : BOOST_CONTRACT_DETAIL_NOOP) - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/operation/constructor.hpp b/contrib/restricted/boost/boost/contract/detail/operation/constructor.hpp deleted file mode 100644 index ce4d2de30c8..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/operation/constructor.hpp +++ /dev/null @@ -1,95 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_CONSTRUCTOR_HPP_ -#define BOOST_CONTRACT_DETAIL_CONSTRUCTOR_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/core/exception.hpp> -#include <boost/contract/core/config.hpp> -#include <boost/contract/detail/condition/cond_inv.hpp> -#include <boost/contract/detail/none.hpp> -#if !defined(BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION) && ( \ - !defined(BOOST_CONTRACT_NO_INVARIANTS) || \ - !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS)) - #include <boost/contract/detail/checking.hpp> -#endif -#if !defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) || \ - !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS) - #include <boost/config.hpp> - #include <exception> -#endif - -namespace boost { namespace contract { namespace detail { - -// Ctor subcontracting impl via C++ obj construction mechanism. -template<class C> // Non-copyable base. -class constructor : public cond_inv</* VR = */ none, C> { -public: - explicit constructor(C* obj) : cond_inv</* VR = */ none, C>( - boost::contract::from_constructor, obj) {} - -private: - #if !defined(BOOST_CONTRACT_NO_ENTRY_INVARIANTS) || \ - !defined(BOOST_CONTRACT_NO_OLDS) - void init() /* override */ { - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - if(checking::already()) return; - #endif - - #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS - { - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - checking k; - #endif - this->check_entry_static_inv(); - // No object before ctor body so check only static inv at - // entry. Ctor pre checked by constructor_precondition. - } - #endif - #ifndef BOOST_CONTRACT_NO_OLDS - this->copy_old(); - #endif - } - #endif - -public: - #if !defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) || \ - !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS) - ~constructor() BOOST_NOEXCEPT_IF(false) { - this->assert_initialized(); - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - if(checking::already()) return; - checking k; - #endif - - // If ctor body threw, no obj so check only static inv. Otherwise, - // obj constructed so check static inv, non-static inv, and post. - if(std::uncaught_exception()) { - #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS - this->check_exit_static_inv(); - #endif - #ifndef BOOST_CONTRACT_NO_EXCEPTS - this->check_except(); - #endif - } else { - #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS - this->check_exit_all_inv(); - #endif - #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - this->check_post(none()); - #endif - } - } - #endif -}; - -} } } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/operation/destructor.hpp b/contrib/restricted/boost/boost/contract/detail/operation/destructor.hpp deleted file mode 100644 index ea8d8780a1b..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/operation/destructor.hpp +++ /dev/null @@ -1,102 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_DESTRUCTOR_HPP_ -#define BOOST_CONTRACT_DETAIL_DESTRUCTOR_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/core/exception.hpp> -#include <boost/contract/core/config.hpp> -#include <boost/contract/detail/condition/cond_inv.hpp> -#include <boost/contract/detail/none.hpp> -#if !defined(BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION) && ( \ - !defined(BOOST_CONTRACT_NO_INVARIANTS) || \ - !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS)) - #include <boost/contract/detail/checking.hpp> -#endif -#if !defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) || \ - !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS) - #include <boost/config.hpp> - #include <exception> -#endif - -namespace boost { namespace contract { namespace detail { - -// Dtor subcontracting impl via C++ obj destruction mechanism. -template<class C> // Non-copyable base. -class destructor : public cond_inv</* VR = */ none, C> { -public: - explicit destructor(C* obj) : cond_inv</* VR = */ none, C>( - boost::contract::from_destructor, obj) {} - -private: - #if !defined(BOOST_CONTRACT_NO_ENTRY_INVARIANTS) || \ - !defined(BOOST_CONTRACT_NO_OLDS) - void init() /* override */ { - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - if(checking::already()) return; - #endif - - #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS - { - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - checking k; - #endif - // Obj exists (before dtor body), check static and non- inv. - this->check_entry_all_inv(); - // Dtor cannot have pre because it has no parameters. - } - #endif - #ifndef BOOST_CONTRACT_NO_OLDS - this->copy_old(); - #endif - } - #endif - -public: - #if !defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) || \ - !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS) - ~destructor() BOOST_NOEXCEPT_IF(false) { - this->assert_initialized(); - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - if(checking::already()) return; - checking k; - #endif - - // If dtor body threw, obj still exists so check subcontracted - // static and non- inv (but no post because of throw). Otherwise, - // obj destructed so check static inv and post (even if there is no - // obj after dtor body, this library allows dtor post, for example - // to check static members for an instance counter class). - // NOTE: In theory C++ destructors should not throw, but the - // language allows for that (even if in C++11 dtors declarations are - // implicitly noexcept(true) unless specified otherwise) so this - // library must handle such a case. - if(std::uncaught_exception()) { - #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS - this->check_exit_all_inv(); - #endif - #ifndef BOOST_CONTRACT_NO_EXCEPTS - this->check_except(); - #endif - } else { - #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS - this->check_exit_static_inv(); - #endif - #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - this->check_post(none()); - #endif - } - } - #endif -}; - -} } } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/operation/function.hpp b/contrib/restricted/boost/boost/contract/detail/operation/function.hpp deleted file mode 100644 index db0503c33bb..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/operation/function.hpp +++ /dev/null @@ -1,82 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_FUNCTION_HPP_ -#define BOOST_CONTRACT_DETAIL_FUNCTION_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/core/exception.hpp> -#include <boost/contract/core/config.hpp> -#include <boost/contract/detail/condition/cond_post.hpp> -#if !defined(BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION) && ( \ - !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS)) - #include <boost/contract/detail/checking.hpp> -#endif -#if !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS) - #include <boost/config.hpp> - #include <exception> -#endif - -namespace boost { namespace contract { namespace detail { - -// Used for free function, private and protected member functions. -class function : public cond_post</* VR = */ none> { // Non-copyable base. -public: - explicit function() : cond_post</* VR = */ none>( - boost::contract::from_function) {} - -private: - #if !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_OLDS) - void init() /* override */ { - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - if(checking::already()) return; - #endif - #ifndef BOOST_CONTRACT_NO_PRECONDITIONS - { - #if !defined(BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION) && \ - !defined( \ - BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION) - checking k; - #endif - this->check_pre(); - } - #endif - #ifndef BOOST_CONTRACT_NO_OLDS - this->copy_old(); - #endif - } - #endif - -public: - #if !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS) - ~function() BOOST_NOEXCEPT_IF(false) { - this->assert_initialized(); - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - if(checking::already()) return; - checking k; - #endif - - if(std::uncaught_exception()) { - #ifndef BOOST_CONTRACT_NO_EXCEPTS - this->check_except(); - #endif - } else { - #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - this->check_post(none()); - #endif - } - } - #endif -}; - -} } } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/operation/public_function.hpp b/contrib/restricted/boost/boost/contract/detail/operation/public_function.hpp deleted file mode 100644 index 6392e4ddbe1..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/operation/public_function.hpp +++ /dev/null @@ -1,161 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_PUBLIC_FUNCTION_HPP_ -#define BOOST_CONTRACT_DETAIL_PUBLIC_FUNCTION_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/core/virtual.hpp> -#include <boost/contract/core/exception.hpp> -#include <boost/contract/core/config.hpp> -#include <boost/contract/detail/condition/cond_subcontracting.hpp> -#include <boost/contract/detail/tvariadic.hpp> -#include <boost/contract/core/virtual.hpp> -#if !defined(BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION) && ( \ - !defined(BOOST_CONTRACT_NO_INVARIANTS) || \ - !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS)) - #include <boost/contract/detail/checking.hpp> -#endif -#if !defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) || \ - !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS) - #include <boost/config.hpp> -#endif -#if !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS) - #include <exception> -#endif - -namespace boost { namespace contract { namespace detail { - -template< - class O, typename VR, typename F, class C - BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(BOOST_CONTRACT_MAX_ARGS) - BOOST_CONTRACT_DETAIL_TVARIADIC_TPARAMS_Z(1, BOOST_CONTRACT_MAX_ARGS, Args) -> -class public_function : // Non-copyable base. - public cond_subcontracting< - O, VR, F, C - BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(BOOST_CONTRACT_MAX_ARGS) - BOOST_CONTRACT_DETAIL_TVARIADIC_ARGS_Z(1, BOOST_CONTRACT_MAX_ARGS, Args) - > -{ -public: - explicit public_function( - boost::contract::virtual_* v, C* obj, VR& r - BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(BOOST_CONTRACT_MAX_ARGS) - BOOST_CONTRACT_DETAIL_TVARIADIC_FPARAMS_Z(1, - BOOST_CONTRACT_MAX_ARGS, Args, &, args) - ) : - cond_subcontracting< - O, VR, F, C - BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(BOOST_CONTRACT_MAX_ARGS) - BOOST_CONTRACT_DETAIL_TVARIADIC_ARGS_Z(1, - BOOST_CONTRACT_MAX_ARGS, Args) - >( - boost::contract::from_function, v, obj, r - BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(BOOST_CONTRACT_MAX_ARGS) - BOOST_CONTRACT_DETAIL_TVARIADIC_ARGS_Z(1, - BOOST_CONTRACT_MAX_ARGS, args) - ) - {} - -private: - #if !defined(BOOST_CONTRACT_NO_INVARIANTS) || \ - !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS) - void init() /* override */ { - #if !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS) - this->init_subcontracted_old(); - #endif - if(!this->base_call()) { - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - if(checking::already()) return; - #endif - { // Acquire checking guard. - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - checking k; - #endif - #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS - this->check_subcontracted_entry_inv(); - #endif - #ifndef BOOST_CONTRACT_NO_PRECONDITIONS - #ifndef \ - BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION - this->check_subcontracted_pre(); - } // Release checking guard (after pre check). - #else - } // Release checking guard (before pre check). - this->check_subcontracted_pre(); - #endif - #else - } // Release checking guard. - #endif - #ifndef BOOST_CONTRACT_NO_OLDS - this->copy_subcontracted_old(); - #endif - } else { - #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS - this->check_subcontracted_entry_inv(); - #endif - #ifndef BOOST_CONTRACT_NO_PRECONDITIONS - this->check_subcontracted_pre(); - #endif - #ifndef BOOST_CONTRACT_NO_OLDS - this->copy_subcontracted_old(); - #endif - #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS - this->check_subcontracted_exit_inv(); - #endif - if(std::uncaught_exception()) { - #ifndef BOOST_CONTRACT_NO_EXCEPTS - this->check_subcontracted_except(); - #endif - } else { - #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - this->check_subcontracted_post(); - #endif - } - } - } - #endif - -public: - #if !defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) || \ - !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS) - ~public_function() BOOST_NOEXCEPT_IF(false) { - this->assert_initialized(); - if(!this->base_call()) { - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - if(checking::already()) return; - checking k; - #endif - - #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS - this->check_subcontracted_exit_inv(); - #endif - if(std::uncaught_exception()) { - #ifndef BOOST_CONTRACT_NO_EXCEPTS - this->check_subcontracted_except(); - #endif - } else { - #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - this->check_subcontracted_post(); - #endif - } - } - } - #endif -}; - -} } } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/operation/static_public_function.hpp b/contrib/restricted/boost/boost/contract/detail/operation/static_public_function.hpp deleted file mode 100644 index d49fcd091d3..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/operation/static_public_function.hpp +++ /dev/null @@ -1,103 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_STATIC_PUBLIC_FUNCTION_HPP_ -#define BOOST_CONTRACT_DETAIL_STATIC_PUBLIC_FUNCTION_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/core/exception.hpp> -#include <boost/contract/core/config.hpp> -#include <boost/contract/detail/condition/cond_inv.hpp> -#include <boost/contract/detail/none.hpp> -#if !defined(BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION) && ( \ - !defined(BOOST_CONTRACT_NO_INVARIANTS) || \ - !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS)) - #include <boost/contract/detail/checking.hpp> -#endif -#if !defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) || \ - !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS) - #include <boost/config.hpp> - #include <exception> -#endif - -namespace boost { namespace contract { namespace detail { - -// No subcontracting because static so no obj and no substitution principle. -template<class C> // Non-copyable base. -class static_public_function : public cond_inv</* VR = */ none, C> { -public: - explicit static_public_function() : cond_inv</* VR = */ none, C>( - boost::contract::from_function, /* obj = */ 0) {} - -private: - #if !defined(BOOST_CONTRACT_NO_ENTRY_INVARIANTS) || \ - !defined(BOOST_CONTRACT_NO_PRECONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_OLDS) - void init() /* override */ { - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - if(checking::already()) return; - #endif - #if !defined(BOOST_CONTRACT_NO_ENTRY_INVARIANTS) || \ - !defined(BOOST_CONTRACT_NO_PRECONDITIONS) - { // Acquire checking guard. - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - checking k; - #endif - #ifndef BOOST_CONTRACT_NO_ENTRY_INVARIANTS - this->check_entry_static_inv(); - #endif - #ifndef BOOST_CONTRACT_NO_PRECONDITIONS - #ifndef \ - BOOST_CONTRACT_PRECONDITIONS_DISABLE_NO_ASSERTION - this->check_pre(); - } // Release checking guard (after pre check). - #else - } // Release checking guard (before pre check). - this->check_pre(); - #endif - #else - } // Release checking guard - #endif - #endif - #ifndef BOOST_CONTRACT_NO_OLDS - this->copy_old(); - #endif - } - #endif - -public: - #if !defined(BOOST_CONTRACT_NO_EXIT_INVARIANTS) || \ - !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) || \ - !defined(BOOST_CONTRACT_NO_EXCEPTS) - ~static_public_function() BOOST_NOEXCEPT_IF(false) { - this->assert_initialized(); - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - if(checking::already()) return; - checking k; - #endif - - #ifndef BOOST_CONTRACT_NO_EXIT_INVARIANTS - this->check_exit_static_inv(); - #endif - if(std::uncaught_exception()) { - #ifndef BOOST_CONTRACT_NO_EXCEPTS - this->check_except(); - #endif - } else { - #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - this->check_post(none()); - #endif - } - } - #endif -}; - -} } } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/operator_safe_bool.hpp b/contrib/restricted/boost/boost/contract/detail/operator_safe_bool.hpp deleted file mode 100644 index 65edc32dd81..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/operator_safe_bool.hpp +++ /dev/null @@ -1,73 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL_HPP_ -#define BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/detail/name.hpp> -#include <boost/config.hpp> -#include <boost/detail/workaround.hpp> - -// NOTE: This code is inspired by <boost/shared_ptr/detail/operator_bool.hpp>. - -/* PRIVATE */ - -// operator! is redundant, but some compilers need it. -#define BOOST_CONTRACT_OPERATOR_SAFE_BOOL_NOT_(bool_expr) \ - bool operator!() const BOOST_NOEXCEPT { return !(bool_expr); } - -/* PUBLIC */ - -#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) && \ - !defined(BOOST_NO_CXX11_NULLPTR) - #define BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL(this_type, bool_expr) \ - explicit operator bool() const BOOST_NOEXCEPT { return (bool_expr); } \ - BOOST_CONTRACT_OPERATOR_SAFE_BOOL_NOT_(bool_expr) -#elif (defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570) ) || \ - defined(__CINT__) - #define BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL(this_type, bool_expr) \ - operator bool() const BOOST_NOEXCEPT { return (bool_expr); } \ - BOOST_CONTRACT_OPERATOR_SAFE_BOOL_NOT_(bool_expr) -#elif defined(_MANAGED) - #define BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL(this_type, bool_expr) \ - static void BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_func)( \ - this_type***) {} \ - typedef void (*BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_type))( \ - this_type***); \ - operator BOOST_CONTRACT_DETAIL_NANE(operator_safe_bool_type)() \ - const BOOST_NOEXCEPT { \ - return (bool_expr) ? \ - &BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_func) : 0; \ - } \ - BOOST_CONTRACT_OPERATOR_SAFE_BOOL_NOT_(bool_expr) -#elif (defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, < 0x3200)) || \ - (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304)) || \ - (defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590)) - #define BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL(this_type, bool_expr) \ - void BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_func)() const {} \ - typedef void (this_type::*BOOST_CONTRACT_DETAIL_NAME1( \ - operator_safe_bool_type))() const; \ - operator BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_type)() \ - const BOOST_NOEXCEPT { \ - return (bool_expr) ? &this_type:: \ - BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_func) : 0; \ - } \ - BOOST_CONTRACT_OPERATOR_SAFE_BOOL_NOT_(bool_expr) -#else - #define BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL(this_type, bool_expr) \ - void* BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_data); \ - typedef void* this_type::*BOOST_CONTRACT_DETAIL_NAME1( \ - operator_safe_bool_type);\ - operator BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_type)() \ - const BOOST_NOEXCEPT { \ - return (bool_expr) ? &this_type:: \ - BOOST_CONTRACT_DETAIL_NAME1(operator_safe_bool_data) : 0; \ - } \ - BOOST_CONTRACT_OPERATOR_SAFE_BOOL_NOT_(bool_expr) -#endif - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/preprocessor/keyword/private.hpp b/contrib/restricted/boost/boost/contract/detail/preprocessor/keyword/private.hpp deleted file mode 100644 index 2fc0d853f48..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/preprocessor/keyword/private.hpp +++ /dev/null @@ -1,35 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_PP_KEYWORD_PRIVATE_HPP_ -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_PRIVATE_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/detail/preprocessor/keyword/utility/is.hpp> -#include <boost/preprocessor/cat.hpp> - -/* PRIVATE */ - -// Must expand to a single comma `,` (not local macros, do not #undefine). -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_PRIVATE_CAT_TO_COMMAprivate , - -// Must expand to empty `` (not local macros, do not #undefine). -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_PRIVATE_CAT_TO_EMPTYprivate - -/* PUBLIC */ - -// Precondition: tokens must start with a token concatenable to a macro name -// (e.g., a literal or integral token). -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_IS_PRIVATE(tokens) \ - BOOST_CONTRACT_DETAIL_PP_KEYWORD_UTILITY_IS( \ - BOOST_CONTRACT_DETAIL_PP_KEYWORD_PRIVATE_CAT_TO_COMMA, tokens) - -// Precondition: tokens must start with `private` (this can be -// checked with `..._IS_PRIVATE` macro above). -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_REMOVE_PRIVATE(tokens) \ - BOOST_PP_CAT(BOOST_CONTRACT_DETAIL_PP_KEYWORD_PRIVATE_CAT_TO_EMPTY, tokens) - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/preprocessor/keyword/protected.hpp b/contrib/restricted/boost/boost/contract/detail/preprocessor/keyword/protected.hpp deleted file mode 100644 index e9ac94e78c6..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/preprocessor/keyword/protected.hpp +++ /dev/null @@ -1,36 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_PP_KEYWORD_PROTECTED_HPP_ -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_PROTECTED_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/detail/preprocessor/keyword/utility/is.hpp> -#include <boost/preprocessor/cat.hpp> - -/* PRIVATE */ - -// Must expand to a single comma `,` (not local macros, do not #undefine). -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_PROTECTED_CAT_TO_COMMAprotected , - -// Must expand to empty `` (not local macros, do not #undefine). -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_PROTECTED_CAT_TO_EMPTYprotected - -/* PUBLIC */ - -// Precondition: tokens must start with a token concatenable to a macro name -// (e.g., a literal or integral token). -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_IS_PROTECTED(tokens) \ - BOOST_CONTRACT_DETAIL_PP_KEYWORD_UTILITY_IS( \ - BOOST_CONTRACT_DETAIL_PP_KEYWORD_PROTECTED_CAT_TO_COMMA, tokens) - -// Precondition: tokens must start with `protected` (this can be -// checked with `..._IS_PROTECTED` macro above). -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_REMOVE_PROTECTED(tokens) \ - BOOST_PP_CAT(BOOST_CONTRACT_DETAIL_PP_KEYWORD_PROTECTED_CAT_TO_EMPTY, \ - tokens) - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/preprocessor/keyword/public.hpp b/contrib/restricted/boost/boost/contract/detail/preprocessor/keyword/public.hpp deleted file mode 100644 index b5e79946101..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/preprocessor/keyword/public.hpp +++ /dev/null @@ -1,35 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_PP_KEYWORD_PUBLIC_HPP_ -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_PUBLIC_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/detail/preprocessor/keyword/utility/is.hpp> -#include <boost/preprocessor/cat.hpp> - -/* PRIVATE */ - -// Must expand to a single comma `,` (not local macros, do not #undefine). -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_PUBLIC_CAT_TO_COMMApublic , - -// Must expand to empty `` (not local macros, do not #undefine). -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_PUBLIC_CAT_TO_EMPTYpublic - -/* PUBLIC */ - -// Precondition: tokens must start with a token concatenable to a macro name -// (e.g., a literal or integral token). -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_IS_PUBLIC(tokens) \ - BOOST_CONTRACT_DETAIL_PP_KEYWORD_UTILITY_IS( \ - BOOST_CONTRACT_DETAIL_PP_KEYWORD_PUBLIC_CAT_TO_COMMA, tokens) - -// Precondition: tokens must start with `public` (this can be -// checked with `..._IS_PUBLIC` macro above). -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_REMOVE_PUBLIC(tokens) \ - BOOST_PP_CAT(BOOST_CONTRACT_DETAIL_PP_KEYWORD_PUBLIC_CAT_TO_EMPTY, tokens) - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/preprocessor/keyword/utility/is.hpp b/contrib/restricted/boost/boost/contract/detail/preprocessor/keyword/utility/is.hpp deleted file mode 100644 index d786033544c..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/preprocessor/keyword/utility/is.hpp +++ /dev/null @@ -1,30 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_PP_KEYWORD_UTILITY_IS_HPP_ -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_UTILITY_IS_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/preprocessor/cat.hpp> -#include <boost/preprocessor/variadic/size.hpp> - -/* PRIVATE */ - -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_UTILITY_IS_1 0 -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_UTILITY_IS_2 1 - -/* PUBLIC */ - -// Precondition: A macro named `cat_to_comma_prefix ## token-to-check` must be -// #defined to expand to `,`. -// Precondition: tokens must start with a token concatenable to a macro name -// (e.g., a literal or integral token). -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_UTILITY_IS( \ - cat_to_comma_prefix, tokens) \ - BOOST_PP_CAT(BOOST_CONTRACT_DETAIL_PP_KEYWORD_UTILITY_IS_, \ - BOOST_PP_VARIADIC_SIZE(BOOST_PP_CAT(cat_to_comma_prefix, tokens))) - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/preprocessor/keyword/virtual.hpp b/contrib/restricted/boost/boost/contract/detail/preprocessor/keyword/virtual.hpp deleted file mode 100644 index 2acfaa1de3f..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/preprocessor/keyword/virtual.hpp +++ /dev/null @@ -1,35 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_PP_KEYWORD_VIRTUAL_HPP_ -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_VIRTUAL_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/detail/preprocessor/keyword/utility/is.hpp> -#include <boost/preprocessor/cat.hpp> - -/* PRIVATE */ - -// Must expand to a single comma `,` (not local macros, do not #undefine). -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_VIRTUAL_CAT_TO_COMMAvirtual , - -// Must expand to empty `` (not local macros, do not #undefine). -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_VIRTUAL_CAT_TO_EMPTYvirtual - -/* PUBLIC */ - -// Precondition: tokens must start with a token concatenable to a macro name -// (e.g., a literal or integral token). -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_IS_VIRTUAL(tokens) \ - BOOST_CONTRACT_DETAIL_PP_KEYWORD_UTILITY_IS( \ - BOOST_CONTRACT_DETAIL_PP_KEYWORD_VIRTUAL_CAT_TO_COMMA, tokens) - -// Precondition: tokens must start with `virtual` (this can be -// checked with `..._IS_VIRTUAL` macro above). -#define BOOST_CONTRACT_DETAIL_PP_KEYWORD_REMOVE_VIRTUAL(tokens) \ - BOOST_PP_CAT(BOOST_CONTRACT_DETAIL_PP_KEYWORD_VIRTUAL_CAT_TO_EMPTY, tokens) - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/static_local_var.hpp b/contrib/restricted/boost/boost/contract/detail/static_local_var.hpp deleted file mode 100644 index 53495a089ad..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/static_local_var.hpp +++ /dev/null @@ -1,41 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_STATIC_LOCAL_VAR_HPP_ -#define BOOST_CONTRACT_DETAIL_STATIC_LOCAL_VAR_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -namespace boost { namespace contract { namespace detail { - -// This is used to hold the state of this library (already checking assertions, -// failure handers, mutexes, etc.). Local static variables are used instead of -// global or class-level static variables to avoid ODR errors when this library -// is used as header-only. - -// Use T's default constructor to init the local var. -template<typename Tag, typename T> -struct static_local_var { - static T& ref() { - static T data; - return data; - } -}; - -// Use `init` param to init local var (Init same as or convertible to T). -// NOTE: Template specializations could be used to program both this and the -// template above together but some pre-C++11 compilers give errors (e.g., Clang -// without -std=c++11), plus the `_init` postfix is more readable at call site. -template<typename Tag, typename T, typename Init, Init init> -struct static_local_var_init { - static T& ref() { - static T data = init; - return data; - } -}; - -} } } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/tvariadic.hpp b/contrib/restricted/boost/boost/contract/detail/tvariadic.hpp deleted file mode 100644 index 3172d0972b8..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/tvariadic.hpp +++ /dev/null @@ -1,190 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_TVARIADIC_HPP_ -#define BOOST_CONTRACT_DETAIL_TVARIADIC_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/config.hpp> -#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES - #define BOOST_CONTRACT_DETAIL_TVARIADIC 0 -#else - #define BOOST_CONTRACT_DETAIL_TVARIADIC 1 -#endif - -#if BOOST_CONTRACT_DETAIL_TVARIADIC - #include <tuple> - - /* CODE */ - - namespace boost { namespace contract { namespace detail { - namespace tvariadic_ { - template<int...> struct indexes {}; - - template<int N, int... I> struct indexes_of : - indexes_of<N - 1, N - 1, I...> {}; - template<int... I> struct indexes_of<0, I...> - { typedef indexes<I...> type; }; - } } } } // namespace - -#else - #include <boost/preprocessor/repetition/enum.hpp> - #include <boost/preprocessor/repetition/repeat.hpp> - #include <boost/preprocessor/tuple/elem.hpp> - #include <boost/preprocessor/punctuation/comma_if.hpp> - #include <boost/preprocessor/cat.hpp> - - /* PRIVATE */ - - #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_ELEM_(z, n, tuple) \ - BOOST_PP_CAT(tuple, n) - - #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INIT_(z, n, tuplevar_values) \ - BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 0, tuplevar_values), n)( \ - BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 1, tuplevar_values), n)) - - #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_(z, n, type_qualifier_name) \ - BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(3, 0, type_qualifier_name), n) \ - BOOST_PP_TUPLE_ELEM(3, 1, type_qualifier_name) \ - BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(3, 2, type_qualifier_name), n) \ - ; - - #define BOOST_CONTRACT_DETAIL_NO_TVARIADIC_ENUM_(z, n, tokens) \ - tokens - - #define BOOST_CONTRACT_DETAIL_TVARIADIC_ARG_(z, n, name) \ - BOOST_PP_CAT(name, n) - - #define BOOST_CONTRACT_DETAIL_TVARIADIC_FPARAM_(z, n, type_qualifier_name) \ - BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(3, 0, type_qualifier_name), n) \ - BOOST_PP_TUPLE_ELEM(3, 1, type_qualifier_name) \ - BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(3, 2, type_qualifier_name), n) - - #define BOOST_CONTRACT_DETAIL_TVARIADIC_TPARAM_(z, n, name) \ - typename BOOST_PP_CAT(name, n) -#endif - -/* PUBLIC */ - -#if BOOST_CONTRACT_DETAIL_TVARIADIC - #define BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(arity) \ - , -#else - #define BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(arity) \ - BOOST_PP_COMMA_IF(arity) -#endif - -#if BOOST_CONTRACT_DETAIL_TVARIADIC - #define BOOST_CONTRACT_DETAIL_NO_TVARIADIC_COMMA(arity) /* nothing */ -#else - #define BOOST_CONTRACT_DETAIL_NO_TVARIADIC_COMMA(arity) \ - BOOST_PP_COMMA_IF(arity) -#endif - -#if BOOST_CONTRACT_DETAIL_TVARIADIC - #define BOOST_CONTRACT_DETAIL_TVARIADIC_SIZEOF(arity, name) sizeof...(name) -#else - #define BOOST_CONTRACT_DETAIL_TVARIADIC_SIZEOF(arity, name) arity -#endif - -#if BOOST_CONTRACT_DETAIL_TVARIADIC - #define BOOST_CONTRACT_DETAIL_TVARIADIC_TPARAMS_Z(z, arity, name) \ - typename... name -#else - #define BOOST_CONTRACT_DETAIL_TVARIADIC_TPARAMS_Z(z, arity, name) \ - BOOST_PP_ENUM_ ## z(arity, BOOST_CONTRACT_DETAIL_TVARIADIC_TPARAM_, \ - name) -#endif - -#if BOOST_CONTRACT_DETAIL_TVARIADIC - #define BOOST_CONTRACT_DETAIL_TVARIADIC_FPARAMS_Z( \ - z, arity, type, qualifier, name) \ - type qualifier ... name -#else - #define BOOST_CONTRACT_DETAIL_TVARIADIC_FPARAMS_Z( \ - z, arity, type, qualifier, name) \ - BOOST_PP_ENUM_ ## z(arity, BOOST_CONTRACT_DETAIL_TVARIADIC_FPARAM_, \ - (type, qualifier, name)) -#endif - -#if BOOST_CONTRACT_DETAIL_TVARIADIC - #define BOOST_CONTRACT_DETAIL_TVARIADIC_ARGS_Z(z, arity, name) \ - name... -#else - #define BOOST_CONTRACT_DETAIL_TVARIADIC_ARGS_Z(z, arity, name) \ - BOOST_PP_ENUM_ ## z(arity, BOOST_CONTRACT_DETAIL_TVARIADIC_ARG_, name) -#endif - -#if BOOST_CONTRACT_DETAIL_TVARIADIC - #define BOOST_CONTRACT_DETAIL_NO_TVARIADIC_ENUM_Z(z, arity, tokens) \ - /* nothing */ -#else - #define BOOST_CONTRACT_DETAIL_NO_TVARIADIC_ENUM_Z(z, arity, tokens) \ - BOOST_PP_ENUM_ ## z(arity, BOOST_CONTRACT_DETAIL_NO_TVARIADIC_ENUM_, \ - tokens) -#endif - -// Tuple. - -#if BOOST_CONTRACT_DETAIL_TVARIADIC - #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_Z( \ - z, arity, type, qualifier, name) \ - std::tuple<type qualifier ...> name; -#else - #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_Z( \ - z, arity, type, qualifier, name) \ - BOOST_PP_REPEAT_ ## z(arity, BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_, \ - (type, qualifier, name)) -#endif - -#if BOOST_CONTRACT_DETAIL_TVARIADIC - #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INIT_Z(z, \ - arity, tuple, values) \ - tuple(values...) -#else - #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INIT_Z(z, \ - arity, tuple, values) \ - BOOST_PP_ENUM_ ## z(arity, BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INIT_,\ - (tuple, values)) -#endif - -#if BOOST_CONTRACT_DETAIL_TVARIADIC - #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INDEXES_TPARAM(indexes) \ - int... indexes -#else - #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INDEXES_TPARAM(indexes) \ - /* nothing */ -#endif - -#if BOOST_CONTRACT_DETAIL_TVARIADIC - #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INDEXES_FPARAM(_indexes) \ - boost::contract::detail::tvariadic_::indexes<_indexes...> -#else - #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INDEXES_FPARAM(_indexes) \ - /* nothing */ -#endif - -#if BOOST_CONTRACT_DETAIL_TVARIADIC - #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INDEXES_OF(tuple_type) \ - typename boost::contract::detail::tvariadic_::indexes_of< \ - sizeof...(tuple_type)>::type() -#else - #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_INDEXES_OF(unused) \ - /* nothing */ -#endif - -#if BOOST_CONTRACT_DETAIL_TVARIADIC - #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_ELEMS_Z( \ - z, arity, indexes, tuple) \ - std::get<indexes>(tuple)... -#else - #define BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_ELEMS_Z( \ - z, arity, indexes, tuple) \ - BOOST_PP_ENUM_ ## z(arity, BOOST_CONTRACT_DETAIL_TVARIADIC_TUPLE_ELEM_,\ - tuple) -#endif - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/type_traits/member_function_types.hpp b/contrib/restricted/boost/boost/contract/detail/type_traits/member_function_types.hpp deleted file mode 100644 index 4966f1db1e2..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/type_traits/member_function_types.hpp +++ /dev/null @@ -1,72 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_MEMBER_FUNCTION_TYPES_HPP_ -#define BOOST_CONTRACT_DETAIL_MEMBER_FUNCTION_TYPES_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/detail/none.hpp> -#include <boost/function_types/parameter_types.hpp> -#include <boost/function_types/result_type.hpp> -#include <boost/function_types/property_tags.hpp> -#include <boost/type_traits/is_const.hpp> -#include <boost/type_traits/is_volatile.hpp> -#include <boost/type_traits/is_same.hpp> -#include <boost/mpl/pop_front.hpp> -#include <boost/mpl/push_back.hpp> -#include <boost/mpl/back.hpp> -#include <boost/mpl/and.hpp> -#include <boost/mpl/if.hpp> -#include <boost/mpl/identity.hpp> - -namespace boost { - namespace contract { - class virtual_; - } -} - -namespace boost { namespace contract { namespace detail { - -template<class C, typename F> -struct member_function_types { - typedef typename boost::function_types::result_type<F>::type result_type; - - // Never include leading class type. - typedef typename boost::mpl::pop_front<typename boost::function_types:: - parameter_types<F>::type>::type argument_types; - - // Always include trailing virtual_* type. - typedef typename boost::mpl::if_<boost::is_same<typename boost:: - mpl::back<argument_types>::type, boost::contract::virtual_*>, - boost::mpl::identity<argument_types> - , - boost::mpl::push_back<argument_types, boost::contract::virtual_*> - >::type::type virtual_argument_types; - - typedef typename boost::mpl::if_<boost::mpl::and_<boost::is_const<C>, - boost::is_volatile<C> >, - boost::function_types::cv_qualified - , typename boost::mpl::if_<boost::is_const<C>, - boost::function_types::const_non_volatile - , typename boost::mpl::if_<boost::is_volatile<C>, - boost::function_types::volatile_non_const - , - boost::function_types::null_tag - >::type>::type>::type property_tag; -}; - -// Also handles none type. -template<class C> -struct member_function_types<C, none> { - typedef none result_type; - typedef none argument_types; - typedef none virtual_argument_types; - typedef none property_tag; -}; - -} } } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/type_traits/mirror.hpp b/contrib/restricted/boost/boost/contract/detail/type_traits/mirror.hpp deleted file mode 100644 index ef71451677c..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/type_traits/mirror.hpp +++ /dev/null @@ -1,111 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_MIRROR_HPP_ -#define BOOST_CONTRACT_DETAIL_MIRROR_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/contract/detail/name.hpp> -#include <boost/function_types/member_function_pointer.hpp> -#include <boost/function_types/function_pointer.hpp> -#include <boost/function_types/property_tags.hpp> -#include <boost/mpl/push_front.hpp> -#include <boost/mpl/bool.hpp> -#include <boost/preprocessor/control/iif.hpp> -#include <boost/preprocessor/tuple/rem.hpp> -#include <boost/preprocessor/tuple/eat.hpp> - -// NOTE: Unfortunately, it is not possible to use Boost.TTI because it not -// always works on MSVC (e.g., when the mirror meta-function is invoked -// multiple times, MSVC 2010 gives an internal compiler error). This is a -// simpler mirror implementation that seems to work better on MSVC. - -/* PRIVATE */ - -#define BOOST_CONTRACT_DETAIL_MIRROR_END_(tparam) \ - template<typename> \ - static boost::contract::detail::mirror::no& apply(...); \ - public: \ - static bool const value = sizeof(apply<tparam>(0)) == \ - sizeof(boost::contract::detail::mirror::yes); \ - typedef boost::mpl::bool_<value> type; - -#define BOOST_CONTRACT_DETAIL_MIRROR_HAS_MEMBER_FUNCTION_(is_static, \ - trait, func_name) \ - template< \ - typename BOOST_CONTRACT_DETAIL_NAME1(T), \ - typename BOOST_CONTRACT_DETAIL_NAME1(R), \ - class BOOST_CONTRACT_DETAIL_NAME1(P), \ - class BOOST_CONTRACT_DETAIL_NAME1(G) = boost::function_types::null_tag \ - > \ - class trait { \ - template<class BOOST_CONTRACT_DETAIL_NAME1(C)> \ - static boost::contract::detail::mirror::yes& apply( \ - boost::contract::detail::mirror::check_function< \ - typename \ - BOOST_PP_IIF(is_static, \ - boost::function_types::function_pointer \ - , \ - boost::function_types::member_function_pointer \ - ) \ - < \ - typename boost::mpl::push_front< \ - BOOST_PP_IIF(is_static, \ - BOOST_CONTRACT_DETAIL_NAME1(P) \ - BOOST_PP_TUPLE_EAT(2) \ - , \ - BOOST_PP_TUPLE_REM(2) \ - )( \ - typename boost::mpl::push_front< \ - BOOST_CONTRACT_DETAIL_NAME1(P), \ - BOOST_CONTRACT_DETAIL_NAME1(C) \ - >::type \ - ) \ - , BOOST_CONTRACT_DETAIL_NAME1(R) \ - >::type, \ - BOOST_CONTRACT_DETAIL_NAME1(G) \ - >::type, \ - &BOOST_CONTRACT_DETAIL_NAME1(C)::func_name \ - >* \ - ); \ - BOOST_CONTRACT_DETAIL_MIRROR_END_( \ - BOOST_CONTRACT_DETAIL_NAME1(T)) \ - }; - -/* PUBLIC */ - -#define BOOST_CONTRACT_DETAIL_MIRROR_HAS_TYPE(trait, type_name)\ - template<typename BOOST_CONTRACT_DETAIL_NAME1(T)> \ - class trait { \ - template<class BOOST_CONTRACT_DETAIL_NAME1(C)> \ - static boost::contract::detail::mirror::yes& apply( \ - typename BOOST_CONTRACT_DETAIL_NAME1(C)::type_name*); \ - BOOST_CONTRACT_DETAIL_MIRROR_END_( \ - BOOST_CONTRACT_DETAIL_NAME1(T)) \ - }; - -#define BOOST_CONTRACT_DETAIL_MIRROR_HAS_MEMBER_FUNCTION( \ - trait, func_name) \ - BOOST_CONTRACT_DETAIL_MIRROR_HAS_MEMBER_FUNCTION_( \ - /* is_static = */ 0, trait, func_name) - -#define BOOST_CONTRACT_DETAIL_MIRROR_HAS_STATIC_MEMBER_FUNCTION(trait, \ - func_name) \ - BOOST_CONTRACT_DETAIL_MIRROR_HAS_MEMBER_FUNCTION_( \ - /* is_static = */ 1, trait, func_name) - -/* CODE */ - -namespace boost { namespace contract { namespace detail { namespace mirror { - -typedef class {} yes; -typedef yes no[2]; - -template<typename F, F> class check_function; - -} } } } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/detail/type_traits/optional.hpp b/contrib/restricted/boost/boost/contract/detail/type_traits/optional.hpp deleted file mode 100644 index 453df2f7788..00000000000 --- a/contrib/restricted/boost/boost/contract/detail/type_traits/optional.hpp +++ /dev/null @@ -1,42 +0,0 @@ - -#ifndef BOOST_CONTRACT_DETAIL_OPTIONAL_HPP_ -#define BOOST_CONTRACT_DETAIL_OPTIONAL_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -#include <boost/optional.hpp> -#include <boost/type_traits/remove_reference.hpp> -#include <boost/type_traits/integral_constant.hpp> - -namespace boost { namespace contract { namespace detail { - -template<typename T> -struct is_optional : boost::false_type {}; -template<typename T> -struct is_optional<boost::optional<T> > : boost::true_type {}; - -template<typename T> -struct optional_value_type { typedef T type; }; -template<typename T> -struct optional_value_type<boost::optional<T> > { typedef T type; }; - -template<typename T> -struct remove_value_reference_if_optional { typedef T type; }; -template<typename T> -struct remove_value_reference_if_optional<boost::optional<T> > - { typedef typename boost::remove_reference<T>::type type; }; - -template<typename T> -T& optional_get(T& x) { return x; } -template<typename T> -T& optional_get(boost::optional<T>& x) { return x.get(); } -template<typename T> -T& optional_get(boost::optional<T&>& x) { return x.get(); } - -} } } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/function.hpp b/contrib/restricted/boost/boost/contract/function.hpp deleted file mode 100644 index 5811ff93452..00000000000 --- a/contrib/restricted/boost/boost/contract/function.hpp +++ /dev/null @@ -1,89 +0,0 @@ - -#ifndef BOOST_CONTRACT_FUNCTION_HPP_ -#define BOOST_CONTRACT_FUNCTION_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -/** @file -Program contracts for (non-public) functions. -*/ - -#include <boost/contract/core/config.hpp> -#include <boost/contract/core/specify.hpp> -#if !defined(BOOST_CONTRACT_NO_FUNCTIONS) || \ - !defined(BOOST_CONTRACT_NO_INVARIANTS) || \ - defined(BOOST_CONTRACT_STATIC_LINK) - #include <boost/contract/detail/operation/function.hpp> -#endif - -namespace boost { namespace contract { - -/** -Program contracts for non-member, private and protected functions. - -This is used to specify preconditions, postconditions, exception guarantees, and -old value copies at body for non-member, private and protected functions (these -functions never check class invariants, see -@RefSect{contract_programming_overview.function_calls, Function Calls}): - -@code -void f(...) { - boost::contract::old_ptr<old_type> old_var; - boost::contract::check c = boost::contract::function() - .precondition([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - .old([&] { // Optional. - old_var = BOOST_CONTRACT_OLDOF(old_expr); - ... - }) - .postcondition([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - .except([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - ; - - ... // Function body. -} -@endcode - -This can be used also to program contracts in implementation code for lambda -functions, loops, and arbitrary blocks of code. -For optimization, this can be omitted for code that does not have preconditions, -postconditions, and exception guarantees. - -@see @RefSect{tutorial.non_member_functions, Non-Member Functions}, - @RefSect{advanced.private_and_protected_functions, - Private and Protected Functions}, - @RefSect{advanced.lambdas__loops__code_blocks__and__constexpr__, - Lambdas\, Loops\, Code Blocks} - -@return The result of this function must be explicitly assigned to a variable of - type @RefClass{boost::contract::check} declared locally just before the - function body code (otherwise this library will generate a run-time - error, see @RefMacro{BOOST_CONTRACT_ON_MISSING_CHECK_DECL}). -*/ -inline specify_precondition_old_postcondition_except<> function() { - // Must #if also on ..._INVARIANTS here because specify_... is generic. - #if !defined(BOOST_CONTRACT_NO_FUNCTIONS) || \ - !defined(BOOST_CONTRACT_NO_INVARIANTS) || \ - defined(BOOST_CONTRACT_STATIC_LINK) - return specify_precondition_old_postcondition_except<>( - new boost::contract::detail::function()); - #else - return specify_precondition_old_postcondition_except<>(); - #endif -} - -} } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/old.hpp b/contrib/restricted/boost/boost/contract/old.hpp deleted file mode 100644 index 652ff3993a3..00000000000 --- a/contrib/restricted/boost/boost/contract/old.hpp +++ /dev/null @@ -1,810 +0,0 @@ - -#ifndef BOOST_CONTRACT_OLD_HPP_ -#define BOOST_CONTRACT_OLD_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -/** @file -Handle old values. -*/ - -#include <boost/contract/core/config.hpp> -#include <boost/contract/core/virtual.hpp> -#ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - #include <boost/contract/detail/checking.hpp> -#endif -#include <boost/contract/detail/operator_safe_bool.hpp> -#include <boost/contract/detail/declspec.hpp> -#include <boost/contract/detail/debug.hpp> -#include <boost/make_shared.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/type_traits/is_copy_constructible.hpp> -#include <boost/utility/enable_if.hpp> -#include <boost/static_assert.hpp> -#include <boost/preprocessor/control/expr_iif.hpp> -#include <boost/preprocessor/config/config.hpp> -#include <queue> - -#if !BOOST_PP_VARIADICS - -#define BOOST_CONTRACT_OLDOF \ -BOOST_CONTRACT_ERROR_macro_OLDOF_requires_variadic_macros_otherwise_manually_program_old_values - -#else // variadics - -#include <boost/preprocessor/facilities/overload.hpp> -#include <boost/preprocessor/facilities/empty.hpp> -#include <boost/preprocessor/cat.hpp> -#include <boost/config.hpp> - -/* PRIVATE */ - -/** @cond */ - -#ifdef BOOST_NO_CXX11_AUTO_DECLARATIONS - #define BOOST_CONTRACT_OLDOF_AUTO_TYPEOF_(value) /* nothing */ -#else - #include <boost/typeof/typeof.hpp> - // Explicitly force old_ptr<...> conversion to allow for C++11 auto decl. - #define BOOST_CONTRACT_OLDOF_AUTO_TYPEOF_(value) \ - boost::contract::old_ptr<BOOST_TYPEOF(value)> -#endif - -#define BOOST_CONTRACT_ERROR_macro_OLDOF_has_invalid_number_of_arguments_2( \ - v, value) \ - BOOST_CONTRACT_OLDOF_AUTO_TYPEOF_(value)(boost::contract::make_old(v, \ - boost::contract::copy_old(v) ? (value) : boost::contract::null_old() \ - )) - -#define BOOST_CONTRACT_ERROR_macro_OLDOF_has_invalid_number_of_arguments_1( \ - value) \ - BOOST_CONTRACT_OLDOF_AUTO_TYPEOF_(value)(boost::contract::make_old( \ - boost::contract::copy_old() ? (value) : boost::contract::null_old() \ - )) - -/** @endcond */ - -/* PUBLIC */ - -// NOTE: Leave this #defined the same regardless of ..._NO_OLDS. -/** -Macro typically used to copy an old value expression and assign it to an old -value pointer. - -The expression expanded by this macro should be assigned to an old value -pointer of type @RefClass{boost::contract::old_ptr} or -@RefClass{boost::contract::old_ptr_if_copyable}. -This is an overloaded variadic macro and it can be used in the following -different ways. - -1\. From within virtual public functions and public functions overrides: - -@code -BOOST_CONTRACT_OLDOF(v, old_expr) -@endcode - -2\. From all other operations: - -@code -BOOST_CONTRACT_OLDOF(old_expr) -@endcode - -Where: - -@arg <c><b>v</b></c> is the extra parameter of type - @RefClass{boost::contract::virtual_}<c>*</c> and default value @c 0 - from the enclosing virtual public function or public function - overrides declaring the contract. -@arg <c><b>old_expr</b></c> is the expression to be evaluated and copied to - the old value pointer. - (This is not a variadic macro parameter so any comma it might contain - must be protected by round parenthesis, - <c>BOOST_CONTRACT_OLDOF(v, (old_expr))</c> will always work.) - -On compilers that do not support variadic macros, programmers can manually copy -old value expressions without using this macro (see -@RefSect{extras.no_macros__and_no_variadic_macros_, No Macros}). - -@see @RefSect{tutorial.old_values, Old Values} -*/ -#define BOOST_CONTRACT_OLDOF(...) \ - BOOST_PP_CAT( /* CAT(..., EMTPY()) required on MSVC */ \ - BOOST_PP_OVERLOAD( \ - BOOST_CONTRACT_ERROR_macro_OLDOF_has_invalid_number_of_arguments_, \ - __VA_ARGS__ \ - )(__VA_ARGS__), \ - BOOST_PP_EMPTY() \ - ) - -#endif // variadics - -/* CODE */ - -namespace boost { namespace contract { - -/** -Trait to check if an old value type can be copied or not. - -By default, this unary boolean meta-function is equivalent to -@c boost::is_copy_constructible<T> but programmers can chose to specialize it -for user-defined types (in general some kind of specialization is needed on -compilers that do not support C++11, see -<a href="http://www.boost.org/doc/libs/release/libs/type_traits/doc/html/boost_typetraits/reference/is_copy_constructible.html"> -<c>boost::is_copy_constructible</c></a>): - -@code -class u; // Some user-defined type. - -namespace boost { namespace contract { - template<> // Specialization. - struct is_old_value_copyable<u> : boost::false_type {}; -} } // namespace -@endcode - -In summary, a given old value type @c T is copied only if -@c boost::contract::is_old_value_copyable<T>::value is @c true. -Copyable old value types are always copied using -@c boost::contract::old_value_copy<T>. -Non-copyable old value types generate a compile-time error when -@c boost::contract::old_ptr<T> is dereferenced, but instead leave -@c boost::contract::old_ptr_if_copyable<T> always null (without generating -compile-time errors). - -@see @RefSect{extras.old_value_requirements__templates_, - Old Value Requirements} -*/ -template<typename T> -struct is_old_value_copyable : boost::is_copy_constructible<T> {}; - -/** @cond */ -class old_value; - -template<> // Needed because `old_value` incomplete type when trait first used. -struct is_old_value_copyable<old_value> : boost::true_type {}; -/** @endcond */ - -/** -Trait to copy an old value. - -By default, the implementation of this trait uses @c T's copy constructor to -make one single copy of the specified @p value. -However, programmers can specialize this trait to copy old values using -user-specific operations different from @c T's copy constructor. -The default implementation of this trait is equivalent to: - -@code -template<typename T> -class old_value_copy { -public: - explicit old_value_copy(T const& old) : - old_(value) // One single copy of value using T's copy constructor. - {} - - T const& old() const { return old_; } - -private: - T const old_; // The old value copy. -}; -@endcode - -This library will instantiate and use this trait only on old value types @c T -that are copyable (i.e., for which -<c>boost::contract::is_old_value_copyable<T>::value</c> is @c true). - -@see @RefSect{extras.old_value_requirements__templates_, - Old Value Requirements} -*/ -template<typename T> // Used only if is_old_value_copyable<T>. -struct old_value_copy { - /** - Construct this object by making one single copy of the specified old value. - - This is the only operation within this library that actually copies old - values. - This ensures this library makes one and only one copy of old values (if they - actually need to be copied). - - @param old The old value to copy. - */ - explicit old_value_copy(T const& old) : - old_(old) {} // This makes the one single copy of T. - - /** - Return a (constant) reference to the old value that was copied. - - Contract assertions should not change the state of the program so the old - value copy is returned as @c const (see - @RefSect{contract_programming_overview.constant_correctness, - Constant Correctness}). - */ - T const& old() const { return old_; } - -private: - T const old_; -}; - -template<typename T> -class old_ptr_if_copyable; - -/** -Old value pointer that requires the pointed old value type to be copyable. - -This is set to point to an actual old value copy using either -@RefMacro{BOOST_CONTRACT_OLDOF} or @RefFunc{boost::contract::make_old} (that is -why this class does not have public non-default constructors): - -@code -class u { -public: - virtual void f(..., boost::contract::virtual_* v = 0) { - boost::contract::old_ptr<old_type> old_var = - BOOST_CONTRACT_OLDOF(v, old_expr); - ... - } - - ... -}; -@endcode - -@see @RefSect{tutorial.old_values, Old Values} - -@tparam T Type of the pointed old value. - This type must be copyable (i.e., - <c>boost::contract::is_old_value_copyable<T>::value</c> is @c true), - otherwise this pointer will always be null and this library will - generate a compile-time error when the pointer is dereferenced. -*/ -template<typename T> -class old_ptr { /* copyable (as *) */ -public: - /** Pointed old value type. */ - typedef T element_type; - - /** Construct this old value pointer as null. */ - old_ptr() {} - - /** - Dereference this old value pointer. - - This will generate a run-time error if this pointer is null and a - compile-time error if the pointed type @c T is not copyable (i.e., if - @c boost::contract::is_old_value_copyable<T>::value is @c false). - - @return The pointed old value. - Contract assertions should not change the state of the program so - this member function is @c const and it returns the old value as a - reference to a constant object (see - @RefSect{contract_programming_overview.constant_correctness, - Constant Correctness}). - */ - T const& operator*() const { - BOOST_STATIC_ASSERT_MSG( - boost::contract::is_old_value_copyable<T>::value, - "old_ptr<T> requires T copyable (see is_old_value_copyable<T>), " - "otherwise use old_ptr_if_copyable<T>" - ); - BOOST_CONTRACT_DETAIL_DEBUG(typed_copy_); - return typed_copy_->old(); - } - - /** - Structure-dereference this old value pointer. - - This will generate a compile-time error if the pointed type @c T is not - copyable (i.e., if @c boost::contract::is_old_value_copyable<T>::value is - @c false). - - @return A pointer to the old value (null if this old value pointer is null). - Contract assertions should not change the state of the program so - this member function is @c const and it returns the old value as a - constant pointer to a constant object (see - @RefSect{contract_programming_overview.constant_correctness, - Constant Correctness}). - */ - T const* const operator->() const { - BOOST_STATIC_ASSERT_MSG( - boost::contract::is_old_value_copyable<T>::value, - "old_ptr<T> requires T copyble (see is_old_value_copyable<T>), " - "otherwise use old_ptr_if_copyable<T>" - ); - if(typed_copy_) return &typed_copy_->old(); - return 0; - } - - #ifndef BOOST_CONTRACT_DETAIL_DOXYGEN - BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL(old_ptr<T>, - !!typed_copy_) - #else - /** - Check if this old value pointer is null or not. - - (This is implemented using safe-bool emulation on compilers that do not - support C++11 explicit type conversion operators.) - - @return True if this pointer is not null, false otherwise. - */ - explicit operator bool() const; - #endif - -/** @cond */ -private: - #ifndef BOOST_CONTRACT_NO_OLDS - explicit old_ptr(boost::shared_ptr<old_value_copy<T> > old) - : typed_copy_(old) {} - #endif - - boost::shared_ptr<old_value_copy<T> > typed_copy_; - - friend class old_pointer; - friend class old_ptr_if_copyable<T>; -/** @endcond */ -}; - -/** -Old value pointer that does not require the pointed old value type to be -copyable. - -This is set to point to an actual old value copy using either -@RefMacro{BOOST_CONTRACT_OLDOF} or @RefFunc{boost::contract::make_old}: - -@code -template<typename T> // Type `T` might or not be copyable. -class u { -public: - virtual void f(..., boost::contract::virtual_* v = 0) { - boost::contract::old_ptr_if_copyable<T> old_var = - BOOST_CONTRACT_OLDOF(v, old_expr); - ... - if(old_var) ... // Always null for non-copyable types. - ... - } - - ... -}; -@endcode - -@see @RefSect{extras.old_value_requirements__templates_, - Old Value Requirements} - -@tparam T Type of the pointed old value. - If this type is not copyable (i.e., - <c>boost::contract::is_old_value_copyable<T>::value</c> is @c false), - this pointer will always be null (but this library will not generate a - compile-time error when this pointer is dereferenced). -*/ -template<typename T> -class old_ptr_if_copyable { /* copyable (as *) */ -public: - /** Pointed old value type. */ - typedef T element_type; - - /** Construct this old value pointer as null. */ - old_ptr_if_copyable() {} - - /** - Construct this old value pointer from an old value pointer that requires - the old value type to be copyable. - - This constructor is implicitly called by this library when assigning an - object of this type using @RefMacro{BOOST_CONTRACT_OLDOF} (this constructor - is usually not explicitly called by user code). - - @param other Old value pointer that requires the old value type to be - copyable. - */ - /* implicit */ old_ptr_if_copyable(old_ptr<T> const& other) : - typed_copy_(other.typed_copy_) {} - - /** - Dereference this old value pointer. - - This will generate a run-time error if this pointer is null, but no - compile-time error is generated if the pointed type @c T is not copyable - (i.e., if @c boost::contract::is_old_value_copyable<T>::value is @c false). - - @return The pointed old value. - Contract assertions should not change the state of the program so - this member function is @c const and it returns the old value as a - reference to a constant object (see - @RefSect{contract_programming_overview.constant_correctness, - Constant Correctness}). - */ - T const& operator*() const { - BOOST_CONTRACT_DETAIL_DEBUG(typed_copy_); - return typed_copy_->old(); - } - - /** - Structure-dereference this old value pointer. - - This will return null but will not generate a compile-time error if the - pointed type @c T is not copyable (i.e., if - @c boost::contract::is_old_value_copyable<T>::value is @c false). - - @return A pointer to the old value (null if this old value pointer is null). - Contract assertions should not change the state of the program so - this member function is @c const and it returns the old value as a - constant pointer to a constant object (see - @RefSect{contract_programming_overview.constant_correctness, - Constant Correctness}). - */ - T const* const operator->() const { - if(typed_copy_) return &typed_copy_->old(); - return 0; - } - - #ifndef BOOST_CONTRACT_DETAIL_DOXYGEN - BOOST_CONTRACT_DETAIL_OPERATOR_SAFE_BOOL(old_ptr_if_copyable<T>, - !!typed_copy_) - #else - /** - Check if this old value pointer is null or not (safe-bool operator). - - (This is implemented using safe-bool emulation on compilers that do not - support C++11 explicit type conversion operators.) - - @return True if this pointer is not null, false otherwise. - */ - explicit operator bool() const; - #endif - -/** @cond */ -private: - #ifndef BOOST_CONTRACT_NO_OLDS - explicit old_ptr_if_copyable(boost::shared_ptr<old_value_copy<T> > old) - : typed_copy_(old) {} - #endif - - boost::shared_ptr<old_value_copy<T> > typed_copy_; - - friend class old_pointer; -/** @endcond */ -}; - -/** -Convert user-specified expressions to old values. - -This class is often only implicitly used by this library and it does not -explicitly appear in user code. - -On older compilers that cannot correctly deduce the -@c boost::contract::is_old_value_copyable trait, programmers can manually -specialize that trait to make sure that only old value types that are copyable -are actually copied. - -@see @RefSect{extras.old_value_requirements__templates_, - Old Value Requirements} -*/ -class old_value { // Copyable (as *). -public: - // Following implicitly called by ternary operator `... ? ... : null_old()`. - - /** - Construct this object from the specified old value when the old value type - is copy constructible. - - The specified old value is copied (one time only) using - @c boost::contract::old_value_copy, in which case related old value pointer - will not be null (no copy is made if postconditions and exception guarantees - are not being checked, see @RefMacro{BOOST_CONTRACT_NO_OLDS}). - - @param old Old value to be copied. - - @tparam T Old value type. - */ - template<typename T> - /* implicit */ old_value( - T const& old, - typename boost::enable_if<boost::contract::is_old_value_copyable<T> - >::type* = 0 - ) - #ifndef BOOST_CONTRACT_NO_OLDS - : untyped_copy_(new old_value_copy<T>(old)) - #endif // Else, leave ptr_ null (thus no copy of T). - {} - - /** - Construct this object from the specified old value when the old value type - is not copyable. - - The specified old value cannot be copied in this case so it is not copied - and the related old value pointer will always be null (thus a call to this - constructor has no effect and it will likely be optimized away by most - compilers). - - @param old Old value (that will not be copied in this case). - - @tparam T Old value type. - */ - template<typename T> - /* implicit */ old_value( - T const& old, - typename boost::disable_if<boost::contract::is_old_value_copyable<T> - >::type* = 0 - ) {} // Leave ptr_ null (thus no copy of T). - -/** @cond */ -private: - explicit old_value() {} - - #ifndef BOOST_CONTRACT_NO_OLDS - boost::shared_ptr<void> untyped_copy_; // Type erasure. - #endif - - friend class old_pointer; - friend BOOST_CONTRACT_DETAIL_DECLSPEC old_value null_old(); -/** @endcond */ -}; - -/** -Convert old value copies to old value pointers. - -This class is often only implicitly used by this library and it does not -explicitly appear in user code (that is why this class does not have public -constructors, etc.). -*/ -class old_pointer { // Copyable (as *). -public: - /** - Convert this object to an actual old value pointer for which the old value - type @c T might or not be copyable. - - For example, this is implicitly called when assigning or initializing old - value pointers. - - @tparam T Type of the pointed old value. - The old value pointer will always be null if this type is not - copyable (see - @c boost::contract::is_old_value_copyable), but this library - will not generate a compile-time error. - */ - template<typename T> - /* implicit */ operator old_ptr_if_copyable<T>() { - return get<old_ptr_if_copyable<T> >(); - } - - /** - Convert this object to an actual old value pointer for which the old value - type @c T must be copyable. - - For example, this is implicitly called when assigning or initializing old - value pointers. - - @tparam T Type of the pointed old value. This type must be copyable - (see @c boost::contract::is_old_value_copyable), - otherwise this library will generate a compile-time error when - the old value pointer is dereferenced. - */ - template<typename T> - /* implicit */ operator old_ptr<T>() { - return get<old_ptr<T> >(); - } - -/** @cond */ -private: - explicit old_pointer(virtual_* v, old_value const& old) - #ifndef BOOST_CONTRACT_NO_OLDS - : v_(v), untyped_copy_(old.untyped_copy_) - #endif - {} - - template<typename Ptr> - Ptr get() { - #ifndef BOOST_CONTRACT_NO_OLDS - if(!boost::contract::is_old_value_copyable<typename - Ptr::element_type>::value) { - BOOST_CONTRACT_DETAIL_DEBUG(!untyped_copy_); - return Ptr(); // Non-copyable so no old value and return null. - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - } else if(!v_ && boost::contract::detail::checking::already()) { - return Ptr(); // Not checking (so return null). - #endif - } else if(!v_) { - BOOST_CONTRACT_DETAIL_DEBUG(untyped_copy_); - typedef old_value_copy<typename Ptr::element_type> copied_type; - boost::shared_ptr<copied_type> typed_copy = // Un-erase type. - boost::static_pointer_cast<copied_type>(untyped_copy_); - BOOST_CONTRACT_DETAIL_DEBUG(typed_copy); - return Ptr(typed_copy); - } else if( - v_->action_ == boost::contract::virtual_::push_old_init_copy || - v_->action_ == boost::contract::virtual_::push_old_ftor_copy - ) { - BOOST_CONTRACT_DETAIL_DEBUG(untyped_copy_); - std::queue<boost::shared_ptr<void> >& copies = v_->action_ == - boost::contract::virtual_::push_old_ftor_copy ? - v_->old_ftor_copies_ - : - v_->old_init_copies_ - ; - copies.push(untyped_copy_); - return Ptr(); // Pushed (so return null). - } else if( - boost::contract::virtual_::pop_old_init_copy(v_->action_) || - v_->action_ == boost::contract::virtual_::pop_old_ftor_copy - ) { - // Copy not null, but still pop it from the queue. - BOOST_CONTRACT_DETAIL_DEBUG(!untyped_copy_); - - std::queue<boost::shared_ptr<void> >& copies = v_->action_ == - boost::contract::virtual_::pop_old_ftor_copy ? - v_->old_ftor_copies_ - : - v_->old_init_copies_ - ; - boost::shared_ptr<void> untyped_copy = copies.front(); - BOOST_CONTRACT_DETAIL_DEBUG(untyped_copy); - copies.pop(); - - typedef old_value_copy<typename Ptr::element_type> copied_type; - boost::shared_ptr<copied_type> typed_copy = // Un-erase type. - boost::static_pointer_cast<copied_type>(untyped_copy); - BOOST_CONTRACT_DETAIL_DEBUG(typed_copy); - return Ptr(typed_copy); - } - BOOST_CONTRACT_DETAIL_DEBUG(!untyped_copy_); - #endif - return Ptr(); - } - - #ifndef BOOST_CONTRACT_NO_OLDS - virtual_* v_; - boost::shared_ptr<void> untyped_copy_; // Type erasure. - #endif - - friend BOOST_CONTRACT_DETAIL_DECLSPEC - old_pointer make_old(old_value const&); - - friend BOOST_CONTRACT_DETAIL_DECLSPEC - old_pointer make_old(virtual_*, old_value const&); -/** @endcond */ -}; - -/** -Return a null old value. - -The related old value pointer will also be null. -This function is often only used by the code expanded by -@RefMacro{BOOST_CONTRACT_OLDOF}. - -@see @RefSect{extras.no_macros__and_no_variadic_macros_, No Macros} - -@return Null old value. -*/ -/** @cond */ BOOST_CONTRACT_DETAIL_DECLSPEC /** @endcond */ -old_value null_old(); - -/** -Make an old value pointer (but not for virtual public functions and public -functions overrides). - -The related old value pointer will not be null if the specified old value was -actually copied. -This function is often only used by code expanded by -@c BOOST_CONTRACT_OLDOF(old_expr): - -@code -boost::contract::make_old(boost::contract::copy_old() ? old_expr : - boost::contract::null_old()) -@endcode - -@see @RefSect{extras.no_macros__and_no_variadic_macros_, No Macros} - -@param old Old value which is usually implicitly constructed from the user old - value expression to be copied (use the ternary operator <c>?:</c> - to avoid evaluating the old value expression all together when - @c boost::contract::copy_old() is @c false). - -@return Old value pointer (usually implicitly converted to either - @RefClass{boost::contract::old_ptr} or - @RefClass{boost::contract::old_ptr_if_copyable} in user code). -*/ -/** @cond */ BOOST_CONTRACT_DETAIL_DECLSPEC /** @endcond */ -old_pointer make_old(old_value const& old); - -/** -Make an old value pointer (for virtual public functions and public functions -overrides). - -The related old value pointer will not be null if the specified old value was -actually copied. -This function is often only used by code expanded by -@c BOOST_CONTRACT_OLDOF(v, old_expr): - -@code -boost::contract::make_old(v, boost::contract::copy_old(v) ? old_expr : - boost::contract::null_old()) -@endcode - -@see @RefSect{extras.no_macros__and_no_variadic_macros_, No Macros} - -@param v The trailing parameter of type - @RefClass{boost::contract::virtual_}<c>*</c> and default value @c 0 - from the enclosing virtual or overriding public function declaring - the contract. -@param old Old value which is usually implicitly constructed from the user old - value expression to be copied (use the ternary operator <c>?:</c> - to avoid evaluating the old value expression all together when - @c boost::contract::copy_old(v) is @c false). - -@return Old value pointer (usually implicitly converted to either - @RefClass{boost::contract::old_ptr} or - @RefClass{boost::contract::old_ptr_if_copyable} in user code). -*/ -/** @cond */ BOOST_CONTRACT_DETAIL_DECLSPEC /** @endcond */ -old_pointer make_old(virtual_* v, old_value const& old); - -/** -Check if old values need to be copied (but not for virtual public functions and -public function overrides). - -For example, this function always returns false when both postconditions and -exception guarantees are not being checked (see -@RefMacro{BOOST_CONTRACT_NO_OLDS}). -This function is often only used by the code expanded by -@RefMacro{BOOST_CONTRACT_OLDOF}. - -@see @RefSect{extras.no_macros__and_no_variadic_macros_, No Macros} - -@return True if old values need to be copied, false otherwise. -*/ -inline bool copy_old() { - #ifndef BOOST_CONTRACT_NO_OLDS - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - return !boost::contract::detail::checking::already(); - #else - return true; - #endif - #else - return false; // No post checking, so never copy old values. - #endif -} - -/** -Check if old values need to be copied (for virtual public functions and public -function overrides). - -For example, this function always returns false when both postconditions and -exception guarantees are not being checked (see -@RefMacro{BOOST_CONTRACT_NO_OLDS}). -In addition, this function returns false when overridden functions are being -called subsequent times by this library to support subcontracting. -This function is often only used by the code expanded by -@RefMacro{BOOST_CONTRACT_OLDOF}. - -@see @RefSect{extras.no_macros__and_no_variadic_macros_, No Macros} - -@param v The trailing parameter of type - @RefClass{boost::contract::virtual_}<c>*</c> and default value @c 0 - from the enclosing virtual or overriding public function declaring - the contract. - -@return True if old values need to be copied, false otherwise. -*/ -inline bool copy_old(virtual_* v) { - #ifndef BOOST_CONTRACT_NO_OLDS - if(!v) { - #ifndef BOOST_CONTRACT_ALL_DISABLE_NO_ASSERTION - return !boost::contract::detail::checking::already(); - #else - return true; - #endif - } - return v->action_ == boost::contract::virtual_::push_old_init_copy || - v->action_ == boost::contract::virtual_::push_old_ftor_copy; - #else - return false; // No post checking, so never copy old values. - #endif -} - -} } // namespace - -#ifdef BOOST_CONTRACT_HEADER_ONLY - #include <boost/contract/detail/inlined/old.hpp> -#endif - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/override.hpp b/contrib/restricted/boost/boost/contract/override.hpp deleted file mode 100644 index 96a4ceafbcc..00000000000 --- a/contrib/restricted/boost/boost/contract/override.hpp +++ /dev/null @@ -1,184 +0,0 @@ - -#ifndef BOOST_CONTRACT_OVERRIDE_HPP_ -#define BOOST_CONTRACT_OVERRIDE_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -/** @file -Handle public function overrides (for subcontracting). -*/ - -// IMPORTANT: Included by contract_macro.hpp so must #if-guard all its includes. -#include <boost/contract/core/config.hpp> -#include <boost/preprocessor/cat.hpp> -#include <boost/preprocessor/config/config.hpp> - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Declare an override type with an arbitrary name. - - Declare the override type to pass as an explicit template parameter to - @RefFunc{boost::contract::public_function} for public function overrides. - - @see @RefSect{advanced.named_overrides, Named Overrides} - - @param type_name Name of the override type this macro will declare. - (This is not a variadic macro parameter but it should - never contain commas because it is an identifier.) - @param func_name Function name of the public function override. - This macro is called just once even if the function name - is overloaded (the same override type is used for all - overloaded functions with the same name, see - @RefSect{advanced.function_overloads, - Function Overloads}). - (This is not a variadic macro parameter but it should - never contain commas because it is an identifier.) - */ - #define BOOST_CONTRACT_NAMED_OVERRIDE(type_name, func_name) -#elif !defined(BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS) - #include <boost/contract/core/virtual.hpp> - #include <boost/contract/detail/type_traits/mirror.hpp> - #include <boost/contract/detail/tvariadic.hpp> - #include <boost/contract/detail/none.hpp> - #include <boost/contract/detail/name.hpp> - - /* PRIVATE */ - - #define BOOST_CONTRACT_OVERRIDE_CALL_BASE_(z, arity, arity_compl, \ - func_name) \ - template< \ - class BOOST_CONTRACT_DETAIL_NAME1(B), \ - class BOOST_CONTRACT_DETAIL_NAME1(C) \ - BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(arity) \ - BOOST_CONTRACT_DETAIL_TVARIADIC_TPARAMS_Z(z, arity, \ - BOOST_CONTRACT_DETAIL_NAME1(Args)) \ - > \ - static void BOOST_CONTRACT_DETAIL_NAME1(call_base)( \ - boost::contract::virtual_* BOOST_CONTRACT_DETAIL_NAME1(v), \ - BOOST_CONTRACT_DETAIL_NAME1(C)* BOOST_CONTRACT_DETAIL_NAME1(obj) \ - BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(arity) \ - BOOST_CONTRACT_DETAIL_TVARIADIC_FPARAMS_Z(z, arity, \ - BOOST_CONTRACT_DETAIL_NAME1(Args), \ - &, \ - BOOST_CONTRACT_DETAIL_NAME1(args) \ - ) \ - BOOST_CONTRACT_DETAIL_NO_TVARIADIC_COMMA(arity_compl) \ - BOOST_CONTRACT_DETAIL_NO_TVARIADIC_ENUM_Z(z, arity_compl, \ - boost::contract::detail::none&) \ - ) { \ - BOOST_CONTRACT_DETAIL_NAME1(obj)-> \ - BOOST_CONTRACT_DETAIL_NAME1(B)::func_name( \ - BOOST_CONTRACT_DETAIL_TVARIADIC_ARGS_Z(z, arity, \ - BOOST_CONTRACT_DETAIL_NAME1(args)) \ - BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(arity) \ - BOOST_CONTRACT_DETAIL_NAME1(v) \ - ); \ - } - - #if BOOST_CONTRACT_DETAIL_TVARIADIC - #define BOOST_CONTRACT_OVERRIDE_CALL_BASE_DECL_(func_name) \ - BOOST_CONTRACT_OVERRIDE_CALL_BASE_(1, ~, ~, func_name) - #else - #include <boost/preprocessor/repetition/repeat.hpp> - #include <boost/preprocessor/arithmetic/inc.hpp> - #include <boost/preprocessor/arithmetic/sub.hpp> - - #define BOOST_CONTRACT_OVERRIDE_CALL_BASE_DECL_(func_name) \ - BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_CONTRACT_MAX_ARGS), \ - BOOST_CONTRACT_OVERRIDE_CALL_BASE_ARITY_, func_name) \ - - #define BOOST_CONTRACT_OVERRIDE_CALL_BASE_ARITY_(z, arity, func_name) \ - BOOST_CONTRACT_OVERRIDE_CALL_BASE_(z, arity, \ - BOOST_PP_SUB(BOOST_CONTRACT_MAX_ARGS, arity), func_name) - #endif - - /* PUBLIC */ - - #define BOOST_CONTRACT_NAMED_OVERRIDE(type_name, func_name) \ - struct type_name { \ - BOOST_CONTRACT_DETAIL_MIRROR_HAS_MEMBER_FUNCTION( \ - BOOST_CONTRACT_DETAIL_NAME1(has_member_function), \ - func_name \ - ) \ - BOOST_CONTRACT_OVERRIDE_CALL_BASE_DECL_(func_name) \ - }; -#else - #define BOOST_CONTRACT_NAMED_OVERRIDE(type_name, func_name) \ - struct type_name {}; /* empty (not used), just to compile */ -#endif - -/* PUBLIC */ - -/** -Declare an override type named <c>override_<i>func_name</i></c>. - -Declare the override type to pass as an explicit template parameter to -@RefFunc{boost::contract::public_function} for public function overrides. - -@see @RefSect{tutorial.public_function_overrides__subcontracting_, - Public Function Overrides} - -@param func_name Function name of the public function override. - This macro is called just once even if the function name is - overloaded (the same override type is used for all - overloaded functions with the same name, see - @RefSect{advanced.function_overloads, Function Overloads}). - (This is not a variadic macro parameter but it should never - contain any comma because it is an identifier.) -*/ -#define BOOST_CONTRACT_OVERRIDE(func_name) \ - BOOST_CONTRACT_NAMED_OVERRIDE(BOOST_PP_CAT(override_, func_name), func_name) - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Declare multiple override types at once naming them <c>override_...</c> (for - convenience). - - This variadic macro is provided for convenience only, - <c>BOOST_CONTRACT_OVERRIDES(f_1, f_2, ..., f_n)</c> expands to code - equivalent to: - - @code - BOOST_CONTRACT_OVERRIDE(f_1) - BOOST_CONTRACT_OVERRIDE(f_2) - ... - BOOST_CONTRACT_OVERRIDE(f_n) - @endcode - - On compilers that do not support variadic macros, - the override types can be equivalently programmed one-by-one calling - @RefMacro{BOOST_CONTRACT_OVERRIDE} for each function name as shown above. - - @see @RefSect{tutorial.public_function_overrides__subcontracting_, - Public Function Overrides} - - @param ... A comma separated list of one or more function names of public - function overrides. - (Each function name should never contain commas because it is an - identifier.) - */ - #define BOOST_CONTRACT_OVERRIDES(...) -#elif BOOST_PP_VARIADICS - #include <boost/preprocessor/seq/for_each.hpp> - #include <boost/preprocessor/variadic/to_seq.hpp> - - /* PRIVATE */ - - #define BOOST_CONTRACT_OVERRIDES_SEQ_(r, unused, func_name) \ - BOOST_CONTRACT_OVERRIDE(func_name) - - /* PUBLIC */ - - #define BOOST_CONTRACT_OVERRIDES(...) \ - BOOST_PP_SEQ_FOR_EACH(BOOST_CONTRACT_OVERRIDES_SEQ_, ~, \ - BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) -#else - #define BOOST_CONTRACT_OVERRIDES \ -BOOST_CONTRACT_ERROR_macro_OVERRIDES_requires_variadic_macros_otherwise_manually_repeat_OVERRIDE_macro -#endif - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract/public_function.hpp b/contrib/restricted/boost/boost/contract/public_function.hpp deleted file mode 100644 index f66e666cb93..00000000000 --- a/contrib/restricted/boost/boost/contract/public_function.hpp +++ /dev/null @@ -1,876 +0,0 @@ - -#ifndef BOOST_CONTRACT_PUBLIC_FUNCTION_HPP_ -#define BOOST_CONTRACT_PUBLIC_FUNCTION_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -/** @file -Program contracts for public functions (including subcontracting). -Overloads handle public functions that are static, virtual void, virtual non-void, overriding void, and overriding non-void. -*/ - -#include <boost/contract/core/config.hpp> -#include <boost/contract/core/specify.hpp> -#include <boost/contract/core/access.hpp> -#include <boost/contract/core/virtual.hpp> -/** @cond */ -// Needed within macro expansions below instead of defined(...) (PRIVATE macro). -#if !defined(BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS) || \ - defined(BOOST_CONTRACT_STATIC_LINK) - #define BOOST_CONTRACT_PUBLIC_FUNCTIONS_IMPL_ 1 -#else - #define BOOST_CONTRACT_PUBLIC_FUNCTIONS_IMPL_ 0 -#endif -/** @endcond */ -#include <boost/contract/detail/decl.hpp> -#include <boost/contract/detail/tvariadic.hpp> -#if BOOST_CONTRACT_PUBLIC_FUNCTIONS_IMPL_ - #include <boost/contract/detail/operation/static_public_function.hpp> - #include <boost/contract/detail/operation/public_function.hpp> - #include <boost/contract/detail/type_traits/optional.hpp> - #include <boost/contract/detail/none.hpp> - #include <boost/function_types/result_type.hpp> - #include <boost/function_types/function_arity.hpp> - #include <boost/optional.hpp> - #include <boost/type_traits/remove_reference.hpp> - #include <boost/type_traits/is_same.hpp> - #include <boost/static_assert.hpp> - #include <boost/preprocessor/tuple/eat.hpp> -#endif -#if !BOOST_CONTRACT_DETAIL_TVARIADIC - #include <boost/preprocessor/repetition/repeat.hpp> - #include <boost/preprocessor/arithmetic/sub.hpp> - #include <boost/preprocessor/arithmetic/inc.hpp> -#endif -#include <boost/preprocessor/control/expr_iif.hpp> -#include <boost/preprocessor/control/iif.hpp> -#include <boost/preprocessor/punctuation/comma_if.hpp> - -namespace boost { namespace contract { - -// NOTE: Override and (optionally) VirtualResult allowed only when v is present -// because: -// * An overriding func must override a base func declared virtual so with -// v extra param, thus the overriding func must also always have v (i.e., -// Override might be present only if v is also present). However, the first -// appearing virtual func (e.g., in root class) will not override any -// previously declared virtual func so does not need Override (i.e., Override -// always optional). -// Furthermore, F needs to be specified only together with Override. -// * VirtualResult is only used for virtual functions (i.e., VirtualResult might -// be present only if v is also present). -// However, VirtualResult is never specified, not even for virtual functions, -// when the return type is void (i.e., VirtualResult always optional). - -/** -Program contracts for static public functions. - -This is used to specify preconditions, postconditions, exception guarantees, old -value copies at body, and check static class invariants for static public -functions: - -@code -class u { - friend class boost::contract::access; - - static void static_invariant() { // Optional (as for non-static). - BOOST_CONTRACT_ASSERT(...); - ... - } - -public: - static void f(...) { - boost::contract::old_ptr<old_type> old_var; - boost::contract::check c = boost::contract::public_function<u>() - .precondition([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - .old([&] { // Optional. - old_var = BOOST_CONTRACT_OLDOF(old_expr); - ... - }) - .postcondition([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - .except([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - ; - - ... // Function body. - } - - ... -}; -@endcode - -For optimization, this can be omitted for static public functions that do not -have preconditions, postconditions and exception guarantees, within classes that -have no static invariants. - -@see @RefSect{tutorial.static_public_functions, Static Public Functions} - -@tparam Class The type of the class containing the static public function - declaring the contract. - This template parameter must be explicitly specified for static - public functions (because they have no object @c this so there - is no function argument from which this type template parameter - can be deduced by this library). - -@return The result of this function must be explicitly assigned to a variable of - type @RefClass{boost::contract::check} declared locally just before the - code of the static function body (otherwise this library will generate a - run-time error, see @RefMacro{BOOST_CONTRACT_ON_MISSING_CHECK_DECL}). -*/ -template<class Class> -specify_precondition_old_postcondition_except<> public_function() { - #if BOOST_CONTRACT_PUBLIC_FUNCTIONS_IMPL_ - return specify_precondition_old_postcondition_except<>( - new boost::contract::detail::static_public_function<Class>()); - #else - return specify_precondition_old_postcondition_except<>(); - #endif -} - -/** -Program contracts for public functions that are not static, not virtual, and do -not not override. - -This is used to specify preconditions, postconditions, exception guarantees, old -value copies at body, and check class invariants for public functions that are -not static, not virtual, and do not override: - -@code -class u { - friend class boost::contract::access; - - void invariant() const { // Optional (as for static and volatile). - BOOST_CONTRACT_ASSERT(...); - ... - } - -public: - void f(...) { - boost::contract::old_ptr<old_type> old_var; - boost::contract::check c = boost::contract::public_function(this) - .precondition([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - .old([&] { // Optional. - old_var = BOOST_CONTRACT_OLDOF(old_expr); - ... - }) - .postcondition([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - .except([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - ; - - ... // Function body. - } - - ... -}; -@endcode - -For optimization, this can be omitted for public functions that do not have -preconditions, postconditions and exception guarantees, within classes that have -no invariants. - -@see @RefSect{tutorial.public_functions, Public Functions} - -@param obj The object @c this from the scope of the enclosing public function - declaring the contract. - This object might be mutable, @c const, @c volatile, or - <c>const volatile</c> depending on the cv-qualifier of the enclosing - function (volatile public functions will check volatile class - invariants, see - @RefSect{extras.volatile_public_functions, - Volatile Public Functions}). - -@tparam Class The type of the class containing the public function declaring - the contract. - (Usually this template parameter is automatically deduced by C++ - and it does not need to be explicitly specified by programmers.) - -@return The result of this function must be explicitly assigned to a variable of - type @RefClass{boost::contract::check} declared locally just before the - code of the public function body (otherwise this library will generate a - run-time error, see @RefMacro{BOOST_CONTRACT_ON_MISSING_CHECK_DECL}). -*/ -template<class Class> -specify_precondition_old_postcondition_except<> public_function(Class* obj) { - #if BOOST_CONTRACT_PUBLIC_FUNCTIONS_IMPL_ - return specify_precondition_old_postcondition_except<>( - new boost::contract::detail::public_function< - boost::contract::detail::none, - boost::contract::detail::none, - boost::contract::detail::none, - Class - BOOST_CONTRACT_DETAIL_NO_TVARIADIC_COMMA( - BOOST_CONTRACT_MAX_ARGS) - BOOST_CONTRACT_DETAIL_NO_TVARIADIC_ENUM_Z(1, - BOOST_CONTRACT_MAX_ARGS, - boost::contract::detail::none - ) - >( - static_cast<boost::contract::virtual_*>(0), - obj, - boost::contract::detail::none::value() - BOOST_CONTRACT_DETAIL_NO_TVARIADIC_COMMA( - BOOST_CONTRACT_MAX_ARGS) - BOOST_CONTRACT_DETAIL_NO_TVARIADIC_ENUM_Z(1, - BOOST_CONTRACT_MAX_ARGS, - boost::contract::detail::none::value() - ) - ) - ); - #else - return specify_precondition_old_postcondition_except<>(); - #endif -} - -/** @cond */ - -// For non-static, virtual, and non-overriding public functions (PRIVATE macro). -#define BOOST_CONTRACT_PUBLIC_FUNCTION_VIRTUAL_NO_OVERRIDE_( \ - has_virtual_result) \ - template< \ - BOOST_PP_EXPR_IIF(has_virtual_result, typename VirtualResult) \ - BOOST_PP_COMMA_IF(has_virtual_result) \ - class Class \ - > \ - specify_precondition_old_postcondition_except< \ - BOOST_PP_EXPR_IIF(has_virtual_result, VirtualResult)> \ - public_function( \ - virtual_* v \ - BOOST_PP_COMMA_IF(has_virtual_result) \ - BOOST_PP_EXPR_IIF(has_virtual_result, VirtualResult& r) \ - , Class* obj \ - ) { \ - BOOST_PP_IIF(BOOST_CONTRACT_PUBLIC_FUNCTIONS_IMPL_, \ - /* no F... so cannot enforce contracted F returns VirtualResult */ \ - return (specify_precondition_old_postcondition_except< \ - BOOST_PP_EXPR_IIF(has_virtual_result, VirtualResult)>( \ - new boost::contract::detail::public_function< \ - boost::contract::detail::none, \ - BOOST_PP_IIF(has_virtual_result, \ - VirtualResult \ - , \ - boost::contract::detail::none \ - ), \ - boost::contract::detail::none, \ - Class \ - BOOST_CONTRACT_DETAIL_NO_TVARIADIC_COMMA( \ - BOOST_CONTRACT_MAX_ARGS) \ - BOOST_CONTRACT_DETAIL_NO_TVARIADIC_ENUM_Z(1, \ - BOOST_CONTRACT_MAX_ARGS, \ - boost::contract::detail::none \ - ) \ - >( \ - v, \ - obj, \ - BOOST_PP_IIF(has_virtual_result, \ - r \ - , \ - boost::contract::detail::none::value() \ - ) \ - BOOST_CONTRACT_DETAIL_NO_TVARIADIC_COMMA( \ - BOOST_CONTRACT_MAX_ARGS) \ - BOOST_CONTRACT_DETAIL_NO_TVARIADIC_ENUM_Z(1, \ - BOOST_CONTRACT_MAX_ARGS, \ - boost::contract::detail::none::value() \ - ) \ - ) \ - )); \ - , \ - return specify_precondition_old_postcondition_except< \ - BOOST_PP_EXPR_IIF(has_virtual_result, VirtualResult)>(); \ - ) \ - } - -/** @endcond */ - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Program contracts for void virtual public functions that do not override. - - This is used to specify preconditions, postconditions, exception guarantees, - old value copies at body, and check class invariants for public functions - that are virtual, do not override, and return @c void: - - @code - class u { - friend class boost::contract::access; - - void invariant() const { // Optional (as for static and volatile). - BOOST_CONTRACT_ASSERT(...); - ... - } - - public: - void f(..., boost::contract::virtual_* v = 0) { - boost::contract::old_ptr<old_type> old_var; - boost::contract::check c = boost::contract::public_function(v, this) - .precondition([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - .old([&] { // Optional. - old_var = BOOST_CONTRACT_OLDOF(v, old_expr); - ... - }) - .postcondition([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - .except([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - ; - - ... // Function body. - } - - ... - }; - @endcode - - A virtual public function should always call - @RefFunc{boost::contract::public_function} otherwise this library will not - be able to correctly use it for subcontracting. - - @see @RefSect{tutorial.virtual_public_functions, Virtual Public Functions} - - @param v The trailing parameter of type - @RefClass{boost::contract::virtual_}<c>*</c> and default value - @c 0 from the enclosing virtual public function. - @param obj The object @c this from the scope of the enclosing virtual - public function declaring the contract. - This object might be mutable, @c const, @c volatile, or - <c>const volatile</c> depending on the cv-qualifier of the - enclosing function (volatile public functions will check - volatile class invariants, see - @RefSect{extras.volatile_public_functions, - Volatile Public Functions}). - - @tparam Class The type of the class containing the virtual public function - declaring the contract. - (Usually this template parameter is automatically deduced by - C++ and it does not need to be explicitly specified by - programmers.) - - @return The result of this function must be explicitly assigned to a - variable of type @RefClass{boost::contract::check} declared locally - just before the code of the public function body (otherwise this - library will generate a run-time error, see - @RefMacro{BOOST_CONTRACT_ON_MISSING_CHECK_DECL}). - */ - template<class Class> - specify_precondition_old_postcondition_except<> public_function( - virtual_* v, Class* obj); - - /** - Program contracts for non-void virtual public functions that do not - override. - - This is used to specify preconditions, postconditions, exception guarantees, - old value copies at body, and check class invariants for public functions - that are virtual, do not override, and do not return @c void: - - @code - class u { - friend class boost::contract::access; - - void invariant() const { // Optional (as for static and volatile). - BOOST_CONTRACT_ASSERT(...); - ... - } - - public: - t f(..., boost::contract::virtual_* v = 0) { - t result; - boost::contract::old_ptr<old_type> old_var; - boost::contract::check c = boost::contract::public_function( - v, result, this) - .precondition([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - .old([&] { // Optional. - old_var = BOOST_CONTRACT_OLDOF(v, old_expr); - ... - }) - .postcondition([&] (t const& result) { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - .except([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - ; - - ... // Function body (use `return result = return_expr`). - } - - ... - }; - @endcode - - A virtual public function should always call - @RefFunc{boost::contract::public_function} otherwise this library will not - be able to correctly use it for subcontracting. - - @see @RefSect{tutorial.virtual_public_functions, Virtual Public Functions} - - @param v The trailing parameter of type - @RefClass{boost::contract::virtual_}<c>*</c> and default value - @c 0 from the enclosing virtual public function. - @param r A reference to the return value of the enclosing virtual public - function declaring the contract. - This is usually a local variable declared by the enclosing - virtual public function just before the contract, but - programmers must set it to the actual value being returned by - the function at each @c return statement. - @param obj The object @c this from the scope of the enclosing virtual - public function declaring the contract. - This object might be mutable, @c const, @c volatile, or - <c>const volatile</c> depending on the cv-qualifier of the - enclosing function (volatile public functions will check - volatile class invariants, see - @RefSect{extras.volatile_public_functions, - Volatile Public Functions}). - - @tparam VirtualResult This type must be the same as, or compatible with, - the return type of the enclosing virtual public - function declaring the contract (this library might - not be able to generate a compile-time error if - these types mismatch, but in general that will cause - run-time errors or undefined behaviour). - Alternatively, - <c>boost::optional<<i>return-type</i>></c> can also - be used (see - @RefSect{advanced.optional_return_values, - Optional Return Values}). - (Usually this template parameter is automatically - deduced by C++ and it does not need to be explicitly - specified by programmers.) - @tparam Class The type of the class containing the virtual public function - declaring the contract. - (Usually this template parameter is automatically deduced by - C++ and it does not need to be explicitly specified by - programmers.) - - @return The result of this function must be explicitly assigned to a - variable of type @RefClass{boost::contract::check} declared locally - just before the code of the public function body (otherwise this - library will generate a run-time error, see - @RefMacro{BOOST_CONTRACT_ON_MISSING_CHECK_DECL}). - */ - template<typename VirtualResult, class Class> - specify_precondition_old_postcondition_except<VirtualResult> - public_function(virtual_* v, VirtualResult& r, Class* obj); -#else - BOOST_CONTRACT_PUBLIC_FUNCTION_VIRTUAL_NO_OVERRIDE_( - /* has_virtual_result = */ 0) - BOOST_CONTRACT_PUBLIC_FUNCTION_VIRTUAL_NO_OVERRIDE_( - /* has_virtual_result = */ 1) -#endif - -/** @cond */ - -// For non-static, virtual, and overriding public functions (PRIVATE macro). -#define BOOST_CONTRACT_PUBLIC_FUNCTION_VIRTUAL_OVERRIDE_Z_( \ - z, arity, arity_compl, has_virtual_result) \ - BOOST_CONTRACT_DETAIL_DECL_OVERRIDING_PUBLIC_FUNCTION_Z(z, \ - arity, /* is_friend = */ 0, has_virtual_result, \ - Override, VirtualResult, F, Class, Args, \ - v, r, f, obj, args \ - ) { \ - BOOST_PP_IIF(BOOST_CONTRACT_PUBLIC_FUNCTIONS_IMPL_, \ - { /* extra scope paren to expand STATIC_STATIC emu on same line */ \ - /* assert not strictly necessary as compilation will fail */ \ - /* anyways, but helps limiting cryptic compiler's errors */ \ - BOOST_STATIC_ASSERT_MSG( \ - /* -2 for both `this` and `virtual_*` extra parameters */ \ - ( \ - boost::function_types::function_arity<F>::value - 2 \ - == \ - BOOST_CONTRACT_DETAIL_TVARIADIC_SIZEOF(arity, Args) \ - ), \ - "missing one or more arguments for specified function" \ - ); \ - } \ - { /* extra scope paren to expand STATIC_STATIC emu on same line */ \ - /* assert consistency of F's result type and VirtualResult */ \ - BOOST_PP_IIF(has_virtual_result, \ - BOOST_STATIC_ASSERT_MSG \ - , \ - BOOST_PP_TUPLE_EAT(2) \ - )( \ - (boost::is_same< \ - typename boost::remove_reference<typename boost:: \ - function_types::result_type<F>::type>::type, \ - typename boost::contract::detail:: \ - remove_value_reference_if_optional< \ - VirtualResult \ - >::type \ - >::value), \ - "mismatching result type for specified function" \ - ); \ - } \ - { /* extra scope paren to expand STATIC_STATIC emu on same line */ \ - /* assert this so lib can check and enforce override */ \ - BOOST_STATIC_ASSERT_MSG( \ - boost::contract::access::has_base_types<Class>::value, \ - "enclosing class missing 'base-types' typedef" \ - ); \ - } \ - return (specify_precondition_old_postcondition_except< \ - BOOST_PP_EXPR_IIF(has_virtual_result, VirtualResult)>( \ - new boost::contract::detail::public_function< \ - Override, \ - BOOST_PP_IIF(has_virtual_result, \ - VirtualResult \ - , \ - boost::contract::detail::none \ - ), \ - F, \ - Class \ - BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(arity) \ - BOOST_CONTRACT_DETAIL_TVARIADIC_ARGS_Z(z, arity, Args) \ - BOOST_CONTRACT_DETAIL_NO_TVARIADIC_COMMA(arity_compl) \ - BOOST_CONTRACT_DETAIL_NO_TVARIADIC_ENUM_Z(z, arity_compl, \ - boost::contract::detail::none) \ - >( \ - v, \ - obj, \ - BOOST_PP_IIF(has_virtual_result, \ - r \ - , \ - boost::contract::detail::none::value() \ - ) \ - BOOST_CONTRACT_DETAIL_TVARIADIC_COMMA(arity) \ - BOOST_CONTRACT_DETAIL_TVARIADIC_ARGS_Z(z, arity, args) \ - BOOST_CONTRACT_DETAIL_NO_TVARIADIC_COMMA(arity_compl) \ - BOOST_CONTRACT_DETAIL_NO_TVARIADIC_ENUM_Z(z, arity_compl, \ - boost::contract::detail::none::value()) \ - ) \ - )); \ - , \ - return specify_precondition_old_postcondition_except< \ - BOOST_PP_EXPR_IIF(has_virtual_result, VirtualResult)>(); \ - ) \ - } - -/** @endcond */ - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Program contracts for void public functions overrides (virtual or not). - - This is used to specify preconditions, postconditions, exception guarantees, - old value copies at body, and check class invariants for public function - overrides (virtual or not) that return @c void: - - @code - class u - #define BASES private boost::contract::constructor_precondition<u>, \ - public b, private w - : BASES - { - friend class boost::contract::access; - - typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types; - #undef BASES - - void invariant() const { // Optional (as for static and volatile). - BOOST_CONTRACT_ASSERT(...); - ... - } - - BOOST_CONTRACT_OVERRIDES(f) - - public: - // Override from `b::f`. - void f(t_1 a_1, ..., t_n a_n, boost::contract::virtual_* v = 0) { - boost::contract::old_ptr<old_type> old_var; - boost::contract::check c = boost::contract::public_function< - override_f>(v, &u::f, this, a_1, ..., a_n) - .precondition([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - .old([&] { // Optional. - old_var = BOOST_CONTRACT_OLDOF(v, old_expr); - ... - }) - .postcondition([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - .except([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - ; - - ... // Function body. - } - - ... - }; - @endcode - - A public function override should always call - @RefFunc{boost::contract::public_function} otherwise this library will not - be able to correctly use it for subcontracting. - - @see @RefSect{tutorial.public_function_overrides__subcontracting_, - Public Function Overrides} - - @param v The trailing parameter of type - @RefClass{boost::contract::virtual_}<c>*</c> and default value - @c 0 from the enclosing public function override. - @param f A pointer to the enclosing public function override declaring - the contract. - @param obj The object @c this from the scope of the enclosing public - function override declaring the contract. - This object might be mutable, @c const, @c volatile, or - <c>const volatile</c> depending on the cv-qualifier of the - enclosing function (volatile public functions will check - volatile class invariants, see - @RefSect{extras.volatile_public_functions, - Volatile Public Functions}). - @param args All arguments passed to the enclosing public function override - declaring the contract (by reference and in the order they - appear in the enclosing function declaration), but excluding the - trailing argument @c v. - - @tparam Override The type <c>override_<i>function-name</i></c> declared - using the @RefMacro{BOOST_CONTRACT_OVERRIDE} or related - macros. - This template parameter must be explicitly specified - (because there is no function argument from which it can - be automatically deduced by C++). - @tparam F The function pointer type of the enclosing public function - override declaring the contract. - (Usually this template parameter is automatically deduced by - C++ and it does not need to be explicitly specified by - programmers, but see - @RefSect{advanced.function_overloads, Function Overloads}.) - @tparam Class The type of the class containing the virtual public function - declaring the contract. - (Usually this template parameter is automatically deduced by - C++ and it does not need to be explicitly specified by - programmers.) - @tparam Args The types of all parameters passed to the enclosing public - function override declaring the contract, but excluding the - trailing parameter type <c>boost::contract::virtual_*</c>. - On compilers that do not support variadic templates, this - library internally implements this function using - preprocessor meta-programming (in this case, the maximum - number of supported arguments is defined by - @RefMacro{BOOST_CONTRACT_MAX_ARGS}). - (Usually these template parameters are automatically deduced - by C++ and they do not need to be explicitly specified by - programmers.) - - @return The result of this function must be explicitly assigned to a - variable of type @RefClass{boost::contract::check} declared locally - just before the code of the public function body (otherwise this - library will generate a run-time error, see - @RefMacro{BOOST_CONTRACT_ON_MISSING_CHECK_DECL}). - */ - template<class Override, typename F, class Class, typename... Args> - specify_precondition_old_postcondition_except<> public_function( - virtual_* v, F f, Class* obj, Args&... args); - - /** - Program contracts for non-void public functions overrides (virtual or not). - - This is used to specify preconditions, postconditions, exception guarantees, - old value copies at body, and check class invariants for public function - overrides (virtual or not) that do not return @c void: - - @code - class u - #define BASES private boost::contract::constructor_precondition<u>, \ - public b, private w - : BASES - { - friend class boost::contract::access; - - typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types; - #undef BASES - - void invariant() const { // Optional (as for static and volatile). - BOOST_CONTRACT_ASSERT(...); - ... - } - - BOOST_CONTRACT_OVERRIDES(f) - - public: - // Override from `b::f`. - t f(t_1 a_1, ..., t_n a_n, boost::contract::virtual_* v = 0) { - t result; - boost::contract::old_ptr<old_type> old_var; - boost::contract::check c = boost::contract::public_function< - override_f>(v, result, &u::f, this, a_1, ..., a_n) - .precondition([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - .old([&] { // Optional. - old_var = BOOST_CONTRACT_OLDOF(v, old_expr); - ... - }) - .postcondition([&] (t const& result) { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - .except([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - ; - - ... // Function body (use `return result = return_expr`). - } - - ... - }; - @endcode - - A public function override should always call - @RefFunc{boost::contract::public_function} otherwise this library will not - be able to correctly use it for subcontracting. - - @see @RefSect{tutorial.public_function_overrides__subcontracting_, - Public Function Overrides} - - @param v The trailing parameter of type - @RefClass{boost::contract::virtual_}<c>*</c> and default value - @c 0 from the enclosing public function override. - @param r A reference to the return value of the enclosing public function - override declaring the contract. - This is usually a local variable declared by the enclosing - public function override just before the contract, but - programmers must set it to the actual value being returned by - the function at each @c return statement. - @param f A pointer to the enclosing public function override declaring - the contract. - @param obj The object @c this from the scope of the enclosing public - function override declaring the contract. - This object might be mutable, @c const, @c volatile, or - <c>const volatile</c> depending on the cv-qualifier of the - enclosing function (volatile public functions will check - volatile class invariants, see - @RefSect{extras.volatile_public_functions, - Volatile Public Functions}). - @param args All arguments passed to the enclosing public function override - declaring the contract (by reference and in the order they - appear in the enclosing function declaration), but excluding the - trailing argument @c v. - - @tparam Override The type <c>override_<i>function-name</i></c> declared - using the @RefMacro{BOOST_CONTRACT_OVERRIDE} or related - macros. - This template parameter must be explicitly specified - (because there is no function argument from which it can - be automatically deduced by C++). - @tparam VirtualResult This type must be the same as, or compatible with, - the return type of the enclosing public function - override declaring the contract (this library might - not be able to generate a compile-time error if - these types mismatch, but in general that will cause - run-time errors or undefined behaviour). - Alternatively, - <c>boost::optional<<i>return-type</i>></c> can also - be used (see - @RefSect{advanced.optional_return_values, - Optional Return Values}). - (Usually this template parameter is automatically - deduced by C++ and it does not need to be explicitly - specified by programmers.) - @tparam F The function pointer type of the enclosing public function - override declaring the contract. - (Usually this template parameter is automatically deduced by - C++ and it does not need to be explicitly specified by - programmers, but see - @RefSect{advanced.function_overloads, - Function Overloads}.) - @tparam Class The type of the class containing the virtual public function - declaring the contract. - (Usually this template parameter is automatically deduced by - C++ and it does not need to be explicitly specified by - programmers.) - @tparam Args The types of all parameters passed to the enclosing public - function override declaring the contract, but excluding the - trailing parameter type <c>boost::contract::virtual_*</c>. - On compilers that do not support variadic templates, this - library internally implements this function using - preprocessor meta-programming (in this case, the maximum - number of supported arguments is defined by - @RefMacro{BOOST_CONTRACT_MAX_ARGS}). - (Usually these template parameters are automatically deduced - by C++ and they do not need to be explicitly specified by - programmers.) - - @return The result of this function must be explicitly assigned to a - variable of type @RefClass{boost::contract::check} declared locally - just before the code of the public function body (otherwise this - library will generate a run-time error, see - @RefMacro{BOOST_CONTRACT_ON_MISSING_CHECK_DECL}). - */ - template<class Override, typename VirtualResult, typename F, class Class, - typename... Args> - specify_precondition_old_postcondition_except<VirtualResult> - public_function(virtual_* v, VirtualResult& r, F f, Class* obj, - Args&... args); - -#elif BOOST_CONTRACT_DETAIL_TVARIADIC - BOOST_CONTRACT_PUBLIC_FUNCTION_VIRTUAL_OVERRIDE_Z_(1, /* arity = */ ~, - /* arity_compl = */ ~, /* has_virtual_result = */ 0) - BOOST_CONTRACT_PUBLIC_FUNCTION_VIRTUAL_OVERRIDE_Z_(1, /* arity = */ ~, - /* arity_compl = */ ~, /* has_virtual_result = */ 1) - -#else - /* PRIVATE */ - - #define BOOST_CONTRACT_PUBLIC_FUNCTION_VIRTUAL_OVERRIDE_ARITY_( \ - z, arity, unused) \ - BOOST_CONTRACT_PUBLIC_FUNCTION_VIRTUAL_OVERRIDES_(z, arity, \ - BOOST_PP_SUB(BOOST_CONTRACT_MAX_ARGS, arity), ~) - - #define BOOST_CONTRACT_PUBLIC_FUNCTION_VIRTUAL_OVERRIDES_(z, \ - arity, arity_compl, unused) \ - BOOST_CONTRACT_PUBLIC_FUNCTION_VIRTUAL_OVERRIDE_Z_(z, \ - arity, arity_compl, /* has_virtual_result = */ 0) \ - BOOST_CONTRACT_PUBLIC_FUNCTION_VIRTUAL_OVERRIDE_Z_(z, \ - arity, arity_compl, /* has_virtual_result = */ 1) - - /* CODE */ - - BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_CONTRACT_MAX_ARGS), - BOOST_CONTRACT_PUBLIC_FUNCTION_VIRTUAL_OVERRIDE_ARITY_, ~) -#endif - -} } // namespace - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/contract_macro.hpp b/contrib/restricted/boost/boost/contract_macro.hpp deleted file mode 100644 index 8bfa7c84eb3..00000000000 --- a/contrib/restricted/boost/boost/contract_macro.hpp +++ /dev/null @@ -1,1397 +0,0 @@ - -#ifndef BOOST_CONTRACT_MACRO_HPP_ -#define BOOST_CONTRACT_MACRO_HPP_ - -// Copyright (C) 2008-2018 Lorenzo Caminiti -// Distributed under the Boost Software License, Version 1.0 (see accompanying -// file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). -// See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html - -/** @file -Allow to disable contracts to completely remove their compile-time and run-time -overhead. -This header also includes all headers file <c>boost/contract/\*.hpp</c> that are -necessary to use its macros. - -Almost all the macros defined in this header file are variadic macros. On -compilers that do not support variadic macros, programmers can manually code -<c>\#ifndef BOOST_CONTRACT_NO_...</c> statements instead (see -@RefSect{extras.disable_contract_compilation__macro_interface_, -Disable Contract Compilation}). -*/ - -// IMPORTANT: Following headers can always be #included (without any #if-guard) -// because they expand to trivial code that does not affect compile-time. These -// headers must always be #included here (without any #if-guard) because they -// define types and macros that are typically left in user code even when -// contracts are disables (these types and macros never affect run-time and -// their definitions are trivial when contracts are disabled so their impact on -// compile-time is negligible). -#include <boost/contract/override.hpp> -#include <boost/contract/base_types.hpp> -#include <boost/contract/core/constructor_precondition.hpp> -#include <boost/contract/core/check_macro.hpp> -#include <boost/contract/core/access.hpp> -#include <boost/contract/core/virtual.hpp> -#include <boost/contract/core/exception.hpp> -#include <boost/contract/core/config.hpp> - -#ifndef BOOST_CONTRACT_NO_CONDITIONS - #include <boost/contract/assert.hpp> -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Program preconditions that can be completely disabled at compile-time. - - @c BOOST_CONTRACT_PRECONDITION(f) expands to code equivalent to the - following (note that no code is generated when - @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS} is defined): - - @code - #ifndef BOOST_CONTRACT_NO_PRECONDITIONS - .precondition(f) - #endif - @endcode - - Where: - - @arg <c><b>f</b></c> is the nullay functor called by this library to - check preconditions @c f(). - Assertions within this functor are usually programmed using - @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a call - to this functor indicates a contract assertion failure (and will - result in this library calling - @RefFunc{boost::contract::precondition_failure}). - This functor should capture variables by (constant) value, or better - by (constant) reference (to avoid extra copies). - (This is a variadic macro parameter so it can contain commas not - protected by round parenthesis.) - - @see @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation}, - @RefSect{tutorial.preconditions, Preconditions} - */ - #define BOOST_CONTRACT_PRECONDITION(...) -#elif !defined(BOOST_CONTRACT_NO_PRECONDITIONS) - #define BOOST_CONTRACT_PRECONDITION(...) .precondition(__VA_ARGS__) -#else - #define BOOST_CONTRACT_PRECONDITION(...) /* nothing */ -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Program postconditions that can be completely disabled at compile-time. - - @c BOOST_CONTRACT_POSTCONDITION(f) expands to code equivalent to the - following (note that no code is generated when - @RefMacro{BOOST_CONTRACT_NO_POSTCONDITIONS} is defined): - - @code - #ifndef BOOST_CONTRACT_NO_POSTCONDITIONS - .postcondition(f) - #endif - @endcode - - Where: - - @arg <c><b>f</b></c> is the functor called by this library to check - postconditions <c>f(...)</c>. - Assertions within this functor are usually programmed using - @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a call - to this functor indicates a contract assertion failure (and will - result in this library calling - @RefFunc{boost::contract::postcondition_failure}). - This functor should capture variables by (constant) references (to - access the values they will have at function exit). - This functor takes the return value (preferably by <c>const&</c>) as - its one single parameter but only for virtual public functions and - public functions overrides, otherwise it takes no parameter. - (This is a variadic macro parameter so it can contain commas not - protected by round parenthesis.) - - @see @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation}, - @RefSect{tutorial.postconditions, Postconditions} - */ - #define BOOST_CONTRACT_POSTCONDITION(...) -#elif !defined(BOOST_CONTRACT_NO_POSTCONDITIONS) - #define BOOST_CONTRACT_POSTCONDITION(...) .postcondition(__VA_ARGS__) -#else - #define BOOST_CONTRACT_POSTCONDITION(...) /* nothing */ -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Program exception guarantees that can be completely disabled at - compile-time. - - @c BOOST_CONTRACT_EXCEPT(f) expands to code equivalent to the following - (note that no code is generated when @RefMacro{BOOST_CONTRACT_NO_EXCEPTS} - is defined): - - @code - #ifndef BOOST_CONTRACT_NO_EXCEPTS - .except(f) - #endif - @endcode - - Where: - - @arg <c><b>f</b></c> is the nullary functor called by this library to - check exception guarantees @c f(). - Assertions within this functor are usually programmed using - @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a call - to this functor indicates a contract assertion failure (and will - result in this library calling - @RefFunc{boost::contract::except_failure}). - This functor should capture variables by (constant) references (to - access the values they will have at function exit). - (This is a variadic macro parameter so it can contain commas not - protected by round parenthesis.) - - @see @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation}, - @RefSect{tutorial.exception_guarantees, Exception Guarantees} - */ - #define BOOST_CONTRACT_EXCEPT(...) -#elif !defined(BOOST_CONTRACT_NO_EXCEPTS) - #define BOOST_CONTRACT_EXCEPT(...) .except(__VA_ARGS__) -#else - #define BOOST_CONTRACT_EXCEPT(...) /* nothing */ -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Program old value copies at body that can be completely disabled at - compile-time. - - @c BOOST_CONTRACT_OLD(f) expands to code equivalent to the following (note - that no code is generated when @RefMacro{BOOST_CONTRACT_NO_OLDS} is - defined): - - @code - #ifndef BOOST_CONTRACT_NO_OLDS - .old(f) - #endif - @endcode - - Where: - - @arg <c><b>f</b></c> is the nullary functor called by this library - @c f() to assign old value copies just before the body is execute - but after entry invariants (when they apply) and preconditions are - checked. - Old value pointers within this functor call are usually assigned - using @RefMacro{BOOST_CONTRACT_OLDOF}. - Any exception thrown by a call to this functor will result in - this library calling @RefFunc{boost::contract::old_failure} (because - old values could not be copied to check postconditions and exception - guarantees). - This functor should capture old value pointers by references so they - can be assigned (all other variables needed to evaluate old value - expressions can be captured by (constant) value, or better by - (constant) reference to avoid extra copies). - (This is a variadic macro parameter so it can contain commas not - protected by round parenthesis.) - - @see @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation}, - @RefSect{advanced.old_value_copies_at_body, - Old Value Copies at Body} - */ - #define BOOST_CONTRACT_OLD(...) - - /** - Program old values that can be completely disabled at compile-time and - require the old value type to be copyable. - - This is used to program old value copies for copyable types: - - @code - class u { - public: - void f(...) { - BOOST_CONTRACT_OLD_PTR(old_type_a)(old_var_a); - BOOST_CONTRACT_OLD_PTR(old_type_b)(old_var_b, old_expr_b); - BOOST_CONTRACT_PUBLIC_FUNCTION(this) - ... - BOOST_CONTRACT_OLD([&] { - old_var_a = BOOST_CONTRACT_OLDOF(old_expr_a); - ... - }) - ... - ; - - ... // Function body. - } - - virtual void g(..., boost::contract::virtual_* v = 0) { - BOOST_CONTRACT_OLD_PTR(old_type_a)(old_var_a); - BOOST_CONTRACT_OLD_PTR(old_type_b)(v, old_var_b, old_expr_b); - BOOST_CONTRACT_PUBLIC_FUNCTION(v, this) - ... - BOOST_CONTRACT_OLD([&] { - old_var_a = BOOST_CONTRACT_OLDOF(v, old_expr_a); - ... - }) - ... - ; - - ... // Function body. - } - - ... - }; - @endcode - - This is an overloaded variadic macro and it can be used in the following - different ways (note that no code is generated when - @RefMacro{BOOST_CONTRACT_NO_OLDS} is defined). - - 1\. <c>BOOST_CONTRACT_OLD_PTR(old_type)(old_var)</c> expands to code - equivalent to the following (this leaves the old value pointer null): - - @code - #ifndef BOOST_CONTRACT_NO_OLDS - // This declaration does not need to use `v`. - boost::contract::old_ptr<old_type> old_var - #endif - @endcode - - 2\. <c>BOOST_CONTRACT_OLD_PTR(old_type)(old_var, old_expr)</c> expands to - code equivalent to the following (this initializes the pointer to the - old value copy, but not to be used for virtual public functions and - public function overrides): - - @code - #ifndef BOOST_CONTRACT_NO_OLDS - boost::contract::old_ptr<old_type> old_var = - BOOST_CONTRACT_OLDOF(old_expr) - #endif - @endcode - - 3\. <c>BOOST_CONTRACT_OLD_PTR(old_type)(v, old_var, old_expr)</c> expands to - code equivalent to the following (this initializes the pointer to the - old value copy for virtual public functions and public function - overrides): - - @code - #ifndef BOOST_CONTRACT_NO_OLDS - boost::contract::old_ptr<old_type> old_var = - BOOST_CONTRACT_OLDOF(v, old_expr) - #endif - @endcode - - Where: - - @arg <c><b>old_type</b></c> is the type of the pointed old value. - This type must be copyable (i.e., - <c>boost::contract::is_old_value_copyable<old_type>::value</c> is - @c true), otherwise this pointer will always be null and this - library will generate a compile-time error when the pointer is - dereferenced (see @RefMacro{BOOST_CONTRACT_OLD_PTR_IF_COPYABLE}). - (This is a variadic macro parameter so it can contain commas not - protected by round parenthesis.) - @arg <c><b>v</b></c> is the extra parameter of type - @RefClass{boost::contract::virtual_}<c>*</c> and default value @c 0 - from the enclosing virtual public function or public function - override declaring the contract. - (This is not a variadic macro parameter.) - @arg <c><b>old_var</b></c> is the name of the old value pointer variable. - (This is not a variadic macro parameter but it should never contain - commas because it is an identifier.) - @arg <c><b>old_expr</b></c> is the expression to be evaluated and copied - in the old value pointer. - (This is not a variadic macro parameter so any comma it might - contain must be protected by round parenthesis, - <c>BOOST_CONTRACT_OLD_PTR(old_type)(v, old_var, (old_expr))</c> - will always work.) - - @see @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation}, - @RefSect{tutorial.old_values, Old Values} - */ - #define BOOST_CONTRACT_OLD_PTR(...) - - /** - Program old values that can be completely disabled at compile-time and do - not require the old value type to be copyable. - - This is used to program old value copies for types that might or might not - be copyable: - - @code - template<typename T> // Type `T` might or not be copyable. - class u { - public: - void f(...) { - BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type_a)(old_var_a); - BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type_b)(old_var_b, - old_expr_b); - BOOST_CONTRACT_PUBLIC_FUNCTION(this) - ... - BOOST_CONTRACT_OLD([&] { - old_var_a = BOOST_CONTRACT_OLDOF(old_expr_a); - ... - }) - ... // In postconditions or exception guarantees: - if(old_var_a) ... // Always null for non-copyable types. - if(old_var_b) ... // Always null for non-copyable types. - ... - ; - - ... // Function body. - } - - virtual void g(..., boost::contract::virtual_* v = 0) { - BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type_a)(old_var_a); - BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type_b)(v, old_var_b, - old_expr_b); - BOOST_CONTRACT_PUBLIC_FUNCTION(v, this) - ... - BOOST_CONTRACT_OLD([&] { - old_var_a = BOOST_CONTRACT_OLDOF(v, old_expr_a); - ... - }) - ... // In postconditions or exception guarantees: - if(old_var_a) ... // Always null for non-copyable types. - if(old_var_b) ... // Always null for non-copyable types. - ... - ; - - ... // Function body. - } - - ... - }; - @endcode - - This is an overloaded variadic macro and it can be used in the following - different ways (note that no code is generated when - @RefMacro{BOOST_CONTRACT_NO_OLDS} is defined). - - 1\. <c>BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type)(old_var)</c> expands to - code equivalent to the following (this leaves the old value pointer - null): - - @code - #ifndef BOOST_CONTRACT_NO_OLDS - // This declaration does not need to use `v`. - boost::contract::old_ptr_if_copyable<old_type> old_var - #endif - @endcode - - 2\. <c>BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type)(old_var, old_expr)</c> - expands to code equivalent to the following (this initializes the - pointer to the old value copy, but not to be used for virtual public - functions and public function overrides): - - @code - #ifndef BOOST_CONTRACT_NO_OLDS - boost::contract::old_ptr_if_copyable<old_type> old_var = - BOOST_CONTRACT_OLDOF(old_expr) - #endif - @endcode - - 3\. <c>BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type)(v, old_var, - old_expr)</c> expands to code equivalent to the following (this - initializes the pointer to the old value copy for virtual public - functions and public function overrides): - - @code - #ifndef BOOST_CONTRACT_NO_OLDS - boost::contract::old_ptr_if_copyable<old_type> old_var = - BOOST_CONTRACT_OLDOF(v, old_expr) - #endif - @endcode - - Where: - - @arg <c><b>old_type</b></c> is the type of the pointed old value. - If this type is not copyable (i.e., - <c>boost::contract::is_old_value_copyable<old_type>::value</c> is - @c false), this pointer will always be null, but this library will - not generate a compile-time error when this pointer is dereferenced - (see @RefMacro{BOOST_CONTRACT_OLD_PTR}). - (This is a variadic macro parameter so it can contain commas not - protected by round parenthesis.) - @arg <c><b>v</b></c> is the extra parameter of type - @RefClass{boost::contract::virtual_}<c>*</c> and default value @c 0 - from the enclosing virtual public function or public function - override declaring the contract. - (This is not a variadic macro parameter.) - @arg <c><b>old_var</b></c> is the name of the old value pointer variable. - (This is not a variadic macro parameter but it should never contain - commas because it is an identifier.) - @arg <c><b>old_expr</b></c> is the expression to be evaluated and copied - in the old value pointer. - (This is not a variadic macro parameter so any comma it might - contain must be protected by round parenthesis, - <c>BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(old_type)(v, old_var, - (old_expr))</c> will always work.) - - @see @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation}, - @RefSect{extras.old_value_requirements__templates_, - Old Value Requirements} - */ - #define BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(...) -#elif !defined(BOOST_CONTRACT_NO_OLDS) - #include <boost/contract/old.hpp> - #include <boost/preprocessor/facilities/overload.hpp> - #include <boost/preprocessor/facilities/empty.hpp> - #include <boost/preprocessor/cat.hpp> - - /* PRIVATE */ - - #define BOOST_CONTRACT_OLD_VAR_1(ptr) \ - ptr - #define BOOST_CONTRACT_OLD_VAR_2(ptr, expr) \ - ptr = BOOST_CONTRACT_OLDOF(expr) - #define BOOST_CONTRACT_OLD_VAR_3(v, ptr, expr) \ - ptr = BOOST_CONTRACT_OLDOF(v, expr) - - #define BOOST_CONTRACT_OLD_VAR_(...) \ - BOOST_PP_CAT(BOOST_PP_OVERLOAD(BOOST_CONTRACT_OLD_VAR_, __VA_ARGS__) \ - (__VA_ARGS__), BOOST_PP_EMPTY()) - - /* PUBLIC */ - - #define BOOST_CONTRACT_OLD(...) .old(__VA_ARGS__) - - #define BOOST_CONTRACT_OLD_PTR(...) \ - boost::contract::old_ptr< __VA_ARGS__ > \ - BOOST_CONTRACT_OLD_VAR_ - - #define BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(...) \ - boost::contract::old_ptr_if_copyable< __VA_ARGS__ > \ - BOOST_CONTRACT_OLD_VAR_ -#else - #include <boost/preprocessor/tuple/eat.hpp> - - #define BOOST_CONTRACT_OLD(...) /* nothing */ - - #define BOOST_CONTRACT_OLD_PTR(...) BOOST_PP_TUPLE_EAT(0) - - #define BOOST_CONTRACT_OLD_PTR_IF_COPYABLE(...) BOOST_PP_TUPLE_EAT(0) -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Program (constant) class invariants that can be completely disabled at - compile-time. - - @c BOOST_CONTRACT_INVARIANT({ ... }) expands to code equivalent to the - following (note that no code is generated when - @RefMacro{BOOST_CONTRACT_NO_INVARIANTS} is defined): - - @code - #ifndef BOOST_CONTRACT_NO_INVARIANTS - void BOOST_CONTRACT_INVARIANT_FUNC() const { - ... - } - #endif - @endcode - - Where: - - @arg <b>{ ... }</b> is the definition of the function that checks class - invariants for public functions that are not static and not volatile - (see @RefMacro{BOOST_CONTRACT_STATIC_INVARIANT} and - @RefMacro{BOOST_CONTRACT_INVARIANT_VOLATILE}). - The curly parenthesis are mandatory. - Assertions within this function are usually programmed using - @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a call - to this function indicates a contract assertion failure (and will - result in this library calling either - @RefFunc{boost::contract::entry_invariant_failure} or - @RefFunc{boost::contract::exit_invariant_failure}). - (This is a variadic macro parameter so it can contain commas not - protected by round parenthesis.) - - @see @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation}, - @RefSect{tutorial.class_invariants, Class Invariants} - */ - #define BOOST_CONTRACT_INVARIANT(...) - - /** - Program volatile class invariants that can be completely disabled at - compile-time. - - @c BOOST_CONTRACT_INVARIANT_VOLATILE({ ... }) expands to code equivalent to - the following (note that no code is generated when - @RefMacro{BOOST_CONTRACT_NO_INVARIANTS} is defined): - - @code - #ifndef BOOST_CONTRACT_NO_INVARIANTS - void BOOST_CONTRACT_INVARIANT_FUNC() const volatile { - ... - } - #endif - @endcode - - Where: - - @arg <b>{ ... }</b> is the definition of the function that checks class - invariants for volatile public functions - (see @RefMacro{BOOST_CONTRACT_INVARIANT} and - @RefMacro{BOOST_CONTRACT_STATIC_INVARIANT}). - The curly parenthesis are mandatory. - Assertions within this function are usually programmed using - @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a call - to this function indicates a contract assertion failure (and will - result in this library calling either - @RefFunc{boost::contract::entry_invariant_failure} or - @RefFunc{boost::contract::exit_invariant_failure}). - (This is a variadic macro parameter so it can contain commas not - protected by round parenthesis.) - - @see @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation}, - @RefSect{extras.volatile_public_functions, - Volatile Public Functions} - */ - #define BOOST_CONTRACT_INVARIANT_VOLATILE(...) - - /** - Program static class invariants that can be completely disabled at - compile-time. - - @c BOOST_CONTRACT_STATIC_INVARIANT({ ... }) expands to code equivalent to - the following (note that no code is generated when - @RefMacro{BOOST_CONTRACT_NO_INVARIANTS} is defined): - - @code - #ifndef BOOST_CONTRACT_NO_INVARIANTS - static void BOOST_CONTRACT_STATIC_INVARIANT_FUNC() { - ... - } - #endif - @endcode - - Where: - - @arg <b>{ ... }</b> is the definition of the function that checks class - invariants for static public functions - (see @RefMacro{BOOST_CONTRACT_INVARIANT} and - @RefMacro{BOOST_CONTRACT_INVARIANT_VOLATILE}). - The curly parenthesis are mandatory. - Assertions within this function are usually programmed using - @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a call - to this function indicates a contract assertion failure (and will - result in this library calling either - @RefFunc{boost::contract::entry_invariant_failure} or - @RefFunc{boost::contract::exit_invariant_failure}). - (This is a variadic macro parameter so it can contain commas not - protected by round parenthesis.) - - @see @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation}, - @RefSect{tutorial.class_invariants, Class Invariants} - */ - #define BOOST_CONTRACT_STATIC_INVARIANT(...) -#elif !defined(BOOST_CONTRACT_NO_INVARIANTS) - #include <boost/contract/core/config.hpp> - - #define BOOST_CONTRACT_INVARIANT(...) \ - void BOOST_CONTRACT_INVARIANT_FUNC() const __VA_ARGS__ - - #define BOOST_CONTRACT_INVARIANT_VOLATILE(...) \ - void BOOST_CONTRACT_INVARIANT_FUNC() const volatile __VA_ARGS__ - - #define BOOST_CONTRACT_STATIC_INVARIANT(...) \ - static void BOOST_CONTRACT_STATIC_INVARIANT_FUNC() __VA_ARGS__ -#else - #define BOOST_CONTRACT_INVARIANT(...) /* nothing */ - - #define BOOST_CONTRACT_INVARIANT_VOLATILE(...) /* nothing */ - - #define BOOST_CONTRACT_STATIC_INVARIANT(...) /* nothing */ -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Program contracts that can be completely disabled at compile-time for - constructors. - - This is used together with @RefMacro{BOOST_CONTRACT_POSTCONDITION}, - @RefMacro{BOOST_CONTRACT_EXCEPT}, and @RefMacro{BOOST_CONTRACT_OLD} to - specify postconditions, exception guarantees, and old value copies at body - that can be completely disabled at compile-time for constructors (see - @RefMacro{BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION} to specify preconditions - for constructors): - - @code - class u { - friend class boost::contract::access; - - BOOST_CONTRACT_INVARIANT({ // Optional (as for static and volatile). - BOOST_CONTRACT_ASSERT(...); - ... - }) - - public: - u(...) { - BOOST_CONTRACT_OLD_PTR(old_type)(old_var); - BOOST_CONTRACT_CONSTRUCTOR(this) - // No `PRECONDITION` (use `CONSTRUCTOR_PRECONDITION` if needed). - BOOST_CONTRACT_OLD([&] { // Optional. - old_var = BOOST_CONTRACT_OLDOF(old_epxr); - ... - }) - BOOST_CONTRACT_POSTCONDITION([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - BOOST_CONTRACT_EXCEPT([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - ; - - ... // Constructor body. - } - - ... - }; - @endcode - - For optimization, this can be omitted for constructors that do not have - postconditions and exception guarantees, within classes that have no - invariants. - - @c BOOST_CONTRACT_CONSTRUCTOR(obj) expands to code equivalent to the - following (note that no code is generated when - @RefMacro{BOOST_CONTRACT_NO_CONSTRUCTORS} is defined): - - @code - #ifndef BOOST_CONTRACT_NO_CONSTRUCTORS - boost::contract::check internal_var = - boost::contract::constructor(obj) - #endif - @endcode - - Where: - - @arg <c><b>obj</b></c> is the object @c this from the scope of the - enclosing constructor declaring the contract. - Constructors check all class invariants, including static and - volatile invariants (see @RefMacro{BOOST_CONTRACT_INVARIANT}, - @RefMacro{BOOST_CONTRACT_STATIC_INVARIANT}, and - @RefMacro{BOOST_CONTRACT_INVARIANT_VOLATILE}). - (This is a variadic macro parameter so it can contain commas not - protected by round parenthesis.) - @arg <c><b>internal_var</b></c> is a variable name internally generated - by this library (this name is unique but only on different line - numbers so this macro cannot be expanded multiple times on the same - line). - - @see @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation}, - @RefSect{tutorial.constructors, Constructors} - */ - #define BOOST_CONTRACT_CONSTRUCTOR(...) -#elif !defined(BOOST_CONTRACT_NO_CONSTRUCTORS) - #include <boost/contract/constructor.hpp> - #include <boost/contract/check.hpp> - #include <boost/contract/detail/name.hpp> - - #define BOOST_CONTRACT_CONSTRUCTOR(...) \ - boost::contract::check BOOST_CONTRACT_DETAIL_NAME2(c, __LINE__) = \ - boost::contract::constructor(__VA_ARGS__) -#else - #define BOOST_CONTRACT_CONSTRUCTOR(...) /* nothing */ -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Program preconditions that can be disabled at compile-time for constructors. - - This is used together with @RefMacro{BOOST_CONTRACT_CONSTRUCTOR} to specify - contracts for constructors. - Constructors that do not have preconditions do not use this macro. - When at least one of the class constructors uses this macro, - @RefClass{boost::contract::constructor_precondition} must be the first and - private base class of the class declaring the constructor for which - preconditions are programmed: - - @code - class u - #define BASES private boost::contract::constructor_precondition<u>, \ - public b - : BASES - { - ... - #undef BASES - - public: - explicit u(unsigned x) : - BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION(u)([&] { - BOOST_CONTRACT_ASSERT(x != 0); - }), - b(1.0 / float(x)) - { - ... - } - - ... - }; - @endcode - - <c>BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION(class_type)(f)</c> expands - to code equivalent to the following (note that when - @RefMacro{BOOST_CONTRACT_NO_PRECONDITIONS} is defined, this macro trivially - expands to a default constructor call that is internally implemented to do - nothing so this should have minimal to no overhead): - - @code - // Guarded only by NO_PRECONDITIONS (and not also by NO_CONSTRUCTORS) - // because for constructor's preconditions (not for postconditions, etc.). - #ifndef BOOST_CONTRACT_NO_PRECONDITIONS - boost::contract::constructor_precondition<class_type>(f) - #else - // No-op call (likely optimized away, minimal to no overhead). - boost::contract::constructor_precondition<class_type>() - #endif - - @endcode - - Where: - - @arg <c><b>class_type</b></c> is the type of the class containing the - constructor for which preconditions are being programmed. - (This is a variadic macro parameter so it can contain commas not - protected by round parenthesis.) - @arg <c><b>f</b></c> is the nullary functor called by this library to - check constructor preconditions @c f(). - Assertions within this functor call are usually programmed using - @RefMacro{BOOST_CONTRACT_ASSERT}, but any exception thrown by a call - to this functor indicates a contract failure (and will result in - this library calling - @RefFunc{boost::contract::precondition_failure}). - This functor should capture variables by (constant) value, or better - by (constant) reference to avoid extra copies. - (This is a variadic macro parameter so it can contain commas not - protected by round parenthesis.) - - @see @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation}, - @RefSect{tutorial.constructors, Constructors} - */ - #define BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION(...) -#elif !defined(BOOST_CONTRACT_NO_PRECONDITIONS) // Not NO_CONSTRUCTORS here. - // constructor_precondition.hpp already #included at top. - - #define BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION(...) \ - boost::contract::constructor_precondition< __VA_ARGS__ > -#else - #include <boost/preprocessor/tuple/eat.hpp> - // constructor_precondition.hpp always #included at top of this file. - - #define BOOST_CONTRACT_CONSTRUCTOR_PRECONDITION(...) \ - /* always use default ctor (i.e., do nothing) */ \ - boost::contract::constructor_precondition< __VA_ARGS__ >() \ - BOOST_PP_TUPLE_EAT(0) -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Program contracts that can be completely disabled at compile-time for - destructors. - - This is used together with @RefMacro{BOOST_CONTRACT_POSTCONDITION}, - @RefMacro{BOOST_CONTRACT_EXCEPT}, and @RefMacro{BOOST_CONTRACT_OLD} to - specify postconditions, exception guarantees, and old value copies at body - that can be completely disabled at compile-time for destructors (destructors - cannot have preconditions, see - @RefSect{contract_programming_overview.destructor_calls, Destructor Calls}): - - @code - class u { - friend class boost::contract::access; - - BOOST_CONTRACT_INVARIANT({ // Optional (as for static and volatile). - BOOST_CONTRACT_ASSERT(...); - ... - }) - - public: - ~u() { - BOOST_CONTRACT_OLD_PTR(old_type)(old_var); - BOOST_CONTRACT_DESTRUCTOR(this) - // No `PRECONDITION` (destructors have no preconditions). - BOOST_CONTRACT_OLD([&] { // Optional. - old_var = BOOST_CONTRACT_OLDOF(old_expr); - ... - }) - BOOST_CONTRACT_POSTCONDITION([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - BOOST_CONTRACT_EXCEPT([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - ; - - ... // Destructor body. - } - - ... - }; - @endcode - - For optimization, this can be omitted for destructors that do not have - postconditions and exception guarantees, within classes that have no - invariants. - - @c BOOST_CONTRACT_DESTRUCTOR(obj) expands to code equivalent to the - following (note that no code is generated when - @RefMacro{BOOST_CONTRACT_NO_DESTRUCTORS} is defined): - - @code - #ifndef BOOST_CONTRACT_NO_DESTRUCTORS - boost::contract::check internal_var = - boost::contract::destructor(obj) - #endif - @endcode - - Where: - - @arg <c><b>obj</b></c> is the object @c this from the scope of the - enclosing destructor declaring the contract. - Destructors check all class invariants, including static and - volatile invariants (see @RefSect{tutorial.class_invariants, - Class Invariants} and - @RefSect{extras.volatile_public_functions, - Volatile Public Functions}). - (This is a variadic macro parameter so it can contain commas not - protected by round parenthesis.) - @arg <c><b>internal_var</b></c> is a variable name internally generated - by this library (this name is unique but only on different line - numbers so this macro cannot be expanded multiple times on the same - line). - - @see @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation}, - @RefSect{tutorial.destructors, Destructors} - */ - #define BOOST_CONTRACT_DESTRUCTOR(...) -#elif !defined(BOOST_CONTRACT_NO_DESTRUCTORS) - #include <boost/contract/destructor.hpp> - #include <boost/contract/check.hpp> - #include <boost/contract/detail/name.hpp> - - #define BOOST_CONTRACT_DESTRUCTOR(...) \ - boost::contract::check BOOST_CONTRACT_DETAIL_NAME2(c, __LINE__) = \ - boost::contract::destructor(__VA_ARGS__) -#else - #define BOOST_CONTRACT_DESTRUCTOR(...) /* nothing */ -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Program contracts that can be completely disabled at compile-time for - (non-public) functions. - - This is used together with @RefMacro{BOOST_CONTRACT_PRECONDITION}, - @RefMacro{BOOST_CONTRACT_POSTCONDITION}, @RefMacro{BOOST_CONTRACT_EXCEPT}, - and @RefMacro{BOOST_CONTRACT_OLD} to specify preconditions, postconditions, - exception guarantees, and old value copies at body that can be completely - disabled at compile-time for (non-public) functions: - - @code - void f(...) { - BOOST_CONTRACT_OLD_PTR(old_type)(old_var); - BOOST_CONTRACT_FUNCTION() - BOOST_CONTRACT_PRECONDITION([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - BOOST_CONTRACT_OLD([&] { // Optional. - old_var = BOOST_CONTRACT_OLDOF(old_expr); - ... - }) - BOOST_CONTRACT_POSTCONDITION([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - BOOST_CONTRACT_EXCEPT([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - ; - - ... // Function body. - } - @endcode - - This can be used to program contracts for non-member functions but also for - private and protected functions, lambda functions, loops, arbitrary blocks - of code, etc. - For optimization, this can be omitted for code that does not have - preconditions, postconditions, and exception guarantees. - - @c BOOST_CONTRACT_FUNCTION() expands to code equivalent to the following - (note that no code is generated when @RefMacro{BOOST_CONTRACT_NO_FUNCTIONS} - is defined): - - @code - #ifndef BOOST_CONTRACT_NO_FUNCTIONS - boost::contract::check internal_var = - boost::contract::function() - #endif - @endcode - - Where: - - @arg <c><b>internal_var</b></c> is a variable name internally generated - by this library (this name is unique but only on different line - numbers so this macro cannot be expanded multiple times on the same - line). - - @see @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation}, - @RefSect{tutorial.non_member_functions, Non-Member Functions}, - @RefSect{advanced.private_and_protected_functions, - Private and Protected Functions}, - @RefSect{advanced.lambdas__loops__code_blocks__and__constexpr__, - Lambdas\, Loops\, Code Blocks} - */ - #define BOOST_CONTRACT_FUNCTION() -#elif !defined(BOOST_CONTRACT_NO_FUNCTIONS) - #include <boost/contract/function.hpp> - #include <boost/contract/check.hpp> - #include <boost/contract/detail/name.hpp> - - #define BOOST_CONTRACT_FUNCTION() \ - boost::contract::check BOOST_CONTRACT_DETAIL_NAME2(c, __LINE__) = \ - boost::contract::function() -#else - #include <boost/preprocessor/facilities/empty.hpp> - - #define BOOST_CONTRACT_FUNCTION() /* nothing */ -#endif - -#ifdef BOOST_CONTRACT_DETAIL_DOXYGEN - /** - Program contracts that can be completely disabled at compile-time for static - public functions. - - This is used together with @RefMacro{BOOST_CONTRACT_PRECONDITION}, - @RefMacro{BOOST_CONTRACT_POSTCONDITION}, @RefMacro{BOOST_CONTRACT_EXCEPT}, - and @RefMacro{BOOST_CONTRACT_OLD} to specify preconditions, postconditions, - exception guarantees, and old value copies at body that can be completely - disabled at compile-time for static public functions: - - @code - class u { - friend class boost::contract::access; - - BOOST_CONTRACT_STATIC_INVARIANT({ // Optional (as for non-static). - BOOST_CONTRACT_ASSERT(...); - ... - }) - - public: - static void f(...) { - BOOST_CONTRACT_OLD_PTR(old_type)(old_var); - BOOST_CONTRACT_PUBLIC_FUNCTION(u) - BOOST_CONTRACT_PRECONDITION([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - BOOST_CONTRACT_OLD([&] { // Optional. - old_var = BOOST_CONTRACT_OLDOF(old_expr); - ... - }) - BOOST_CONTRACT_POSTCONDITION([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - BOOST_CONTRACT_EXCEPT([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - ; - - ... // Function body. - } - - ... - }; - @endcode - - For optimization, this can be omitted for static public functions that do - not have preconditions, postconditions and exception guarantees, within - classes that have no static invariants. - - @c BOOST_CONTRACT_STATIC_PUBLIC_FUNCTION(class_type) expands to code - equivalent to the following (note that no code is generated when - @RefMacro{BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS} is defined): - - @code - #ifndef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS - boost::contract::check internal_var = - boost::contract::public_function<class_type>() - #endif - @endcode - - Where: - - @arg <c><b>class_type</b></c> is the type of the class containing the - static public function declaring the contract. - (This is a variadic macro parameter so it can contain commas not - protected by round parenthesis.) - @arg <c><b>internal_var</b></c> is a variable name internally generated - by this library (this name is unique but only on different line - numbers so this macro cannot be expanded multiple times on the same - line). - - @see @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation}, - @RefSect{tutorial.static_public_functions, Static Public Functions} - */ - #define BOOST_CONTRACT_STATIC_PUBLIC_FUNCTION(...) - - /** - Program contracts that can be completely disabled at compile-time for - non-static public functions that do not override. - - This is used together with @RefMacro{BOOST_CONTRACT_PRECONDITION}, - @RefMacro{BOOST_CONTRACT_POSTCONDITION}, @RefMacro{BOOST_CONTRACT_EXCEPT}, - and @RefMacro{BOOST_CONTRACT_OLD} to specify preconditions, postconditions, - exception guarantees, and old value copies at body that can be completely - disabled at compile-time for non-static public functions (virtual or not, - void or not) that do not override: - - @code - class u { - friend class boost::contract::access; - - BOOST_CONTRACT_INVARIANT({ // Optional (as for static and volatile). - BOOST_CONTRACT_ASSERT(...); - ... - }) - - public: - // Non-virtual (same if void). - t f(...) { - t result; - BOOST_CONTRACT_OLD_PTR(old_type)(old_var); - BOOST_CONTRACT_PUBLIC_FUNCTION(this) - BOOST_CONTRACT_PRECONDITION([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - BOOST_CONTRACT_OLD([&] { // Optional. - old_var = BOOST_CONTRACT_OLDOF(old_expr); - ... - }) - BOOST_CONTRACT_POSTCONDITION([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - BOOST_CONTRACT_EXCEPT([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - ; - - ... // Function body (use `return result = return_expr`). - } - - // Virtual and void. - virtual void g(..., boost::contract::virtual_* v = 0) { - BOOST_CONTRACT_OLD_PTR(old_type)(old_var); - BOOST_CONTRACT_PUBLIC_FUNCTION(v, this) - ... - BOOST_CONTRACT_OLD([&] { // Optional. - old_var = BOOST_CONTRACT_OLDOF(v, old_expr); - ... - }) - ... - ; - - ... // Function body. - } - - // Virtual and non-void. - virtual t h(..., boost::contract::virtual_* v = 0) { - t result; - BOOST_CONTRACT_OLD_PTR(old_type)(old_var); - BOOST_CONTRACT_PUBLIC_FUNCTION(v, result, this) - ... - BOOST_CONTRACT_OLD([&] { // Optional. - old_var = BOOST_CONTRACT_OLDOF(v, old_expr); - ... - }) - BOOST_CONTRACT_POSTCONDITION([&] (t const& result) { // Optional - BOOST_CONTRACT_ASSERT(...); - ... - }) - ... - ; - - ... // Function body (use `return result = return_expr`). - } - - ... - }; - @endcode - - For optimization, this can be omitted for non-virtual public functions that - do not have preconditions, postconditions and exception guarantees, within - classes that have no invariants. - Virtual public functions should always use - @RefMacro{BOOST_CONTRACT_PUBLIC_FUNCTION} otherwise this library will not - be able to correctly use them for subcontracting. - - This is an overloaded variadic macro and it can be used in the following - different ways (note that no code is generated when - @RefMacro{BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS} is defined). - - 1\. <c>BOOST_CONTRACT_PUBLIC_FUNCTION(obj)</c> expands to code - equivalent to the following (for non-virtual public functions that are - not static and do not override, returning void or not): - - @code - #ifndef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS - boost::contract::check internal_var = - boost::contract::public_function(obj) - #endif - @endcode - - 2\. <c>BOOST_CONTRACT_PUBLIC_FUNCTION(v, obj)</c> expands to code - equivalent to the following (for virtual public functions that are - not static and do not override, returning void): - - @code - #ifndef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS - boost::contract::check internal_var = - boost::contract::public_function(v, obj) - #endif - @endcode - - 3\. <c>BOOST_CONTRACT_PUBLIC_FUNCTION(v, r, obj)</c> expands to code - equivalent to the following (for virtual public functions that are - not static and do not override, not returning void): - - @code - #ifndef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS - boost::contract::check internal_var = - boost::contract::public_function(v, r, obj) - #endif - @endcode - - Where (these are all variadic macro parameters so they can contain commas - not protected by round parenthesis): - - @arg <c><b>v</b></c> is the extra parameter of type - @RefClass{boost::contract::virtual_}<c>*</c> and default value @c 0 - from the enclosing virtual public function declaring the contract. - @arg <c><b>r</b></c> is a reference to the return value of the enclosing - virtual public function declaring the contract. - This is usually a local variable declared by the enclosing virtual - public function just before the contract, but programmers must set - it to the actual value being returned by the function at each - @c return statement. - @arg <c><b>obj</b></c> is the object @c this from the scope of the - enclosing public function declaring the contract. - This object might be mutable, @c const, @c volatile, or - <c>const volatile</c> depending on the cv-qualifier of the enclosing - function (volatile public functions will check volatile class - invariants, see @RefSect{extras.volatile_public_functions, - Volatile Public Functions}). - @arg <c><b>internal_var</b></c> is a variable name internally generated - by this library (this name is unique but only on different line - numbers so this macro cannot be expanded multiple times on the same - line). - - @see @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation}, - @RefSect{tutorial.public_functions, Public Functions}, - @RefSect{tutorial.virtual_public_functions, - Virtual Public Functions} - */ - #define BOOST_CONTRACT_PUBLIC_FUNCTION(...) - - /** - Program contracts that can be completely disabled at compile-time for - public function overrides. - - This is used together with @RefMacro{BOOST_CONTRACT_PRECONDITION}, - @RefMacro{BOOST_CONTRACT_POSTCONDITION}, @RefMacro{BOOST_CONTRACT_EXCEPT}, - and @RefMacro{BOOST_CONTRACT_OLD} to specify preconditions, postconditions, - exception guarantees, and old value copies at body that can be completely - disabled at compile-time for public function overrides (virtual or not): - - @code - class u - #define BASES private boost::contract::constructor_precondition<u>, \ - public b, private w - : BASES - { - friend class boost::contract::access; - - typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types; - #undef BASES - - BOOST_CONTRACT_INVARIANT({ // Optional (as for static and volatile). - BOOST_CONTRACT_ASSERT(...); - ... - }) - - BOOST_CONTRACT_OVERRIDES(f, g) - - public: - // Override from `b::f`, and void. - void f(t_1 a_1, ..., t_n a_n, boost::contract::virtual_* v = 0) { - BOOST_CONTRACT_OLD_PTR(old_type)(old_var); - BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE(override_f)( - v, &u::f, this, a_1, ..., a_n) - BOOST_CONTRACT_PRECONDITION([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - BOOST_CONTRACT_OLD([&] { // Optional. - old_var = BOOST_CONTRACT_OLDOF(v, old_expr); - ... - }) - BOOST_CONTRACT_POSTCONDITION([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - BOOST_CONTRACT_EXCEPT([&] { // Optional. - BOOST_CONTRACT_ASSERT(...); - ... - }) - ; - - ... // Function body. - } - - // Override from `b::g`, and void. - t g(t_1 a_1, ..., t_n a_n, boost::contract::virtual_* v = 0) { - t result; - BOOST_CONTRACT_OLD_PTR(old_type)(old_var); - BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE(override_g)( - v, result, &u::g, this, a_1, ..., a_n) - ... - BOOST_CONTRACT_OLD([&] { // Optional. - old_var = BOOST_CONTRACT_OLDOF(v, old_expr); - ... - }) - BOOST_CONTRACT_POSTCONDITION([&] (t const& result) { // Optional - BOOST_CONTRACT_ASSERT(...); - ... - }) - ... - ; - - ... // Function body (use `return result = return_expr`). - } - - ... - }; - @endcode - - Public function overrides should always use - @RefMacro{BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE} otherwise this library - will not be able to correctly use it for subcontracting. - - This is an overloaded variadic macro and it can be used in the following - different ways (note that no code is generated when - @RefMacro{BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS} is defined). - - 1\. <c>BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE(override_type)(v, f, obj, - ...)</c> expands to code equivalent to the following (for public - function overrides that return void): - - @code - #ifndef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS - boost::contract::check internal_var = boost::contract:: - public_function<override_type>(v, f, obj, ...) - #endif - @endcode - - 2\. <c>BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE(override_type)(v, r, f, obj, - ...)</c> expands to code equivalent to the following (for public - function overrides that do not return void): - - @code - #ifndef BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS - boost::contract::check internal_var = boost::contract:: - public_function<override_type>(v, r, f, obj, ...) - #endif - @endcode - - Where (these are all variadic macro parameters so they can contain commas - not protected by round parenthesis): - - @arg <c><b>override_type</b></c> is the type - <c>override_<i>function-name</i></c> declared using the - @RefMacro{BOOST_CONTRACT_OVERRIDE} or related macros. - @arg <c><b>v</b></c> is the extra parameter of type - @RefClass{boost::contract::virtual_}<c>*</c> and default value @c 0 - from the enclosing virtual public function declaring the contract. - @arg <c><b>r</b></c> is a reference to the return value of the enclosing - virtual public function declaring the contract. - This is usually a local variable declared by the enclosing virtual - public function just before the contract, but programmers must set - it to the actual value being returned by the function at each - @c return statement. - @arg <c><b>f</b></c> is a pointer to the enclosing public function - override declaring the contract. - @arg <c><b>obj</b></c> is the object @c this from the scope of the - enclosing public function declaring the contract. - This object might be mutable, @c const, @c volatile, or - <c>const volatile</c> depending on the cv-qualifier of the enclosing - function (volatile public functions will check volatile class - invariants, see @RefSect{extras.volatile_public_functions, - Volatile Public Functions}). - @arg <c><b>...</b></c> is a variadic macro parameter listing all the - arguments passed to the enclosing public function override declaring - the contract (by reference and in order they appear in the enclosing - function declaration), but excluding the trailing argument @c v. - @arg <c><b>internal_var</b></c> is a variable name internally generated - by this library (this name is unique but only on different line - numbers so this macro cannot be expanded multiple times on the same - line). - - @see @RefSect{extras.disable_contract_compilation__macro_interface_, - Disable Contract Compilation}, - @RefSect{tutorial.public_function_overrides__subcontracting_, - Public Function Overrides} - */ - #define BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE(...) -#elif !defined(BOOST_CONTRACT_NO_PUBLIC_FUNCTIONS) - #include <boost/contract/public_function.hpp> - #include <boost/contract/check.hpp> - #include <boost/contract/detail/name.hpp> - - #define BOOST_CONTRACT_STATIC_PUBLIC_FUNCTION(...) \ - boost::contract::check BOOST_CONTRACT_DETAIL_NAME2(c, __LINE__) = \ - boost::contract::public_function< __VA_ARGS__ >() - - #define BOOST_CONTRACT_PUBLIC_FUNCTION(...) \ - boost::contract::check BOOST_CONTRACT_DETAIL_NAME2(c, __LINE__) = \ - boost::contract::public_function(__VA_ARGS__) - - #define BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE(...) \ - boost::contract::check BOOST_CONTRACT_DETAIL_NAME2(c, __LINE__) = \ - boost::contract::public_function<__VA_ARGS__> -#else - #include <boost/preprocessor/tuple/eat.hpp> - - #define BOOST_CONTRACT_STATIC_PUBLIC_FUNCTION(...) /* nothing */ - - #define BOOST_CONTRACT_PUBLIC_FUNCTION(...) /* nothing */ - - #define BOOST_CONTRACT_PUBLIC_FUNCTION_OVERRIDE(...) BOOST_PP_TUPLE_EAT(0) -#endif - -#endif // #include guard - diff --git a/contrib/restricted/boost/boost/convert.hpp b/contrib/restricted/boost/boost/convert.hpp deleted file mode 100644 index efde44ff7b6..00000000000 --- a/contrib/restricted/boost/boost/convert.hpp +++ /dev/null @@ -1,215 +0,0 @@ -/// @file -// Boost.Convert -// Copyright (c) 2009-2016 Vladimir Batov. -// -// Many thanks to Julian Gonggrijp, Rob Stewart, Andrzej Krzemienski, Matus Chochlik, Jeroen Habraken, -// Hartmut Kaiser, Joel De Guzman, Thijs (M.A.) van den Berg, Roland Bock, Gavin Lambert, Paul Bristow, -// Alex Hagen-Zanker, Christopher Kormanyos for taking part in the Boost.Convert review. -// -// Special thanks to: -// -// 1. Alex Hagen-Zanker, Roland Bock, Rob Stewart for their considerable contributions to the design -// and implementation of the library; -// 2. Andrzej Krzemienski for helping to partition responsibilities and to ultimately pave -// the way for the boost::optional and future std::tr2::optional deployment; -// 3. Edward Diener the Boost Review Manager for helping with the converters' design, his continuous -// involvement, technical and administrative help, guidance and advice; -// 4. Joel De Guzman, Rob Stewart and Alex Hagen-Zanker for making sure the performance tests work -// as they should; -// 5. Paul Bristow for helping great deal with the documentation; -// 6. Kevlin Henney and Dave Abrahams for their lexical_cast-related insights and explanations. -// -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. - -#ifndef BOOST_CONVERT_HPP -#define BOOST_CONVERT_HPP - -#include <boost/convert/detail/is_fun.hpp> -#include <boost/ref.hpp> - -namespace boost -{ - namespace detail { enum throw_on_failure {}; } - - /// @details boost::throw_on_failure is the 'tag' object - /// to request the exception-throwing behavior. - detail::throw_on_failure const throw_on_failure = detail::throw_on_failure(0); - - namespace cnv - { - template<typename, typename, typename> struct reference; - struct by_default; - } - - /// @brief Boost.Convert main deployment interface - /// @param[in] value_in Value of the TypeIn type to be converted to the TypeOut type - /// @param[in] converter Converter to be used for conversion - /// @return boost::optional<TypeOut> result of conversion together with the indication of - /// success or failure of the conversion request. - /// @details For example, - /// @code - /// boost::cnv::cstream cnv; - /// - /// boost::optional<int> i = boost::convert<int>("12", cnv); - /// boost::optional<string> s = boost::convert<string>(123.456, cnv); - /// @endcode - - template<typename TypeOut, typename TypeIn, typename Converter> - boost::optional<TypeOut> - convert(TypeIn const& value_in, Converter const& converter) - { - optional<TypeOut> result; - boost::unwrap_ref(converter)(value_in, result); - return result; - } - - namespace cnv { namespace detail - { - template<typename TypeOut, typename TypeIn, typename Converter =boost::cnv::by_default> - struct delayed_resolution - { - static optional<TypeOut> convert(TypeIn const& value_in) - { - return boost::convert<TypeOut>(value_in, Converter()); - } - }; - }} - /// @brief Boost.Convert deployment interface with the default converter - /// @details For example, - /// @code - /// struct boost::cnv::by_default : boost::cnv::cstream {}; - /// - /// // boost::cnv::cstream (through boost::cnv::by_default) is deployed - /// // as the default converter when no converter is provided explicitly. - /// boost::optional<int> i = boost::convert<int>("12"); - /// boost::optional<string> s = boost::convert<string>(123.456); - /// @endcode - - template<typename TypeOut, typename TypeIn> - boost::optional<TypeOut> - convert(TypeIn const& value_in) - { - return cnv::detail::delayed_resolution<TypeOut, TypeIn>::convert(value_in); - } -} - -namespace boost -{ - /// @brief Boost.Convert non-optional deployment interface - - template<typename TypeOut, typename TypeIn, typename Converter> - TypeOut - convert(TypeIn const& value_in, Converter const& converter, boost::detail::throw_on_failure) - { - return convert<TypeOut>(value_in, converter).value(); - } - - template<typename TypeOut, typename TypeIn, typename Converter, typename Fallback> - typename enable_if<is_convertible<Fallback, TypeOut>, TypeOut>::type - convert(TypeIn const& value_in, Converter const& converter, Fallback const& fallback) - { - return convert<TypeOut>(value_in, converter).value_or(fallback); - } - - template<typename TypeOut, typename TypeIn, typename Converter, typename Fallback> - typename enable_if<cnv::is_fun<Fallback, TypeOut>, TypeOut>::type - convert(TypeIn const& value_in, Converter const& converter, Fallback fallback) - { - return convert<TypeOut>(value_in, converter).value_or_eval(fallback); - } -} - -namespace boost { namespace cnv -{ - template<typename Converter, typename TypeOut, typename TypeIn> - struct reference - { - typedef reference this_type; - - reference(Converter const& cnv) : converter_(cnv) {} - -#ifdef BOOST_CONVERT_CXX11 - reference(Converter&& cnv) : converter_(std::move(cnv)) {} -#endif - - this_type& - value_or(TypeOut const& fallback) - { - return (fallback_ = fallback, *this); - } - - TypeOut - operator()(TypeIn const& value_in) - { - optional<TypeOut> result = convert<TypeOut>(value_in, converter_); - return result ? result.get() : fallback_.value(); - } - - private: - - Converter converter_; - optional<TypeOut> fallback_; - }; - template<typename Converter, typename TypeOut> - struct reference<Converter, TypeOut, void> - { - typedef reference this_type; - - reference(Converter const& cnv) : converter_(cnv) {} - -#ifdef BOOST_CONVERT_CXX11 - reference(Converter&& cnv) : converter_(std::move(cnv)) {} -#endif - - this_type& - value_or(TypeOut const& fallback) - { - return (fallback_ = fallback, *this); - } - - template<typename TypeIn> - TypeOut - operator()(TypeIn const& value_in) - { - optional<TypeOut> result = convert<TypeOut>(value_in, converter_); - return result ? result.get() : fallback_.value(); - } - - private: - - Converter converter_; - optional<TypeOut> fallback_; - }; - - /// @brief Boost.Convert deployment interface with algorithms - /// @details For example, - /// @code - /// boost::array<char const*, 3> strs = {{ " 5", "0XF", "not an int" }}; - /// std::vector<int> ints; - /// boost::cnv::cstream cnv; - /// - /// cnv(std::hex)(std::skipws); - /// - /// std::transform( - /// strs.begin(), - /// strs.end(), - /// std::back_inserter(ints), - /// boost::cnv::apply<int>(boost::cref(cnv)).value_or(-1)); - /// @endcode - - template<typename TypeOut, typename TypeIn, typename Converter> - reference<Converter, TypeOut, TypeIn> - apply(Converter const& cnv) - { - return cnv::reference<Converter, TypeOut, TypeIn>(cnv); - } - template<typename TypeOut, typename Converter> - reference<Converter, TypeOut, void> - apply(Converter const& cnv) - { - return cnv::reference<Converter, TypeOut, void>(cnv); - } -}} - -#endif // BOOST_CONVERT_HPP diff --git a/contrib/restricted/boost/boost/convert/base.hpp b/contrib/restricted/boost/boost/convert/base.hpp deleted file mode 100644 index 678d99cfc60..00000000000 --- a/contrib/restricted/boost/boost/convert/base.hpp +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright (c) 2009-2016 Vladimir Batov. -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. - -#ifndef BOOST_CONVERT_CONVERTER_BASE_HPP -#define BOOST_CONVERT_CONVERTER_BASE_HPP - -#include <boost/convert/parameters.hpp> -#include <boost/convert/detail/is_string.hpp> -#include <cstring> - -namespace boost { namespace cnv -{ - namespace ARG = boost::cnv::parameter; - - template<typename> struct cnvbase; -}} - -#define BOOST_CNV_TO_STRING \ - template<typename string_type> \ - typename boost::enable_if<cnv::is_string<string_type>, void>::type \ - operator() - -#define BOOST_CNV_STRING_TO \ - template<typename string_type> \ - typename boost::enable_if<cnv::is_string<string_type>, void>::type \ - operator() - -#define BOOST_CNV_PARAM(param_name, param_type) \ - derived_type& operator()(boost::parameter::aux::tag<ARG::type::param_name, param_type>::type const& arg) - -template<typename derived_type> -struct boost::cnv::cnvbase -{ - using this_type = cnvbase; - using int_type = int; - using uint_type = unsigned int; - using lint_type = long int; - using ulint_type = unsigned long int; - using sint_type = short int; - using usint_type = unsigned short int; - using llint_type = long long int; - using ullint_type = unsigned long long int; - using flt_type = float; - using dbl_type = double; - using ldbl_type = long double; - - // Integration of user-types via operator>>() - template<typename type_in, typename type_out> - void - operator()(type_in const& in, boost::optional<type_out>& out) const - { - in >> out; - } - - // Basic type to string - BOOST_CNV_TO_STRING ( int_type v, optional<string_type>& r) const { to_str_(v, r); } - BOOST_CNV_TO_STRING ( uint_type v, optional<string_type>& r) const { to_str_(v, r); } - BOOST_CNV_TO_STRING ( lint_type v, optional<string_type>& r) const { to_str_(v, r); } - BOOST_CNV_TO_STRING ( llint_type v, optional<string_type>& r) const { to_str_(v, r); } - BOOST_CNV_TO_STRING ( ulint_type v, optional<string_type>& r) const { to_str_(v, r); } - BOOST_CNV_TO_STRING (ullint_type v, optional<string_type>& r) const { to_str_(v, r); } - BOOST_CNV_TO_STRING ( sint_type v, optional<string_type>& r) const { to_str_(v, r); } - BOOST_CNV_TO_STRING ( usint_type v, optional<string_type>& r) const { to_str_(v, r); } - BOOST_CNV_TO_STRING ( flt_type v, optional<string_type>& r) const { to_str_(v, r); } - BOOST_CNV_TO_STRING ( dbl_type v, optional<string_type>& r) const { to_str_(v, r); } - BOOST_CNV_TO_STRING ( ldbl_type v, optional<string_type>& r) const { to_str_(v, r); } - // String to basic type - BOOST_CNV_STRING_TO (string_type const& s, optional< int_type>& r) const { str_to_(s, r); } - BOOST_CNV_STRING_TO (string_type const& s, optional< uint_type>& r) const { str_to_(s, r); } - BOOST_CNV_STRING_TO (string_type const& s, optional< lint_type>& r) const { str_to_(s, r); } - BOOST_CNV_STRING_TO (string_type const& s, optional< llint_type>& r) const { str_to_(s, r); } - BOOST_CNV_STRING_TO (string_type const& s, optional< ulint_type>& r) const { str_to_(s, r); } - BOOST_CNV_STRING_TO (string_type const& s, optional<ullint_type>& r) const { str_to_(s, r); } - BOOST_CNV_STRING_TO (string_type const& s, optional< sint_type>& r) const { str_to_(s, r); } - BOOST_CNV_STRING_TO (string_type const& s, optional< usint_type>& r) const { str_to_(s, r); } - BOOST_CNV_STRING_TO (string_type const& s, optional< flt_type>& r) const { str_to_(s, r); } - BOOST_CNV_STRING_TO (string_type const& s, optional< dbl_type>& r) const { str_to_(s, r); } - BOOST_CNV_STRING_TO (string_type const& s, optional< ldbl_type>& r) const { str_to_(s, r); } - // Formatters -// BOOST_CNV_PARAM (locale, std::locale const) { locale_ = arg[ARG:: locale]; return dncast(); } - BOOST_CNV_PARAM (base, base::type const) { base_ = arg[ARG:: base]; return dncast(); } - BOOST_CNV_PARAM (adjust, adjust::type const) { adjust_ = arg[ARG:: adjust]; return dncast(); } - BOOST_CNV_PARAM (precision, int const) { precision_ = arg[ARG::precision]; return dncast(); } - BOOST_CNV_PARAM (precision, int) { precision_ = arg[ARG::precision]; return dncast(); } - BOOST_CNV_PARAM (uppercase, bool const) { uppercase_ = arg[ARG::uppercase]; return dncast(); } - BOOST_CNV_PARAM (skipws, bool const) { skipws_ = arg[ARG:: skipws]; return dncast(); } - BOOST_CNV_PARAM (width, int const) { width_ = arg[ARG:: width]; return dncast(); } - BOOST_CNV_PARAM (fill, char const) { fill_ = arg[ARG:: fill]; return dncast(); } - - protected: - - cnvbase() - : - base_ (10), - skipws_ (false), - precision_ (0), - uppercase_ (false), - width_ (0), - fill_ (' '), - adjust_ (boost::cnv::adjust::right) - {} - - template<typename string_type, typename out_type> - void - str_to_(string_type const& str, optional<out_type>& result_out) const - { - cnv::range<string_type const> range (str); - - if (skipws_) - for (; !range.empty() && cnv::is_space(*range.begin()); ++range); - - if (range.empty()) return; - if (cnv::is_space(*range.begin())) return; - - dncast().str_to(range, result_out); - } - template<typename in_type, typename string_type> - void - to_str_(in_type value_in, optional<string_type>& result_out) const - { - using char_type = typename cnv::range<string_type>::value_type; - using range_type = cnv::range<char_type*>; - using buf_type = char_type[bufsize_]; - - buf_type buf; - range_type range = dncast().to_str(value_in, buf); - char_type* beg = range.begin(); - char_type* end = range.end(); - int str_size = end - beg; - - if (str_size <= 0) - return; - - if (uppercase_) - for (char_type* p = beg; p < end; ++p) *p = cnv::to_upper(*p); - - if (width_) - { - int num_fill = (std::max)(0, int(width_ - (end - beg))); - int num_left = adjust_ == cnv::adjust::left ? 0 - : adjust_ == cnv::adjust::right ? num_fill - : (num_fill / 2); - int num_right = num_fill - num_left; - bool move = (beg < buf + num_left) // No room for left fillers - || (buf + bufsize_ < end + num_right); // No room for right fillers - if (move) - { - std::memmove(buf + num_left, beg, str_size * sizeof(char_type)); - beg = buf + num_left; - end = beg + str_size; - } - for (int k = 0; k < num_left; *(--beg) = fill_, ++k); - for (int k = 0; k < num_right; *(end++) = fill_, ++k); - } - result_out = string_type(beg, end); - } - - derived_type const& dncast () const { return *static_cast<derived_type const*>(this); } - derived_type& dncast () { return *static_cast<derived_type*>(this); } - - // ULONG_MAX(8 bytes) = 18446744073709551615 (20(10) or 32(2) characters) - // double (8 bytes) max is 316 chars - static int const bufsize_ = 512; - int base_; - bool skipws_; - int precision_; - bool uppercase_; - int width_; - int fill_; - adjust::type adjust_; -// std::locale locale_; -}; - -#undef BOOST_CNV_TO_STRING -#undef BOOST_CNV_STRING_TO -#undef BOOST_CNV_PARAM - -#endif // BOOST_CONVERT_CONVERTER_BASE_HPP diff --git a/contrib/restricted/boost/boost/convert/detail/boost_parameter_ext.hpp b/contrib/restricted/boost/boost/convert/detail/boost_parameter_ext.hpp deleted file mode 100644 index 8d2ee3c4028..00000000000 --- a/contrib/restricted/boost/boost/convert/detail/boost_parameter_ext.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2009-2016 Vladimir Batov. -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. - -#ifndef BOOST_PARAMETER_EXT_PRIVATE_HPP -#define BOOST_PARAMETER_EXT_PRIVATE_HPP - -#include <boost/parameter/keyword.hpp> - -// A Boost.Parameter extension by Andrey Semashev. -// This should really go to Boost.Parameter in the end. - -namespace boost { namespace parameter { - -// The metafunction, given the type of the arguments pack and the keyword tag, -// returns the corresponding parameter type -template< typename ArgsT, typename KeywordTagT > -struct parameter_type -{ - typedef void type; -}; - -template< typename ArgT, typename KeywordTagT > -struct parameter_type<aux::tagged_argument<KeywordTagT, ArgT>, KeywordTagT> -{ - typedef typename aux::tagged_argument< KeywordTagT, ArgT >::value_type type; -}; - -template< typename KeywordTagT1, typename ArgT, typename KeywordTagT2 > -struct parameter_type< aux::tagged_argument< KeywordTagT1, ArgT >, KeywordTagT2 > -{ - typedef void type; -}; - -template< typename ArgT, typename TailT, typename KeywordTagT > -struct parameter_type< - aux::arg_list< - aux::tagged_argument< KeywordTagT, ArgT >, - TailT - >, - KeywordTagT -> -{ - typedef typename aux::tagged_argument< KeywordTagT, ArgT >::value_type type; -}; - -template< typename KeywordTagT1, typename ArgT, typename TailT, typename KeywordTagT2 > -struct parameter_type< - aux::arg_list< - aux::tagged_argument< KeywordTagT1, ArgT >, - TailT - >, - KeywordTagT2 -> : - public parameter_type< TailT, KeywordTagT2 > -{ -}; - -}} // boost::parameter - -#endif // BOOST_PARAMETER_EXT_PRIVATE_HPP - diff --git a/contrib/restricted/boost/boost/convert/detail/char.hpp b/contrib/restricted/boost/boost/convert/detail/char.hpp deleted file mode 100644 index a829dc8806b..00000000000 --- a/contrib/restricted/boost/boost/convert/detail/char.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2009-2016 Vladimir Batov. -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. - -#ifndef BOOST_CONVERT_DETAIL_IS_CHAR_HPP -#define BOOST_CONVERT_DETAIL_IS_CHAR_HPP - -#include <boost/convert/detail/config.hpp> -#include <type_traits> -#include <cctype> -#include <cwctype> - -namespace boost { namespace cnv -{ - using char_type = char; - using uchar_type = unsigned char; - using wchar_type = wchar_t; - - namespace detail - { - template<typename> struct is_char : std::false_type {}; - template<> struct is_char< char_type> : std:: true_type {}; - template<> struct is_char<wchar_type> : std:: true_type {}; - } - template <typename T> struct is_char : detail::is_char<typename boost::remove_const<T>::type> {}; - - template<typename char_type> inline bool is_space(char_type); - template<typename char_type> inline char_type to_upper(char_type); - - template<> inline bool is_space ( char_type c) { return bool(std::isspace(static_cast<uchar_type>(c))); } - template<> inline bool is_space (uchar_type c) { return bool(std::isspace(c)); } - template<> inline bool is_space (wchar_type c) { return bool(std::iswspace(c)); } - template<> inline char_type to_upper ( char_type c) { return std::toupper(static_cast<uchar_type>(c)); } - template<> inline uchar_type to_upper (uchar_type c) { return std::toupper(c); } - template<> inline wchar_type to_upper (wchar_type c) { return std::towupper(c); } -}} - -#endif // BOOST_CONVERT_DETAIL_IS_CHAR_HPP - diff --git a/contrib/restricted/boost/boost/convert/detail/config.hpp b/contrib/restricted/boost/boost/convert/detail/config.hpp deleted file mode 100644 index 6c74cd308a3..00000000000 --- a/contrib/restricted/boost/boost/convert/detail/config.hpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2009-2016 Vladimir Batov. -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. - -#ifndef BOOST_CONVERT_FORWARD_HPP -#define BOOST_CONVERT_FORWARD_HPP - -#include <boost/config.hpp> -#include <boost/version.hpp> -#include <boost/optional.hpp> - -#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES) -#undef BOOST_CONVERT_CXX11 -#else -#define BOOST_CONVERT_CXX11 -#endif - -// Intel 12.0 and lower have broken SFINAE -#if defined(BOOST_INTEL) && (BOOST_INTEL <= 1200) -# define BOOST_CONVERT_IS_NOT_SUPPORTED -#endif - -// No C++11 support -#if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION <= 40600) -# define BOOST_CONVERT_IS_NOT_SUPPORTED -#endif - -// MSVC-11 and lower have broken SFINAE -#if defined(BOOST_MSVC) && (BOOST_MSVC < 1800) -# define BOOST_CONVERT_IS_NOT_SUPPORTED -#endif - -#if defined(_MSC_VER) - -//MSVC++ 7.0 _MSC_VER == 1300 -//MSVC++ 7.1 _MSC_VER == 1310 (Visual Studio 2003) -//MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005) -//MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008) -//MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010) -//MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012) -//MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013) -//MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015) -//MSVC++ 15.0 _MSC_VER == 1910 (Visual Studio 2017) - -# pragma warning(disable: 4244) -# pragma warning(disable: 4224) -# pragma warning(disable: 4996) -# pragma warning(disable: 4180) // qualifier applied to function type has no meaning -# pragma warning(disable: 4100) // unreferenced formal parameter -# pragma warning(disable: 4146) // unary minus operator applied to unsigned type - -#if _MSC_VER < 1900 /* MSVC-14 defines real snprintf()... just about time! */ -# define snprintf _snprintf -#endif - -#endif - -#endif // BOOST_CONVERT_FORWARD_HPP diff --git a/contrib/restricted/boost/boost/convert/detail/has_member.hpp b/contrib/restricted/boost/boost/convert/detail/has_member.hpp deleted file mode 100644 index 2cd617f7b05..00000000000 --- a/contrib/restricted/boost/boost/convert/detail/has_member.hpp +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) 2009-2016 Vladimir Batov. -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. - -#ifndef BOOST_CONVERT_HAS_MEMBER_HPP -#define BOOST_CONVERT_HAS_MEMBER_HPP - -#include <boost/type_traits/detail/yes_no_type.hpp> - -// This macro allows to check if a type has a member named "__member_name__"... -// ... regardless of the signature. If takes advantage of the following behavior related to -// function resolution. Say, both, foo and base, declare a method with the same name "func": -// -// struct foo { int func (int, int) { return 0; } }; -// struct base { void func () {} }; -// struct mixin : public foo, public base {}; -// -// Now, if we inherit from both -- foo and base -- classes, then the following calls will fail -// mixin_ptr(0)->func(); -// mixin_ptr(0)->func(5, 5); -// with the error message (gcc): request for member func is ambiguous -// regardless if we provide any arguments or not even though one might expect that -// arg-based signature resolution might kick in. The only way to deploy those methods is: -// -// mixin_ptr(0)->foo::func(); -// mixin_ptr(0)->base::func(5, 5); -// -// C2. The actual signature of __member_name__ is not taken into account. If -// __T__::__member_name__(any-signature) exists, then the introduced base::__member_name__ -// will cause mixin->__member_name__() call to fail to compile (due to ambiguity). -// C3. &U::__member_name__ (a.k.a. &mixin::__member_name__) -// has the type of func_type only if __T__::__member_name__ does not exist. -// If __T__::member_name does exist, then mixin::__member_name__ is ambiguous -// and "yes_type test (...)" kicks in instead. -// C4. Need to find some unique/ugly name so that it does not clash if this macro is -// used inside some other template class; - -#define BOOST_DECLARE_HAS_MEMBER(__trait_name__, __member_name__) \ - \ - template <typename __boost_has_member_T__> /*C4*/ \ - class __trait_name__ \ - { \ - typedef typename boost::remove_const<__boost_has_member_T__>::type check_type; \ - typedef ::boost::type_traits::yes_type yes_type; \ - typedef ::boost::type_traits:: no_type no_type; \ - \ - struct base { void __member_name__(/*C2*/) {}}; \ - struct mixin : public base, public check_type {}; \ - \ - template <void (base::*)()> struct aux {}; \ - \ - template <typename U> static no_type test(aux<&U::__member_name__>*); /*C3*/ \ - template <typename U> static yes_type test(...); \ - \ - public: \ - \ - BOOST_STATIC_CONSTANT(bool, value = (sizeof(yes_type) == sizeof(test<mixin>(0)))); \ - } - -#endif // BOOST_CONVERT_HAS_MEMBER_HPP diff --git a/contrib/restricted/boost/boost/convert/detail/is_callable.hpp b/contrib/restricted/boost/boost/convert/detail/is_callable.hpp deleted file mode 100644 index 838c248c631..00000000000 --- a/contrib/restricted/boost/boost/convert/detail/is_callable.hpp +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) 2009-2016 Vladimir Batov. -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. - -#ifndef BOOST_CONVERT_IS_CALLABLE_HPP -#define BOOST_CONVERT_IS_CALLABLE_HPP - -#include <boost/convert/detail/has_member.hpp> - -namespace boost { namespace cnv { namespace detail -{ - typedef ::boost::type_traits::yes_type yes_type; - typedef ::boost::type_traits:: no_type no_type; - - struct not_found {}; - struct void_return_substitute {}; - - // The overloaded comma operator only kicks in for U != void essentially short-circuiting - // itself ineffective. Otherwise, when U=void, the standard op,() kicks in and returns - // 'void_return_substitute'. - template<typename U> U const& operator, (U const&, void_return_substitute); - template<typename U> U& operator, (U&, void_return_substitute); - - template <typename src, typename dst> struct match_const { typedef dst type; }; - template <typename src, typename dst> struct match_const<src const, dst> { typedef dst const type; }; - - template<typename T, typename return_type> - struct redirect - { - static no_type test (...); - static yes_type test (return_type); - }; - - template<typename T> - struct redirect<T, void> - { - static yes_type test (...); - static no_type test (not_found); - }; -}}} - -// No-args case needs to be implemented differently and has not been implemented yet. -// template <typename R> -// struct check<true, R ()> - -// C1. Need to find some unique/ugly names so that they do not clash if this macro is -// used inside some other template class; -// C2. Body of the function is not actually used anywhere. -// However, Intel C++ compiler treats it as an error. So, we provide the body. - -#define BOOST_DECLARE_IS_CALLABLE(__trait_name__, __member_name__) \ - \ -template <typename __boost_is_callable_T__, typename __boost_is_callable_signature__> \ -class __trait_name__ \ -{ \ - typedef __boost_is_callable_T__ class_type; /*C1*/ \ - typedef __boost_is_callable_signature__ signature; /*C1*/ \ - typedef boost::cnv::detail::not_found not_found; \ - \ - BOOST_DECLARE_HAS_MEMBER(has_member, __member_name__); \ - \ - struct mixin : public class_type \ - { \ - using class_type::__member_name__; \ - not_found __member_name__(...) const { return not_found(); /*C2*/} \ - }; \ - \ - typedef typename boost::cnv::detail::match_const<class_type, mixin>::type* mixin_ptr; \ - \ - template <bool has, typename F> struct check { static bool const value = false; }; \ - \ - template <typename Arg1, typename R> \ - struct check<true, R (Arg1)> \ - { \ - typedef typename boost::decay<Arg1>::type* a1; \ - \ - static bool const value = sizeof(boost::type_traits::yes_type) \ - == sizeof(boost::cnv::detail::redirect<class_type, R>::test( \ - (mixin_ptr(0)->__member_name__(*a1(0)), \ - boost::cnv::detail::void_return_substitute()))); \ - }; \ - template <typename Arg1, typename Arg2, typename R> \ - struct check<true, R (Arg1, Arg2)> \ - { \ - typedef typename boost::decay<Arg1>::type* a1; \ - typedef typename boost::decay<Arg2>::type* a2; \ - \ - static bool const value = sizeof(boost::type_traits::yes_type) \ - == sizeof(boost::cnv::detail::redirect<class_type, R>::test( \ - (mixin_ptr(0)->__member_name__(*a1(0), *a2(0)), \ - boost::cnv::detail::void_return_substitute()))); \ - }; \ - \ - public: \ - \ - /* Check the existence of __member_name__ first, then the signature. */ \ - static bool const value = check<has_member<class_type>::value, signature>::value; \ -} - -#endif // BOOST_CONVERT_IS_CALLABLE_HPP diff --git a/contrib/restricted/boost/boost/convert/detail/is_converter.hpp b/contrib/restricted/boost/boost/convert/detail/is_converter.hpp deleted file mode 100644 index 69646554092..00000000000 --- a/contrib/restricted/boost/boost/convert/detail/is_converter.hpp +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2009-2016 Vladimir Batov. -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. - -#ifndef BOOST_CONVERT_IS_CONVERTER_HPP -#define BOOST_CONVERT_IS_CONVERTER_HPP - -#include <boost/convert/detail/config.hpp> -#include <boost/convert/detail/is_callable.hpp> -#include <boost/utility/enable_if.hpp> -#include <boost/type_traits.hpp> -#include <boost/ref.hpp> - -namespace boost { namespace cnv -{ - template<typename, typename, typename, typename =void> - struct is_cnv { BOOST_STATIC_CONSTANT(bool, value = false); }; - - template<typename Class, typename TypeIn, typename TypeOut> - struct is_cnv<Class, TypeIn, TypeOut, typename enable_if<is_class<Class>, void>::type> - { - typedef typename ::boost::unwrap_reference<Class>::type class_type; - typedef void signature_type(TypeIn const&, optional<TypeOut>&); - - BOOST_DECLARE_IS_CALLABLE(is_callable, operator()); - - BOOST_STATIC_CONSTANT(bool, value = (is_callable<class_type, signature_type>::value)); - }; - - template<typename Function, typename TypeIn, typename TypeOut> - struct is_cnv<Function, TypeIn, TypeOut, - typename enable_if_c<is_function<Function>::value && function_types::function_arity<Function>::value == 2, - void>::type> - { - typedef TypeIn in_type; - typedef optional<TypeOut>& out_type; - typedef typename function_traits<Function>::arg1_type func_in_type; - typedef typename function_traits<Function>::arg2_type func_out_type; - - BOOST_STATIC_CONSTANT(bool, in_good = (is_convertible<in_type, func_in_type>::value)); - BOOST_STATIC_CONSTANT(bool, out_good = (is_same<out_type, func_out_type>::value)); - BOOST_STATIC_CONSTANT(bool, value = (in_good && out_good)); - }; -}} - -#endif // BOOST_CONVERT_IS_CONVERTER_HPP - diff --git a/contrib/restricted/boost/boost/convert/detail/is_fun.hpp b/contrib/restricted/boost/boost/convert/detail/is_fun.hpp deleted file mode 100644 index 72a768188a5..00000000000 --- a/contrib/restricted/boost/boost/convert/detail/is_fun.hpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2009-2016 Vladimir Batov. -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. - -#ifndef BOOST_CONVERT_IS_FUNCTION_HPP -#define BOOST_CONVERT_IS_FUNCTION_HPP - -#include <boost/convert/detail/config.hpp> -#include <boost/convert/detail/has_member.hpp> -#include <boost/utility/enable_if.hpp> -#include <boost/type_traits.hpp> -#include <boost/function_types/is_function_pointer.hpp> -#include <boost/function_types/function_arity.hpp> -#include <boost/function_types/result_type.hpp> - -namespace boost { namespace cnv -{ - typedef ::boost::type_traits::yes_type yes_type; - typedef ::boost::type_traits:: no_type no_type; - - template <bool has_operator, typename Functor, typename TypeOut> - struct check_functor { BOOST_STATIC_CONSTANT(bool, value = false); }; - - template<typename Func, typename TypeOut, class Enable =void> - struct is_fun { BOOST_STATIC_CONSTANT(bool, value = false); }; - - template <typename Functor, typename TypeOut> - struct check_functor<true, Functor, TypeOut> - { - static yes_type test (TypeOut const&); - static no_type test (...); - - static const bool value = sizeof(yes_type) == sizeof(test(((Functor*) 0)->operator()())); - }; - - template<typename Functor, typename TypeOut> - struct is_fun<Functor, TypeOut, - typename enable_if_c<is_class<Functor>::value && !is_convertible<Functor, TypeOut>::value, void>::type> - { - BOOST_DECLARE_HAS_MEMBER(has_funop, operator()); - - BOOST_STATIC_CONSTANT(bool, value = (check_functor<has_funop<Functor>::value, Functor, TypeOut>::value)); - }; - - template<typename Function, typename TypeOut> - struct is_fun<Function, TypeOut, - typename enable_if_c< - function_types::is_function_pointer<Function>::value && - function_types::function_arity<Function>::value == 0 && - !is_same<Function, TypeOut>::value, - void>::type> - { - typedef TypeOut out_type; - typedef typename function_types::result_type<Function>::type func_out_type; - - BOOST_STATIC_CONSTANT(bool, value = (is_convertible<func_out_type, out_type>::value)); - }; -}} - -#endif // BOOST_CONVERT_IS_FUNCTION_HPP - diff --git a/contrib/restricted/boost/boost/convert/detail/is_string.hpp b/contrib/restricted/boost/boost/convert/detail/is_string.hpp deleted file mode 100644 index 75d565e3e77..00000000000 --- a/contrib/restricted/boost/boost/convert/detail/is_string.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2009-2016 Vladimir Batov. -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. - -#ifndef BOOST_CONVERT_DETAIL_IS_STRING_HPP -#define BOOST_CONVERT_DETAIL_IS_STRING_HPP - -#include <boost/convert/detail/range.hpp> - -namespace boost { namespace cnv -{ - namespace detail - { - template<typename T, bool is_range_class> struct is_string : std::false_type {}; - - template<typename T> struct is_string<T*, false> - { - static bool const value = cnv::is_char<T>::value; - }; - template <typename T, std::size_t N> struct is_string<T [N], false> - { - static bool const value = cnv::is_char<T>::value; - }; - template<typename T> struct is_string<T, /*is_range_class=*/true> - { - static bool const value = cnv::is_char<typename T::value_type>::value; - }; - } - template<typename T> struct is_string : detail::is_string< - typename boost::remove_const<T>::type, - boost::is_class<T>::value && boost::cnv::is_range<T>::value> {}; -}} - -#endif // BOOST_CONVERT_DETAIL_IS_STRING_HPP diff --git a/contrib/restricted/boost/boost/convert/detail/range.hpp b/contrib/restricted/boost/boost/convert/detail/range.hpp deleted file mode 100644 index 82d105f9493..00000000000 --- a/contrib/restricted/boost/boost/convert/detail/range.hpp +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) 2009-2016 Vladimir Batov. -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. - -#ifndef BOOST_CONVERT_DETAIL_RANGE_HPP -#define BOOST_CONVERT_DETAIL_RANGE_HPP - -#include <boost/convert/detail/has_member.hpp> -#include <boost/convert/detail/char.hpp> -#include <boost/utility/enable_if.hpp> -#include <boost/range/iterator.hpp> - -namespace boost { namespace cnv -{ - namespace detail - { - template<typename T, bool is_class> struct is_range : std::false_type {}; - - template<typename T> struct is_range<T, /*is_class=*/true> - { - BOOST_DECLARE_HAS_MEMBER(has_begin, begin); - BOOST_DECLARE_HAS_MEMBER( has_end, end); - - static bool const value = has_begin<T>::value && has_end<T>::value; - }; - } - template<typename T> struct is_range : detail::is_range<typename boost::remove_const<T>::type, boost::is_class<T>::value> {}; - template<typename T, typename enable =void> struct range; - template<typename T, typename enable =void> struct iterator; - - template<typename T> - struct iterator<T, typename enable_if<is_range<T> >::type> - { - typedef typename boost::range_iterator<T>::type type; - typedef typename boost::range_iterator<T const>::type const_type; - typedef typename boost::iterator_value<type>::type value_type; - }; - template<typename T> - struct iterator<T*, void> - { - typedef typename boost::remove_const<T>::type value_type; - typedef T* type; - typedef value_type const* const_type; - }; - template<typename T> - struct range_base - { - typedef typename cnv::iterator<T>::value_type value_type; - typedef typename cnv::iterator<T>::type iterator; - typedef typename cnv::iterator<T>::const_type const_iterator; - typedef const_iterator sentry_type; - - iterator begin () { return begin_; } - const_iterator begin () const { return begin_; } - void operator++ () { ++begin_; } -// void operator-- () { --end_; } - - protected: - - range_base (iterator b, iterator e) : begin_(b), end_(e) {} - - iterator begin_; - iterator mutable end_; - }; - - template<typename T> - struct range<T, typename enable_if<is_range<T> >::type> : public range_base<T> - { - typedef range this_type; - typedef range_base<T> base_type; - typedef typename base_type::iterator iterator; - typedef typename base_type::const_iterator const_iterator; - typedef const_iterator sentry_type; - - range (T& r) : base_type(r.begin(), r.end()) {} - - iterator end () { return base_type::end_; } - const_iterator end () const { return base_type::end_; } - sentry_type sentry () const { return base_type::end_; } - std::size_t size () const { return base_type::end_ - base_type::begin_; } - bool empty () const { return base_type::begin_ == base_type::end_; } - }; - - template<typename T> - struct range<T*, typename enable_if<cnv::is_char<T> >::type> : public range_base<T*> - { - using this_type = range; - using base_type = range_base<T*>; - using value_type = typename boost::remove_const<T>::type; - using iterator = T*; - using const_iterator = value_type const*; - - struct sentry_type - { - friend bool operator!=(iterator it, sentry_type) { return !!*it; } - }; - - range (iterator b, iterator e =0) : base_type(b, e) {} - - iterator end () { return base_type::end_ ? base_type::end_ : (base_type::end_ = base_type::begin_ + size()); } - const_iterator end () const { return base_type::end_ ? base_type::end_ : (base_type::end_ = base_type::begin_ + size()); } - sentry_type sentry () const { return sentry_type(); } - std::size_t size () const { return std::char_traits<value_type>::length(base_type::begin_); } - bool empty () const { return !*base_type::begin_; } - }; - template<typename T> - struct range<T* const, void> : public range<T*> - { - range (T* b, T* e =0) : range<T*>(b, e) {} - }; - template <typename T, std::size_t N> - struct range<T [N], void> : public range<T*> - { - range (T* b, T* e =0) : range<T*>(b, e) {} - }; -}} - -#endif // BOOST_CONVERT_DETAIL_RANGE_HPP diff --git a/contrib/restricted/boost/boost/convert/lexical_cast.hpp b/contrib/restricted/boost/boost/convert/lexical_cast.hpp deleted file mode 100644 index 49b96a15df2..00000000000 --- a/contrib/restricted/boost/boost/convert/lexical_cast.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2009-2016 Vladimir Batov. -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. - -#ifndef BOOST_CONVERT_LEXICAL_CAST_HPP -#define BOOST_CONVERT_LEXICAL_CAST_HPP - -#include <boost/lexical_cast.hpp> - -namespace boost { namespace cnv -{ - struct lexical_cast; -}} - -/// @brief boost::lexical_cast-based converter -/// @details The purpose of the converter is to -/// * Make use of the boost::lexical_cast functionality and performance that many people have become -/// accustomed to and comfortable with; -/// * Demonstrate how existing independent conversion/transformation-related facilities might be -// incorporated in to the Boost.Convert framework. -/// -/// The converter can easily replace boost::lexical_cast, adding flexibility and convenience. - -struct boost::cnv::lexical_cast -{ - template<typename TypeOut, typename TypeIn> - void - operator()(TypeIn const& value_in, boost::optional<TypeOut>& result_out) const - { - try - { - result_out = boost::lexical_cast<TypeOut>(value_in); - } - catch (boost::bad_lexical_cast const&) - { - } - } -}; - -#endif // BOOST_CONVERT_LEXICAL_CAST_HPP diff --git a/contrib/restricted/boost/boost/convert/parameters.hpp b/contrib/restricted/boost/boost/convert/parameters.hpp deleted file mode 100644 index fc427c19b55..00000000000 --- a/contrib/restricted/boost/boost/convert/parameters.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2009-2016 Vladimir Batov. -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. - -#ifndef BOOST_CONVERT_PARAMETERS_HPP -#define BOOST_CONVERT_PARAMETERS_HPP - -#include <boost/convert/detail/boost_parameter_ext.hpp> - -namespace boost -{ - namespace cnv - { - struct adjust { enum type { left, right, center };}; - struct base { enum type { bin =2, dec =10, hex =16, oct =8 };}; - struct notation { enum type { fixed, scientific };}; - - namespace parameter - { - BOOST_PARAMETER_KEYWORD(type, adjust) - BOOST_PARAMETER_KEYWORD(type, base) - BOOST_PARAMETER_KEYWORD(type, fill) - BOOST_PARAMETER_KEYWORD(type, locale) - BOOST_PARAMETER_KEYWORD(type, notation) - BOOST_PARAMETER_KEYWORD(type, precision) - BOOST_PARAMETER_KEYWORD(type, skipws) - BOOST_PARAMETER_KEYWORD(type, uppercase) - BOOST_PARAMETER_KEYWORD(type, width) - } - } -} - -#endif // BOOST_CONVERT_PARAMETERS_HPP diff --git a/contrib/restricted/boost/boost/convert/printf.hpp b/contrib/restricted/boost/boost/convert/printf.hpp deleted file mode 100644 index 443464f0e27..00000000000 --- a/contrib/restricted/boost/boost/convert/printf.hpp +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) 2009-2016 Vladimir Batov. -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. - -#ifndef BOOST_CONVERT_PRINTF_HPP -#define BOOST_CONVERT_PRINTF_HPP - -#include <boost/convert/base.hpp> -#include <boost/make_default.hpp> -#include <boost/mpl/vector.hpp> -#include <boost/mpl/find.hpp> -#include <boost/range/as_literal.hpp> -#include <string> -#include <cstdio> - -namespace boost { namespace cnv -{ - struct printf; -}} - -struct boost::cnv::printf : public boost::cnv::cnvbase<boost::cnv::printf> -{ - typedef boost::cnv::printf this_type; - typedef boost::cnv::cnvbase<this_type> base_type; - - using base_type::operator(); - - template<typename in_type> - cnv::range<char*> - to_str(in_type value_in, char* buf) const - { - char const* fmt = pformat(pos<in_type>()); - int const num_chars = snprintf(buf, bufsize_, fmt, precision_, value_in); - bool const success = num_chars < bufsize_; - - return cnv::range<char*>(buf, success ? (buf + num_chars) : buf); - } - template<typename string_type, typename out_type> - void - str_to(cnv::range<string_type> range, optional<out_type>& result_out) const - { - out_type result = boost::make_default<out_type>(); - int const num_read = sscanf(&*range.begin(), format(pos<out_type>()), &result); - - if (num_read == 1) - result_out = result; - } - - private: - - template<typename Type> int pos() const - { - typedef boost::mpl::vector<double, float, - int, unsigned int, - short int, unsigned short int, - long int, unsigned long int - > managed_types; - - typedef typename boost::mpl::find<managed_types, Type>::type type_iterator; - typedef typename type_iterator::pos type_pos; - - return type_pos::value; - } - - char const* pformat(int pos) const - { - static char const* d_format[] = { "%.*f", "%.*f", "%.*d", "%.*u", "%.*hd", "%.*hu", "%.*ld", "%.*lu" }; // Must match managed_types - static char const* x_format[] = { "%.*f", "%.*f", "%.*x", "%.*x", "%.*hx", "%.*hx", "%.*lx", "%.*lx" }; // Must match managed_types - static char const* o_format[] = { "%.*f", "%.*f", "%.*o", "%.*o", "%.*ho", "%.*ho", "%.*lo", "%.*lo" }; // Must match managed_types - char const* format = base_ == 10 ? d_format[pos] - : base_ == 16 ? x_format[pos] - : base_ == 8 ? o_format[pos] - : (BOOST_ASSERT(0), (char const*) 0); - return format; - } - char const* format(int pos) const - { - static char const* d_format[] = { "%f", "%f", "%d", "%u", "%hd", "%hu", "%ld", "%lu" }; // Must match managed_types - static char const* x_format[] = { "%f", "%f", "%x", "%x", "%hx", "%hx", "%lx", "%lx" }; // Must match managed_types - static char const* o_format[] = { "%f", "%f", "%o", "%o", "%ho", "%ho", "%lo", "%lo" }; // Must match managed_types - char const* format = base_ == 10 ? d_format[pos] - : base_ == 16 ? x_format[pos] - : base_ == 8 ? o_format[pos] - : (BOOST_ASSERT(0), (char const*) 0); - return format; - } -}; - -#endif // BOOST_CONVERT_PRINTF_HPP diff --git a/contrib/restricted/boost/boost/convert/spirit.hpp b/contrib/restricted/boost/boost/convert/spirit.hpp deleted file mode 100644 index b33a793f381..00000000000 --- a/contrib/restricted/boost/boost/convert/spirit.hpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2009-2016 Vladimir Batov. -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. - -#ifndef BOOST_CONVERT_SPIRIT_BASED_CONVERTER_HPP -#define BOOST_CONVERT_SPIRIT_BASED_CONVERTER_HPP - -#include <boost/convert/base.hpp> -#include <boost/convert/detail/config.hpp> -#include <boost/spirit/include/qi.hpp> -#include <boost/spirit/include/karma.hpp> - -namespace boost { namespace cnv -{ - struct spirit; -}} - -struct boost::cnv::spirit : public boost::cnv::cnvbase<boost::cnv::spirit> -{ - typedef boost::cnv::spirit this_type; - typedef boost::cnv::cnvbase<this_type> base_type; - - using base_type::operator(); - - template<typename string_type, typename out_type> - void - str_to(cnv::range<string_type> range, optional<out_type>& result_out) const - { - typedef typename cnv::range<string_type>::iterator iterator; - typedef typename boost::spirit::traits::create_parser<out_type>::type parser; - - iterator beg = range.begin(); - iterator end = range.end(); - out_type result; - - if (boost::spirit::qi::parse(beg, end, parser(), result)) - if (beg == end) // ensure the whole string has been parsed - result_out = result; - } - template<typename in_type, typename char_type> - cnv::range<char_type*> - to_str(in_type value_in, char_type* beg) const - { - typedef typename boost::spirit::traits::create_generator<in_type>::type generator; - - char_type* end = beg; - bool good = boost::spirit::karma::generate(end, generator(), value_in); - - return cnv::range<char_type*>(beg, good ? end : beg); - } -}; - -#endif // BOOST_CONVERT_SPIRIT_BASED_CONVERTER_HPP - diff --git a/contrib/restricted/boost/boost/convert/stream.hpp b/contrib/restricted/boost/boost/convert/stream.hpp deleted file mode 100644 index 086d8361750..00000000000 --- a/contrib/restricted/boost/boost/convert/stream.hpp +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright (c) 2009-2016 Vladimir Batov. -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. - -#ifndef BOOST_CONVERT_STRINGSTREAM_BASED_CONVERTER_HPP -#define BOOST_CONVERT_STRINGSTREAM_BASED_CONVERTER_HPP - -#include <boost/convert/parameters.hpp> -#include <boost/convert/detail/is_string.hpp> -#include <boost/make_default.hpp> -#include <sstream> -#include <iomanip> - -#define BOOST_CNV_STRING_ENABLE \ - template<typename string_type, typename type> \ - typename boost::enable_if<cnv::is_string<string_type>, void>::type \ - operator() - -#define BOOST_CNV_PARAM(PARAM_NAME, PARAM_TYPE) \ - this_type& \ - operator()(boost::parameter::aux::tag<boost::cnv::parameter::type::PARAM_NAME, PARAM_TYPE>::type const& arg) - -namespace boost { namespace cnv -{ - template<class Char> struct basic_stream; - - typedef boost::cnv::basic_stream<char> cstream; - typedef boost::cnv::basic_stream<wchar_t> wstream; -}} - -template<class Char> -struct boost::cnv::basic_stream : boost::noncopyable -{ - // C01. In string-to-type conversions the "string" must be a CONTIGUOUS ARRAY of - // characters because "ibuffer_type" uses/relies on that (it deals with char_type*). - // C02. Use the provided "string_in" as the input (read-from) buffer and, consequently, - // avoid the overhead associated with stream_.str(string_in) -- - // copying of the content into internal buffer. - // C03. The "strbuf.gptr() != strbuf.egptr()" check replaces "istream.eof() != true" - // which for some reason does not work when we try converting the "true" string - // to "bool" with std::boolalpha set. Seems that istream state gets unsynced compared - // to the actual underlying buffer. - - typedef Char char_type; - typedef boost::cnv::basic_stream<char_type> this_type; - typedef std::basic_stringstream<char_type> stream_type; - typedef std::basic_istream<char_type> istream_type; - typedef std::basic_streambuf<char_type> buffer_type; - typedef std::basic_string<char_type> stdstr_type; - typedef std::ios_base& (*manipulator_type)(std::ios_base&); - - struct ibuffer_type : public buffer_type - { - using buffer_type::eback; - using buffer_type::gptr; - using buffer_type::egptr; - - ibuffer_type(char_type const* beg, std::size_t sz) //C01 - { - char_type* b = const_cast<char_type*>(beg); - - buffer_type::setg(b, b, b + sz); - } - }; - struct obuffer_type : public buffer_type - { - using buffer_type::pbase; - using buffer_type::pptr; - using buffer_type::epptr; - }; - - basic_stream() : stream_(std::ios_base::in | std::ios_base::out) {} -#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) - basic_stream(this_type&& other) : stream_(std::move(other.stream_)) {} -#endif - - BOOST_CNV_STRING_ENABLE(type const& v, optional<string_type>& s) const { to_str(v, s); } - BOOST_CNV_STRING_ENABLE(string_type const& s, optional<type>& r) const { str_to(cnv::range<string_type const>(s), r); } - // Resolve ambiguity of string-to-string - template<typename type> void operator()( char_type const* s, optional<type>& r) const { str_to(cnv::range< char_type const*>(s), r); } - template<typename type> void operator()(stdstr_type const& s, optional<type>& r) const { str_to(cnv::range<stdstr_type const>(s), r); } - - // Formatters - template<typename manipulator> - this_type& operator() (manipulator m) { return (stream_ << m, *this); } - this_type& operator() (manipulator_type m) { return (m(stream_), *this); } - this_type& operator() (std::locale const& l) { return (stream_.imbue(l), *this); } - - BOOST_CNV_PARAM(locale, std::locale const) { return (stream_.imbue(arg[cnv::parameter::locale]), *this); } - BOOST_CNV_PARAM(precision, int const) { return (stream_.precision(arg[cnv::parameter::precision]), *this); } - BOOST_CNV_PARAM(precision, int) { return (stream_.precision(arg[cnv::parameter::precision]), *this); } - BOOST_CNV_PARAM(width, int const) { return (stream_.width(arg[cnv::parameter::width]), *this); } - BOOST_CNV_PARAM(fill, char const) { return (stream_.fill(arg[cnv::parameter::fill]), *this); } - BOOST_CNV_PARAM(uppercase, bool const) - { - bool uppercase = arg[cnv::parameter::uppercase]; - uppercase ? (void) stream_.setf(std::ios::uppercase) : stream_.unsetf(std::ios::uppercase); - return *this; - } - BOOST_CNV_PARAM(skipws, bool const) - { - bool skipws = arg[cnv::parameter::skipws]; - skipws ? (void) stream_.setf(std::ios::skipws) : stream_.unsetf(std::ios::skipws); - return *this; - } - BOOST_CNV_PARAM(adjust, boost::cnv::adjust::type const) - { - cnv::adjust::type adjust = arg[cnv::parameter::adjust]; - - /**/ if (adjust == cnv::adjust:: left) stream_.setf(std::ios::adjustfield, std::ios:: left); - else if (adjust == cnv::adjust::right) stream_.setf(std::ios::adjustfield, std::ios::right); - else BOOST_ASSERT(!"Not implemented"); - - return *this; - } - BOOST_CNV_PARAM(base, boost::cnv::base::type const) - { - cnv::base::type base = arg[cnv::parameter::base]; - - /**/ if (base == cnv::base::dec) std::dec(stream_); - else if (base == cnv::base::hex) std::hex(stream_); - else if (base == cnv::base::oct) std::oct(stream_); - else BOOST_ASSERT(!"Not implemented"); - - return *this; - } - BOOST_CNV_PARAM(notation, boost::cnv::notation::type const) - { - cnv::notation::type notation = arg[cnv::parameter::notation]; - - /**/ if (notation == cnv::notation:: fixed) std::fixed(stream_); - else if (notation == cnv::notation::scientific) std::scientific(stream_); - else BOOST_ASSERT(!"Not implemented"); - - return *this; - } - - private: - - template<typename string_type, typename out_type> void str_to(cnv::range<string_type>, optional<out_type>&) const; - template<typename string_type, typename in_type> void to_str(in_type const&, optional<string_type>&) const; - - mutable stream_type stream_; -}; - -template<typename char_type> -template<typename string_type, typename in_type> -inline -void -boost::cnv::basic_stream<char_type>::to_str( - in_type const& value_in, - boost::optional<string_type>& string_out) const -{ - stream_.clear(); // Clear the flags - stream_.str(stdstr_type()); // Clear/empty the content of the stream - - if (!(stream_ << value_in).fail()) - { - buffer_type* buf = stream_.rdbuf(); - obuffer_type* obuf = static_cast<obuffer_type*>(buf); - char_type const* beg = obuf->pbase(); - char_type const* end = obuf->pptr(); - - string_out = string_type(beg, end); // Instead of stream_.str(); - } -} - -template<typename char_type> -template<typename string_type, typename out_type> -inline -void -boost::cnv::basic_stream<char_type>::str_to( - boost::cnv::range<string_type> string_in, - boost::optional<out_type>& result_out) const -{ - if (string_in.empty ()) return; - - istream_type& istream = stream_; - buffer_type* oldbuf = istream.rdbuf(); - char_type const* beg = &*string_in.begin(); - std::size_t sz = string_in.end() - string_in.begin(); - ibuffer_type newbuf (beg, sz); //C02 - - istream.rdbuf(&newbuf); - istream.clear(); // Clear the flags - - istream >> *(result_out = boost::make_default<out_type>()); - - if (istream.fail() || newbuf.gptr() != newbuf.egptr()/*C03*/) - result_out = boost::none; - - istream.rdbuf(oldbuf); -} - -#undef BOOST_CNV_STRING_ENABLE -#undef BOOST_CNV_PARAM - -#endif // BOOST_CONVERT_STRINGSTREAM_BASED_CONVERTER_HPP diff --git a/contrib/restricted/boost/boost/convert/strtol.hpp b/contrib/restricted/boost/boost/convert/strtol.hpp deleted file mode 100644 index 4dd26eef7f3..00000000000 --- a/contrib/restricted/boost/boost/convert/strtol.hpp +++ /dev/null @@ -1,219 +0,0 @@ -// Copyright (c) 2009-2016 Vladimir Batov. -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. - -#ifndef BOOST_CONVERT_STRTOL_CONVERTER_HPP -#define BOOST_CONVERT_STRTOL_CONVERTER_HPP - -#include <boost/convert/base.hpp> -#include <boost/type_traits/make_unsigned.hpp> -#include <boost/type_traits/is_same.hpp> -#include <boost/math/special_functions/round.hpp> -#include <limits> -#include <cmath> -#include <cstdlib> -#include <climits> - -#if __GNUC__ == 4 && __GNUC_MINOR__ <= 2 -namespace std -{ - using ::strtold; // Tests indicated that gcc-4.2.1 does not have 'std::strtold' -} -#endif - -namespace boost { namespace cnv -{ - struct strtol; -}} - -/// @brief std::strtol-based extended converter -/// @details The converter offers a fairly decent overall performance and moderate formatting facilities. - -struct boost::cnv::strtol : public boost::cnv::cnvbase<boost::cnv::strtol> -{ - typedef boost::cnv::strtol this_type; - typedef boost::cnv::cnvbase<this_type> base_type; - - using base_type::operator(); - - private: - - friend struct boost::cnv::cnvbase<this_type>; - - template<typename string_type> void str_to(cnv::range<string_type> v, optional< int_type>& r) const { str_to_i (v, r); } - template<typename string_type> void str_to(cnv::range<string_type> v, optional< sint_type>& r) const { str_to_i (v, r); } - template<typename string_type> void str_to(cnv::range<string_type> v, optional< lint_type>& r) const { str_to_i (v, r); } - template<typename string_type> void str_to(cnv::range<string_type> v, optional< llint_type>& r) const { str_to_i (v, r); } - template<typename string_type> void str_to(cnv::range<string_type> v, optional< uint_type>& r) const { str_to_i (v, r); } - template<typename string_type> void str_to(cnv::range<string_type> v, optional< usint_type>& r) const { str_to_i (v, r); } - template<typename string_type> void str_to(cnv::range<string_type> v, optional< ulint_type>& r) const { str_to_i (v, r); } - template<typename string_type> void str_to(cnv::range<string_type> v, optional<ullint_type>& r) const { str_to_i (v, r); } - template<typename string_type> void str_to(cnv::range<string_type> v, optional< flt_type>& r) const { str_to_d (v, r); } - template<typename string_type> void str_to(cnv::range<string_type> v, optional< dbl_type>& r) const { str_to_d (v, r); } - template<typename string_type> void str_to(cnv::range<string_type> v, optional< ldbl_type>& r) const { str_to_d (v, r); } - - template <typename char_type> cnv::range<char_type*> to_str ( int_type v, char_type* buf) const { return i_to_str(v, buf); } - template <typename char_type> cnv::range<char_type*> to_str ( uint_type v, char_type* buf) const { return i_to_str(v, buf); } - template <typename char_type> cnv::range<char_type*> to_str ( lint_type v, char_type* buf) const { return i_to_str(v, buf); } - template <typename char_type> cnv::range<char_type*> to_str ( ulint_type v, char_type* buf) const { return i_to_str(v, buf); } - template <typename char_type> cnv::range<char_type*> to_str ( llint_type v, char_type* buf) const { return i_to_str(v, buf); } - template <typename char_type> cnv::range<char_type*> to_str (ullint_type v, char_type* buf) const { return i_to_str(v, buf); } - template <typename char_type> cnv::range<char_type*> to_str ( dbl_type v, char_type* buf) const; - - template<typename char_type, typename in_type> cnv::range<char_type*> i_to_str (in_type, char_type*) const; - template<typename string_type, typename out_type> void str_to_i (cnv::range<string_type>, optional<out_type>&) const; - template<typename string_type, typename out_type> void str_to_d (cnv::range<string_type>, optional<out_type>&) const; - - static double adjust_fraction (double, int); - static int get_char (int v) { return (v < 10) ? (v += '0') : (v += 'A' - 10); } -}; - -template<typename char_type, typename Type> -boost::cnv::range<char_type*> -boost::cnv::strtol::i_to_str(Type in_value, char_type* buf) const -{ - // C1. Base=10 optimization improves performance 10% - - typedef typename boost::make_unsigned<Type>::type unsigned_type; - - char_type* beg = buf + bufsize_ / 2; - char_type* end = beg; - bool const is_neg = std::is_signed<Type>::value && in_value < 0; - unsigned_type value = static_cast<unsigned_type>(is_neg ? -in_value : in_value); - - if (base_ == 10) for (; value; *(--beg) = int(value % 10) + '0', value /= 10); //C1 - else for (; value; *(--beg) = get_char(value % base_), value /= base_); - - if (beg == end) *(--beg) = '0'; - if (is_neg) *(--beg) = '-'; - - return cnv::range<char_type*>(beg, end); -} - -inline -double -boost::cnv::strtol::adjust_fraction(double fraction, int precision) -{ - // C1. Bring forward the fraction coming right after precision digits. - // That is, say, fraction=0.234567, precision=2. Then brought forward=23.4567 - // C3. INT_MAX(4bytes)=2,147,483,647. So, 10^8 seems appropriate. If not, drop it down to 4. - // C4. ::round() returns the integral value that is nearest to x, - // with halfway cases rounded away from zero. Therefore, - // round( 0.4) = 0 - // round( 0.5) = 1 - // round( 0.6) = 1 - // round(-0.4) = 0 - // round(-0.5) = -1 - // round(-0.6) = -1 - - int const tens[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000 }; - - for (int k = precision / 8; k; --k) fraction *= 100000000; //C3. - - fraction *= tens[precision % 8]; //C1 - -// return ::rint(fraction); //C4 - return boost::math::round(fraction); //C4 -} - -template <typename char_type> -inline -boost::cnv::range<char_type*> -boost::cnv::strtol::to_str(double value, char_type* buf) const -{ - char_type* beg = buf + bufsize_ / 2; - char_type* end = beg; - char_type* ipos = end - 1; - bool const is_negative = (value < 0) ? (value = -value, true) : false; - double ipart = std::floor(value); - double fpart = adjust_fraction(value - ipart, precision_); - int precision = precision_; - int const base = 10; - - for (; 1 <= ipart; ipart /= base) - *(--beg) = get_char(int(ipart - std::floor(ipart / base) * base)); - - if (beg == end) *(--beg) = '0'; - if (precision) *(end++) = '.'; - - for (char_type* fpos = end += precision; precision; --precision, fpart /= base) - *(--fpos) = get_char(int(fpart - std::floor(fpart / base) * base)); - - if (1 <= fpart) - { - for (; beg <= ipos; --ipos) - if (*ipos == '9') *ipos = '0'; - else { ++*ipos; break; } - - if (ipos < beg) - *(beg = ipos) = '1'; - } - if (is_negative) *(--beg) = '-'; - - return cnv::range<char_type*>(beg, end); -} - -template<typename string_type, typename out_type> -void -boost::cnv::strtol::str_to_i(cnv::range<string_type> range, boost::optional<out_type>& result_out) const -{ - typedef typename boost::make_unsigned<out_type>::type unsigned_type; - typedef cnv::range<string_type> range_type; - typedef typename range_type::iterator iterator; - - iterator s = range.begin(); - unsigned int ch = *s; - bool const is_negative = ch == '-' ? (ch = *++s, true) : ch == '+' ? (ch = *++s, false) : false; - bool const is_unsigned = boost::is_same<out_type, unsigned_type>::value; - unsigned int base = base_; - - /**/ if (is_negative && is_unsigned) return; - else if ((base == 0 || base == 16) && ch == '0' && (*++s == 'x' || *s == 'X')) ++s, base = 16; - else if (base == 0) base = ch == '0' ? (++s, 8) : 10; - - unsigned_type const max = (std::numeric_limits<out_type>::max)() + (is_negative ? 1 : 0); - unsigned_type const cutoff = max / base; - unsigned int const cutlim = max % base; - unsigned_type result = 0; - - for (; s != range.sentry(); ++s) - { - ch = *s; - - /**/ if (std::isdigit(ch)) ch -= '0'; - else if (std::isalpha(ch)) ch -= (std::isupper(ch) ? 'A' : 'a') - 10; - else return; - - if (base <= ch || cutoff < result || (result == cutoff && cutlim < ch)) - return; - - result *= base; - result += ch; - } - result_out = is_negative ? -out_type(result) : out_type(result); -} - -template<typename string_type, typename out_type> -void -boost::cnv::strtol::str_to_d(cnv::range<string_type> range, optional<out_type>& result_out) const -{ - // C1. Because of strtold() currently only works with 'char' - // C2. strtold() does not work with ranges. - // Consequently, we have to copy the supplied range into a string for strtold(). - // C3. Check if the end-of-string was reached -- *cnv_end == 0. - - typedef cnv::range<string_type> range_type; - typedef typename range_type::value_type ch_type; - - size_t const sz = 128; - ch_type str[sz] = {0}; std::strncpy(str, &*range.begin(), std::min(sz - 1, range.size())); - char* cnv_end = 0; - ldbl_type result = strtold(str, &cnv_end); - bool good = result != -HUGE_VALL && result != HUGE_VALL && *cnv_end == 0; //C3 - out_type max = (std::numeric_limits<out_type>::max)(); - - if (good && -max <= result && result <= max) - result_out = out_type(result); -} - -#endif // BOOST_CONVERT_STRTOL_CONVERTER_HPP diff --git a/contrib/restricted/boost/boost/lockfree/detail/atomic.hpp b/contrib/restricted/boost/boost/lockfree/detail/atomic.hpp deleted file mode 100644 index 6083800f0ff..00000000000 --- a/contrib/restricted/boost/boost/lockfree/detail/atomic.hpp +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2011-2013, 2016 Tim Blechmann -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_LOCKFREE_DETAIL_ATOMIC_HPP -#define BOOST_LOCKFREE_DETAIL_ATOMIC_HPP - -#include <boost/config.hpp> - -#ifndef BOOST_LOCKFREE_FORCE_STD_ATOMIC - -#define BOOST_LOCKFREE_NO_HDR_ATOMIC - -// MSVC supports atomic<> from version 2012 onwards. -#if defined(BOOST_MSVC) && (BOOST_MSVC >= 1700) -#undef BOOST_LOCKFREE_NO_HDR_ATOMIC -#endif - - -// GCC supports atomic<> from version 4.8 onwards. -#if (BOOST_GCC >= 40800) && (__cplusplus >= 201103L) -#undef BOOST_LOCKFREE_NO_HDR_ATOMIC -#endif - - -// Apple clang is 2 mayor versions ahead, but in fact 1 minor version behind -#ifdef BOOST_CLANG - -#define BOOST_ATOMIC_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) - -#if defined(__apple_build_version__) && (BOOST_ATOMIC_CLANG_VERSION >= 60100) && (__cplusplus >= 201103L) -#undef BOOST_LOCKFREE_NO_HDR_ATOMIC -#endif - -#if !defined(__apple_build_version__) && (BOOST_ATOMIC_CLANG_VERSION >= 30600) && (__cplusplus >= 201103L) -#undef BOOST_LOCKFREE_NO_HDR_ATOMIC -#endif - -#undef BOOST_ATOMIC_CLANG_VERSION - -#endif // BOOST_CLANG - -// Stdlib should also be checked -#include <boost/config.hpp> -#if defined(BOOST_NO_CXX11_HDR_ATOMIC) && !defined(BOOST_LOCKFREE_NO_HDR_ATOMIC) -# define BOOST_LOCKFREE_NO_HDR_ATOMIC -#endif - -#endif // BOOST_LOCKFREE_FORCE_STD_ATOMIC - - -#if defined(BOOST_LOCKFREE_NO_HDR_ATOMIC) || defined(BOOST_LOCKFREE_FORCE_BOOST_ATOMIC) -#include <boost/atomic.hpp> -#else -#include <atomic> -#endif - -namespace boost { -namespace lockfree { -namespace detail { - -#if defined(BOOST_LOCKFREE_NO_HDR_ATOMIC) || defined(BOOST_LOCKFREE_FORCE_BOOST_ATOMIC) -using boost::atomic; -using boost::memory_order_acquire; -using boost::memory_order_consume; -using boost::memory_order_relaxed; -using boost::memory_order_release; -#else -using std::atomic; -using std::memory_order_acquire; -using std::memory_order_consume; -using std::memory_order_relaxed; -using std::memory_order_release; -#endif - -} -using detail::atomic; -using detail::memory_order_acquire; -using detail::memory_order_consume; -using detail::memory_order_relaxed; -using detail::memory_order_release; - -}} - -#endif /* BOOST_LOCKFREE_DETAIL_ATOMIC_HPP */ diff --git a/contrib/restricted/boost/boost/lockfree/detail/copy_payload.hpp b/contrib/restricted/boost/boost/lockfree/detail/copy_payload.hpp deleted file mode 100644 index 5972da7c641..00000000000 --- a/contrib/restricted/boost/boost/lockfree/detail/copy_payload.hpp +++ /dev/null @@ -1,83 +0,0 @@ -// boost lockfree: copy_payload helper -// -// Copyright (C) 2011, 2016 Tim Blechmann -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_LOCKFREE_DETAIL_COPY_PAYLOAD_HPP_INCLUDED -#define BOOST_LOCKFREE_DETAIL_COPY_PAYLOAD_HPP_INCLUDED - -#include <boost/mpl/if.hpp> -#include <boost/type_traits/is_convertible.hpp> - -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable: 4512) // assignment operator could not be generated -#endif - -namespace boost { -namespace lockfree { -namespace detail { - -struct copy_convertible -{ - template <typename T, typename U> - static void copy(T & t, U & u) - { - u = t; - } -}; - -struct copy_constructible_and_copyable -{ - template <typename T, typename U> - static void copy(T & t, U & u) - { - u = U(t); - } -}; - -template <typename T, typename U> -void copy_payload(T & t, U & u) -{ - typedef typename boost::mpl::if_<typename boost::is_convertible<T, U>::type, - copy_convertible, - copy_constructible_and_copyable - >::type copy_type; - copy_type::copy(t, u); -} - -template <typename T> -struct consume_via_copy -{ - consume_via_copy(T & out): - out_(out) - {} - - template <typename U> - void operator()(U & element) - { - copy_payload(element, out_); - } - - T & out_; -}; - -struct consume_noop -{ - template <typename U> - void operator()(const U &) - { - } -}; - - -}}} - -#if defined(_MSC_VER) -#pragma warning(pop) -#endif - -#endif /* BOOST_LOCKFREE_DETAIL_COPY_PAYLOAD_HPP_INCLUDED */ diff --git a/contrib/restricted/boost/boost/lockfree/detail/freelist.hpp b/contrib/restricted/boost/boost/lockfree/detail/freelist.hpp deleted file mode 100644 index 48dbb508f5f..00000000000 --- a/contrib/restricted/boost/boost/lockfree/detail/freelist.hpp +++ /dev/null @@ -1,656 +0,0 @@ -// lock-free freelist -// -// Copyright (C) 2008-2016 Tim Blechmann -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_LOCKFREE_FREELIST_HPP_INCLUDED -#define BOOST_LOCKFREE_FREELIST_HPP_INCLUDED - -#include <limits> -#include <memory> - -#include <boost/array.hpp> -#include <boost/config.hpp> -#include <boost/cstdint.hpp> -#include <boost/noncopyable.hpp> -#include <boost/static_assert.hpp> - -#include <boost/align/align_up.hpp> -#include <boost/align/aligned_allocator_adaptor.hpp> - -#include <boost/lockfree/detail/atomic.hpp> -#include <boost/lockfree/detail/parameter.hpp> -#include <boost/lockfree/detail/tagged_ptr.hpp> - -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable: 4100) // unreferenced formal parameter -#pragma warning(disable: 4127) // conditional expression is constant -#endif - -namespace boost { -namespace lockfree { -namespace detail { - -template <typename T, - typename Alloc = std::allocator<T> - > -class freelist_stack: - Alloc -{ - struct freelist_node - { - tagged_ptr<freelist_node> next; - }; - - typedef tagged_ptr<freelist_node> tagged_node_ptr; - -public: - typedef T * index_t; - typedef tagged_ptr<T> tagged_node_handle; - - template <typename Allocator> - freelist_stack (Allocator const & alloc, std::size_t n = 0): - Alloc(alloc), - pool_(tagged_node_ptr(NULL)) - { - for (std::size_t i = 0; i != n; ++i) { - T * node = Alloc::allocate(1); -#ifdef BOOST_LOCKFREE_FREELIST_INIT_RUNS_DTOR - destruct<false>(node); -#else - deallocate<false>(node); -#endif - } - } - - template <bool ThreadSafe> - void reserve (std::size_t count) - { - for (std::size_t i = 0; i != count; ++i) { - T * node = Alloc::allocate(1); - deallocate<ThreadSafe>(node); - } - } - - template <bool ThreadSafe, bool Bounded> - T * construct (void) - { - T * node = allocate<ThreadSafe, Bounded>(); - if (node) - new(node) T(); - return node; - } - - template <bool ThreadSafe, bool Bounded, typename ArgumentType> - T * construct (ArgumentType const & arg) - { - T * node = allocate<ThreadSafe, Bounded>(); - if (node) - new(node) T(arg); - return node; - } - - template <bool ThreadSafe, bool Bounded, typename ArgumentType1, typename ArgumentType2> - T * construct (ArgumentType1 const & arg1, ArgumentType2 const & arg2) - { - T * node = allocate<ThreadSafe, Bounded>(); - if (node) - new(node) T(arg1, arg2); - return node; - } - - template <bool ThreadSafe> - void destruct (tagged_node_handle tagged_ptr) - { - T * n = tagged_ptr.get_ptr(); - n->~T(); - deallocate<ThreadSafe>(n); - } - - template <bool ThreadSafe> - void destruct (T * n) - { - n->~T(); - deallocate<ThreadSafe>(n); - } - - ~freelist_stack(void) - { - tagged_node_ptr current = pool_.load(); - - while (current) { - freelist_node * current_ptr = current.get_ptr(); - if (current_ptr) - current = current_ptr->next; - Alloc::deallocate((T*)current_ptr, 1); - } - } - - bool is_lock_free(void) const - { - return pool_.is_lock_free(); - } - - T * get_handle(T * pointer) const - { - return pointer; - } - - T * get_handle(tagged_node_handle const & handle) const - { - return get_pointer(handle); - } - - T * get_pointer(tagged_node_handle const & tptr) const - { - return tptr.get_ptr(); - } - - T * get_pointer(T * pointer) const - { - return pointer; - } - - T * null_handle(void) const - { - return NULL; - } - -protected: // allow use from subclasses - template <bool ThreadSafe, bool Bounded> - T * allocate (void) - { - if (ThreadSafe) - return allocate_impl<Bounded>(); - else - return allocate_impl_unsafe<Bounded>(); - } - -private: - template <bool Bounded> - T * allocate_impl (void) - { - tagged_node_ptr old_pool = pool_.load(memory_order_consume); - - for(;;) { - if (!old_pool.get_ptr()) { - if (!Bounded) - return Alloc::allocate(1); - else - return 0; - } - - freelist_node * new_pool_ptr = old_pool->next.get_ptr(); - tagged_node_ptr new_pool (new_pool_ptr, old_pool.get_next_tag()); - - if (pool_.compare_exchange_weak(old_pool, new_pool)) { - void * ptr = old_pool.get_ptr(); - return reinterpret_cast<T*>(ptr); - } - } - } - - template <bool Bounded> - T * allocate_impl_unsafe (void) - { - tagged_node_ptr old_pool = pool_.load(memory_order_relaxed); - - if (!old_pool.get_ptr()) { - if (!Bounded) - return Alloc::allocate(1); - else - return 0; - } - - freelist_node * new_pool_ptr = old_pool->next.get_ptr(); - tagged_node_ptr new_pool (new_pool_ptr, old_pool.get_next_tag()); - - pool_.store(new_pool, memory_order_relaxed); - void * ptr = old_pool.get_ptr(); - return reinterpret_cast<T*>(ptr); - } - -protected: - template <bool ThreadSafe> - void deallocate (T * n) - { - if (ThreadSafe) - deallocate_impl(n); - else - deallocate_impl_unsafe(n); - } - -private: - void deallocate_impl (T * n) - { - void * node = n; - tagged_node_ptr old_pool = pool_.load(memory_order_consume); - freelist_node * new_pool_ptr = reinterpret_cast<freelist_node*>(node); - - for(;;) { - tagged_node_ptr new_pool (new_pool_ptr, old_pool.get_tag()); - new_pool->next.set_ptr(old_pool.get_ptr()); - - if (pool_.compare_exchange_weak(old_pool, new_pool)) - return; - } - } - - void deallocate_impl_unsafe (T * n) - { - void * node = n; - tagged_node_ptr old_pool = pool_.load(memory_order_relaxed); - freelist_node * new_pool_ptr = reinterpret_cast<freelist_node*>(node); - - tagged_node_ptr new_pool (new_pool_ptr, old_pool.get_tag()); - new_pool->next.set_ptr(old_pool.get_ptr()); - - pool_.store(new_pool, memory_order_relaxed); - } - - atomic<tagged_node_ptr> pool_; -}; - -class -BOOST_ALIGNMENT( 4 ) // workaround for bugs in MSVC -tagged_index -{ -public: - typedef boost::uint16_t tag_t; - typedef boost::uint16_t index_t; - - /** uninitialized constructor */ - tagged_index(void) BOOST_NOEXCEPT //: index(0), tag(0) - {} - - /** copy constructor */ -#ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS - tagged_index(tagged_index const & rhs): - index(rhs.index), tag(rhs.tag) - {} -#else - tagged_index(tagged_index const & rhs) = default; -#endif - - explicit tagged_index(index_t i, tag_t t = 0): - index(i), tag(t) - {} - - /** index access */ - /* @{ */ - index_t get_index() const - { - return index; - } - - void set_index(index_t i) - { - index = i; - } - /* @} */ - - /** tag access */ - /* @{ */ - tag_t get_tag() const - { - return tag; - } - - tag_t get_next_tag() const - { - tag_t next = (get_tag() + 1u) & (std::numeric_limits<tag_t>::max)(); - return next; - } - - void set_tag(tag_t t) - { - tag = t; - } - /* @} */ - - bool operator==(tagged_index const & rhs) const - { - return (index == rhs.index) && (tag == rhs.tag); - } - - bool operator!=(tagged_index const & rhs) const - { - return !operator==(rhs); - } - -protected: - index_t index; - tag_t tag; -}; - -template <typename T, - std::size_t size> -struct compiletime_sized_freelist_storage -{ - // array-based freelists only support a 16bit address space. - BOOST_STATIC_ASSERT(size < 65536); - - boost::array<char, size * sizeof(T) + 64> data; - - // unused ... only for API purposes - template <typename Allocator> - compiletime_sized_freelist_storage(Allocator const & /* alloc */, std::size_t /* count */) - {} - - T * nodes(void) const - { - char * data_pointer = const_cast<char*>(data.data()); - return reinterpret_cast<T*>( boost::alignment::align_up( data_pointer, BOOST_LOCKFREE_CACHELINE_BYTES ) ); - } - - std::size_t node_count(void) const - { - return size; - } -}; - -template <typename T, - typename Alloc = std::allocator<T> > -struct runtime_sized_freelist_storage: - boost::alignment::aligned_allocator_adaptor<Alloc, BOOST_LOCKFREE_CACHELINE_BYTES > -{ - typedef boost::alignment::aligned_allocator_adaptor<Alloc, BOOST_LOCKFREE_CACHELINE_BYTES > allocator_type; - T * nodes_; - std::size_t node_count_; - - template <typename Allocator> - runtime_sized_freelist_storage(Allocator const & alloc, std::size_t count): - allocator_type(alloc), node_count_(count) - { - if (count > 65535) - boost::throw_exception(std::runtime_error("boost.lockfree: freelist size is limited to a maximum of 65535 objects")); - nodes_ = allocator_type::allocate(count); - } - - ~runtime_sized_freelist_storage(void) - { - allocator_type::deallocate(nodes_, node_count_); - } - - T * nodes(void) const - { - return nodes_; - } - - std::size_t node_count(void) const - { - return node_count_; - } -}; - - -template <typename T, - typename NodeStorage = runtime_sized_freelist_storage<T> - > -class fixed_size_freelist: - NodeStorage -{ - struct freelist_node - { - tagged_index next; - }; - - void initialize(void) - { - T * nodes = NodeStorage::nodes(); - for (std::size_t i = 0; i != NodeStorage::node_count(); ++i) { - tagged_index * next_index = reinterpret_cast<tagged_index*>(nodes + i); - next_index->set_index(null_handle()); - -#ifdef BOOST_LOCKFREE_FREELIST_INIT_RUNS_DTOR - destruct<false>(nodes + i); -#else - deallocate<false>(static_cast<index_t>(i)); -#endif - } - } - -public: - typedef tagged_index tagged_node_handle; - typedef tagged_index::index_t index_t; - - template <typename Allocator> - fixed_size_freelist (Allocator const & alloc, std::size_t count): - NodeStorage(alloc, count), - pool_(tagged_index(static_cast<index_t>(count), 0)) - { - initialize(); - } - - fixed_size_freelist (void): - pool_(tagged_index(NodeStorage::node_count(), 0)) - { - initialize(); - } - - template <bool ThreadSafe, bool Bounded> - T * construct (void) - { - index_t node_index = allocate<ThreadSafe>(); - if (node_index == null_handle()) - return NULL; - - T * node = NodeStorage::nodes() + node_index; - new(node) T(); - return node; - } - - template <bool ThreadSafe, bool Bounded, typename ArgumentType> - T * construct (ArgumentType const & arg) - { - index_t node_index = allocate<ThreadSafe>(); - if (node_index == null_handle()) - return NULL; - - T * node = NodeStorage::nodes() + node_index; - new(node) T(arg); - return node; - } - - template <bool ThreadSafe, bool Bounded, typename ArgumentType1, typename ArgumentType2> - T * construct (ArgumentType1 const & arg1, ArgumentType2 const & arg2) - { - index_t node_index = allocate<ThreadSafe>(); - if (node_index == null_handle()) - return NULL; - - T * node = NodeStorage::nodes() + node_index; - new(node) T(arg1, arg2); - return node; - } - - template <bool ThreadSafe> - void destruct (tagged_node_handle tagged_index) - { - index_t index = tagged_index.get_index(); - T * n = NodeStorage::nodes() + index; - (void)n; // silence msvc warning - n->~T(); - deallocate<ThreadSafe>(index); - } - - template <bool ThreadSafe> - void destruct (T * n) - { - n->~T(); - deallocate<ThreadSafe>(n - NodeStorage::nodes()); - } - - bool is_lock_free(void) const - { - return pool_.is_lock_free(); - } - - index_t null_handle(void) const - { - return static_cast<index_t>(NodeStorage::node_count()); - } - - index_t get_handle(T * pointer) const - { - if (pointer == NULL) - return null_handle(); - else - return static_cast<index_t>(pointer - NodeStorage::nodes()); - } - - index_t get_handle(tagged_node_handle const & handle) const - { - return handle.get_index(); - } - - T * get_pointer(tagged_node_handle const & tptr) const - { - return get_pointer(tptr.get_index()); - } - - T * get_pointer(index_t index) const - { - if (index == null_handle()) - return 0; - else - return NodeStorage::nodes() + index; - } - - T * get_pointer(T * ptr) const - { - return ptr; - } - -protected: // allow use from subclasses - template <bool ThreadSafe> - index_t allocate (void) - { - if (ThreadSafe) - return allocate_impl(); - else - return allocate_impl_unsafe(); - } - -private: - index_t allocate_impl (void) - { - tagged_index old_pool = pool_.load(memory_order_consume); - - for(;;) { - index_t index = old_pool.get_index(); - if (index == null_handle()) - return index; - - T * old_node = NodeStorage::nodes() + index; - tagged_index * next_index = reinterpret_cast<tagged_index*>(old_node); - - tagged_index new_pool(next_index->get_index(), old_pool.get_next_tag()); - - if (pool_.compare_exchange_weak(old_pool, new_pool)) - return old_pool.get_index(); - } - } - - index_t allocate_impl_unsafe (void) - { - tagged_index old_pool = pool_.load(memory_order_consume); - - index_t index = old_pool.get_index(); - if (index == null_handle()) - return index; - - T * old_node = NodeStorage::nodes() + index; - tagged_index * next_index = reinterpret_cast<tagged_index*>(old_node); - - tagged_index new_pool(next_index->get_index(), old_pool.get_next_tag()); - - pool_.store(new_pool, memory_order_relaxed); - return old_pool.get_index(); - } - - template <bool ThreadSafe> - void deallocate (index_t index) - { - if (ThreadSafe) - deallocate_impl(index); - else - deallocate_impl_unsafe(index); - } - - void deallocate_impl (index_t index) - { - freelist_node * new_pool_node = reinterpret_cast<freelist_node*>(NodeStorage::nodes() + index); - tagged_index old_pool = pool_.load(memory_order_consume); - - for(;;) { - tagged_index new_pool (index, old_pool.get_tag()); - new_pool_node->next.set_index(old_pool.get_index()); - - if (pool_.compare_exchange_weak(old_pool, new_pool)) - return; - } - } - - void deallocate_impl_unsafe (index_t index) - { - freelist_node * new_pool_node = reinterpret_cast<freelist_node*>(NodeStorage::nodes() + index); - tagged_index old_pool = pool_.load(memory_order_consume); - - tagged_index new_pool (index, old_pool.get_tag()); - new_pool_node->next.set_index(old_pool.get_index()); - - pool_.store(new_pool); - } - - atomic<tagged_index> pool_; -}; - -template <typename T, - typename Alloc, - bool IsCompileTimeSized, - bool IsFixedSize, - std::size_t Capacity - > -struct select_freelist -{ - typedef typename mpl::if_c<IsCompileTimeSized, - compiletime_sized_freelist_storage<T, Capacity>, - runtime_sized_freelist_storage<T, Alloc> - >::type fixed_sized_storage_type; - - typedef typename mpl::if_c<IsCompileTimeSized || IsFixedSize, - fixed_size_freelist<T, fixed_sized_storage_type>, - freelist_stack<T, Alloc> - >::type type; -}; - -template <typename T, bool IsNodeBased> -struct select_tagged_handle -{ - typedef typename mpl::if_c<IsNodeBased, - tagged_ptr<T>, - tagged_index - >::type tagged_handle_type; - - typedef typename mpl::if_c<IsNodeBased, - T*, - typename tagged_index::index_t - >::type handle_type; -}; - - -} /* namespace detail */ -} /* namespace lockfree */ -} /* namespace boost */ - -#if defined(_MSC_VER) -#pragma warning(pop) -#endif - - -#endif /* BOOST_LOCKFREE_FREELIST_HPP_INCLUDED */ diff --git a/contrib/restricted/boost/boost/lockfree/detail/parameter.hpp b/contrib/restricted/boost/boost/lockfree/detail/parameter.hpp deleted file mode 100644 index e5db1206e5f..00000000000 --- a/contrib/restricted/boost/boost/lockfree/detail/parameter.hpp +++ /dev/null @@ -1,78 +0,0 @@ -// boost lockfree -// -// Copyright (C) 2011, 2016 Tim Blechmann -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_LOCKFREE_DETAIL_PARAMETER_HPP -#define BOOST_LOCKFREE_DETAIL_PARAMETER_HPP - -#include <boost/lockfree/policies.hpp> -#include <boost/parameter/parameters.hpp> -#include <boost/parameter/binding.hpp> - -#include <boost/mpl/void.hpp> - - -namespace boost { -namespace lockfree { -namespace detail { - -namespace mpl = boost::mpl; - -template <typename bound_args, typename tag_type> -struct has_arg -{ - typedef typename parameter::binding<bound_args, tag_type, mpl::void_>::type type; - static const bool value = mpl::is_not_void_<type>::type::value; -}; - - -template <typename bound_args> -struct extract_capacity -{ - static const bool has_capacity = has_arg<bound_args, tag::capacity>::value; - - typedef typename mpl::if_c<has_capacity, - typename has_arg<bound_args, tag::capacity>::type, - mpl::size_t< 0 > - >::type capacity_t; - - static const std::size_t capacity = capacity_t::value; -}; - - -template <typename bound_args, typename T> -struct extract_allocator -{ - static const bool has_allocator = has_arg<bound_args, tag::allocator>::value; - - typedef typename mpl::if_c<has_allocator, - typename has_arg<bound_args, tag::allocator>::type, - std::allocator<T> - >::type allocator_arg; - - typedef typename allocator_arg::template rebind<T>::other type; -}; - -template <typename bound_args, bool default_ = false> -struct extract_fixed_sized -{ - static const bool has_fixed_sized = has_arg<bound_args, tag::fixed_sized>::value; - - typedef typename mpl::if_c<has_fixed_sized, - typename has_arg<bound_args, tag::fixed_sized>::type, - mpl::bool_<default_> - >::type type; - - static const bool value = type::value; -}; - - -} /* namespace detail */ -} /* namespace lockfree */ -} /* namespace boost */ - -#endif /* BOOST_LOCKFREE_DETAIL_PARAMETER_HPP */ diff --git a/contrib/restricted/boost/boost/lockfree/detail/prefix.hpp b/contrib/restricted/boost/boost/lockfree/detail/prefix.hpp deleted file mode 100644 index 6ad96d1fe62..00000000000 --- a/contrib/restricted/boost/boost/lockfree/detail/prefix.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2009, 2016 Tim Blechmann -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_LOCKFREE_PREFIX_HPP_INCLUDED -#define BOOST_LOCKFREE_PREFIX_HPP_INCLUDED - -/* this file defines the following macros: - BOOST_LOCKFREE_CACHELINE_BYTES: size of a cache line - BOOST_LOCKFREE_PTR_COMPRESSION: use tag/pointer compression to utilize parts - of the virtual address space as tag (at least 16bit) -*/ - -// PowerPC caches support 128-byte cache lines. -#if defined(powerpc) || defined(__powerpc__) || defined(__ppc__) - #define BOOST_LOCKFREE_CACHELINE_BYTES 128 -#else - #define BOOST_LOCKFREE_CACHELINE_BYTES 64 -#endif - -#include <boost/predef.h> - -#ifdef BOOST_ARCH_X86_64 -#define BOOST_LOCKFREE_PTR_COMPRESSION 1 -#endif - -#endif /* BOOST_LOCKFREE_PREFIX_HPP_INCLUDED */ diff --git a/contrib/restricted/boost/boost/lockfree/detail/tagged_ptr.hpp b/contrib/restricted/boost/boost/lockfree/detail/tagged_ptr.hpp deleted file mode 100644 index 10ab2e9126c..00000000000 --- a/contrib/restricted/boost/boost/lockfree/detail/tagged_ptr.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// tagged pointer, for aba prevention -// -// Copyright (C) 2008, 2016 Tim Blechmann -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_LOCKFREE_TAGGED_PTR_HPP_INCLUDED -#define BOOST_LOCKFREE_TAGGED_PTR_HPP_INCLUDED - -#include <boost/config.hpp> -#include <boost/lockfree/detail/prefix.hpp> - -#ifndef BOOST_LOCKFREE_PTR_COMPRESSION -#include <boost/lockfree/detail/tagged_ptr_dcas.hpp> -#else -#include <boost/lockfree/detail/tagged_ptr_ptrcompression.hpp> -#endif - -#endif /* BOOST_LOCKFREE_TAGGED_PTR_HPP_INCLUDED */ diff --git a/contrib/restricted/boost/boost/lockfree/detail/tagged_ptr_dcas.hpp b/contrib/restricted/boost/boost/lockfree/detail/tagged_ptr_dcas.hpp deleted file mode 100644 index 83718daea2b..00000000000 --- a/contrib/restricted/boost/boost/lockfree/detail/tagged_ptr_dcas.hpp +++ /dev/null @@ -1,136 +0,0 @@ -// tagged pointer, for aba prevention -// -// Copyright (C) 2008, 2016 Tim Blechmann -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_LOCKFREE_TAGGED_PTR_DCAS_HPP_INCLUDED -#define BOOST_LOCKFREE_TAGGED_PTR_DCAS_HPP_INCLUDED - -#include <cstddef> /* for std::size_t */ -#include <limits> - -#include <boost/predef.h> - -namespace boost { -namespace lockfree { -namespace detail { - - - -template <class T> -class BOOST_ALIGNMENT(2 * sizeof(void*)) tagged_ptr -{ -public: - typedef std::size_t tag_t; - - /** uninitialized constructor */ - tagged_ptr(void) BOOST_NOEXCEPT//: ptr(0), tag(0) - {} - -#ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS - tagged_ptr(tagged_ptr const & p): - ptr(p.ptr), tag(p.tag) - {} -#else - tagged_ptr(tagged_ptr const & p) = default; -#endif - - explicit tagged_ptr(T * p, tag_t t = 0): - ptr(p), tag(t) - {} - - /** unsafe set operation */ - /* @{ */ -#ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS - tagged_ptr & operator= (tagged_ptr const & p) - { - set(p.ptr, p.tag); - return *this; - } -#else - tagged_ptr & operator= (tagged_ptr const & p) = default; -#endif - - void set(T * p, tag_t t) - { - ptr = p; - tag = t; - } - /* @} */ - - /** comparing semantics */ - /* @{ */ - bool operator== (volatile tagged_ptr const & p) const - { - return (ptr == p.ptr) && (tag == p.tag); - } - - bool operator!= (volatile tagged_ptr const & p) const - { - return !operator==(p); - } - /* @} */ - - /** pointer access */ - /* @{ */ - T * get_ptr(void) const - { - return ptr; - } - - void set_ptr(T * p) - { - ptr = p; - } - /* @} */ - - /** tag access */ - /* @{ */ - tag_t get_tag() const - { - return tag; - } - - tag_t get_next_tag() const - { - tag_t next = (get_tag() + 1) & (std::numeric_limits<tag_t>::max)(); - return next; - } - - void set_tag(tag_t t) - { - tag = t; - } - /* @} */ - - /** smart pointer support */ - /* @{ */ - T & operator*() const - { - return *ptr; - } - - T * operator->() const - { - return ptr; - } - - operator bool(void) const - { - return ptr != 0; - } - /* @} */ - -protected: - T * ptr; - tag_t tag; -}; - -} /* namespace detail */ -} /* namespace lockfree */ -} /* namespace boost */ - -#endif /* BOOST_LOCKFREE_TAGGED_PTR_DCAS_HPP_INCLUDED */ diff --git a/contrib/restricted/boost/boost/lockfree/detail/tagged_ptr_ptrcompression.hpp b/contrib/restricted/boost/boost/lockfree/detail/tagged_ptr_ptrcompression.hpp deleted file mode 100644 index bcf6e34f6b1..00000000000 --- a/contrib/restricted/boost/boost/lockfree/detail/tagged_ptr_ptrcompression.hpp +++ /dev/null @@ -1,174 +0,0 @@ -// tagged pointer, for aba prevention -// -// Copyright (C) 2008, 2009, 2016 Tim Blechmann, based on code by Cory Nelson -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_LOCKFREE_TAGGED_PTR_PTRCOMPRESSION_HPP_INCLUDED -#define BOOST_LOCKFREE_TAGGED_PTR_PTRCOMPRESSION_HPP_INCLUDED - -#include <cstddef> /* for std::size_t */ -#include <limits> - -#include <boost/cstdint.hpp> -#include <boost/predef.h> - -namespace boost { -namespace lockfree { -namespace detail { - -#ifdef BOOST_ARCH_X86_64 - -template <class T> -class tagged_ptr -{ - typedef boost::uint64_t compressed_ptr_t; - -public: - typedef boost::uint16_t tag_t; - -private: - union cast_unit - { - compressed_ptr_t value; - tag_t tag[4]; - }; - - static const int tag_index = 3; - static const compressed_ptr_t ptr_mask = 0xffffffffffffUL; //(1L<<48L)-1; - - static T* extract_ptr(volatile compressed_ptr_t const & i) - { - return (T*)(i & ptr_mask); - } - - static tag_t extract_tag(volatile compressed_ptr_t const & i) - { - cast_unit cu; - cu.value = i; - return cu.tag[tag_index]; - } - - static compressed_ptr_t pack_ptr(T * ptr, tag_t tag) - { - cast_unit ret; - ret.value = compressed_ptr_t(ptr); - ret.tag[tag_index] = tag; - return ret.value; - } - -public: - /** uninitialized constructor */ - tagged_ptr(void) BOOST_NOEXCEPT//: ptr(0), tag(0) - {} - - /** copy constructor */ -#ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS - tagged_ptr(tagged_ptr const & p): - ptr(p.ptr) - {} -#else - tagged_ptr(tagged_ptr const & p) = default; -#endif - - explicit tagged_ptr(T * p, tag_t t = 0): - ptr(pack_ptr(p, t)) - {} - - /** unsafe set operation */ - /* @{ */ -#ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS - tagged_ptr & operator= (tagged_ptr const & p) - { - ptr = p.ptr; - return *this; - } -#else - tagged_ptr & operator= (tagged_ptr const & p) = default; -#endif - - void set(T * p, tag_t t) - { - ptr = pack_ptr(p, t); - } - /* @} */ - - /** comparing semantics */ - /* @{ */ - bool operator== (volatile tagged_ptr const & p) const - { - return (ptr == p.ptr); - } - - bool operator!= (volatile tagged_ptr const & p) const - { - return !operator==(p); - } - /* @} */ - - /** pointer access */ - /* @{ */ - T * get_ptr() const - { - return extract_ptr(ptr); - } - - void set_ptr(T * p) - { - tag_t tag = get_tag(); - ptr = pack_ptr(p, tag); - } - /* @} */ - - /** tag access */ - /* @{ */ - tag_t get_tag() const - { - return extract_tag(ptr); - } - - tag_t get_next_tag() const - { - tag_t next = (get_tag() + 1u) & (std::numeric_limits<tag_t>::max)(); - return next; - } - - void set_tag(tag_t t) - { - T * p = get_ptr(); - ptr = pack_ptr(p, t); - } - /* @} */ - - /** smart pointer support */ - /* @{ */ - T & operator*() const - { - return *get_ptr(); - } - - T * operator->() const - { - return get_ptr(); - } - - operator bool(void) const - { - return get_ptr() != 0; - } - /* @} */ - -protected: - compressed_ptr_t ptr; -}; -#else -#error unsupported platform -#endif - -} /* namespace detail */ -} /* namespace lockfree */ -} /* namespace boost */ - -#endif /* BOOST_LOCKFREE_TAGGED_PTR_PTRCOMPRESSION_HPP_INCLUDED */ diff --git a/contrib/restricted/boost/boost/lockfree/lockfree_forward.hpp b/contrib/restricted/boost/boost/lockfree/lockfree_forward.hpp deleted file mode 100644 index b1d72b32d24..00000000000 --- a/contrib/restricted/boost/boost/lockfree/lockfree_forward.hpp +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (C) 2008-2016 Tim Blechmann -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - - -#ifndef BOOST_LOCKFREE_FORWARD_HPP_INCLUDED -#define BOOST_LOCKFREE_FORWARD_HPP_INCLUDED - - -#ifndef BOOST_DOXYGEN_INVOKED - -#include <cstddef> // size_t - -#include <boost/config.hpp> - -#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES -#include <boost/parameter/aux_/void.hpp> -#endif - -namespace boost { -namespace lockfree { - -// policies -template <bool IsFixedSized> -struct fixed_sized; - -template <size_t Size> -struct capacity; - -template <class Alloc> -struct allocator; - - -// data structures - -#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES -template <typename T, - class A0 = boost::parameter::void_, - class A1 = boost::parameter::void_, - class A2 = boost::parameter::void_> -#else -template <typename T, typename ...Options> -#endif -class queue; - -#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES -template <typename T, - class A0 = boost::parameter::void_, - class A1 = boost::parameter::void_, - class A2 = boost::parameter::void_> -#else -template <typename T, typename ...Options> -#endif -class stack; - -#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES -template <typename T, - class A0 = boost::parameter::void_, - class A1 = boost::parameter::void_> -#else -template <typename T, typename ...Options> -#endif -class spsc_queue; - -} -} - -#endif // BOOST_DOXYGEN_INVOKED - -#endif // BOOST_LOCKFREE_FORWARD_HPP_INCLUDED diff --git a/contrib/restricted/boost/boost/lockfree/policies.hpp b/contrib/restricted/boost/boost/lockfree/policies.hpp deleted file mode 100644 index cf43ad22f3e..00000000000 --- a/contrib/restricted/boost/boost/lockfree/policies.hpp +++ /dev/null @@ -1,57 +0,0 @@ -// boost lockfree -// -// Copyright (C) 2011 Tim Blechmann -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_LOCKFREE_POLICIES_HPP_INCLUDED -#define BOOST_LOCKFREE_POLICIES_HPP_INCLUDED - -#include <boost/parameter/aux_/template_keyword.hpp> -#include <boost/mpl/bool.hpp> -#include <boost/mpl/size_t.hpp> - -namespace boost { -namespace lockfree { - -#ifndef BOOST_DOXYGEN_INVOKED -namespace tag { struct allocator ; } -namespace tag { struct fixed_sized; } -namespace tag { struct capacity; } - -#endif - -/** Configures a data structure as \b fixed-sized. - * - * The internal nodes are stored inside an array and they are addressed by array indexing. This limits the possible size of the - * queue to the number of elements that can be addressed by the index type (usually 2**16-2), but on platforms that lack - * double-width compare-and-exchange instructions, this is the best way to achieve lock-freedom. - * This implies that a data structure is bounded. - * */ -template <bool IsFixedSized> -struct fixed_sized: - boost::parameter::template_keyword<tag::fixed_sized, boost::mpl::bool_<IsFixedSized> > -{}; - -/** Sets the \b capacity of a data structure at compile-time. - * - * This implies that a data structure is bounded and fixed-sized. - * */ -template <size_t Size> -struct capacity: - boost::parameter::template_keyword<tag::capacity, boost::mpl::size_t<Size> > -{}; - -/** Defines the \b allocator type of a data structure. - * */ -template <class Alloc> -struct allocator: - boost::parameter::template_keyword<tag::allocator, Alloc> -{}; - -} -} - -#endif /* BOOST_LOCKFREE_POLICIES_HPP_INCLUDED */ diff --git a/contrib/restricted/boost/boost/lockfree/queue.hpp b/contrib/restricted/boost/boost/lockfree/queue.hpp deleted file mode 100644 index bb699efc459..00000000000 --- a/contrib/restricted/boost/boost/lockfree/queue.hpp +++ /dev/null @@ -1,551 +0,0 @@ -// lock-free queue from -// Michael, M. M. and Scott, M. L., -// "simple, fast and practical non-blocking and blocking concurrent queue algorithms" -// -// Copyright (C) 2008-2013 Tim Blechmann -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_LOCKFREE_FIFO_HPP_INCLUDED -#define BOOST_LOCKFREE_FIFO_HPP_INCLUDED - -#include <boost/assert.hpp> -#include <boost/static_assert.hpp> -#include <boost/type_traits/has_trivial_assign.hpp> -#include <boost/type_traits/has_trivial_destructor.hpp> -#include <boost/config.hpp> // for BOOST_LIKELY & BOOST_ALIGNMENT - -#include <boost/lockfree/detail/atomic.hpp> -#include <boost/lockfree/detail/copy_payload.hpp> -#include <boost/lockfree/detail/freelist.hpp> -#include <boost/lockfree/detail/parameter.hpp> -#include <boost/lockfree/detail/tagged_ptr.hpp> - -#include <boost/lockfree/lockfree_forward.hpp> - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - - -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) -#endif - - -namespace boost { -namespace lockfree { -namespace detail { - -typedef parameter::parameters<boost::parameter::optional<tag::allocator>, - boost::parameter::optional<tag::capacity> - > queue_signature; - -} /* namespace detail */ - - -/** The queue class provides a multi-writer/multi-reader queue, pushing and popping is lock-free, - * construction/destruction has to be synchronized. It uses a freelist for memory management, - * freed nodes are pushed to the freelist and not returned to the OS before the queue is destroyed. - * - * \b Policies: - * - \ref boost::lockfree::fixed_sized, defaults to \c boost::lockfree::fixed_sized<false> \n - * Can be used to completely disable dynamic memory allocations during push in order to ensure lockfree behavior. \n - * If the data structure is configured as fixed-sized, the internal nodes are stored inside an array and they are addressed - * by array indexing. This limits the possible size of the queue to the number of elements that can be addressed by the index - * type (usually 2**16-2), but on platforms that lack double-width compare-and-exchange instructions, this is the best way - * to achieve lock-freedom. - * - * - \ref boost::lockfree::capacity, optional \n - * If this template argument is passed to the options, the size of the queue is set at compile-time.\n - * This option implies \c fixed_sized<true> - * - * - \ref boost::lockfree::allocator, defaults to \c boost::lockfree::allocator<std::allocator<void>> \n - * Specifies the allocator that is used for the internal freelist - * - * \b Requirements: - * - T must have a copy constructor - * - T must have a trivial assignment operator - * - T must have a trivial destructor - * - * */ -#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES -template <typename T, class A0, class A1, class A2> -#else -template <typename T, typename ...Options> -#endif -class queue -{ -private: -#ifndef BOOST_DOXYGEN_INVOKED - -#ifdef BOOST_HAS_TRIVIAL_DESTRUCTOR - BOOST_STATIC_ASSERT((boost::has_trivial_destructor<T>::value)); -#endif - -#ifdef BOOST_HAS_TRIVIAL_ASSIGN - BOOST_STATIC_ASSERT((boost::has_trivial_assign<T>::value)); -#endif - -#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES - typedef typename detail::queue_signature::bind<A0, A1, A2>::type bound_args; -#else - typedef typename detail::queue_signature::bind<Options...>::type bound_args; -#endif - - static const bool has_capacity = detail::extract_capacity<bound_args>::has_capacity; - static const size_t capacity = detail::extract_capacity<bound_args>::capacity + 1; // the queue uses one dummy node - static const bool fixed_sized = detail::extract_fixed_sized<bound_args>::value; - static const bool node_based = !(has_capacity || fixed_sized); - static const bool compile_time_sized = has_capacity; - - struct BOOST_ALIGNMENT(BOOST_LOCKFREE_CACHELINE_BYTES) node - { - typedef typename detail::select_tagged_handle<node, node_based>::tagged_handle_type tagged_node_handle; - typedef typename detail::select_tagged_handle<node, node_based>::handle_type handle_type; - - node(T const & v, handle_type null_handle): - data(v)//, next(tagged_node_handle(0, 0)) - { - /* increment tag to avoid ABA problem */ - tagged_node_handle old_next = next.load(memory_order_relaxed); - tagged_node_handle new_next (null_handle, old_next.get_next_tag()); - next.store(new_next, memory_order_release); - } - - node (handle_type null_handle): - next(tagged_node_handle(null_handle, 0)) - {} - - node(void) - {} - - atomic<tagged_node_handle> next; - T data; - }; - - typedef typename detail::extract_allocator<bound_args, node>::type node_allocator; - typedef typename detail::select_freelist<node, node_allocator, compile_time_sized, fixed_sized, capacity>::type pool_t; - typedef typename pool_t::tagged_node_handle tagged_node_handle; - typedef typename detail::select_tagged_handle<node, node_based>::handle_type handle_type; - - void initialize(void) - { - node * n = pool.template construct<true, false>(pool.null_handle()); - tagged_node_handle dummy_node(pool.get_handle(n), 0); - head_.store(dummy_node, memory_order_relaxed); - tail_.store(dummy_node, memory_order_release); - } - - struct implementation_defined - { - typedef node_allocator allocator; - typedef std::size_t size_type; - }; - -#endif - - BOOST_DELETED_FUNCTION(queue(queue const&)) - BOOST_DELETED_FUNCTION(queue& operator= (queue const&)) - -public: - typedef T value_type; - typedef typename implementation_defined::allocator allocator; - typedef typename implementation_defined::size_type size_type; - - /** - * \return true, if implementation is lock-free. - * - * \warning It only checks, if the queue head and tail nodes and the freelist can be modified in a lock-free manner. - * On most platforms, the whole implementation is lock-free, if this is true. Using c++0x-style atomics, there is - * no possibility to provide a completely accurate implementation, because one would need to test every internal - * node, which is impossible if further nodes will be allocated from the operating system. - * */ - bool is_lock_free (void) const - { - return head_.is_lock_free() && tail_.is_lock_free() && pool.is_lock_free(); - } - - //! Construct queue - // @{ - queue(void): - head_(tagged_node_handle(0, 0)), - tail_(tagged_node_handle(0, 0)), - pool(node_allocator(), capacity) - { - BOOST_ASSERT(has_capacity); - initialize(); - } - - template <typename U> - explicit queue(typename node_allocator::template rebind<U>::other const & alloc): - head_(tagged_node_handle(0, 0)), - tail_(tagged_node_handle(0, 0)), - pool(alloc, capacity) - { - BOOST_STATIC_ASSERT(has_capacity); - initialize(); - } - - explicit queue(allocator const & alloc): - head_(tagged_node_handle(0, 0)), - tail_(tagged_node_handle(0, 0)), - pool(alloc, capacity) - { - BOOST_ASSERT(has_capacity); - initialize(); - } - // @} - - //! Construct queue, allocate n nodes for the freelist. - // @{ - explicit queue(size_type n): - head_(tagged_node_handle(0, 0)), - tail_(tagged_node_handle(0, 0)), - pool(node_allocator(), n + 1) - { - BOOST_ASSERT(!has_capacity); - initialize(); - } - - template <typename U> - queue(size_type n, typename node_allocator::template rebind<U>::other const & alloc): - head_(tagged_node_handle(0, 0)), - tail_(tagged_node_handle(0, 0)), - pool(alloc, n + 1) - { - BOOST_STATIC_ASSERT(!has_capacity); - initialize(); - } - // @} - - /** \copydoc boost::lockfree::stack::reserve - * */ - void reserve(size_type n) - { - pool.template reserve<true>(n); - } - - /** \copydoc boost::lockfree::stack::reserve_unsafe - * */ - void reserve_unsafe(size_type n) - { - pool.template reserve<false>(n); - } - - /** Destroys queue, free all nodes from freelist. - * */ - ~queue(void) - { - T dummy; - while(unsynchronized_pop(dummy)) - {} - - pool.template destruct<false>(head_.load(memory_order_relaxed)); - } - - /** Check if the queue is empty - * - * \return true, if the queue is empty, false otherwise - * \note The result is only accurate, if no other thread modifies the queue. Therefore it is rarely practical to use this - * value in program logic. - * */ - bool empty(void) const - { - return pool.get_handle(head_.load()) == pool.get_handle(tail_.load()); - } - - /** Pushes object t to the queue. - * - * \post object will be pushed to the queue, if internal node can be allocated - * \returns true, if the push operation is successful. - * - * \note Thread-safe. If internal memory pool is exhausted and the memory pool is not fixed-sized, a new node will be allocated - * from the OS. This may not be lock-free. - * */ - bool push(T const & t) - { - return do_push<false>(t); - } - - /** Pushes object t to the queue. - * - * \post object will be pushed to the queue, if internal node can be allocated - * \returns true, if the push operation is successful. - * - * \note Thread-safe and non-blocking. If internal memory pool is exhausted, operation will fail - * \throws if memory allocator throws - * */ - bool bounded_push(T const & t) - { - return do_push<true>(t); - } - - -private: -#ifndef BOOST_DOXYGEN_INVOKED - template <bool Bounded> - bool do_push(T const & t) - { - node * n = pool.template construct<true, Bounded>(t, pool.null_handle()); - handle_type node_handle = pool.get_handle(n); - - if (n == NULL) - return false; - - for (;;) { - tagged_node_handle tail = tail_.load(memory_order_acquire); - node * tail_node = pool.get_pointer(tail); - tagged_node_handle next = tail_node->next.load(memory_order_acquire); - node * next_ptr = pool.get_pointer(next); - - tagged_node_handle tail2 = tail_.load(memory_order_acquire); - if (BOOST_LIKELY(tail == tail2)) { - if (next_ptr == 0) { - tagged_node_handle new_tail_next(node_handle, next.get_next_tag()); - if ( tail_node->next.compare_exchange_weak(next, new_tail_next) ) { - tagged_node_handle new_tail(node_handle, tail.get_next_tag()); - tail_.compare_exchange_strong(tail, new_tail); - return true; - } - } - else { - tagged_node_handle new_tail(pool.get_handle(next_ptr), tail.get_next_tag()); - tail_.compare_exchange_strong(tail, new_tail); - } - } - } - } -#endif - -public: - - /** Pushes object t to the queue. - * - * \post object will be pushed to the queue, if internal node can be allocated - * \returns true, if the push operation is successful. - * - * \note Not Thread-safe. If internal memory pool is exhausted and the memory pool is not fixed-sized, a new node will be allocated - * from the OS. This may not be lock-free. - * \throws if memory allocator throws - * */ - bool unsynchronized_push(T const & t) - { - node * n = pool.template construct<false, false>(t, pool.null_handle()); - - if (n == NULL) - return false; - - for (;;) { - tagged_node_handle tail = tail_.load(memory_order_relaxed); - tagged_node_handle next = tail->next.load(memory_order_relaxed); - node * next_ptr = next.get_ptr(); - - if (next_ptr == 0) { - tail->next.store(tagged_node_handle(n, next.get_next_tag()), memory_order_relaxed); - tail_.store(tagged_node_handle(n, tail.get_next_tag()), memory_order_relaxed); - return true; - } - else - tail_.store(tagged_node_handle(next_ptr, tail.get_next_tag()), memory_order_relaxed); - } - } - - /** Pops object from queue. - * - * \post if pop operation is successful, object will be copied to ret. - * \returns true, if the pop operation is successful, false if queue was empty. - * - * \note Thread-safe and non-blocking - * */ - bool pop (T & ret) - { - return pop<T>(ret); - } - - /** Pops object from queue. - * - * \pre type U must be constructible by T and copyable, or T must be convertible to U - * \post if pop operation is successful, object will be copied to ret. - * \returns true, if the pop operation is successful, false if queue was empty. - * - * \note Thread-safe and non-blocking - * */ - template <typename U> - bool pop (U & ret) - { - for (;;) { - tagged_node_handle head = head_.load(memory_order_acquire); - node * head_ptr = pool.get_pointer(head); - - tagged_node_handle tail = tail_.load(memory_order_acquire); - tagged_node_handle next = head_ptr->next.load(memory_order_acquire); - node * next_ptr = pool.get_pointer(next); - - tagged_node_handle head2 = head_.load(memory_order_acquire); - if (BOOST_LIKELY(head == head2)) { - if (pool.get_handle(head) == pool.get_handle(tail)) { - if (next_ptr == 0) - return false; - - tagged_node_handle new_tail(pool.get_handle(next), tail.get_next_tag()); - tail_.compare_exchange_strong(tail, new_tail); - - } else { - if (next_ptr == 0) - /* this check is not part of the original algorithm as published by michael and scott - * - * however we reuse the tagged_ptr part for the freelist and clear the next part during node - * allocation. we can observe a null-pointer here. - * */ - continue; - detail::copy_payload(next_ptr->data, ret); - - tagged_node_handle new_head(pool.get_handle(next), head.get_next_tag()); - if (head_.compare_exchange_weak(head, new_head)) { - pool.template destruct<true>(head); - return true; - } - } - } - } - } - - /** Pops object from queue. - * - * \post if pop operation is successful, object will be copied to ret. - * \returns true, if the pop operation is successful, false if queue was empty. - * - * \note Not thread-safe, but non-blocking - * - * */ - bool unsynchronized_pop (T & ret) - { - return unsynchronized_pop<T>(ret); - } - - /** Pops object from queue. - * - * \pre type U must be constructible by T and copyable, or T must be convertible to U - * \post if pop operation is successful, object will be copied to ret. - * \returns true, if the pop operation is successful, false if queue was empty. - * - * \note Not thread-safe, but non-blocking - * - * */ - template <typename U> - bool unsynchronized_pop (U & ret) - { - for (;;) { - tagged_node_handle head = head_.load(memory_order_relaxed); - node * head_ptr = pool.get_pointer(head); - tagged_node_handle tail = tail_.load(memory_order_relaxed); - tagged_node_handle next = head_ptr->next.load(memory_order_relaxed); - node * next_ptr = pool.get_pointer(next); - - if (pool.get_handle(head) == pool.get_handle(tail)) { - if (next_ptr == 0) - return false; - - tagged_node_handle new_tail(pool.get_handle(next), tail.get_next_tag()); - tail_.store(new_tail); - } else { - if (next_ptr == 0) - /* this check is not part of the original algorithm as published by michael and scott - * - * however we reuse the tagged_ptr part for the freelist and clear the next part during node - * allocation. we can observe a null-pointer here. - * */ - continue; - detail::copy_payload(next_ptr->data, ret); - tagged_node_handle new_head(pool.get_handle(next), head.get_next_tag()); - head_.store(new_head); - pool.template destruct<false>(head); - return true; - } - } - } - - /** consumes one element via a functor - * - * pops one element from the queue and applies the functor on this object - * - * \returns true, if one element was consumed - * - * \note Thread-safe and non-blocking, if functor is thread-safe and non-blocking - * */ - template <typename Functor> - bool consume_one(Functor & f) - { - T element; - bool success = pop(element); - if (success) - f(element); - - return success; - } - - /// \copydoc boost::lockfree::queue::consume_one(Functor & rhs) - template <typename Functor> - bool consume_one(Functor const & f) - { - T element; - bool success = pop(element); - if (success) - f(element); - - return success; - } - - /** consumes all elements via a functor - * - * sequentially pops all elements from the queue and applies the functor on each object - * - * \returns number of elements that are consumed - * - * \note Thread-safe and non-blocking, if functor is thread-safe and non-blocking - * */ - template <typename Functor> - size_t consume_all(Functor & f) - { - size_t element_count = 0; - while (consume_one(f)) - element_count += 1; - - return element_count; - } - - /// \copydoc boost::lockfree::queue::consume_all(Functor & rhs) - template <typename Functor> - size_t consume_all(Functor const & f) - { - size_t element_count = 0; - while (consume_one(f)) - element_count += 1; - - return element_count; - } - -private: -#ifndef BOOST_DOXYGEN_INVOKED - atomic<tagged_node_handle> head_; - static const int padding_size = BOOST_LOCKFREE_CACHELINE_BYTES - sizeof(tagged_node_handle); - char padding1[padding_size]; - atomic<tagged_node_handle> tail_; - char padding2[padding_size]; - - pool_t pool; -#endif -}; - -} /* namespace lockfree */ -} /* namespace boost */ - -#if defined(_MSC_VER) -#pragma warning(pop) -#endif - -#endif /* BOOST_LOCKFREE_FIFO_HPP_INCLUDED */ diff --git a/contrib/restricted/boost/boost/lockfree/spsc_queue.hpp b/contrib/restricted/boost/boost/lockfree/spsc_queue.hpp deleted file mode 100644 index c7f2953fea4..00000000000 --- a/contrib/restricted/boost/boost/lockfree/spsc_queue.hpp +++ /dev/null @@ -1,1002 +0,0 @@ -// lock-free single-producer/single-consumer ringbuffer -// this algorithm is implemented in various projects (linux kernel) -// -// Copyright (C) 2009-2013 Tim Blechmann -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_LOCKFREE_SPSC_QUEUE_HPP_INCLUDED -#define BOOST_LOCKFREE_SPSC_QUEUE_HPP_INCLUDED - -#include <algorithm> -#include <memory> - -#include <boost/aligned_storage.hpp> -#include <boost/assert.hpp> -#include <boost/static_assert.hpp> -#include <boost/utility.hpp> -#include <boost/next_prior.hpp> -#include <boost/utility/enable_if.hpp> -#include <boost/config.hpp> // for BOOST_LIKELY - -#include <boost/type_traits/has_trivial_destructor.hpp> -#include <boost/type_traits/is_convertible.hpp> - -#include <boost/lockfree/detail/atomic.hpp> -#include <boost/lockfree/detail/copy_payload.hpp> -#include <boost/lockfree/detail/parameter.hpp> -#include <boost/lockfree/detail/prefix.hpp> - -#include <boost/lockfree/lockfree_forward.hpp> - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost { -namespace lockfree { -namespace detail { - -typedef parameter::parameters<boost::parameter::optional<tag::capacity>, - boost::parameter::optional<tag::allocator> - > ringbuffer_signature; - -template <typename T> -class ringbuffer_base -{ -#ifndef BOOST_DOXYGEN_INVOKED -protected: - typedef std::size_t size_t; - static const int padding_size = BOOST_LOCKFREE_CACHELINE_BYTES - sizeof(size_t); - atomic<size_t> write_index_; - char padding1[padding_size]; /* force read_index and write_index to different cache lines */ - atomic<size_t> read_index_; - - BOOST_DELETED_FUNCTION(ringbuffer_base(ringbuffer_base const&)) - BOOST_DELETED_FUNCTION(ringbuffer_base& operator= (ringbuffer_base const&)) - -protected: - ringbuffer_base(void): - write_index_(0), read_index_(0) - {} - - static size_t next_index(size_t arg, size_t max_size) - { - size_t ret = arg + 1; - while (BOOST_UNLIKELY(ret >= max_size)) - ret -= max_size; - return ret; - } - - static size_t read_available(size_t write_index, size_t read_index, size_t max_size) - { - if (write_index >= read_index) - return write_index - read_index; - - const size_t ret = write_index + max_size - read_index; - return ret; - } - - static size_t write_available(size_t write_index, size_t read_index, size_t max_size) - { - size_t ret = read_index - write_index - 1; - if (write_index >= read_index) - ret += max_size; - return ret; - } - - size_t read_available(size_t max_size) const - { - size_t write_index = write_index_.load(memory_order_acquire); - const size_t read_index = read_index_.load(memory_order_relaxed); - return read_available(write_index, read_index, max_size); - } - - size_t write_available(size_t max_size) const - { - size_t write_index = write_index_.load(memory_order_relaxed); - const size_t read_index = read_index_.load(memory_order_acquire); - return write_available(write_index, read_index, max_size); - } - - bool push(T const & t, T * buffer, size_t max_size) - { - const size_t write_index = write_index_.load(memory_order_relaxed); // only written from push thread - const size_t next = next_index(write_index, max_size); - - if (next == read_index_.load(memory_order_acquire)) - return false; /* ringbuffer is full */ - - new (buffer + write_index) T(t); // copy-construct - - write_index_.store(next, memory_order_release); - - return true; - } - - size_t push(const T * input_buffer, size_t input_count, T * internal_buffer, size_t max_size) - { - return push(input_buffer, input_buffer + input_count, internal_buffer, max_size) - input_buffer; - } - - template <typename ConstIterator> - ConstIterator push(ConstIterator begin, ConstIterator end, T * internal_buffer, size_t max_size) - { - // FIXME: avoid std::distance - - const size_t write_index = write_index_.load(memory_order_relaxed); // only written from push thread - const size_t read_index = read_index_.load(memory_order_acquire); - const size_t avail = write_available(write_index, read_index, max_size); - - if (avail == 0) - return begin; - - size_t input_count = std::distance(begin, end); - input_count = (std::min)(input_count, avail); - - size_t new_write_index = write_index + input_count; - - const ConstIterator last = boost::next(begin, input_count); - - if (write_index + input_count > max_size) { - /* copy data in two sections */ - const size_t count0 = max_size - write_index; - const ConstIterator midpoint = boost::next(begin, count0); - - std::uninitialized_copy(begin, midpoint, internal_buffer + write_index); - std::uninitialized_copy(midpoint, last, internal_buffer); - new_write_index -= max_size; - } else { - std::uninitialized_copy(begin, last, internal_buffer + write_index); - - if (new_write_index == max_size) - new_write_index = 0; - } - - write_index_.store(new_write_index, memory_order_release); - return last; - } - - template <typename Functor> - bool consume_one(Functor & functor, T * buffer, size_t max_size) - { - const size_t write_index = write_index_.load(memory_order_acquire); - const size_t read_index = read_index_.load(memory_order_relaxed); // only written from pop thread - if ( empty(write_index, read_index) ) - return false; - - T & object_to_consume = buffer[read_index]; - functor( object_to_consume ); - object_to_consume.~T(); - - size_t next = next_index(read_index, max_size); - read_index_.store(next, memory_order_release); - return true; - } - - template <typename Functor> - bool consume_one(Functor const & functor, T * buffer, size_t max_size) - { - const size_t write_index = write_index_.load(memory_order_acquire); - const size_t read_index = read_index_.load(memory_order_relaxed); // only written from pop thread - if ( empty(write_index, read_index) ) - return false; - - T & object_to_consume = buffer[read_index]; - functor( object_to_consume ); - object_to_consume.~T(); - - size_t next = next_index(read_index, max_size); - read_index_.store(next, memory_order_release); - return true; - } - - template <typename Functor> - size_t consume_all (Functor const & functor, T * internal_buffer, size_t max_size) - { - const size_t write_index = write_index_.load(memory_order_acquire); - const size_t read_index = read_index_.load(memory_order_relaxed); // only written from pop thread - - const size_t avail = read_available(write_index, read_index, max_size); - - if (avail == 0) - return 0; - - const size_t output_count = avail; - - size_t new_read_index = read_index + output_count; - - if (read_index + output_count > max_size) { - /* copy data in two sections */ - const size_t count0 = max_size - read_index; - const size_t count1 = output_count - count0; - - run_functor_and_delete(internal_buffer + read_index, internal_buffer + max_size, functor); - run_functor_and_delete(internal_buffer, internal_buffer + count1, functor); - - new_read_index -= max_size; - } else { - run_functor_and_delete(internal_buffer + read_index, internal_buffer + read_index + output_count, functor); - - if (new_read_index == max_size) - new_read_index = 0; - } - - read_index_.store(new_read_index, memory_order_release); - return output_count; - } - - template <typename Functor> - size_t consume_all (Functor & functor, T * internal_buffer, size_t max_size) - { - const size_t write_index = write_index_.load(memory_order_acquire); - const size_t read_index = read_index_.load(memory_order_relaxed); // only written from pop thread - - const size_t avail = read_available(write_index, read_index, max_size); - - if (avail == 0) - return 0; - - const size_t output_count = avail; - - size_t new_read_index = read_index + output_count; - - if (read_index + output_count > max_size) { - /* copy data in two sections */ - const size_t count0 = max_size - read_index; - const size_t count1 = output_count - count0; - - run_functor_and_delete(internal_buffer + read_index, internal_buffer + max_size, functor); - run_functor_and_delete(internal_buffer, internal_buffer + count1, functor); - - new_read_index -= max_size; - } else { - run_functor_and_delete(internal_buffer + read_index, internal_buffer + read_index + output_count, functor); - - if (new_read_index == max_size) - new_read_index = 0; - } - - read_index_.store(new_read_index, memory_order_release); - return output_count; - } - - size_t pop (T * output_buffer, size_t output_count, T * internal_buffer, size_t max_size) - { - const size_t write_index = write_index_.load(memory_order_acquire); - const size_t read_index = read_index_.load(memory_order_relaxed); // only written from pop thread - - const size_t avail = read_available(write_index, read_index, max_size); - - if (avail == 0) - return 0; - - output_count = (std::min)(output_count, avail); - - size_t new_read_index = read_index + output_count; - - if (read_index + output_count > max_size) { - /* copy data in two sections */ - const size_t count0 = max_size - read_index; - const size_t count1 = output_count - count0; - - copy_and_delete(internal_buffer + read_index, internal_buffer + max_size, output_buffer); - copy_and_delete(internal_buffer, internal_buffer + count1, output_buffer + count0); - - new_read_index -= max_size; - } else { - copy_and_delete(internal_buffer + read_index, internal_buffer + read_index + output_count, output_buffer); - if (new_read_index == max_size) - new_read_index = 0; - } - - read_index_.store(new_read_index, memory_order_release); - return output_count; - } - - template <typename OutputIterator> - size_t pop_to_output_iterator (OutputIterator it, T * internal_buffer, size_t max_size) - { - const size_t write_index = write_index_.load(memory_order_acquire); - const size_t read_index = read_index_.load(memory_order_relaxed); // only written from pop thread - - const size_t avail = read_available(write_index, read_index, max_size); - if (avail == 0) - return 0; - - size_t new_read_index = read_index + avail; - - if (read_index + avail > max_size) { - /* copy data in two sections */ - const size_t count0 = max_size - read_index; - const size_t count1 = avail - count0; - - it = copy_and_delete(internal_buffer + read_index, internal_buffer + max_size, it); - copy_and_delete(internal_buffer, internal_buffer + count1, it); - - new_read_index -= max_size; - } else { - copy_and_delete(internal_buffer + read_index, internal_buffer + read_index + avail, it); - if (new_read_index == max_size) - new_read_index = 0; - } - - read_index_.store(new_read_index, memory_order_release); - return avail; - } - - const T& front(const T * internal_buffer) const - { - const size_t read_index = read_index_.load(memory_order_relaxed); // only written from pop thread - return *(internal_buffer + read_index); - } - - T& front(T * internal_buffer) - { - const size_t read_index = read_index_.load(memory_order_relaxed); // only written from pop thread - return *(internal_buffer + read_index); - } -#endif - - -public: - /** reset the ringbuffer - * - * \note Not thread-safe - * */ - void reset(void) - { - if ( !boost::has_trivial_destructor<T>::value ) { - // make sure to call all destructors! - - T dummy_element; - while (pop(dummy_element)) - {} - } else { - write_index_.store(0, memory_order_relaxed); - read_index_.store(0, memory_order_release); - } - } - - /** Check if the ringbuffer is empty - * - * \return true, if the ringbuffer is empty, false otherwise - * \note Due to the concurrent nature of the ringbuffer the result may be inaccurate. - * */ - bool empty(void) - { - return empty(write_index_.load(memory_order_relaxed), read_index_.load(memory_order_relaxed)); - } - - /** - * \return true, if implementation is lock-free. - * - * */ - bool is_lock_free(void) const - { - return write_index_.is_lock_free() && read_index_.is_lock_free(); - } - -private: - bool empty(size_t write_index, size_t read_index) - { - return write_index == read_index; - } - - template< class OutputIterator > - OutputIterator copy_and_delete( T * first, T * last, OutputIterator out ) - { - if (boost::has_trivial_destructor<T>::value) { - return std::copy(first, last, out); // will use memcpy if possible - } else { - for (; first != last; ++first, ++out) { - *out = *first; - first->~T(); - } - return out; - } - } - - template< class Functor > - void run_functor_and_delete( T * first, T * last, Functor & functor ) - { - for (; first != last; ++first) { - functor(*first); - first->~T(); - } - } - - template< class Functor > - void run_functor_and_delete( T * first, T * last, Functor const & functor ) - { - for (; first != last; ++first) { - functor(*first); - first->~T(); - } - } -}; - -template <typename T, std::size_t MaxSize> -class compile_time_sized_ringbuffer: - public ringbuffer_base<T> -{ - typedef std::size_t size_type; - static const std::size_t max_size = MaxSize + 1; - - typedef typename boost::aligned_storage<max_size * sizeof(T), - boost::alignment_of<T>::value - >::type storage_type; - - storage_type storage_; - - T * data() - { - return static_cast<T*>(storage_.address()); - } - - const T * data() const - { - return static_cast<const T*>(storage_.address()); - } - -protected: - size_type max_number_of_elements() const - { - return max_size; - } - -public: - bool push(T const & t) - { - return ringbuffer_base<T>::push(t, data(), max_size); - } - - template <typename Functor> - bool consume_one(Functor & f) - { - return ringbuffer_base<T>::consume_one(f, data(), max_size); - } - - template <typename Functor> - bool consume_one(Functor const & f) - { - return ringbuffer_base<T>::consume_one(f, data(), max_size); - } - - template <typename Functor> - size_type consume_all(Functor & f) - { - return ringbuffer_base<T>::consume_all(f, data(), max_size); - } - - template <typename Functor> - size_type consume_all(Functor const & f) - { - return ringbuffer_base<T>::consume_all(f, data(), max_size); - } - - size_type push(T const * t, size_type size) - { - return ringbuffer_base<T>::push(t, size, data(), max_size); - } - - template <size_type size> - size_type push(T const (&t)[size]) - { - return push(t, size); - } - - template <typename ConstIterator> - ConstIterator push(ConstIterator begin, ConstIterator end) - { - return ringbuffer_base<T>::push(begin, end, data(), max_size); - } - - size_type pop(T * ret, size_type size) - { - return ringbuffer_base<T>::pop(ret, size, data(), max_size); - } - - template <typename OutputIterator> - size_type pop_to_output_iterator(OutputIterator it) - { - return ringbuffer_base<T>::pop_to_output_iterator(it, data(), max_size); - } - - const T& front(void) const - { - return ringbuffer_base<T>::front(data()); - } - - T& front(void) - { - return ringbuffer_base<T>::front(data()); - } -}; - -template <typename T, typename Alloc> -class runtime_sized_ringbuffer: - public ringbuffer_base<T>, - private Alloc -{ - typedef std::size_t size_type; - size_type max_elements_; - typedef typename Alloc::pointer pointer; - pointer array_; - -protected: - size_type max_number_of_elements() const - { - return max_elements_; - } - -public: - explicit runtime_sized_ringbuffer(size_type max_elements): - max_elements_(max_elements + 1) - { - array_ = Alloc::allocate(max_elements_); - } - - template <typename U> - runtime_sized_ringbuffer(typename Alloc::template rebind<U>::other const & alloc, size_type max_elements): - Alloc(alloc), max_elements_(max_elements + 1) - { - array_ = Alloc::allocate(max_elements_); - } - - runtime_sized_ringbuffer(Alloc const & alloc, size_type max_elements): - Alloc(alloc), max_elements_(max_elements + 1) - { - array_ = Alloc::allocate(max_elements_); - } - - ~runtime_sized_ringbuffer(void) - { - // destroy all remaining items - T out; - while (pop(&out, 1)) {} - - Alloc::deallocate(array_, max_elements_); - } - - bool push(T const & t) - { - return ringbuffer_base<T>::push(t, &*array_, max_elements_); - } - - template <typename Functor> - bool consume_one(Functor & f) - { - return ringbuffer_base<T>::consume_one(f, &*array_, max_elements_); - } - - template <typename Functor> - bool consume_one(Functor const & f) - { - return ringbuffer_base<T>::consume_one(f, &*array_, max_elements_); - } - - template <typename Functor> - size_type consume_all(Functor & f) - { - return ringbuffer_base<T>::consume_all(f, &*array_, max_elements_); - } - - template <typename Functor> - size_type consume_all(Functor const & f) - { - return ringbuffer_base<T>::consume_all(f, &*array_, max_elements_); - } - - size_type push(T const * t, size_type size) - { - return ringbuffer_base<T>::push(t, size, &*array_, max_elements_); - } - - template <size_type size> - size_type push(T const (&t)[size]) - { - return push(t, size); - } - - template <typename ConstIterator> - ConstIterator push(ConstIterator begin, ConstIterator end) - { - return ringbuffer_base<T>::push(begin, end, &*array_, max_elements_); - } - - size_type pop(T * ret, size_type size) - { - return ringbuffer_base<T>::pop(ret, size, &*array_, max_elements_); - } - - template <typename OutputIterator> - size_type pop_to_output_iterator(OutputIterator it) - { - return ringbuffer_base<T>::pop_to_output_iterator(it, &*array_, max_elements_); - } - - const T& front(void) const - { - return ringbuffer_base<T>::front(&*array_); - } - - T& front(void) - { - return ringbuffer_base<T>::front(&*array_); - } -}; - -#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES -template <typename T, typename A0, typename A1> -#else -template <typename T, typename ...Options> -#endif -struct make_ringbuffer -{ -#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES - typedef typename ringbuffer_signature::bind<A0, A1>::type bound_args; -#else - typedef typename ringbuffer_signature::bind<Options...>::type bound_args; -#endif - - typedef extract_capacity<bound_args> extract_capacity_t; - - static const bool runtime_sized = !extract_capacity_t::has_capacity; - static const size_t capacity = extract_capacity_t::capacity; - - typedef extract_allocator<bound_args, T> extract_allocator_t; - typedef typename extract_allocator_t::type allocator; - - // allocator argument is only sane, for run-time sized ringbuffers - BOOST_STATIC_ASSERT((mpl::if_<mpl::bool_<!runtime_sized>, - mpl::bool_<!extract_allocator_t::has_allocator>, - mpl::true_ - >::type::value)); - - typedef typename mpl::if_c<runtime_sized, - runtime_sized_ringbuffer<T, allocator>, - compile_time_sized_ringbuffer<T, capacity> - >::type ringbuffer_type; -}; - - -} /* namespace detail */ - - -/** The spsc_queue class provides a single-writer/single-reader fifo queue, pushing and popping is wait-free. - * - * \b Policies: - * - \c boost::lockfree::capacity<>, optional <br> - * If this template argument is passed to the options, the size of the ringbuffer is set at compile-time. - * - * - \c boost::lockfree::allocator<>, defaults to \c boost::lockfree::allocator<std::allocator<T>> <br> - * Specifies the allocator that is used to allocate the ringbuffer. This option is only valid, if the ringbuffer is configured - * to be sized at run-time - * - * \b Requirements: - * - T must have a default constructor - * - T must be copyable - * */ -#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES -template <typename T, class A0, class A1> -#else -template <typename T, typename ...Options> -#endif -class spsc_queue: -#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES - public detail::make_ringbuffer<T, A0, A1>::ringbuffer_type -#else - public detail::make_ringbuffer<T, Options...>::ringbuffer_type -#endif -{ -private: - -#ifndef BOOST_DOXYGEN_INVOKED - -#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES - typedef typename detail::make_ringbuffer<T, A0, A1>::ringbuffer_type base_type; - static const bool runtime_sized = detail::make_ringbuffer<T, A0, A1>::runtime_sized; - typedef typename detail::make_ringbuffer<T, A0, A1>::allocator allocator_arg; -#else - typedef typename detail::make_ringbuffer<T, Options...>::ringbuffer_type base_type; - static const bool runtime_sized = detail::make_ringbuffer<T, Options...>::runtime_sized; - typedef typename detail::make_ringbuffer<T, Options...>::allocator allocator_arg; -#endif - - - struct implementation_defined - { - typedef allocator_arg allocator; - typedef std::size_t size_type; - }; -#endif - -public: - typedef T value_type; - typedef typename implementation_defined::allocator allocator; - typedef typename implementation_defined::size_type size_type; - - /** Constructs a spsc_queue - * - * \pre spsc_queue must be configured to be sized at compile-time - */ - // @{ - spsc_queue(void) - { - BOOST_ASSERT(!runtime_sized); - } - - template <typename U> - explicit spsc_queue(typename allocator::template rebind<U>::other const &) - { - // just for API compatibility: we don't actually need an allocator - BOOST_STATIC_ASSERT(!runtime_sized); - } - - explicit spsc_queue(allocator const &) - { - // just for API compatibility: we don't actually need an allocator - BOOST_ASSERT(!runtime_sized); - } - // @} - - - /** Constructs a spsc_queue for element_count elements - * - * \pre spsc_queue must be configured to be sized at run-time - */ - // @{ - explicit spsc_queue(size_type element_count): - base_type(element_count) - { - BOOST_ASSERT(runtime_sized); - } - - template <typename U> - spsc_queue(size_type element_count, typename allocator::template rebind<U>::other const & alloc): - base_type(alloc, element_count) - { - BOOST_STATIC_ASSERT(runtime_sized); - } - - spsc_queue(size_type element_count, allocator_arg const & alloc): - base_type(alloc, element_count) - { - BOOST_ASSERT(runtime_sized); - } - // @} - - /** Pushes object t to the ringbuffer. - * - * \pre only one thread is allowed to push data to the spsc_queue - * \post object will be pushed to the spsc_queue, unless it is full. - * \return true, if the push operation is successful. - * - * \note Thread-safe and wait-free - * */ - bool push(T const & t) - { - return base_type::push(t); - } - - /** Pops one object from ringbuffer. - * - * \pre only one thread is allowed to pop data to the spsc_queue - * \post if ringbuffer is not empty, object will be discarded. - * \return true, if the pop operation is successful, false if ringbuffer was empty. - * - * \note Thread-safe and wait-free - */ - bool pop () - { - detail::consume_noop consume_functor; - return consume_one( consume_functor ); - } - - /** Pops one object from ringbuffer. - * - * \pre only one thread is allowed to pop data to the spsc_queue - * \post if ringbuffer is not empty, object will be copied to ret. - * \return true, if the pop operation is successful, false if ringbuffer was empty. - * - * \note Thread-safe and wait-free - */ - template <typename U> - typename boost::enable_if<typename is_convertible<T, U>::type, bool>::type - pop (U & ret) - { - detail::consume_via_copy<U> consume_functor(ret); - return consume_one( consume_functor ); - } - - /** Pushes as many objects from the array t as there is space. - * - * \pre only one thread is allowed to push data to the spsc_queue - * \return number of pushed items - * - * \note Thread-safe and wait-free - */ - size_type push(T const * t, size_type size) - { - return base_type::push(t, size); - } - - /** Pushes as many objects from the array t as there is space available. - * - * \pre only one thread is allowed to push data to the spsc_queue - * \return number of pushed items - * - * \note Thread-safe and wait-free - */ - template <size_type size> - size_type push(T const (&t)[size]) - { - return push(t, size); - } - - /** Pushes as many objects from the range [begin, end) as there is space . - * - * \pre only one thread is allowed to push data to the spsc_queue - * \return iterator to the first element, which has not been pushed - * - * \note Thread-safe and wait-free - */ - template <typename ConstIterator> - ConstIterator push(ConstIterator begin, ConstIterator end) - { - return base_type::push(begin, end); - } - - /** Pops a maximum of size objects from ringbuffer. - * - * \pre only one thread is allowed to pop data to the spsc_queue - * \return number of popped items - * - * \note Thread-safe and wait-free - * */ - size_type pop(T * ret, size_type size) - { - return base_type::pop(ret, size); - } - - /** Pops a maximum of size objects from spsc_queue. - * - * \pre only one thread is allowed to pop data to the spsc_queue - * \return number of popped items - * - * \note Thread-safe and wait-free - * */ - template <size_type size> - size_type pop(T (&ret)[size]) - { - return pop(ret, size); - } - - /** Pops objects to the output iterator it - * - * \pre only one thread is allowed to pop data to the spsc_queue - * \return number of popped items - * - * \note Thread-safe and wait-free - * */ - template <typename OutputIterator> - typename boost::disable_if<typename is_convertible<T, OutputIterator>::type, size_type>::type - pop(OutputIterator it) - { - return base_type::pop_to_output_iterator(it); - } - - /** consumes one element via a functor - * - * pops one element from the queue and applies the functor on this object - * - * \returns true, if one element was consumed - * - * \note Thread-safe and non-blocking, if functor is thread-safe and non-blocking - * */ - template <typename Functor> - bool consume_one(Functor & f) - { - return base_type::consume_one(f); - } - - /// \copydoc boost::lockfree::spsc_queue::consume_one(Functor & rhs) - template <typename Functor> - bool consume_one(Functor const & f) - { - return base_type::consume_one(f); - } - - /** consumes all elements via a functor - * - * sequentially pops all elements from the queue and applies the functor on each object - * - * \returns number of elements that are consumed - * - * \note Thread-safe and non-blocking, if functor is thread-safe and non-blocking - * */ - template <typename Functor> - size_type consume_all(Functor & f) - { - return base_type::consume_all(f); - } - - /// \copydoc boost::lockfree::spsc_queue::consume_all(Functor & rhs) - template <typename Functor> - size_type consume_all(Functor const & f) - { - return base_type::consume_all(f); - } - - /** get number of elements that are available for read - * - * \return number of available elements that can be popped from the spsc_queue - * - * \note Thread-safe and wait-free, should only be called from the consumer thread - * */ - size_type read_available() const - { - return base_type::read_available(base_type::max_number_of_elements()); - } - - /** get write space to write elements - * - * \return number of elements that can be pushed to the spsc_queue - * - * \note Thread-safe and wait-free, should only be called from the producer thread - * */ - size_type write_available() const - { - return base_type::write_available(base_type::max_number_of_elements()); - } - - /** get reference to element in the front of the queue - * - * Availability of front element can be checked using read_available(). - * - * \pre only a consuming thread is allowed to check front element - * \pre read_available() > 0. If ringbuffer is empty, it's undefined behaviour to invoke this method. - * \return reference to the first element in the queue - * - * \note Thread-safe and wait-free - */ - const T& front() const - { - BOOST_ASSERT(read_available() > 0); - return base_type::front(); - } - - /// \copydoc boost::lockfree::spsc_queue::front() const - T& front() - { - BOOST_ASSERT(read_available() > 0); - return base_type::front(); - } - - /** reset the ringbuffer - * - * \note Not thread-safe - * */ - void reset(void) - { - if ( !boost::has_trivial_destructor<T>::value ) { - // make sure to call all destructors! - - T dummy_element; - while (pop(dummy_element)) - {} - } else { - base_type::write_index_.store(0, memory_order_relaxed); - base_type::read_index_.store(0, memory_order_release); - } - } -}; - -} /* namespace lockfree */ -} /* namespace boost */ - - -#endif /* BOOST_LOCKFREE_SPSC_QUEUE_HPP_INCLUDED */ diff --git a/contrib/restricted/boost/boost/lockfree/stack.hpp b/contrib/restricted/boost/boost/lockfree/stack.hpp deleted file mode 100644 index 65f46b710df..00000000000 --- a/contrib/restricted/boost/boost/lockfree/stack.hpp +++ /dev/null @@ -1,796 +0,0 @@ -// Copyright (C) 2008-2013 Tim Blechmann -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_LOCKFREE_STACK_HPP_INCLUDED -#define BOOST_LOCKFREE_STACK_HPP_INCLUDED - -#include <boost/assert.hpp> -#include <boost/checked_delete.hpp> -#include <boost/core/no_exceptions_support.hpp> -#include <boost/integer_traits.hpp> -#include <boost/static_assert.hpp> -#include <boost/tuple/tuple.hpp> -#include <boost/type_traits/is_copy_constructible.hpp> - -#include <boost/lockfree/detail/atomic.hpp> -#include <boost/lockfree/detail/copy_payload.hpp> -#include <boost/lockfree/detail/freelist.hpp> -#include <boost/lockfree/detail/parameter.hpp> -#include <boost/lockfree/detail/tagged_ptr.hpp> - -#include <boost/lockfree/lockfree_forward.hpp> - -#ifdef BOOST_HAS_PRAGMA_ONCE -#pragma once -#endif - -namespace boost { -namespace lockfree { -namespace detail { - -typedef parameter::parameters<boost::parameter::optional<tag::allocator>, - boost::parameter::optional<tag::capacity> - > stack_signature; - -} - -/** The stack class provides a multi-writer/multi-reader stack, pushing and popping is lock-free, - * construction/destruction has to be synchronized. It uses a freelist for memory management, - * freed nodes are pushed to the freelist and not returned to the OS before the stack is destroyed. - * - * \b Policies: - * - * - \c boost::lockfree::fixed_sized<>, defaults to \c boost::lockfree::fixed_sized<false> <br> - * Can be used to completely disable dynamic memory allocations during push in order to ensure lockfree behavior.<br> - * If the data structure is configured as fixed-sized, the internal nodes are stored inside an array and they are addressed - * by array indexing. This limits the possible size of the stack to the number of elements that can be addressed by the index - * type (usually 2**16-2), but on platforms that lack double-width compare-and-exchange instructions, this is the best way - * to achieve lock-freedom. - * - * - \c boost::lockfree::capacity<>, optional <br> - * If this template argument is passed to the options, the size of the stack is set at compile-time. <br> - * It this option implies \c fixed_sized<true> - * - * - \c boost::lockfree::allocator<>, defaults to \c boost::lockfree::allocator<std::allocator<void>> <br> - * Specifies the allocator that is used for the internal freelist - * - * \b Requirements: - * - T must have a copy constructor - * */ -#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES -template <typename T, class A0, class A1, class A2> -#else -template <typename T, typename ...Options> -#endif -class stack -{ -private: -#ifndef BOOST_DOXYGEN_INVOKED - BOOST_STATIC_ASSERT(boost::is_copy_constructible<T>::value); - -#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES - typedef typename detail::stack_signature::bind<A0, A1, A2>::type bound_args; -#else - typedef typename detail::stack_signature::bind<Options...>::type bound_args; -#endif - - static const bool has_capacity = detail::extract_capacity<bound_args>::has_capacity; - static const size_t capacity = detail::extract_capacity<bound_args>::capacity; - static const bool fixed_sized = detail::extract_fixed_sized<bound_args>::value; - static const bool node_based = !(has_capacity || fixed_sized); - static const bool compile_time_sized = has_capacity; - - struct node - { - node(T const & val): - v(val) - {} - - typedef typename detail::select_tagged_handle<node, node_based>::handle_type handle_t; - handle_t next; - const T v; - }; - - typedef typename detail::extract_allocator<bound_args, node>::type node_allocator; - typedef typename detail::select_freelist<node, node_allocator, compile_time_sized, fixed_sized, capacity>::type pool_t; - typedef typename pool_t::tagged_node_handle tagged_node_handle; - - // check compile-time capacity - BOOST_STATIC_ASSERT((mpl::if_c<has_capacity, - mpl::bool_<capacity - 1 < boost::integer_traits<boost::uint16_t>::const_max>, - mpl::true_ - >::type::value)); - - struct implementation_defined - { - typedef node_allocator allocator; - typedef std::size_t size_type; - }; - -#endif - - BOOST_DELETED_FUNCTION(stack(stack const&)) - BOOST_DELETED_FUNCTION(stack& operator= (stack const&)) - -public: - typedef T value_type; - typedef typename implementation_defined::allocator allocator; - typedef typename implementation_defined::size_type size_type; - - /** - * \return true, if implementation is lock-free. - * - * \warning It only checks, if the top stack node and the freelist can be modified in a lock-free manner. - * On most platforms, the whole implementation is lock-free, if this is true. Using c++0x-style atomics, - * there is no possibility to provide a completely accurate implementation, because one would need to test - * every internal node, which is impossible if further nodes will be allocated from the operating system. - * - * */ - bool is_lock_free (void) const - { - return tos.is_lock_free() && pool.is_lock_free(); - } - - //! Construct stack - // @{ - stack(void): - pool(node_allocator(), capacity) - { - BOOST_ASSERT(has_capacity); - initialize(); - } - - template <typename U> - explicit stack(typename node_allocator::template rebind<U>::other const & alloc): - pool(alloc, capacity) - { - BOOST_STATIC_ASSERT(has_capacity); - initialize(); - } - - explicit stack(allocator const & alloc): - pool(alloc, capacity) - { - BOOST_ASSERT(has_capacity); - initialize(); - } - // @} - - //! Construct stack, allocate n nodes for the freelist. - // @{ - explicit stack(size_type n): - pool(node_allocator(), n) - { - BOOST_ASSERT(!has_capacity); - initialize(); - } - - template <typename U> - stack(size_type n, typename node_allocator::template rebind<U>::other const & alloc): - pool(alloc, n) - { - BOOST_STATIC_ASSERT(!has_capacity); - initialize(); - } - // @} - - /** Allocate n nodes for freelist - * - * \pre only valid if no capacity<> argument given - * \note thread-safe, may block if memory allocator blocks - * - * */ - void reserve(size_type n) - { - BOOST_STATIC_ASSERT(!has_capacity); - pool.template reserve<true>(n); - } - - /** Allocate n nodes for freelist - * - * \pre only valid if no capacity<> argument given - * \note not thread-safe, may block if memory allocator blocks - * - * */ - void reserve_unsafe(size_type n) - { - BOOST_STATIC_ASSERT(!has_capacity); - pool.template reserve<false>(n); - } - - /** Destroys stack, free all nodes from freelist. - * - * \note not thread-safe - * - * */ - ~stack(void) - { - T dummy; - while(unsynchronized_pop(dummy)) - {} - } - -private: -#ifndef BOOST_DOXYGEN_INVOKED - void initialize(void) - { - tos.store(tagged_node_handle(pool.null_handle(), 0)); - } - - void link_nodes_atomic(node * new_top_node, node * end_node) - { - tagged_node_handle old_tos = tos.load(detail::memory_order_relaxed); - for (;;) { - tagged_node_handle new_tos (pool.get_handle(new_top_node), old_tos.get_tag()); - end_node->next = pool.get_handle(old_tos); - - if (tos.compare_exchange_weak(old_tos, new_tos)) - break; - } - } - - void link_nodes_unsafe(node * new_top_node, node * end_node) - { - tagged_node_handle old_tos = tos.load(detail::memory_order_relaxed); - - tagged_node_handle new_tos (pool.get_handle(new_top_node), old_tos.get_tag()); - end_node->next = pool.get_pointer(old_tos); - - tos.store(new_tos, memory_order_relaxed); - } - - template <bool Threadsafe, bool Bounded, typename ConstIterator> - tuple<node*, node*> prepare_node_list(ConstIterator begin, ConstIterator end, ConstIterator & ret) - { - ConstIterator it = begin; - node * end_node = pool.template construct<Threadsafe, Bounded>(*it++); - if (end_node == NULL) { - ret = begin; - return make_tuple<node*, node*>(NULL, NULL); - } - - node * new_top_node = end_node; - end_node->next = NULL; - - BOOST_TRY { - /* link nodes */ - for (; it != end; ++it) { - node * newnode = pool.template construct<Threadsafe, Bounded>(*it); - if (newnode == NULL) - break; - newnode->next = new_top_node; - new_top_node = newnode; - } - } BOOST_CATCH (...) { - for (node * current_node = new_top_node; current_node != NULL;) { - node * next = current_node->next; - pool.template destruct<Threadsafe>(current_node); - current_node = next; - } - BOOST_RETHROW; - } - BOOST_CATCH_END - - ret = it; - return make_tuple(new_top_node, end_node); - } -#endif - -public: - /** Pushes object t to the stack. - * - * \post object will be pushed to the stack, if internal node can be allocated - * \returns true, if the push operation is successful. - * - * \note Thread-safe. If internal memory pool is exhausted and the memory pool is not fixed-sized, a new node will be allocated - * from the OS. This may not be lock-free. - * \throws if memory allocator throws - * */ - bool push(T const & v) - { - return do_push<false>(v); - } - - /** Pushes object t to the stack. - * - * \post object will be pushed to the stack, if internal node can be allocated - * \returns true, if the push operation is successful. - * - * \note Thread-safe and non-blocking. If internal memory pool is exhausted, the push operation will fail - * */ - bool bounded_push(T const & v) - { - return do_push<true>(v); - } - -#ifndef BOOST_DOXYGEN_INVOKED -private: - template <bool Bounded> - bool do_push(T const & v) - { - node * newnode = pool.template construct<true, Bounded>(v); - if (newnode == 0) - return false; - - link_nodes_atomic(newnode, newnode); - return true; - } - - template <bool Bounded, typename ConstIterator> - ConstIterator do_push(ConstIterator begin, ConstIterator end) - { - node * new_top_node; - node * end_node; - ConstIterator ret; - - tie(new_top_node, end_node) = prepare_node_list<true, Bounded>(begin, end, ret); - if (new_top_node) - link_nodes_atomic(new_top_node, end_node); - - return ret; - } - -public: -#endif - - /** Pushes as many objects from the range [begin, end) as freelist node can be allocated. - * - * \return iterator to the first element, which has not been pushed - * - * \note Operation is applied atomically - * \note Thread-safe. If internal memory pool is exhausted and the memory pool is not fixed-sized, a new node will be allocated - * from the OS. This may not be lock-free. - * \throws if memory allocator throws - */ - template <typename ConstIterator> - ConstIterator push(ConstIterator begin, ConstIterator end) - { - return do_push<false, ConstIterator>(begin, end); - } - - /** Pushes as many objects from the range [begin, end) as freelist node can be allocated. - * - * \return iterator to the first element, which has not been pushed - * - * \note Operation is applied atomically - * \note Thread-safe and non-blocking. If internal memory pool is exhausted, the push operation will fail - * \throws if memory allocator throws - */ - template <typename ConstIterator> - ConstIterator bounded_push(ConstIterator begin, ConstIterator end) - { - return do_push<true, ConstIterator>(begin, end); - } - - - /** Pushes object t to the stack. - * - * \post object will be pushed to the stack, if internal node can be allocated - * \returns true, if the push operation is successful. - * - * \note Not thread-safe. If internal memory pool is exhausted and the memory pool is not fixed-sized, a new node will be allocated - * from the OS. This may not be lock-free. - * \throws if memory allocator throws - * */ - bool unsynchronized_push(T const & v) - { - node * newnode = pool.template construct<false, false>(v); - if (newnode == 0) - return false; - - link_nodes_unsafe(newnode, newnode); - return true; - } - - /** Pushes as many objects from the range [begin, end) as freelist node can be allocated. - * - * \return iterator to the first element, which has not been pushed - * - * \note Not thread-safe. If internal memory pool is exhausted and the memory pool is not fixed-sized, a new node will be allocated - * from the OS. This may not be lock-free. - * \throws if memory allocator throws - */ - template <typename ConstIterator> - ConstIterator unsynchronized_push(ConstIterator begin, ConstIterator end) - { - node * new_top_node; - node * end_node; - ConstIterator ret; - - tie(new_top_node, end_node) = prepare_node_list<false, false>(begin, end, ret); - if (new_top_node) - link_nodes_unsafe(new_top_node, end_node); - - return ret; - } - - - /** Pops object from stack. - * - * \post if pop operation is successful, object will be copied to ret. - * \returns true, if the pop operation is successful, false if stack was empty. - * - * \note Thread-safe and non-blocking - * - * */ - bool pop(T & ret) - { - return pop<T>(ret); - } - - /** Pops object from stack. - * - * \pre type T must be convertible to U - * \post if pop operation is successful, object will be copied to ret. - * \returns true, if the pop operation is successful, false if stack was empty. - * - * \note Thread-safe and non-blocking - * - * */ - template <typename U> - bool pop(U & ret) - { - BOOST_STATIC_ASSERT((boost::is_convertible<T, U>::value)); - detail::consume_via_copy<U> consumer(ret); - - return consume_one(consumer); - } - - - /** Pops object from stack. - * - * \post if pop operation is successful, object will be copied to ret. - * \returns true, if the pop operation is successful, false if stack was empty. - * - * \note Not thread-safe, but non-blocking - * - * */ - bool unsynchronized_pop(T & ret) - { - return unsynchronized_pop<T>(ret); - } - - /** Pops object from stack. - * - * \pre type T must be convertible to U - * \post if pop operation is successful, object will be copied to ret. - * \returns true, if the pop operation is successful, false if stack was empty. - * - * \note Not thread-safe, but non-blocking - * - * */ - template <typename U> - bool unsynchronized_pop(U & ret) - { - BOOST_STATIC_ASSERT((boost::is_convertible<T, U>::value)); - tagged_node_handle old_tos = tos.load(detail::memory_order_relaxed); - node * old_tos_pointer = pool.get_pointer(old_tos); - - if (!pool.get_pointer(old_tos)) - return false; - - node * new_tos_ptr = pool.get_pointer(old_tos_pointer->next); - tagged_node_handle new_tos(pool.get_handle(new_tos_ptr), old_tos.get_next_tag()); - - tos.store(new_tos, memory_order_relaxed); - detail::copy_payload(old_tos_pointer->v, ret); - pool.template destruct<false>(old_tos); - return true; - } - - /** consumes one element via a functor - * - * pops one element from the stack and applies the functor on this object - * - * \returns true, if one element was consumed - * - * \note Thread-safe and non-blocking, if functor is thread-safe and non-blocking - * */ - template <typename Functor> - bool consume_one(Functor & f) - { - tagged_node_handle old_tos = tos.load(detail::memory_order_consume); - - for (;;) { - node * old_tos_pointer = pool.get_pointer(old_tos); - if (!old_tos_pointer) - return false; - - tagged_node_handle new_tos(old_tos_pointer->next, old_tos.get_next_tag()); - - if (tos.compare_exchange_weak(old_tos, new_tos)) { - f(old_tos_pointer->v); - pool.template destruct<true>(old_tos); - return true; - } - } - } - - /// \copydoc boost::lockfree::stack::consume_one(Functor & rhs) - template <typename Functor> - bool consume_one(Functor const & f) - { - tagged_node_handle old_tos = tos.load(detail::memory_order_consume); - - for (;;) { - node * old_tos_pointer = pool.get_pointer(old_tos); - if (!old_tos_pointer) - return false; - - tagged_node_handle new_tos(old_tos_pointer->next, old_tos.get_next_tag()); - - if (tos.compare_exchange_weak(old_tos, new_tos)) { - f(old_tos_pointer->v); - pool.template destruct<true>(old_tos); - return true; - } - } - } - - /** consumes all elements via a functor - * - * sequentially pops all elements from the stack and applies the functor on each object - * - * \returns number of elements that are consumed - * - * \note Thread-safe and non-blocking, if functor is thread-safe and non-blocking - * */ - template <typename Functor> - size_t consume_all(Functor & f) - { - size_t element_count = 0; - while (consume_one(f)) - element_count += 1; - - return element_count; - } - - /// \copydoc boost::lockfree::stack::consume_all(Functor & rhs) - template <typename Functor> - size_t consume_all(Functor const & f) - { - size_t element_count = 0; - while (consume_one(f)) - element_count += 1; - - return element_count; - } - - /** consumes all elements via a functor - * - * atomically pops all elements from the stack and applies the functor on each object - * - * \returns number of elements that are consumed - * - * \note Thread-safe and non-blocking, if functor is thread-safe and non-blocking - * */ - template <typename Functor> - size_t consume_all_atomic(Functor & f) - { - size_t element_count = 0; - tagged_node_handle old_tos = tos.load(detail::memory_order_consume); - - for (;;) { - node * old_tos_pointer = pool.get_pointer(old_tos); - if (!old_tos_pointer) - return 0; - - tagged_node_handle new_tos(pool.null_handle(), old_tos.get_next_tag()); - - if (tos.compare_exchange_weak(old_tos, new_tos)) - break; - } - - tagged_node_handle nodes_to_consume = old_tos; - - for(;;) { - node * node_pointer = pool.get_pointer(nodes_to_consume); - f(node_pointer->v); - element_count += 1; - - node * next_node = pool.get_pointer(node_pointer->next); - - if (!next_node) { - pool.template destruct<true>(nodes_to_consume); - break; - } - - tagged_node_handle next(pool.get_handle(next_node), nodes_to_consume.get_next_tag()); - pool.template destruct<true>(nodes_to_consume); - nodes_to_consume = next; - } - - return element_count; - } - - /// \copydoc boost::lockfree::stack::consume_all_atomic(Functor & rhs) - template <typename Functor> - size_t consume_all_atomic(Functor const & f) - { - size_t element_count = 0; - tagged_node_handle old_tos = tos.load(detail::memory_order_consume); - - for (;;) { - node * old_tos_pointer = pool.get_pointer(old_tos); - if (!old_tos_pointer) - return 0; - - tagged_node_handle new_tos(pool.null_handle(), old_tos.get_next_tag()); - - if (tos.compare_exchange_weak(old_tos, new_tos)) - break; - } - - tagged_node_handle nodes_to_consume = old_tos; - - for(;;) { - node * node_pointer = pool.get_pointer(nodes_to_consume); - f(node_pointer->v); - element_count += 1; - - node * next_node = pool.get_pointer(node_pointer->next); - - if (!next_node) { - pool.template destruct<true>(nodes_to_consume); - break; - } - - tagged_node_handle next(pool.get_handle(next_node), nodes_to_consume.get_next_tag()); - pool.template destruct<true>(nodes_to_consume); - nodes_to_consume = next; - } - - return element_count; - } - - /** consumes all elements via a functor - * - * atomically pops all elements from the stack and applies the functor on each object in reversed order - * - * \returns number of elements that are consumed - * - * \note Thread-safe and non-blocking, if functor is thread-safe and non-blocking - * */ - template <typename Functor> - size_t consume_all_atomic_reversed(Functor & f) - { - size_t element_count = 0; - tagged_node_handle old_tos = tos.load(detail::memory_order_consume); - - for (;;) { - node * old_tos_pointer = pool.get_pointer(old_tos); - if (!old_tos_pointer) - return 0; - - tagged_node_handle new_tos(pool.null_handle(), old_tos.get_next_tag()); - - if (tos.compare_exchange_weak(old_tos, new_tos)) - break; - } - - tagged_node_handle nodes_to_consume = old_tos; - - node * last_node_pointer = NULL; - tagged_node_handle nodes_in_reversed_order; - for(;;) { - node * node_pointer = pool.get_pointer(nodes_to_consume); - node * next_node = pool.get_pointer(node_pointer->next); - - node_pointer->next = pool.get_handle(last_node_pointer); - last_node_pointer = node_pointer; - - if (!next_node) { - nodes_in_reversed_order = nodes_to_consume; - break; - } - - tagged_node_handle next(pool.get_handle(next_node), nodes_to_consume.get_next_tag()); - nodes_to_consume = next; - } - - for(;;) { - node * node_pointer = pool.get_pointer(nodes_in_reversed_order); - f(node_pointer->v); - element_count += 1; - - node * next_node = pool.get_pointer(node_pointer->next); - - if (!next_node) { - pool.template destruct<true>(nodes_in_reversed_order); - break; - } - - tagged_node_handle next(pool.get_handle(next_node), nodes_in_reversed_order.get_next_tag()); - pool.template destruct<true>(nodes_in_reversed_order); - nodes_in_reversed_order = next; - } - - return element_count; - } - - /// \copydoc boost::lockfree::stack::consume_all_atomic_reversed(Functor & rhs) - template <typename Functor> - size_t consume_all_atomic_reversed(Functor const & f) - { - size_t element_count = 0; - tagged_node_handle old_tos = tos.load(detail::memory_order_consume); - - for (;;) { - node * old_tos_pointer = pool.get_pointer(old_tos); - if (!old_tos_pointer) - return 0; - - tagged_node_handle new_tos(pool.null_handle(), old_tos.get_next_tag()); - - if (tos.compare_exchange_weak(old_tos, new_tos)) - break; - } - - tagged_node_handle nodes_to_consume = old_tos; - - node * last_node_pointer = NULL; - tagged_node_handle nodes_in_reversed_order; - for(;;) { - node * node_pointer = pool.get_pointer(nodes_to_consume); - node * next_node = pool.get_pointer(node_pointer->next); - - node_pointer->next = pool.get_handle(last_node_pointer); - last_node_pointer = node_pointer; - - if (!next_node) { - nodes_in_reversed_order = nodes_to_consume; - break; - } - - tagged_node_handle next(pool.get_handle(next_node), nodes_to_consume.get_next_tag()); - nodes_to_consume = next; - } - - for(;;) { - node * node_pointer = pool.get_pointer(nodes_in_reversed_order); - f(node_pointer->v); - element_count += 1; - - node * next_node = pool.get_pointer(node_pointer->next); - - if (!next_node) { - pool.template destruct<true>(nodes_in_reversed_order); - break; - } - - tagged_node_handle next(pool.get_handle(next_node), nodes_in_reversed_order.get_next_tag()); - pool.template destruct<true>(nodes_in_reversed_order); - nodes_in_reversed_order = next; - } - - return element_count; - } - /** - * \return true, if stack is empty. - * - * \note It only guarantees that at some point during the execution of the function the stack has been empty. - * It is rarely practical to use this value in program logic, because the stack can be modified by other threads. - * */ - bool empty(void) const - { - return pool.get_pointer(tos.load()) == NULL; - } - -private: -#ifndef BOOST_DOXYGEN_INVOKED - detail::atomic<tagged_node_handle> tos; - - static const int padding_size = BOOST_LOCKFREE_CACHELINE_BYTES - sizeof(tagged_node_handle); - char padding[padding_size]; - - pool_t pool; -#endif -}; - -} /* namespace lockfree */ -} /* namespace boost */ - -#endif /* BOOST_LOCKFREE_STACK_HPP_INCLUDED */ diff --git a/contrib/restricted/boost/boost/make_default.hpp b/contrib/restricted/boost/boost/make_default.hpp deleted file mode 100644 index e653ef06411..00000000000 --- a/contrib/restricted/boost/boost/make_default.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/// @file -// Copyright (c) 2009-2016 Vladimir Batov. -// Use, modification and distribution are subject to the Boost Software License, -// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. - -#ifndef BOOST_MAKE_DEFAULT_HPP -#define BOOST_MAKE_DEFAULT_HPP - -namespace boost -{ - /// @details A considerable number of libraries require an instance of a class - /// provided (storage created and initialized). For example, - /// @code - /// Type result; - /// ... - /// istream >> result; - /// @endcode - /// In generic code that results in the Default Constructibility requirement imposed - /// on every type 'Type' to be used with the respective code. Inevitably, that requirement - /// a) either excludes all the classes that for various reasons do not meet that requirement or - /// b) imposes certain (not necessarily desirable) design/implementation onto respective classes. - /// - /// Deployment of boost::make_default() eliminates the Default Constructibility requirement with - /// @code - /// Type result = boost::make_default<Type>(); - /// ... - /// istream >> result; - /// @endcode - /// Classes with no default constructor can now be included via a boost::make_default() specialization: - /// @code - /// namespace boost - /// { - /// template<> inline Type make_default<Type>() { return Type(parameters); } - /// } - /// @endcode - - template<typename T> T make_default() { return T(); } -} - -#endif // BOOST_MAKE_DEFAULT_HPP diff --git a/contrib/restricted/boost/boost/msm/active_state_switching_policies.hpp b/contrib/restricted/boost/boost/msm/active_state_switching_policies.hpp deleted file mode 100644 index d9584cb7e87..00000000000 --- a/contrib/restricted/boost/boost/msm/active_state_switching_policies.hpp +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_ACTIVE_STATE_SWITCHING_POLICIES_H -#define BOOST_MSM_ACTIVE_STATE_SWITCHING_POLICIES_H - -namespace boost { namespace msm -{ -// policy classes - -// Default: new active state set after the transition (after entry) -struct active_state_switch_after_entry -{ - static int after_guard(int current_state,int){return current_state;} - static int after_exit(int current_state,int){return current_state;} - static int after_action(int current_state,int){return current_state;} - static int after_entry(int,int next_state){return next_state;} -}; - -// new state set before the transition starts -struct active_state_switch_before_transition -{ - static int after_guard(int,int next_state){return next_state;} - static int after_exit(int,int next_state){return next_state;} - static int after_action(int,int next_state){return next_state;} - static int after_entry(int,int next_state){return next_state;} -}; - -// new state set after exit action completed -struct active_state_switch_after_exit -{ - static int after_guard(int current_state,int){return current_state;} - static int after_exit(int,int next_state){return next_state;} - static int after_action(int,int next_state){return next_state;} - static int after_entry(int,int next_state){return next_state;} -}; - -// new state set after transition action completed -struct active_state_switch_after_transition_action -{ - static int after_guard(int current_state,int){return current_state;} - static int after_exit(int current_state,int){return current_state;} - static int after_action(int,int next_state){return next_state;} - static int after_entry(int,int next_state){return next_state;} -}; - -} }//boost::msm -#endif //BOOST_MSM_ACTIVE_STATE_SWITCHING_POLICIES_H diff --git a/contrib/restricted/boost/boost/msm/back/args.hpp b/contrib/restricted/boost/boost/msm/back/args.hpp deleted file mode 100644 index 125b1eeae8b..00000000000 --- a/contrib/restricted/boost/boost/msm/back/args.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_BACK_ARGS_H -#define BOOST_MSM_BACK_ARGS_H - -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/arithmetic/sub.hpp> -#include <boost/preprocessor/punctuation/comma_if.hpp> -#include <boost/preprocessor/control/expr_if.hpp> -#include <boost/preprocessor/punctuation/comma.hpp> -#include <boost/preprocessor/arithmetic/add.hpp> -#include <boost/preprocessor/cat.hpp> -#include <boost/preprocessor/comparison/less.hpp> -#include <boost/preprocessor/arithmetic/dec.hpp> -#include <boost/function.hpp> - -#ifndef BOOST_MSM_VISITOR_ARG_SIZE -#define BOOST_MSM_VISITOR_ARG_SIZE 2 // default max number of arguments -#endif - -namespace boost { namespace msm { namespace back -{ -struct no_args {}; -#define MSM_ARGS_TYPEDEF_SUB(z, n, unused) typedef ARG ## n argument ## n ; -#define MSM_ARGS_PRINT(z, n, data) data -#define MSM_ARGS_NONE_PRINT(z, n, data) class data ## n = no_args \ - BOOST_PP_COMMA_IF( BOOST_PP_LESS(n, BOOST_PP_DEC(BOOST_MSM_VISITOR_ARG_SIZE) ) ) - -#define MSM_VISITOR_MAIN_ARGS(n) \ - template <class RES, \ - BOOST_PP_REPEAT(BOOST_MSM_VISITOR_ARG_SIZE, MSM_ARGS_NONE_PRINT, ARG)> \ - struct args \ - { \ - typedef ::boost::function<RES(BOOST_PP_ENUM_PARAMS(n, ARG))> type; \ - enum {args_number=n}; \ - BOOST_PP_REPEAT(n, MSM_ARGS_TYPEDEF_SUB, ~ ) \ - }; - -#define MSM_VISITOR_ARGS(z, n, unused) \ - template <class RES BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class ARG)> \ - struct args<RES, \ - BOOST_PP_ENUM_PARAMS(n,ARG) \ - BOOST_PP_COMMA_IF(n) \ - BOOST_PP_ENUM(BOOST_PP_SUB(BOOST_MSM_VISITOR_ARG_SIZE,n), MSM_ARGS_PRINT, no_args) \ - > \ - { \ - typedef ::boost::function<RES(BOOST_PP_ENUM_PARAMS(n, ARG))> type; \ - enum {args_number=n}; \ - BOOST_PP_REPEAT(n, MSM_ARGS_TYPEDEF_SUB, ~ ) \ - }; -MSM_VISITOR_MAIN_ARGS(BOOST_MSM_VISITOR_ARG_SIZE) -BOOST_PP_REPEAT(BOOST_MSM_VISITOR_ARG_SIZE, MSM_VISITOR_ARGS, ~) - -#undef MSM_VISITOR_ARGS -#undef MSM_ARGS_PRINT - -}}} - -#endif //BOOST_MSM_BACK_ARGS_H - diff --git a/contrib/restricted/boost/boost/msm/back/bind_helpers.hpp b/contrib/restricted/boost/boost/msm/back/bind_helpers.hpp deleted file mode 100644 index a537ec32643..00000000000 --- a/contrib/restricted/boost/boost/msm/back/bind_helpers.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_BACK_BIND_HELPERS_H -#define BOOST_MSM_BACK_BIND_HELPERS_H - -#include <functional> - -namespace boost { namespace msm { namespace back -{ - // helper to replace std::plus as the lack of implicit conversion makes it not usable in one of our bind - template<class _Ty,class _Tz> - struct plus2 - : public std::binary_function<_Ty, _Tz, _Ty> - { - // functor for operator+ - _Ty operator()( _Ty _Left, _Tz _Right) const - { - // apply operator+ to operands - return (_Left + _Right); - } - }; - // helper to dereference a pointer to a function pointer - template <class T> - struct deref - { - typedef T& result_type; - T& operator()(T* f) const - { - return *f; - } - }; -} } }//boost::msm::back -#endif //BOOST_MSM_BACK_BIND_HELPERS_H diff --git a/contrib/restricted/boost/boost/msm/back/common_types.hpp b/contrib/restricted/boost/boost/msm/back/common_types.hpp deleted file mode 100644 index 82f6279eb02..00000000000 --- a/contrib/restricted/boost/boost/msm/back/common_types.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_COMMON_TYPES_H -#define BOOST_MSM_COMMON_TYPES_H - -#include <boost/tuple/tuple.hpp> -#include <boost/msm/common.hpp> - -namespace boost { namespace msm { namespace back -{ -// used for disable_if -template <int> struct dummy { dummy(int) {} }; -// return value for transition handling -typedef enum -{ - HANDLED_FALSE=0, - HANDLED_TRUE =1, - HANDLED_GUARD_REJECT=2, - HANDLED_DEFERRED=4 -} HandledEnum; - -typedef HandledEnum execute_return; - -}}} - -#endif //BOOST_MSM_COMMON_TYPES_H - diff --git a/contrib/restricted/boost/boost/msm/back/copy_policies.hpp b/contrib/restricted/boost/boost/msm/back/copy_policies.hpp deleted file mode 100644 index 162231357d2..00000000000 --- a/contrib/restricted/boost/boost/msm/back/copy_policies.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_BACK_COPY_POLICIES_H -#define BOOST_MSM_BACK_COPY_POLICIES_H - -#include <boost/noncopyable.hpp> - -namespace boost { namespace msm { namespace back -{ - // deactivates copy - struct NoCopy : ::boost::noncopyable - { - }; - - // allows deep copy - struct DeepCopy - { - }; -} } }//boost::msm::back - - -#endif //BOOST_MSM_BACK_COPY_POLICIES_H diff --git a/contrib/restricted/boost/boost/msm/back/default_compile_policy.hpp b/contrib/restricted/boost/boost/msm/back/default_compile_policy.hpp deleted file mode 100644 index 8fc3ab73045..00000000000 --- a/contrib/restricted/boost/boost/msm/back/default_compile_policy.hpp +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_BACK_DEFAULT_COMPILE_POLICY_HPP -#define BOOST_MSM_BACK_DEFAULT_COMPILE_POLICY_HPP - -#include <boost/mpl/bool.hpp> - -namespace boost { namespace msm { namespace back -{ -struct favor_runtime_speed -{ - typedef int compile_policy; - typedef ::boost::mpl::true_ add_forwarding_rows; -}; - -}}}// boost::msm::back -#endif // BOOST_MSM_BACK_DEFAULT_COMPILE_POLICY_HPP diff --git a/contrib/restricted/boost/boost/msm/back/dispatch_table.hpp b/contrib/restricted/boost/boost/msm/back/dispatch_table.hpp deleted file mode 100644 index caa830efc10..00000000000 --- a/contrib/restricted/boost/boost/msm/back/dispatch_table.hpp +++ /dev/null @@ -1,414 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_BACK_DISPATCH_TABLE_H -#define BOOST_MSM_BACK_DISPATCH_TABLE_H - -#include <utility> - -#include <boost/mpl/reverse_fold.hpp> -#include <boost/mpl/greater.hpp> -#include <boost/mpl/filter_view.hpp> -#include <boost/mpl/pop_front.hpp> -#include <boost/mpl/for_each.hpp> -#include <boost/mpl/advance.hpp> - -#include <boost/type_traits/is_base_of.hpp> -#include <boost/type_traits/is_same.hpp> - -#include <boost/msm/event_traits.hpp> -#include <boost/msm/back/metafunctions.hpp> -#include <boost/msm/back/common_types.hpp> - -BOOST_MPL_HAS_XXX_TRAIT_DEF(is_frow) - -namespace boost { namespace msm { namespace back -{ - -// Generates a singleton runtime lookup table that maps current state -// to a function that makes the SM take its transition on the given -// Event type. -template <class Fsm,class Stt, class Event,class CompilePolicy> -struct dispatch_table -{ - private: - // This is a table of these function pointers. - typedef HandledEnum (*cell)(Fsm&, int,int,Event const&); - typedef bool (*guard)(Fsm&, Event const&); - - // class used to build a chain (or sequence) of transitions for a given event and start state - // (like an UML diamond). Allows transition conflicts. - template< typename Seq,typename AnEvent,typename State > - struct chain_row - { - typedef State current_state_type; - typedef AnEvent transition_event; - - // helper for building a disable/enable_if-controlled execute function - struct execute_helper - { - template <class Sequence> - static - HandledEnum - execute(Fsm& , int, int, Event const& , ::boost::mpl::true_ const & ) - { - // if at least one guard rejected, this will be ignored, otherwise will generate an error - return HANDLED_FALSE; - } - - template <class Sequence> - static - HandledEnum - execute(Fsm& fsm, int region_index , int state, Event const& evt, - ::boost::mpl::false_ const & ) - { - // try the first guard - typedef typename ::boost::mpl::front<Sequence>::type first_row; - HandledEnum res = first_row::execute(fsm,region_index,state,evt); - if (HANDLED_TRUE!=res && HANDLED_DEFERRED!=res) - { - // if the first rejected, move on to the next one - HandledEnum sub_res = - execute<typename ::boost::mpl::pop_front<Sequence>::type>(fsm,region_index,state,evt, - ::boost::mpl::bool_< - ::boost::mpl::empty<typename ::boost::mpl::pop_front<Sequence>::type>::type::value>()); - // if at least one guards rejects, the event will not generate a call to no_transition - if ((HANDLED_FALSE==sub_res) && (HANDLED_GUARD_REJECT==res) ) - return HANDLED_GUARD_REJECT; - else - return sub_res; - } - return res; - } - }; - // Take the transition action and return the next state. - static HandledEnum execute(Fsm& fsm, int region_index, int state, Event const& evt) - { - // forward to helper - return execute_helper::template execute<Seq>(fsm,region_index,state,evt, - ::boost::mpl::bool_< ::boost::mpl::empty<Seq>::type::value>()); - } - }; - // nullary metafunction whose only job is to prevent early evaluation of _1 - template< typename Entry > - struct make_chain_row_from_map_entry - { - // if we have more than one frow with the same state as source, remove the ones extra - // note: we know the frow's are located at the beginning so we remove at the beginning (number of frows - 1) elements - enum {number_frows = ::boost::mpl::count_if< typename Entry::second,has_is_frow< ::boost::mpl::placeholders::_1> >::value}; - - //erases the first NumberToDelete rows - template<class Sequence, int NumberToDelete> - struct erase_first_rows - { - typedef typename ::boost::mpl::erase< - typename Entry::second, - typename ::boost::mpl::begin<Sequence>::type, - typename ::boost::mpl::advance< - typename ::boost::mpl::begin<Sequence>::type, - ::boost::mpl::int_<NumberToDelete> >::type - >::type type; - }; - // if we have more than 1 frow with this event (not allowed), delete the spare - typedef typename ::boost::mpl::eval_if< - typename ::boost::mpl::bool_< number_frows >= 2 >::type, - erase_first_rows<typename Entry::second,number_frows-1>, - ::boost::mpl::identity<typename Entry::second> - >::type filtered_stt; - - typedef chain_row<filtered_stt,Event, - typename Entry::first > type; - }; - // helper for lazy evaluation in eval_if of change_frow_event - template <class Transition,class NewEvent> - struct replace_event - { - typedef typename Transition::template replace_event<NewEvent>::type type; - }; - // changes the event type for a frow to the event we are dispatching - // this helps ensure that an event does not get processed more than once because of frows and base events. - template <class FrowTransition> - struct change_frow_event - { - typedef typename ::boost::mpl::eval_if< - typename has_is_frow<FrowTransition>::type, - replace_event<FrowTransition,Event>, - boost::mpl::identity<FrowTransition> - >::type type; - }; - // Compute the maximum state value in the sm so we know how big - // to make the table - typedef typename generate_state_set<Stt>::type state_list; - BOOST_STATIC_CONSTANT(int, max_state = ( ::boost::mpl::size<state_list>::value)); - - template <class Transition> - struct convert_event_and_forward - { - static HandledEnum execute(Fsm& fsm, int region_index, int state, Event const& evt) - { - typename Transition::transition_event forwarded(evt); - return Transition::execute(fsm,region_index,state,forwarded); - } - }; - - // A function object for use with mpl::for_each that stuffs - // transitions into cells. - struct init_cell - { - init_cell(dispatch_table* self_) - : self(self_) - {} - // version for transition event not base of our event - // first for all transitions, then for internal ones of a fsm - template <class Transition> - typename ::boost::disable_if< - typename ::boost::is_same<typename Transition::current_state_type,Fsm>::type - ,void>::type - init_event_base_case(Transition const&, ::boost::mpl::true_ const &, ::boost::mpl::false_ const &) const - { - typedef typename create_stt<Fsm>::type stt; - BOOST_STATIC_CONSTANT(int, state_id = - (get_state_id<stt,typename Transition::current_state_type>::value)); - self->entries[state_id+1] = reinterpret_cast<cell>(&Transition::execute); - } - template <class Transition> - typename ::boost::enable_if< - typename ::boost::is_same<typename Transition::current_state_type,Fsm>::type - ,void>::type - init_event_base_case(Transition const&, ::boost::mpl::true_ const &, ::boost::mpl::false_ const &) const - { - self->entries[0] = reinterpret_cast<cell>(&Transition::execute); - } - - // version for transition event is boost::any - // first for all transitions, then for internal ones of a fsm - template <class Transition> - typename ::boost::disable_if< - typename ::boost::is_same<typename Transition::current_state_type,Fsm>::type - ,void>::type - init_event_base_case(Transition const&, ::boost::mpl::false_ const &, ::boost::mpl::true_ const &) const - { - typedef typename create_stt<Fsm>::type stt; - BOOST_STATIC_CONSTANT(int, state_id = - (get_state_id<stt,typename Transition::current_state_type>::value)); - self->entries[state_id+1] = &convert_event_and_forward<Transition>::execute; - } - template <class Transition> - typename ::boost::enable_if< - typename ::boost::is_same<typename Transition::current_state_type,Fsm>::type - ,void>::type - init_event_base_case(Transition const&, ::boost::mpl::false_ const &, ::boost::mpl::true_ const &) const - { - self->entries[0] = &convert_event_and_forward<Transition>::execute; - } - - // version for transition event base of our event - // first for all transitions, then for internal ones of a fsm - template <class Transition> - typename ::boost::disable_if< - typename ::boost::is_same<typename Transition::current_state_type,Fsm>::type - ,void>::type - init_event_base_case(Transition const&, ::boost::mpl::false_ const &, ::boost::mpl::false_ const &) const - { - typedef typename create_stt<Fsm>::type stt; - BOOST_STATIC_CONSTANT(int, state_id = - (get_state_id<stt,typename Transition::current_state_type>::value)); - self->entries[state_id+1] = &Transition::execute; - } - template <class Transition> - typename ::boost::enable_if< - typename ::boost::is_same<typename Transition::current_state_type,Fsm>::type - ,void>::type - init_event_base_case(Transition const&, ::boost::mpl::false_ const &, ::boost::mpl::false_ const &) const - { - self->entries[0] = &Transition::execute; - } - // Cell initializer function object, used with mpl::for_each - template <class Transition> - typename ::boost::enable_if<typename has_not_real_row_tag<Transition>::type,void >::type - operator()(Transition const&,boost::msm::back::dummy<0> = 0) const - { - // version for not real rows. No problem because irrelevant for process_event - } - template <class Transition> - typename ::boost::disable_if<typename has_not_real_row_tag<Transition>::type,void >::type - operator()(Transition const& tr,boost::msm::back::dummy<1> = 0) const - { - //only if the transition event is a base of our event is the reinterpret_case safe - init_event_base_case(tr, - ::boost::mpl::bool_< - ::boost::is_base_of<typename Transition::transition_event,Event>::type::value>(), - ::boost::mpl::bool_< - ::boost::msm::is_kleene_event<typename Transition::transition_event>::type::value>()); - } - - dispatch_table* self; - }; - - // Cell default-initializer function object, used with mpl::for_each - // initializes with call_no_transition, defer_transition or default_eventless_transition - // variant for non-anonymous transitions - template <class EventType,class Enable=void> - struct default_init_cell - { - default_init_cell(dispatch_table* self_,cell* tofill_entries_) - : self(self_),tofill_entries(tofill_entries_) - {} - template <class State> - typename ::boost::enable_if<typename has_state_delayed_event<State,Event>::type,void>::type - operator()(boost::msm::wrap<State> const&,boost::msm::back::dummy<0> = 0) - { - typedef typename create_stt<Fsm>::type stt; - BOOST_STATIC_CONSTANT(int, state_id = (get_state_id<stt,State>::value)); - cell call_no_transition = &Fsm::defer_transition; - tofill_entries[state_id+1] = call_no_transition; - } - template <class State> - typename ::boost::disable_if< - typename ::boost::mpl::or_< - typename has_state_delayed_event<State,Event>::type, - typename ::boost::is_same<State,Fsm>::type - >::type - ,void >::type - operator()(boost::msm::wrap<State> const&,boost::msm::back::dummy<1> = 0) - { - typedef typename create_stt<Fsm>::type stt; - BOOST_STATIC_CONSTANT(int, state_id = (get_state_id<stt,State>::value)); - cell call_no_transition = &Fsm::call_no_transition; - tofill_entries[state_id+1] = call_no_transition; - } - // case for internal transitions of this fsm - template <class State> - typename ::boost::enable_if< - typename ::boost::mpl::and_< - typename ::boost::mpl::not_<typename has_state_delayed_event<State,Event>::type>::type, - typename ::boost::is_same<State,Fsm>::type - >::type - ,void>::type - operator()(boost::msm::wrap<State> const&,boost::msm::back::dummy<2> = 0) - { - cell call_no_transition = &Fsm::call_no_transition_internal; - tofill_entries[0] = call_no_transition; - } - dispatch_table* self; - cell* tofill_entries; - }; - - // variant for anonymous transitions - template <class EventType> - struct default_init_cell<EventType, - typename ::boost::enable_if< - typename is_completion_event<EventType>::type>::type> - { - default_init_cell(dispatch_table* self_,cell* tofill_entries_) - : self(self_),tofill_entries(tofill_entries_) - {} - - // this event is a compound one (not a real one, just one for use in event-less transitions) - // Note this event cannot be used as deferred! - // case for internal transitions of this fsm - template <class State> - typename ::boost::disable_if< - typename ::boost::is_same<State,Fsm>::type - ,void>::type - operator()(boost::msm::wrap<State> const&,boost::msm::back::dummy<0> = 0) - { - typedef typename create_stt<Fsm>::type stt; - BOOST_STATIC_CONSTANT(int, state_id = (get_state_id<stt,State>::value)); - cell call_no_transition = &Fsm::default_eventless_transition; - tofill_entries[state_id+1] = call_no_transition; - } - - template <class State> - typename ::boost::enable_if< - typename ::boost::is_same<State,Fsm>::type - ,void>::type - operator()(boost::msm::wrap<State> const&,boost::msm::back::dummy<1> = 0) - { - cell call_no_transition = &Fsm::default_eventless_transition; - tofill_entries[0] = call_no_transition; - } - dispatch_table* self; - cell* tofill_entries; - }; - - public: - // initialize the dispatch table for a given Event and Fsm - dispatch_table() - { - // Initialize cells for no transition - ::boost::mpl::for_each<typename generate_state_set<Stt>::type, - boost::msm::wrap< ::boost::mpl::placeholders::_1> > - (default_init_cell<Event>(this,entries)); - - // build chaining rows for rows coming from the same state and the current event - // first we build a map of sequence for every source - // in reverse order so that the frow's are handled first (UML priority) - typedef typename ::boost::mpl::reverse_fold< - // filter on event - ::boost::mpl::filter_view - <Stt, boost::mpl::or_< - ::boost::is_base_of<transition_event< ::boost::mpl::placeholders::_>, Event>, - ::boost::msm::is_kleene_event<transition_event< ::boost::mpl::placeholders::_> > - > - >, - // build a map - ::boost::mpl::map<>, - ::boost::mpl::if_< - // if we already have a row on this source state - ::boost::mpl::has_key< ::boost::mpl::placeholders::_1, - transition_source_type< ::boost::mpl::placeholders::_2> >, - // insert a new element in the value type - ::boost::mpl::insert< - ::boost::mpl::placeholders::_1, - ::boost::mpl::pair<transition_source_type< ::boost::mpl::placeholders::_2>, - ::boost::mpl::push_back< - ::boost::mpl::at< ::boost::mpl::placeholders::_1, - transition_source_type< ::boost::mpl::placeholders::_2> >, - change_frow_event< ::boost::mpl::placeholders::_2 > > - > >, - // first row on this source state, make a vector with 1 element - ::boost::mpl::insert< - ::boost::mpl::placeholders::_1, - ::boost::mpl::pair<transition_source_type< ::boost::mpl::placeholders::_2>, - make_vector< change_frow_event< ::boost::mpl::placeholders::_2> > > > - > - >::type map_of_row_seq; - // and then build chaining rows for all source states having more than 1 row - typedef typename ::boost::mpl::fold< - map_of_row_seq,::boost::mpl::vector0<>, - ::boost::mpl::if_< - ::boost::mpl::greater< ::boost::mpl::size< - ::boost::mpl::second< ::boost::mpl::placeholders::_2> >, - ::boost::mpl::int_<1> >, - // we need row chaining - ::boost::mpl::push_back< ::boost::mpl::placeholders::_1, - make_chain_row_from_map_entry< ::boost::mpl::placeholders::_2> >, - // just one row, no chaining, we rebuild the row like it was before - ::boost::mpl::push_back< ::boost::mpl::placeholders::_1, - get_first_element_pair_second< ::boost::mpl::placeholders::_2> > - > >::type chained_rows; - // Go back and fill in cells for matching transitions. - ::boost::mpl::for_each<chained_rows>(init_cell(this)); - } - - // The singleton instance. - static const dispatch_table instance; - - public: // data members - // +1 => 0 is reserved for this fsm (internal transitions) - cell entries[max_state+1]; -}; - -}}} // boost::msm::back - - -#endif //BOOST_MSM_BACK_DISPATCH_TABLE_H - diff --git a/contrib/restricted/boost/boost/msm/back/favor_compile_time.hpp b/contrib/restricted/boost/boost/msm/back/favor_compile_time.hpp deleted file mode 100644 index c19b5f4be54..00000000000 --- a/contrib/restricted/boost/boost/msm/back/favor_compile_time.hpp +++ /dev/null @@ -1,320 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_BACK_FAVOR_COMPILE_TIME_H -#define BOOST_MSM_BACK_FAVOR_COMPILE_TIME_H - -#include <utility> -#include <deque> - -#include <boost/mpl/filter_view.hpp> -#include <boost/mpl/for_each.hpp> -#include <boost/mpl/bool.hpp> -#include <boost/any.hpp> - -#include <boost/msm/common.hpp> -#include <boost/msm/back/metafunctions.hpp> -#include <boost/msm/back/common_types.hpp> -#include <boost/msm/back/dispatch_table.hpp> - -namespace boost { namespace msm { namespace back -{ - -template <class Fsm> -struct process_any_event_helper -{ - process_any_event_helper(msm::back::HandledEnum& res_,Fsm* self_,::boost::any any_event_): - res(res_),self(self_),any_event(any_event_),finished(false){} - template <class Event> - void operator()(boost::msm::wrap<Event> const&) - { - if ( ! finished && ::boost::any_cast<Event>(&any_event)!=0) - { - finished = true; - res = self->process_event_internal(::boost::any_cast<Event>(any_event),false); - - } - } -private: - msm::back::HandledEnum& res; - Fsm* self; - ::boost::any any_event; - bool finished; -}; - -#define BOOST_MSM_BACK_GENERATE_PROCESS_EVENT(fsmname) \ - namespace boost { namespace msm { namespace back{ \ - template<> \ - ::boost::msm::back::HandledEnum fsmname::process_any_event( ::boost::any const& any_event) \ - { \ - typedef ::boost::msm::back::recursive_get_transition_table<fsmname>::type stt; \ - typedef ::boost::msm::back::generate_event_set<stt>::type stt_events; \ - typedef ::boost::msm::back::recursive_get_internal_transition_table<fsmname, ::boost::mpl::true_ >::type istt; \ - typedef ::boost::msm::back::generate_event_set<create_real_stt<fsmname,istt>::type >::type istt_events; \ - typedef ::boost::msm::back::set_insert_range<stt_events,istt_events>::type all_events; \ - ::boost::msm::back::HandledEnum res= ::boost::msm::back::HANDLED_FALSE; \ - ::boost::mpl::for_each<all_events, ::boost::msm::wrap< ::boost::mpl::placeholders::_1> > \ - (::boost::msm::back::process_any_event_helper<fsmname>(res,this,any_event)); \ - return res; \ - } \ - }}} - -struct favor_compile_time -{ - typedef int compile_policy; - typedef ::boost::mpl::false_ add_forwarding_rows; -}; - -// Generates a singleton runtime lookup table that maps current state -// to a function that makes the SM take its transition on the given -// Event type. -template <class Fsm,class Stt, class Event> -struct dispatch_table < Fsm, Stt, Event, ::boost::msm::back::favor_compile_time> -{ - private: - // This is a table of these function pointers. - typedef HandledEnum (*cell)(Fsm&, int,int,Event const&); - typedef bool (*guard)(Fsm&, Event const&); - - // Compute the maximum state value in the sm so we know how big - // to make the table - typedef typename generate_state_set<Stt>::type state_list; - BOOST_STATIC_CONSTANT(int, max_state = ( ::boost::mpl::size<state_list>::value)); - - struct chain_row - { - HandledEnum operator()(Fsm& fsm, int region,int state,Event const& evt) const - { - HandledEnum res = HANDLED_FALSE; - typename std::deque<cell>::const_iterator it = one_state.begin(); - while (it != one_state.end() && (res != HANDLED_TRUE && res != HANDLED_DEFERRED )) - { - HandledEnum handled = (*it)(fsm,region,state,evt); - // reject is considered as erasing an error (HANDLED_FALSE) - if ((HANDLED_FALSE==handled) && (HANDLED_GUARD_REJECT==res) ) - res = HANDLED_GUARD_REJECT; - else - res = handled; - ++it; - } - return res; - } - std::deque<cell> one_state; - }; - template <class TransitionState> - static HandledEnum call_submachine(Fsm& fsm, int , int , Event const& evt) - { - return (fsm.template get_state<TransitionState&>()).process_any_event( ::boost::any(evt)); - } - // A function object for use with mpl::for_each that stuffs - // transitions into cells. - struct init_cell - { - init_cell(dispatch_table* self_) - : self(self_) - {} - // version for transition event not base of our event - template <class Transition> - typename ::boost::disable_if< - typename ::boost::is_same<typename Transition::current_state_type,Fsm>::type - ,void>::type - init_event_base_case(Transition const&, ::boost::mpl::true_ const &) const - { - typedef typename create_stt<Fsm>::type stt; - BOOST_STATIC_CONSTANT(int, state_id = - (get_state_id<stt,typename Transition::current_state_type>::value)); - self->entries[state_id+1].one_state.push_front(reinterpret_cast<cell>(&Transition::execute)); - } - template <class Transition> - typename ::boost::enable_if< - typename ::boost::is_same<typename Transition::current_state_type,Fsm>::type - ,void>::type - init_event_base_case(Transition const&, ::boost::mpl::true_ const &) const - { - self->entries[0].one_state.push_front(reinterpret_cast<cell>(&Transition::execute)); - } - - // version for transition event base of our event - template <class Transition> - typename ::boost::disable_if< - typename ::boost::is_same<typename Transition::current_state_type,Fsm>::type - ,void>::type - init_event_base_case(Transition const&, ::boost::mpl::false_ const &) const - { - typedef typename create_stt<Fsm>::type stt; - BOOST_STATIC_CONSTANT(int, state_id = - (get_state_id<stt,typename Transition::current_state_type>::value)); - self->entries[state_id+1].one_state.push_front(&Transition::execute); - } - template <class Transition> - typename ::boost::enable_if< - typename ::boost::is_same<typename Transition::current_state_type,Fsm>::type - ,void>::type - init_event_base_case(Transition const&, ::boost::mpl::false_ const &) const - { - self->entries[0].one_state.push_front(&Transition::execute); - } - // Cell initializer function object, used with mpl::for_each - template <class Transition> - typename ::boost::enable_if<typename has_not_real_row_tag<Transition>::type,void >::type - operator()(Transition const&,boost::msm::back::dummy<0> = 0) const - { - // version for not real rows. No problem because irrelevant for process_event - } - template <class Transition> - typename ::boost::disable_if<typename has_not_real_row_tag<Transition>::type,void >::type - operator()(Transition const& tr,boost::msm::back::dummy<1> = 0) const - { - //only if the transition event is a base of our event is the reinterpret_case safe - init_event_base_case(tr, - ::boost::mpl::bool_< - ::boost::is_base_of<typename Transition::transition_event,Event>::type::value>() ); - } - - dispatch_table* self; - }; - - // Cell default-initializer function object, used with mpl::for_each - // initializes with call_no_transition, defer_transition or default_eventless_transition - // variant for non-anonymous transitions - template <class EventType,class Enable=void> - struct default_init_cell - { - default_init_cell(dispatch_table* self_,chain_row* tofill_entries_) - : self(self_),tofill_entries(tofill_entries_) - {} - template <bool deferred,bool composite, int some_dummy=0> - struct helper - {}; - template <int some_dummy> struct helper<true,false,some_dummy> - { - template <class State> - static void execute(boost::msm::wrap<State> const&,chain_row* tofill) - { - typedef typename create_stt<Fsm>::type stt; - BOOST_STATIC_CONSTANT(int, state_id = (get_state_id<stt,State>::value)); - cell call_no_transition = &Fsm::defer_transition; - tofill[state_id+1].one_state.push_back(call_no_transition); - } - }; - template <int some_dummy> struct helper<true,true,some_dummy> - { - template <class State> - static void execute(boost::msm::wrap<State> const&,chain_row* tofill) - { - typedef typename create_stt<Fsm>::type stt; - BOOST_STATIC_CONSTANT(int, state_id = (get_state_id<stt,State>::value)); - cell call_no_transition = &Fsm::defer_transition; - tofill[state_id+1].one_state.push_back(call_no_transition); - } - }; - template <int some_dummy> struct helper<false,true,some_dummy> - { - template <class State> - static - typename ::boost::enable_if< - typename ::boost::is_same<State,Fsm>::type - ,void>::type - execute(boost::msm::wrap<State> const&,chain_row* tofill,boost::msm::back::dummy<0> = 0) - { - // for internal tables - cell call_no_transition_internal = &Fsm::call_no_transition; - tofill[0].one_state.push_front(call_no_transition_internal); - } - template <class State> - static - typename ::boost::disable_if< - typename ::boost::is_same<State,Fsm>::type - ,void>::type - execute(boost::msm::wrap<State> const&,chain_row* tofill,boost::msm::back::dummy<1> = 0) - { - typedef typename create_stt<Fsm>::type stt; - BOOST_STATIC_CONSTANT(int, state_id = (get_state_id<stt,State>::value)); - cell call_no_transition = &call_submachine< State >; - tofill[state_id+1].one_state.push_front(call_no_transition); - } - }; - template <int some_dummy> struct helper<false,false,some_dummy> - { - template <class State> - static void execute(boost::msm::wrap<State> const&,chain_row* tofill) - { - typedef typename create_stt<Fsm>::type stt; - BOOST_STATIC_CONSTANT(int, state_id = (get_state_id<stt,State>::value)); - cell call_no_transition = &Fsm::call_no_transition; - tofill[state_id+1].one_state.push_back(call_no_transition); - } - }; - template <class State> - void operator()(boost::msm::wrap<State> const& s) - { - helper<has_state_delayed_event<State,Event>::type::value, - is_composite_state<State>::type::value>::execute(s,tofill_entries); - } - dispatch_table* self; - chain_row* tofill_entries; - }; - - // variant for anonymous transitions - template <class EventType> - struct default_init_cell<EventType, - typename ::boost::enable_if< - typename is_completion_event<EventType>::type>::type> - { - default_init_cell(dispatch_table* self_,chain_row* tofill_entries_) - : self(self_),tofill_entries(tofill_entries_) - {} - - // this event is a compound one (not a real one, just one for use in event-less transitions) - // Note this event cannot be used as deferred! - template <class State> - void operator()(boost::msm::wrap<State> const&) - { - typedef typename create_stt<Fsm>::type stt; - BOOST_STATIC_CONSTANT(int, state_id = (get_state_id<stt,State>::value)); - cell call_no_transition = &Fsm::default_eventless_transition; - tofill_entries[state_id+1].one_state.push_back(call_no_transition); - } - - dispatch_table* self; - chain_row* tofill_entries; - }; - - public: - // initialize the dispatch table for a given Event and Fsm - dispatch_table() - { - // Initialize cells for no transition - ::boost::mpl::for_each< - ::boost::mpl::filter_view< - Stt, ::boost::is_base_of<transition_event< ::boost::mpl::placeholders::_>, Event> > > - (init_cell(this)); - - ::boost::mpl::for_each< - typename generate_state_set<Stt>::type, - boost::msm::wrap< ::boost::mpl::placeholders::_1> > - (default_init_cell<Event>(this,entries)); - - } - - // The singleton instance. - static const dispatch_table instance; - - public: // data members - chain_row entries[max_state+1]; -}; - -template <class Fsm,class Stt, class Event> -const boost::msm::back::dispatch_table<Fsm,Stt, Event,favor_compile_time> -dispatch_table<Fsm,Stt, Event,favor_compile_time>::instance; - -}}} // boost::msm::back - -#endif //BOOST_MSM_BACK_FAVOR_COMPILE_TIME_H diff --git a/contrib/restricted/boost/boost/msm/back/fold_to_list.hpp b/contrib/restricted/boost/boost/msm/back/fold_to_list.hpp deleted file mode 100644 index 3bcc5609c34..00000000000 --- a/contrib/restricted/boost/boost/msm/back/fold_to_list.hpp +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is taken from Boost.Proto's documentation -// Copyright for the original version: -// Copyright 2008 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) - -#ifndef BOOST_MSM_BACK_FOLD_TO_LIST_H -#define BOOST_MSM_BACK_FOLD_TO_LIST_H - -#include <boost/msm/proto_config.hpp> -#include <boost/proto/core.hpp> -#include <boost/proto/transform.hpp> -#include <boost/msm/msm_grammar.hpp> -#include <boost/fusion/container/list/cons.hpp> - -namespace boost { namespace msm { namespace back -{ - struct state_copy_tag - { - }; - -template<class X = proto::is_proto_expr> -struct define_states_creation -{ - BOOST_PROTO_BASIC_EXTENDS( - proto::terminal<state_copy_tag>::type - , define_states_creation - , boost::msm::msm_domain - ) -}; - -define_states_creation<> const states_ = {{{}}}; - - struct FoldToList - : ::boost::proto::or_< - // Don't add the states_ terminal to the list - ::boost::proto::when< - ::boost::proto::terminal< state_copy_tag > - , ::boost::proto::_state - > - // Put all other terminals at the head of the - // list that we're building in the "state" parameter - // first states for the eUML states - , ::boost::proto::when< - ::boost::proto::terminal< state_tag > - , boost::fusion::cons< ::boost::proto::_, ::boost::proto::_state>( - ::boost::proto::_, ::boost::proto::_state - ) - > - // then states from other front-ends - , ::boost::proto::when< - ::boost::proto::terminal< proto::_ > - , boost::fusion::cons< ::boost::proto::_value, ::boost::proto::_state>( - ::boost::proto::_value, ::boost::proto::_state - ) - > - // For left-shift operations, first fold the right - // child to a list using the current state. Use - // the result as the state parameter when folding - // the left child to a list. - , ::boost::proto::when< - ::boost::proto::shift_left<FoldToList, FoldToList> - , FoldToList( - ::boost::proto::_left - , ::boost::proto::call<FoldToList( ::boost::proto::_right, ::boost::proto::_state )> - ) - > - > - {}; - -}}} - -#endif //BOOST_MSM_BACK_FOLD_TO_LIST_H - diff --git a/contrib/restricted/boost/boost/msm/back/history_policies.hpp b/contrib/restricted/boost/boost/msm/back/history_policies.hpp deleted file mode 100644 index 4b2af5866ab..00000000000 --- a/contrib/restricted/boost/boost/msm/back/history_policies.hpp +++ /dev/null @@ -1,201 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_BACK_HISTORY_POLICIES_H -#define BOOST_MSM_BACK_HISTORY_POLICIES_H - -#include <boost/mpl/contains.hpp> - -namespace boost { namespace msm { namespace back -{ - -// policy classes - -// Default: no history used -template <int NumberOfRegions> -class NoHistoryImpl -{ -public: - NoHistoryImpl(){} - ~NoHistoryImpl(){} - void set_initial_states(int* const initial_states) - { - for (int i=0;i<NumberOfRegions;++i) - m_initialStates[i] = initial_states[i]; - } - void history_exit(int* const ) - { - // ignore - } - // returns the state where the state machine should be at start - template <class Event> - const int* history_entry(Event const& ) - { - // always come back to the original state - return m_initialStates; - } - NoHistoryImpl<NumberOfRegions>& operator=(NoHistoryImpl<NumberOfRegions> const& rhs) - { - for (int i=0; i<NumberOfRegions;++i) - { - m_initialStates[i] = rhs.m_initialStates[i]; - } - return *this; - } - // this policy deletes all waiting deferred events - template <class Event> - bool process_deferred_events(Event const&)const - { - return false; - } - template<class Archive> - void serialize(Archive & ar, const unsigned int) - { - ar & m_initialStates; - } -private: - int m_initialStates[NumberOfRegions]; -}; - -// not UML standard. Always activates history, no matter which event generated the transition -template <int NumberOfRegions> -class AlwaysHistoryImpl -{ -public: - AlwaysHistoryImpl(){} - ~AlwaysHistoryImpl(){} - void set_initial_states(int* const initial_states) - { - for (int i=0;i<NumberOfRegions;++i) - m_initialStates[i] = initial_states[i]; - } - void history_exit(int* const current_states) - { - for (int i=0;i<NumberOfRegions;++i) - m_initialStates[i] = current_states[i]; - } - // returns the state where the state machine should be at start - template <class Event> - const int* history_entry(Event const& ) - { - // always load back the last active state - return m_initialStates; - } - AlwaysHistoryImpl<NumberOfRegions>& operator=(AlwaysHistoryImpl<NumberOfRegions> const& rhs) - { - for (int i=0; i<NumberOfRegions;++i) - { - m_initialStates[i] = rhs.m_initialStates[i]; - } - return *this; - } - // the history policy keeps all deferred events until next reentry - template <class Event> - bool process_deferred_events(Event const&)const - { - return true; - } - - template<class Archive> - void serialize(Archive & ar, const unsigned int) - { - ar & m_initialStates; - } -private: - int m_initialStates[NumberOfRegions]; -}; - -// UML Shallow history. For deep history, just use this policy for all the contained state machines -template <class Events,int NumberOfRegions> -class ShallowHistoryImpl -{ -public: - ShallowHistoryImpl(){} - ~ShallowHistoryImpl(){} - void set_initial_states(int* const initial_states) - { - for (int i=0;i<NumberOfRegions;++i) - { - m_currentStates[i] = initial_states[i]; - m_initialStates[i] = initial_states[i]; - } - } - void history_exit(int* const current_states) - { - for (int i=0;i<NumberOfRegions;++i) - m_currentStates[i] = current_states[i]; - } - // returns the state where the state machine should be at start - template <class Event> - const int* history_entry(Event const&) - { - if ( ::boost::mpl::contains<Events,Event>::value) - { - return m_currentStates; - } - // not one of our events, no history - return m_initialStates; - } - ShallowHistoryImpl<Events,NumberOfRegions>& operator=(ShallowHistoryImpl<Events,NumberOfRegions> const& rhs) - { - for (int i=0; i<NumberOfRegions;++i) - { - m_initialStates[i] = rhs.m_initialStates[i]; - m_currentStates[i] = rhs.m_currentStates[i]; - } - return *this; - } - // the history policy keeps deferred events until next reentry if coming from our history event - template <class Event> - bool process_deferred_events(Event const&)const - { - return ::boost::mpl::contains<Events,Event>::value; - } - template<class Archive> - void serialize(Archive & ar, const unsigned int) - { - ar & m_initialStates; - ar & m_currentStates; - } -private: - int m_initialStates[NumberOfRegions]; - int m_currentStates[NumberOfRegions]; -}; - -struct NoHistory -{ - typedef int history_policy; - template <int NumberOfRegions> - struct apply - { - typedef NoHistoryImpl<NumberOfRegions> type; - }; -}; -struct AlwaysHistory -{ - typedef int history_policy; - template <int NumberOfRegions> - struct apply - { - typedef AlwaysHistoryImpl<NumberOfRegions> type; - }; -}; -template <class Events> -struct ShallowHistory -{ - typedef int history_policy; - template <int NumberOfRegions> - struct apply - { - typedef ShallowHistoryImpl<Events,NumberOfRegions> type; - }; -}; -} } }//boost::msm::back -#endif //BOOST_MSM_BACK_HISTORY_POLICIES_H diff --git a/contrib/restricted/boost/boost/msm/back/metafunctions.hpp b/contrib/restricted/boost/boost/msm/back/metafunctions.hpp deleted file mode 100644 index ae06b08ff51..00000000000 --- a/contrib/restricted/boost/boost/msm/back/metafunctions.hpp +++ /dev/null @@ -1,977 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_BACK_METAFUNCTIONS_H -#define BOOST_MSM_BACK_METAFUNCTIONS_H - -#include <boost/mpl/set.hpp> -#include <boost/mpl/at.hpp> -#include <boost/mpl/pair.hpp> -#include <boost/mpl/map.hpp> -#include <boost/mpl/int.hpp> -#include <boost/mpl/has_xxx.hpp> -#include <boost/mpl/find.hpp> -#include <boost/mpl/count_if.hpp> -#include <boost/mpl/fold.hpp> -#include <boost/mpl/if.hpp> -#include <boost/mpl/has_key.hpp> -#include <boost/mpl/insert.hpp> -#include <boost/mpl/next_prior.hpp> -#include <boost/mpl/map.hpp> -#include <boost/mpl/push_back.hpp> -#include <boost/mpl/vector.hpp> -#include <boost/mpl/is_sequence.hpp> -#include <boost/mpl/size.hpp> -#include <boost/mpl/transform.hpp> -#include <boost/mpl/begin_end.hpp> -#include <boost/mpl/bool.hpp> -#include <boost/mpl/empty.hpp> -#include <boost/mpl/identity.hpp> -#include <boost/mpl/eval_if.hpp> -#include <boost/mpl/insert_range.hpp> -#include <boost/mpl/front.hpp> -#include <boost/mpl/logical.hpp> -#include <boost/mpl/plus.hpp> -#include <boost/mpl/copy_if.hpp> -#include <boost/mpl/back_inserter.hpp> -#include <boost/mpl/transform.hpp> - -#include <boost/type_traits/is_same.hpp> -#include <boost/utility/enable_if.hpp> - -#include <boost/msm/row_tags.hpp> - -// mpl_graph graph implementation and depth first search -#include <boost/msm/mpl_graph/incidence_list_graph.hpp> -#include <boost/msm/mpl_graph/depth_first_search.hpp> - -BOOST_MPL_HAS_XXX_TRAIT_DEF(explicit_creation) -BOOST_MPL_HAS_XXX_TRAIT_DEF(pseudo_entry) -BOOST_MPL_HAS_XXX_TRAIT_DEF(pseudo_exit) -BOOST_MPL_HAS_XXX_TRAIT_DEF(concrete_exit_state) -BOOST_MPL_HAS_XXX_TRAIT_DEF(composite_tag) -BOOST_MPL_HAS_XXX_TRAIT_DEF(not_real_row_tag) -BOOST_MPL_HAS_XXX_TRAIT_DEF(event_blocking_flag) -BOOST_MPL_HAS_XXX_TRAIT_DEF(explicit_entry_state) -BOOST_MPL_HAS_XXX_TRAIT_DEF(completion_event) -BOOST_MPL_HAS_XXX_TRAIT_DEF(no_exception_thrown) -BOOST_MPL_HAS_XXX_TRAIT_DEF(no_message_queue) -BOOST_MPL_HAS_XXX_TRAIT_DEF(activate_deferred_events) -BOOST_MPL_HAS_XXX_TRAIT_DEF(wrapped_entry) -BOOST_MPL_HAS_XXX_TRAIT_DEF(active_state_switch_policy) - -namespace boost { namespace msm { namespace back -{ -template <typename Sequence, typename Range> -struct set_insert_range -{ - typedef typename ::boost::mpl::fold< - Range,Sequence, - ::boost::mpl::insert< ::boost::mpl::placeholders::_1, ::boost::mpl::placeholders::_2 > - >::type type; -}; - -// returns the current state type of a transition -template <class Transition> -struct transition_source_type -{ - typedef typename Transition::current_state_type type; -}; - -// returns the target state type of a transition -template <class Transition> -struct transition_target_type -{ - typedef typename Transition::next_state_type type; -}; - -// helper functions for generate_state_ids -// create a pair of a state and a passed id for source and target states -template <class Id,class Transition> -struct make_pair_source_state_id -{ - typedef typename ::boost::mpl::pair<typename Transition::current_state_type,Id> type; -}; -template <class Id,class Transition> -struct make_pair_target_state_id -{ - typedef typename ::boost::mpl::pair<typename Transition::next_state_type,Id> type; -}; - -// iterates through a transition table and automatically generates ids starting at 0 -// first the source states, transition up to down -// then the target states, up to down -template <class stt> -struct generate_state_ids -{ - typedef typename - ::boost::mpl::fold< - stt,::boost::mpl::pair< ::boost::mpl::map< >, ::boost::mpl::int_<0> >, - ::boost::mpl::pair< - ::boost::mpl::if_< - ::boost::mpl::has_key< ::boost::mpl::first< ::boost::mpl::placeholders::_1>, - transition_source_type< ::boost::mpl::placeholders::_2> >, - ::boost::mpl::first< ::boost::mpl::placeholders::_1>, - ::boost::mpl::insert< ::boost::mpl::first<mpl::placeholders::_1>, - make_pair_source_state_id< ::boost::mpl::second< ::boost::mpl::placeholders::_1 >, - ::boost::mpl::placeholders::_2> > - >, - ::boost::mpl::if_< - ::boost::mpl::has_key< ::boost::mpl::first< ::boost::mpl::placeholders::_1>, - transition_source_type< ::boost::mpl::placeholders::_2> >, - ::boost::mpl::second< ::boost::mpl::placeholders::_1 >, - ::boost::mpl::next< ::boost::mpl::second<mpl::placeholders::_1 > > - > - > //pair - >::type source_state_ids; - typedef typename ::boost::mpl::first<source_state_ids>::type source_state_map; - typedef typename ::boost::mpl::second<source_state_ids>::type highest_state_id; - - - typedef typename - ::boost::mpl::fold< - stt,::boost::mpl::pair<source_state_map,highest_state_id >, - ::boost::mpl::pair< - ::boost::mpl::if_< - ::boost::mpl::has_key< ::boost::mpl::first< ::boost::mpl::placeholders::_1>, - transition_target_type< ::boost::mpl::placeholders::_2> >, - ::boost::mpl::first< ::boost::mpl::placeholders::_1>, - ::boost::mpl::insert< ::boost::mpl::first< ::boost::mpl::placeholders::_1>, - make_pair_target_state_id< ::boost::mpl::second< ::boost::mpl::placeholders::_1 >, - ::boost::mpl::placeholders::_2> > - >, - ::boost::mpl::if_< - ::boost::mpl::has_key< ::boost::mpl::first< ::boost::mpl::placeholders::_1>, - transition_target_type< ::boost::mpl::placeholders::_2> >, - ::boost::mpl::second< ::boost::mpl::placeholders::_1 >, - ::boost::mpl::next< ::boost::mpl::second< ::boost::mpl::placeholders::_1 > > - > - > //pair - >::type all_state_ids; - typedef typename ::boost::mpl::first<all_state_ids>::type type; -}; - -template <class Fsm> -struct get_active_state_switch_policy_helper -{ - typedef typename Fsm::active_state_switch_policy type; -}; -template <class Iter> -struct get_active_state_switch_policy_helper2 -{ - typedef typename boost::mpl::deref<Iter>::type Fsm; - typedef typename Fsm::active_state_switch_policy type; -}; -// returns the active state switching policy -template <class Fsm> -struct get_active_state_switch_policy -{ - typedef typename ::boost::mpl::find_if< - typename Fsm::configuration, - has_active_state_switch_policy< ::boost::mpl::placeholders::_1 > >::type iter; - - typedef typename ::boost::mpl::eval_if< - typename ::boost::is_same< - iter, - typename ::boost::mpl::end<typename Fsm::configuration>::type - >::type, - get_active_state_switch_policy_helper<Fsm>, - get_active_state_switch_policy_helper2< iter > - >::type type; -}; - -// returns the id of a given state -template <class stt,class State> -struct get_state_id -{ - typedef typename ::boost::mpl::at<typename generate_state_ids<stt>::type,State>::type type; - enum {value = type::value}; -}; - -// returns a mpl::vector containing the init states of a state machine -template <class States> -struct get_initial_states -{ - typedef typename ::boost::mpl::if_< - ::boost::mpl::is_sequence<States>, - States, - typename ::boost::mpl::push_back< ::boost::mpl::vector0<>,States>::type >::type type; -}; -// returns a mpl::int_ containing the size of a region. If the argument is not a sequence, returns 1 -template <class region> -struct get_number_of_regions -{ - typedef typename mpl::if_< - ::boost::mpl::is_sequence<region>, - ::boost::mpl::size<region>, - ::boost::mpl::int_<1> >::type type; -}; - -// builds a mpl::vector of initial states -//TODO remove duplicate from get_initial_states -template <class region> -struct get_regions_as_sequence -{ - typedef typename ::boost::mpl::if_< - ::boost::mpl::is_sequence<region>, - region, - typename ::boost::mpl::push_back< ::boost::mpl::vector0<>,region>::type >::type type; -}; - -template <class ToCreateSeq> -struct get_explicit_creation_as_sequence -{ - typedef typename ::boost::mpl::if_< - ::boost::mpl::is_sequence<ToCreateSeq>, - ToCreateSeq, - typename ::boost::mpl::push_back< ::boost::mpl::vector0<>,ToCreateSeq>::type >::type type; -}; - -// returns true if 2 transitions have the same source (used to remove duplicates in search of composite states) -template <class stt,class Transition1,class Transition2> -struct have_same_source -{ - enum {current_state1 = get_state_id<stt,typename Transition1::current_state_type >::type::value}; - enum {current_state2 = get_state_id<stt,typename Transition2::current_state_type >::type::value}; - enum {value = ((int)current_state1 == (int)current_state2) }; -}; - - -// A metafunction that returns the Event associated with a transition. -template <class Transition> -struct transition_event -{ - typedef typename Transition::transition_event type; -}; - -// returns true for composite states -template <class State> -struct is_composite_state -{ - enum {value = has_composite_tag<State>::type::value}; - typedef typename has_composite_tag<State>::type type; -}; - -// transform a transition table in a container of source states -template <class stt> -struct keep_source_names -{ - // instead of the rows we want only the names of the states (from source) - typedef typename - ::boost::mpl::transform< - stt,transition_source_type< ::boost::mpl::placeholders::_1> >::type type; -}; - -// transform a transition table in a container of target states -template <class stt> -struct keep_target_names -{ - // instead of the rows we want only the names of the states (from source) - typedef typename - ::boost::mpl::transform< - stt,transition_target_type< ::boost::mpl::placeholders::_1> >::type type; -}; - -template <class stt> -struct generate_state_set -{ - // keep in the original transition table only the source/target state types - typedef typename keep_source_names<stt>::type sources; - typedef typename keep_target_names<stt>::type targets; - typedef typename - ::boost::mpl::fold< - sources, ::boost::mpl::set<>, - ::boost::mpl::insert< ::boost::mpl::placeholders::_1, ::boost::mpl::placeholders::_2> - >::type source_set; - typedef typename - ::boost::mpl::fold< - targets,source_set, - ::boost::mpl::insert< ::boost::mpl::placeholders::_1, ::boost::mpl::placeholders::_2> - >::type type; -}; - -// iterates through the transition table and generate a mpl::set<> containing all the events -template <class stt> -struct generate_event_set -{ - typedef typename - ::boost::mpl::fold< - stt, ::boost::mpl::set<>, - ::boost::mpl::if_< - ::boost::mpl::has_key< ::boost::mpl::placeholders::_1, - transition_event< ::boost::mpl::placeholders::_2> >, - ::boost::mpl::placeholders::_1, - ::boost::mpl::insert< ::boost::mpl::placeholders::_1, - transition_event< ::boost::mpl::placeholders::_2> > > - >::type type; -}; - -// returns a mpl::bool_<true> if State has Event as deferred event -template <class State, class Event> -struct has_state_delayed_event -{ - typedef typename ::boost::mpl::find<typename State::deferred_events,Event>::type found; - typedef typename ::boost::mpl::if_< - ::boost::is_same<found,typename ::boost::mpl::end<typename State::deferred_events>::type >, - ::boost::mpl::bool_<false>, - ::boost::mpl::bool_<true> >::type type; -}; -// returns a mpl::bool_<true> if State has any deferred event -template <class State> -struct has_state_delayed_events -{ - typedef typename ::boost::mpl::if_< - ::boost::mpl::empty<typename State::deferred_events>, - ::boost::mpl::bool_<false>, - ::boost::mpl::bool_<true> >::type type; -}; - -// Template used to create dummy entries for initial states not found in the stt. -template< typename T1 > -struct not_a_row -{ - typedef int not_real_row_tag; - struct dummy_event - { - }; - typedef T1 current_state_type; - typedef T1 next_state_type; - typedef dummy_event transition_event; -}; - -// metafunctions used to find out if a state is entry, exit or something else -template <class State> -struct is_pseudo_entry -{ - typedef typename ::boost::mpl::if_< typename has_pseudo_entry<State>::type, - ::boost::mpl::bool_<true>,::boost::mpl::bool_<false> - >::type type; -}; -// says if a state is an exit pseudo state -template <class State> -struct is_pseudo_exit -{ - typedef typename ::boost::mpl::if_< typename has_pseudo_exit<State>::type, - ::boost::mpl::bool_<true>, ::boost::mpl::bool_<false> - >::type type; -}; -// says if a state is an entry pseudo state or an explicit entry -template <class State> -struct is_direct_entry -{ - typedef typename ::boost::mpl::if_< typename has_explicit_entry_state<State>::type, - ::boost::mpl::bool_<true>, ::boost::mpl::bool_<false> - >::type type; -}; - -//converts a "fake" (simulated in a state_machine_ description )state into one which will really get created -template <class StateType,class CompositeType> -struct convert_fake_state -{ - // converts a state (explicit entry) into the state we really are going to create (explicit<>) - typedef typename ::boost::mpl::if_< - typename is_direct_entry<StateType>::type, - typename CompositeType::template direct<StateType>, - typename ::boost::mpl::identity<StateType>::type - >::type type; -}; - -template <class StateType> -struct get_explicit_creation -{ - typedef typename StateType::explicit_creation type; -}; - -template <class StateType> -struct get_wrapped_entry -{ - typedef typename StateType::wrapped_entry type; -}; -// used for states created with explicit_creation -// if the state is an explicit entry, we reach for the wrapped state -// otherwise, this returns the state itself -template <class StateType> -struct get_wrapped_state -{ - typedef typename ::boost::mpl::eval_if< - typename has_wrapped_entry<StateType>::type, - get_wrapped_entry<StateType>, - ::boost::mpl::identity<StateType> >::type type; -}; - -template <class Derived> -struct create_stt -{ - //typedef typename Derived::transition_table stt; - typedef typename Derived::real_transition_table Stt; - // get the state set - typedef typename generate_state_set<Stt>::type states; - // transform the initial region(s) in a sequence - typedef typename get_regions_as_sequence<typename Derived::initial_state>::type init_states; - // iterate through the initial states and add them in the stt if not already there - typedef typename - ::boost::mpl::fold< - init_states,Stt, - ::boost::mpl::if_< - ::boost::mpl::has_key<states, ::boost::mpl::placeholders::_2>, - ::boost::mpl::placeholders::_1, - ::boost::mpl::insert< ::boost::mpl::placeholders::_1, ::boost::mpl::end< ::boost::mpl::placeholders::_1>, - not_a_row< get_wrapped_state< ::boost::mpl::placeholders::_2> > > - > - >::type with_init; - // do the same for states marked as explicitly created - typedef typename get_explicit_creation_as_sequence< - typename ::boost::mpl::eval_if< - typename has_explicit_creation<Derived>::type, - get_explicit_creation<Derived>, - ::boost::mpl::vector0<> >::type - >::type fake_explicit_created; - - typedef typename - ::boost::mpl::transform< - fake_explicit_created,convert_fake_state< ::boost::mpl::placeholders::_1,Derived> >::type explicit_created; - - typedef typename - ::boost::mpl::fold< - explicit_created,with_init, - ::boost::mpl::if_< - ::boost::mpl::has_key<states, ::boost::mpl::placeholders::_2>, - ::boost::mpl::placeholders::_1, - ::boost::mpl::insert< ::boost::mpl::placeholders::_1, ::boost::mpl::end<mpl::placeholders::_1>, - not_a_row< get_wrapped_state< ::boost::mpl::placeholders::_2> > > - > - >::type type; -}; - -// returns the transition table of a Composite state -template <class Composite> -struct get_transition_table -{ - typedef typename create_stt<Composite>::type type; -}; - -// recursively builds an internal table including those of substates, sub-substates etc. -// variant for submachines -template <class StateType,class IsComposite> -struct recursive_get_internal_transition_table -{ - // get the composite's internal table - typedef typename StateType::internal_transition_table composite_table; - // and for every substate (state of submachine), recursively get the internal transition table - typedef typename generate_state_set<typename StateType::stt>::type composite_states; - typedef typename ::boost::mpl::fold< - composite_states, composite_table, - ::boost::mpl::insert_range< ::boost::mpl::placeholders::_1, ::boost::mpl::end< ::boost::mpl::placeholders::_1>, - recursive_get_internal_transition_table< ::boost::mpl::placeholders::_2, is_composite_state< ::boost::mpl::placeholders::_2> > - > - >::type type; -}; -// stop iterating on leafs (simple states) -template <class StateType> -struct recursive_get_internal_transition_table<StateType, ::boost::mpl::false_ > -{ - typedef typename StateType::internal_transition_table type; -}; -// recursively get a transition table for a given composite state. -// returns the transition table for this state + the tables of all composite sub states recursively -template <class Composite> -struct recursive_get_transition_table -{ - // get the transition table of the state if it's a state machine - typedef typename ::boost::mpl::eval_if<typename is_composite_state<Composite>::type, - get_transition_table<Composite>, - ::boost::mpl::vector0<> - >::type org_table; - - typedef typename generate_state_set<org_table>::type states; - - // and for every substate, recursively get the transition table if it's a state machine - typedef typename ::boost::mpl::fold< - states,org_table, - ::boost::mpl::insert_range< ::boost::mpl::placeholders::_1, ::boost::mpl::end<mpl::placeholders::_1>, - recursive_get_transition_table< ::boost::mpl::placeholders::_2 > > - >::type type; - -}; - -// metafunction used to say if a SM has pseudo exit states -template <class Derived> -struct has_fsm_deferred_events -{ - typedef typename create_stt<Derived>::type Stt; - typedef typename generate_state_set<Stt>::type state_list; - - typedef typename ::boost::mpl::or_< - typename has_activate_deferred_events<Derived>::type, - ::boost::mpl::bool_< ::boost::mpl::count_if< - typename Derived::configuration, - has_activate_deferred_events< ::boost::mpl::placeholders::_1 > >::value != 0> - >::type found_in_fsm; - - typedef typename ::boost::mpl::or_< - found_in_fsm, - ::boost::mpl::bool_< ::boost::mpl::count_if< - state_list,has_state_delayed_events< - ::boost::mpl::placeholders::_1 > >::value != 0> - >::type type; -}; - -// returns a mpl::bool_<true> if State has any delayed event -template <class Event> -struct is_completion_event -{ - typedef typename ::boost::mpl::if_< - has_completion_event<Event>, - ::boost::mpl::bool_<true>, - ::boost::mpl::bool_<false> >::type type; -}; -// metafunction used to say if a SM has eventless transitions -template <class Derived> -struct has_fsm_eventless_transition -{ - typedef typename create_stt<Derived>::type Stt; - typedef typename generate_event_set<Stt>::type event_list; - - typedef ::boost::mpl::bool_< ::boost::mpl::count_if< - event_list,is_completion_event< ::boost::mpl::placeholders::_1 > >::value != 0> type; -}; -template <class Derived> -struct find_completion_events -{ - typedef typename create_stt<Derived>::type Stt; - typedef typename generate_event_set<Stt>::type event_list; - - typedef typename ::boost::mpl::fold< - event_list, ::boost::mpl::set<>, - ::boost::mpl::if_< - is_completion_event< ::boost::mpl::placeholders::_2>, - ::boost::mpl::insert< ::boost::mpl::placeholders::_1, ::boost::mpl::placeholders::_2 >, - ::boost::mpl::placeholders::_1 > - >::type type; -}; - -template <class Transition> -struct make_vector -{ - typedef ::boost::mpl::vector<Transition> type; -}; -template< typename Entry > -struct get_first_element_pair_second -{ - typedef typename ::boost::mpl::front<typename Entry::second>::type type; -}; - - //returns the owner of an explicit_entry state - //which is the containing SM if the transition originates from outside the containing SM - //or else the explicit_entry state itself -template <class State,class ContainingSM> -struct get_owner -{ - typedef typename ::boost::mpl::if_< - typename ::boost::mpl::not_<typename ::boost::is_same<typename State::owner, - ContainingSM >::type>::type, - typename State::owner, - State >::type type; -}; - -template <class Sequence,class ContainingSM> -struct get_fork_owner -{ - typedef typename ::boost::mpl::front<Sequence>::type seq_front; - typedef typename ::boost::mpl::if_< - typename ::boost::mpl::not_< - typename ::boost::is_same<typename seq_front::owner,ContainingSM>::type>::type, - typename seq_front::owner, - seq_front >::type type; -}; - -template <class StateType,class ContainingSM> -struct make_exit -{ - typedef typename ::boost::mpl::if_< - typename is_pseudo_exit<StateType>::type , - typename ContainingSM::template exit_pt<StateType>, - typename ::boost::mpl::identity<StateType>::type - >::type type; -}; - -template <class StateType,class ContainingSM> -struct make_entry -{ - typedef typename ::boost::mpl::if_< - typename is_pseudo_entry<StateType>::type , - typename ContainingSM::template entry_pt<StateType>, - typename ::boost::mpl::if_< - typename is_direct_entry<StateType>::type, - typename ContainingSM::template direct<StateType>, - typename ::boost::mpl::identity<StateType>::type - >::type - >::type type; -}; -// metafunction used to say if a SM has pseudo exit states -template <class StateType> -struct has_exit_pseudo_states_helper -{ - typedef typename StateType::stt Stt; - typedef typename generate_state_set<Stt>::type state_list; - - typedef ::boost::mpl::bool_< ::boost::mpl::count_if< - state_list,is_pseudo_exit< ::boost::mpl::placeholders::_1> >::value != 0> type; -}; -template <class StateType> -struct has_exit_pseudo_states -{ - typedef typename ::boost::mpl::eval_if<typename is_composite_state<StateType>::type, - has_exit_pseudo_states_helper<StateType>, - ::boost::mpl::bool_<false> >::type type; -}; - -// builds flags (add internal_flag_list and flag_list). internal_flag_list is used for terminate/interrupt states -template <class StateType> -struct get_flag_list -{ - typedef typename ::boost::mpl::insert_range< - typename StateType::flag_list, - typename ::boost::mpl::end< typename StateType::flag_list >::type, - typename StateType::internal_flag_list - >::type type; -}; - -template <class StateType> -struct is_state_blocking -{ - typedef typename ::boost::mpl::fold< - typename get_flag_list<StateType>::type, ::boost::mpl::set<>, - ::boost::mpl::if_< - has_event_blocking_flag< ::boost::mpl::placeholders::_2>, - ::boost::mpl::insert< ::boost::mpl::placeholders::_1, ::boost::mpl::placeholders::_2 >, - ::boost::mpl::placeholders::_1 > - >::type blocking_flags; - - typedef typename ::boost::mpl::if_< - ::boost::mpl::empty<blocking_flags>, - ::boost::mpl::bool_<false>, - ::boost::mpl::bool_<true> >::type type; -}; -// returns a mpl::bool_<true> if fsm has an event blocking flag in one of its substates -template <class StateType> -struct has_fsm_blocking_states -{ - typedef typename create_stt<StateType>::type Stt; - typedef typename generate_state_set<Stt>::type state_list; - - typedef typename ::boost::mpl::fold< - state_list, ::boost::mpl::set<>, - ::boost::mpl::if_< - is_state_blocking< ::boost::mpl::placeholders::_2>, - ::boost::mpl::insert< ::boost::mpl::placeholders::_1, ::boost::mpl::placeholders::_2 >, - ::boost::mpl::placeholders::_1 > - >::type blocking_states; - - typedef typename ::boost::mpl::if_< - ::boost::mpl::empty<blocking_states>, - ::boost::mpl::bool_<false>, - ::boost::mpl::bool_<true> >::type type; -}; - -template <class StateType> -struct is_no_exception_thrown -{ - typedef ::boost::mpl::bool_< ::boost::mpl::count_if< - typename StateType::configuration, - has_no_exception_thrown< ::boost::mpl::placeholders::_1 > >::value != 0> found; - - typedef typename ::boost::mpl::or_< - typename has_no_exception_thrown<StateType>::type, - found - >::type type; -}; - -template <class StateType> -struct is_no_message_queue -{ - typedef ::boost::mpl::bool_< ::boost::mpl::count_if< - typename StateType::configuration, - has_no_message_queue< ::boost::mpl::placeholders::_1 > >::value != 0> found; - - typedef typename ::boost::mpl::or_< - typename has_no_message_queue<StateType>::type, - found - >::type type; -}; - -template <class StateType> -struct is_active_state_switch_policy -{ - typedef ::boost::mpl::bool_< ::boost::mpl::count_if< - typename StateType::configuration, - has_active_state_switch_policy< ::boost::mpl::placeholders::_1 > >::value != 0> found; - - typedef typename ::boost::mpl::or_< - typename has_active_state_switch_policy<StateType>::type, - found - >::type type; -}; - -template <class StateType> -struct get_initial_event -{ - typedef typename StateType::initial_event type; -}; - -template <class StateType> -struct get_final_event -{ - typedef typename StateType::final_event type; -}; - -template <class TransitionTable, class InitState> -struct build_one_orthogonal_region -{ - template<typename Row> - struct row_to_incidence : - ::boost::mpl::vector< - ::boost::mpl::pair< - typename Row::next_state_type, - typename Row::transition_event>, - typename Row::current_state_type, - typename Row::next_state_type - > {}; - - template <class Seq, class Elt> - struct transition_incidence_list_helper - { - typedef typename ::boost::mpl::push_back< Seq, row_to_incidence< Elt > >::type type; - }; - - typedef typename ::boost::mpl::fold< - TransitionTable, - ::boost::mpl::vector<>, - transition_incidence_list_helper< ::boost::mpl::placeholders::_1, ::boost::mpl::placeholders::_2> - >::type transition_incidence_list; - - typedef ::boost::msm::mpl_graph::incidence_list_graph<transition_incidence_list> - transition_graph; - - struct preordering_dfs_visitor : - ::boost::msm::mpl_graph::dfs_default_visitor_operations - { - template<typename Node, typename Graph, typename State> - struct discover_vertex : - ::boost::mpl::insert<State, Node> - {}; - }; - - typedef typename mpl::first< - typename ::boost::msm::mpl_graph::depth_first_search< - transition_graph, - preordering_dfs_visitor, - ::boost::mpl::set<>, - InitState - >::type - >::type type; -}; - -template <class Fsm> -struct find_entry_states -{ - typedef typename ::boost::mpl::copy< - typename Fsm::substate_list, - ::boost::mpl::inserter< - ::boost::mpl::set0<>, - ::boost::mpl::if_< - has_explicit_entry_state< ::boost::mpl::placeholders::_2 >, - ::boost::mpl::insert< ::boost::mpl::placeholders::_1, ::boost::mpl::placeholders::_2>, - ::boost::mpl::placeholders::_1 - > - > - >::type type; -}; - -template <class Set1, class Set2> -struct is_common_element -{ - typedef typename ::boost::mpl::fold< - Set1, ::boost::mpl::false_, - ::boost::mpl::if_< - ::boost::mpl::has_key< - Set2, - ::boost::mpl::placeholders::_2 - >, - ::boost::mpl::true_, - ::boost::mpl::placeholders::_1 - > - >::type type; -}; - -template <class EntryRegion, class AllRegions> -struct add_entry_region -{ - typedef typename ::boost::mpl::transform< - AllRegions, - ::boost::mpl::if_< - is_common_element<EntryRegion, ::boost::mpl::placeholders::_1>, - set_insert_range< ::boost::mpl::placeholders::_1, EntryRegion>, - ::boost::mpl::placeholders::_1 - > - >::type type; -}; - -// build a vector of regions states (as a set) -// one set of states for every region -template <class Fsm, class InitStates> -struct build_orthogonal_regions -{ - typedef typename - ::boost::mpl::fold< - InitStates, ::boost::mpl::vector0<>, - ::boost::mpl::push_back< - ::boost::mpl::placeholders::_1, - build_one_orthogonal_region< typename Fsm::stt, ::boost::mpl::placeholders::_2 > > - >::type without_entries; - - typedef typename - ::boost::mpl::fold< - typename find_entry_states<Fsm>::type, ::boost::mpl::vector0<>, - ::boost::mpl::push_back< - ::boost::mpl::placeholders::_1, - build_one_orthogonal_region< typename Fsm::stt, ::boost::mpl::placeholders::_2 > > - >::type only_entries; - - typedef typename ::boost::mpl::fold< - only_entries , without_entries, - add_entry_region< ::boost::mpl::placeholders::_2, ::boost::mpl::placeholders::_1> - >::type type; -}; - -template <class GraphAsSeqOfSets, class StateType> -struct find_region_index -{ - typedef typename - ::boost::mpl::fold< - GraphAsSeqOfSets, ::boost::mpl::pair< ::boost::mpl::int_< -1 > /*res*/, ::boost::mpl::int_<0> /*counter*/ >, - ::boost::mpl::if_< - ::boost::mpl::has_key< ::boost::mpl::placeholders::_2, StateType >, - ::boost::mpl::pair< - ::boost::mpl::second< ::boost::mpl::placeholders::_1 >, - ::boost::mpl::next< ::boost::mpl::second< ::boost::mpl::placeholders::_1 > > - >, - ::boost::mpl::pair< - ::boost::mpl::first< ::boost::mpl::placeholders::_1 >, - ::boost::mpl::next< ::boost::mpl::second< ::boost::mpl::placeholders::_1 > > - > - > - >::type result_pair; - typedef typename ::boost::mpl::first<result_pair>::type type; - enum {value = type::value}; -}; - -template <class Fsm> -struct check_regions_orthogonality -{ - typedef typename build_orthogonal_regions< Fsm,typename Fsm::initial_states>::type regions; - - typedef typename ::boost::mpl::fold< - regions, ::boost::mpl::int_<0>, - ::boost::mpl::plus< ::boost::mpl::placeholders::_1 , ::boost::mpl::size< ::boost::mpl::placeholders::_2> > - >::type number_of_states_in_regions; - - typedef typename ::boost::mpl::fold< - regions,mpl::set0<>, - set_insert_range< - ::boost::mpl::placeholders::_1, - ::boost::mpl::placeholders::_2 > - >::type one_big_states_set; - - enum {states_in_regions_raw = number_of_states_in_regions::value}; - enum {cumulated_states_in_regions_raw = ::boost::mpl::size<one_big_states_set>::value}; -}; - -template <class Fsm> -struct check_no_unreachable_state -{ - typedef typename check_regions_orthogonality<Fsm>::one_big_states_set states_in_regions; - - typedef typename set_insert_range< - states_in_regions, - typename ::boost::mpl::eval_if< - typename has_explicit_creation<Fsm>::type, - get_explicit_creation<Fsm>, - ::boost::mpl::vector0<> - >::type - >::type with_explicit_creation; - - enum {states_in_fsm = ::boost::mpl::size< typename Fsm::substate_list >::value}; - enum {cumulated_states_in_regions = ::boost::mpl::size< with_explicit_creation >::value}; -}; - -// helper to find out if a SM has an active exit state and is therefore waiting for exiting -template <class StateType,class OwnerFct,class FSM> -inline -typename ::boost::enable_if<typename ::boost::mpl::and_<typename is_composite_state<FSM>::type, - typename is_pseudo_exit<StateType>::type>,bool >::type -is_exit_state_active(FSM& fsm) -{ - typedef typename OwnerFct::type Composite; - //typedef typename create_stt<Composite>::type stt; - typedef typename Composite::stt stt; - int state_id = get_state_id<stt,StateType>::type::value; - Composite& comp = fsm.template get_state<Composite&>(); - return (std::find(comp.current_state(),comp.current_state()+Composite::nr_regions::value,state_id) - !=comp.current_state()+Composite::nr_regions::value); -} -template <class StateType,class OwnerFct,class FSM> -inline -typename ::boost::disable_if<typename ::boost::mpl::and_<typename is_composite_state<FSM>::type, - typename is_pseudo_exit<StateType>::type>,bool >::type -is_exit_state_active(FSM&) -{ - return false; -} - -// transformation metafunction to end interrupt flags -template <class Event> -struct transform_to_end_interrupt -{ - typedef boost::msm::EndInterruptFlag<Event> type; -}; -// transform a sequence of events into another one of EndInterruptFlag<Event> -template <class Events> -struct apply_end_interrupt_flag -{ - typedef typename - ::boost::mpl::transform< - Events,transform_to_end_interrupt< ::boost::mpl::placeholders::_1> >::type type; -}; -// returns a mpl vector containing all end interrupt events if sequence, otherwise the same event -template <class Event> -struct get_interrupt_events -{ - typedef typename ::boost::mpl::eval_if< - ::boost::mpl::is_sequence<Event>, - boost::msm::back::apply_end_interrupt_flag<Event>, - boost::mpl::vector1<boost::msm::EndInterruptFlag<Event> > >::type type; -}; - -template <class Events> -struct build_interrupt_state_flag_list -{ - typedef ::boost::mpl::vector<boost::msm::InterruptedFlag> first_part; - typedef typename ::boost::mpl::insert_range< - first_part, - typename ::boost::mpl::end< first_part >::type, - Events - >::type type; -}; - -} } }//boost::msm::back - -#endif // BOOST_MSM_BACK_METAFUNCTIONS_H - diff --git a/contrib/restricted/boost/boost/msm/back/mpl_graph_fsm_check.hpp b/contrib/restricted/boost/boost/msm/back/mpl_graph_fsm_check.hpp deleted file mode 100644 index 86a36b408f9..00000000000 --- a/contrib/restricted/boost/boost/msm/back/mpl_graph_fsm_check.hpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_BACK_MPL_GRAPH_FSM_CHECK_H -#define BOOST_MSM_BACK_MPL_GRAPH_FSM_CHECK_H - -#include <boost/mpl/assert.hpp> - -#include <boost/msm/back/metafunctions.hpp> - -namespace boost { namespace msm { namespace back -{ - struct mpl_graph_fsm_check - { - typedef int fsm_check; - // checks that regions are truly orthogonal (one state belongs to 1 region) - // using the mpl_graph library (part of metagraph) - template <class Fsm> - static void check_orthogonality() - { - BOOST_MPL_ASSERT_RELATION( ::boost::msm::back::check_regions_orthogonality<Fsm>::states_in_regions_raw, - ==, - ::boost::msm::back::check_regions_orthogonality<Fsm>::cumulated_states_in_regions_raw ); - - } - // checks that all states are reachable or created using the explicit_creation typedef - // using the mpl_graph library (part of metagraph) - template <class Fsm> - static void check_unreachable_states() - { - BOOST_MPL_ASSERT_RELATION( ::boost::msm::back::check_no_unreachable_state<Fsm>::states_in_fsm, - ==, - ::boost::msm::back::check_no_unreachable_state<Fsm>::cumulated_states_in_regions ); - - } - }; - -} } }//boost::msm::back - - -#endif //BOOST_MSM_BACK_MPL_GRAPH_FSM_CHECK_H diff --git a/contrib/restricted/boost/boost/msm/back/no_fsm_check.hpp b/contrib/restricted/boost/boost/msm/back/no_fsm_check.hpp deleted file mode 100644 index 1f989de08de..00000000000 --- a/contrib/restricted/boost/boost/msm/back/no_fsm_check.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_BACK_NO_FSM_CHECK_H -#define BOOST_MSM_BACK_NO_FSM_CHECK_H - -#include <boost/mpl/assert.hpp> - -#include <boost/msm/back/metafunctions.hpp> - -namespace boost { namespace msm { namespace back -{ - struct no_fsm_check - { - typedef int fsm_check; - // no fsm structure checking - template <class Fsm> - static void check_orthogonality() - { - } - template <class Fsm> - static void check_unreachable_states() - { - } - }; - -} } }//boost::msm::back - - -#endif //BOOST_MSM_BACK_NO_FSM_CHECK_H diff --git a/contrib/restricted/boost/boost/msm/back/queue_container_circular.hpp b/contrib/restricted/boost/boost/msm/back/queue_container_circular.hpp deleted file mode 100644 index 8ad3fa5d157..00000000000 --- a/contrib/restricted/boost/boost/msm/back/queue_container_circular.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_BACK_QUEUE_CONTAINER_CIRCULAR_H -#define BOOST_MSM_BACK_QUEUE_CONTAINER_CIRCULAR_H - -#include <boost/circular_buffer.hpp> - -namespace boost { namespace msm { namespace back -{ - struct queue_container_circular - { - typedef int queue_container_policy; - - template <class Element> - struct In - { - typedef typename boost::circular_buffer<Element> type; - }; - }; - -} } }//boost::msm::back - - -#endif //BOOST_MSM_BACK_QUEUE_CONTAINER_CIRCULAR_H diff --git a/contrib/restricted/boost/boost/msm/back/queue_container_deque.hpp b/contrib/restricted/boost/boost/msm/back/queue_container_deque.hpp deleted file mode 100644 index b257635be2f..00000000000 --- a/contrib/restricted/boost/boost/msm/back/queue_container_deque.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_BACK_QUEUE_CONTAINER_DEQUE_H -#define BOOST_MSM_BACK_QUEUE_CONTAINER_DEQUE_H - -#include <deque> - -namespace boost { namespace msm { namespace back -{ - struct queue_container_deque - { - typedef int queue_container_policy; - - template <class Element> - struct In - { - typedef typename std::deque<Element> type; - }; - }; - -} } }//boost::msm::back - - -#endif //BOOST_MSM_BACK_QUEUE_CONTAINER_DEQUE_H diff --git a/contrib/restricted/boost/boost/msm/back/state_machine.hpp b/contrib/restricted/boost/boost/msm/back/state_machine.hpp deleted file mode 100644 index 5f9a6fe2996..00000000000 --- a/contrib/restricted/boost/boost/msm/back/state_machine.hpp +++ /dev/null @@ -1,2842 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_BACK_STATEMACHINE_H -#define BOOST_MSM_BACK_STATEMACHINE_H - -#include <exception> -#include <vector> -#include <functional> -#include <numeric> -#include <utility> - -#include <boost/detail/no_exceptions_support.hpp> - -#include <boost/mpl/contains.hpp> -#include <boost/mpl/deref.hpp> -#include <boost/mpl/assert.hpp> - -#include <boost/fusion/container/vector/convert.hpp> -#include <boost/fusion/include/as_vector.hpp> -#include <boost/fusion/include/as_set.hpp> -#include <boost/fusion/container/set.hpp> -#include <boost/fusion/include/set.hpp> -#include <boost/fusion/include/set_fwd.hpp> -#include <boost/fusion/include/mpl.hpp> -#include <boost/fusion/sequence/intrinsic/at_key.hpp> -#include <boost/fusion/include/at_key.hpp> -#include <boost/fusion/algorithm/iteration/for_each.hpp> -#include <boost/fusion/include/for_each.hpp> - -#include <boost/assert.hpp> -#include <boost/ref.hpp> -#include <boost/type_traits.hpp> -#include <boost/utility/enable_if.hpp> -#include <boost/type_traits/is_convertible.hpp> - -#include <boost/bind.hpp> -#include <boost/bind/apply.hpp> -#include <boost/function.hpp> -#ifndef BOOST_NO_RTTI -#include <boost/any.hpp> -#endif - -#include <boost/serialization/base_object.hpp> - -#include <boost/parameter.hpp> - -#include <boost/msm/active_state_switching_policies.hpp> -#include <boost/msm/row_tags.hpp> -#include <boost/msm/msm_grammar.hpp> -#include <boost/msm/back/fold_to_list.hpp> -#include <boost/msm/back/metafunctions.hpp> -#include <boost/msm/back/history_policies.hpp> -#include <boost/msm/back/common_types.hpp> -#include <boost/msm/back/args.hpp> -#include <boost/msm/back/default_compile_policy.hpp> -#include <boost/msm/back/dispatch_table.hpp> -#include <boost/msm/back/no_fsm_check.hpp> -#include <boost/msm/back/queue_container_deque.hpp> - -BOOST_MPL_HAS_XXX_TRAIT_DEF(accept_sig) -BOOST_MPL_HAS_XXX_TRAIT_DEF(no_automatic_create) -BOOST_MPL_HAS_XXX_TRAIT_DEF(non_forwarding_flag) -BOOST_MPL_HAS_XXX_TRAIT_DEF(direct_entry) -BOOST_MPL_HAS_XXX_TRAIT_DEF(initial_event) -BOOST_MPL_HAS_XXX_TRAIT_DEF(final_event) -BOOST_MPL_HAS_XXX_TRAIT_DEF(do_serialize) -BOOST_MPL_HAS_XXX_TRAIT_DEF(history_policy) -BOOST_MPL_HAS_XXX_TRAIT_DEF(fsm_check) -BOOST_MPL_HAS_XXX_TRAIT_DEF(compile_policy) -BOOST_MPL_HAS_XXX_TRAIT_DEF(queue_container_policy) -BOOST_MPL_HAS_XXX_TRAIT_DEF(using_declared_table) - -#ifndef BOOST_MSM_CONSTRUCTOR_ARG_SIZE -#define BOOST_MSM_CONSTRUCTOR_ARG_SIZE 5 // default max number of arguments for constructors -#endif - -namespace boost { namespace msm { namespace back -{ -// event used internally for wrapping a direct entry -template <class StateType,class Event> -struct direct_entry_event -{ - typedef int direct_entry; - typedef StateType active_state; - typedef Event contained_event; - - direct_entry_event(Event const& evt):m_event(evt){} - Event const& m_event; -}; - -// This declares the statically-initialized dispatch_table instance. -template <class Fsm,class Stt, class Event,class CompilePolicy> -const boost::msm::back::dispatch_table<Fsm,Stt, Event,CompilePolicy> -dispatch_table<Fsm,Stt, Event,CompilePolicy>::instance; - -BOOST_PARAMETER_TEMPLATE_KEYWORD(front_end) -BOOST_PARAMETER_TEMPLATE_KEYWORD(history_policy) -BOOST_PARAMETER_TEMPLATE_KEYWORD(compile_policy) -BOOST_PARAMETER_TEMPLATE_KEYWORD(fsm_check_policy) -BOOST_PARAMETER_TEMPLATE_KEYWORD(queue_container_policy) - -typedef ::boost::parameter::parameters< - ::boost::parameter::required< ::boost::msm::back::tag::front_end > - , ::boost::parameter::optional< - ::boost::parameter::deduced< ::boost::msm::back::tag::history_policy>, has_history_policy< ::boost::mpl::_ > - > - , ::boost::parameter::optional< - ::boost::parameter::deduced< ::boost::msm::back::tag::compile_policy>, has_compile_policy< ::boost::mpl::_ > - > - , ::boost::parameter::optional< - ::boost::parameter::deduced< ::boost::msm::back::tag::fsm_check_policy>, has_fsm_check< ::boost::mpl::_ > - > - , ::boost::parameter::optional< - ::boost::parameter::deduced< ::boost::msm::back::tag::queue_container_policy>, - has_queue_container_policy< ::boost::mpl::_ > - > -> state_machine_signature; - -// just here to disable use of proto when not needed -template <class T, class F,class Enable=void> -struct make_euml_terminal; -template <class T,class F> -struct make_euml_terminal<T,F,typename ::boost::disable_if<has_using_declared_table<F> >::type> -{}; -template <class T,class F> -struct make_euml_terminal<T,F,typename ::boost::enable_if<has_using_declared_table<F> >::type> - : public proto::extends<typename proto::terminal< boost::msm::state_tag>::type, T, boost::msm::state_domain> -{}; - -// library-containing class for state machines. Pass the actual FSM class as -// the Concrete parameter. -// A0=Derived,A1=NoHistory,A2=CompilePolicy,A3=FsmCheckPolicy > -template < - class A0 - , class A1 = parameter::void_ - , class A2 = parameter::void_ - , class A3 = parameter::void_ - , class A4 = parameter::void_ -> -class state_machine : //public Derived - public ::boost::parameter::binding< - typename state_machine_signature::bind<A0,A1,A2,A3,A4>::type, ::boost::msm::back::tag::front_end - >::type - , public make_euml_terminal<state_machine<A0,A1,A2,A3,A4>, - typename ::boost::parameter::binding< - typename state_machine_signature::bind<A0,A1,A2,A3,A4>::type, ::boost::msm::back::tag::front_end - >::type - > -{ -public: - // Create ArgumentPack - typedef typename - state_machine_signature::bind<A0,A1,A2,A3,A4>::type - state_machine_args; - - // Extract first logical parameter. - typedef typename ::boost::parameter::binding< - state_machine_args, ::boost::msm::back::tag::front_end>::type Derived; - - typedef typename ::boost::parameter::binding< - state_machine_args, ::boost::msm::back::tag::history_policy, NoHistory >::type HistoryPolicy; - - typedef typename ::boost::parameter::binding< - state_machine_args, ::boost::msm::back::tag::compile_policy, favor_runtime_speed >::type CompilePolicy; - - typedef typename ::boost::parameter::binding< - state_machine_args, ::boost::msm::back::tag::fsm_check_policy, no_fsm_check >::type FsmCheckPolicy; - - typedef typename ::boost::parameter::binding< - state_machine_args, ::boost::msm::back::tag::queue_container_policy, - queue_container_deque >::type QueueContainerPolicy; - -private: - - typedef boost::msm::back::state_machine< - A0,A1,A2,A3,A4> library_sm; - - typedef ::boost::function< - execute_return ()> transition_fct; - typedef ::boost::function< - execute_return () > deferred_fct; - typedef typename QueueContainerPolicy:: - template In< - std::pair<deferred_fct,bool> >::type deferred_events_queue_t; - typedef typename QueueContainerPolicy:: - template In<transition_fct>::type events_queue_t; - - typedef typename boost::mpl::eval_if< - typename is_active_state_switch_policy<Derived>::type, - get_active_state_switch_policy<Derived>, - // default - ::boost::mpl::identity<active_state_switch_after_entry> - >::type active_state_switching; - - typedef bool (*flag_handler)(library_sm const&); - - // all state machines are friend with each other to allow embedding any of them in another fsm - template <class ,class , class, class, class - > friend class boost::msm::back::state_machine; - - // helper to add, if needed, visitors to all states - // version without visitors - template <class StateType,class Enable=void> - struct visitor_fct_helper - { - public: - visitor_fct_helper(){} - void fill_visitors(int) - { - } - template <class FCT> - void insert(int,FCT) - { - } - template <class VISITOR> - void execute(int,VISITOR) - { - } - }; - // version with visitors - template <class StateType> - struct visitor_fct_helper<StateType,typename ::boost::enable_if<has_accept_sig<StateType> >::type> - { - public: - visitor_fct_helper():m_state_visitors(){} - void fill_visitors(int number_of_states) - { - m_state_visitors.resize(number_of_states); - } - template <class FCT> - void insert(int index,FCT fct) - { - m_state_visitors[index]=fct; - } - void execute(int index) - { - m_state_visitors[index](); - } - -#define MSM_VISITOR_HELPER_EXECUTE_SUB(z, n, unused) ARG ## n vis ## n -#define MSM_VISITOR_HELPER_EXECUTE(z, n, unused) \ - template <BOOST_PP_ENUM_PARAMS(n, class ARG)> \ - void execute(int index BOOST_PP_COMMA_IF(n) \ - BOOST_PP_ENUM(n, MSM_VISITOR_HELPER_EXECUTE_SUB, ~ ) ) \ - { \ - m_state_visitors[index](BOOST_PP_ENUM_PARAMS(n,vis)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,BOOST_PP_ADD(BOOST_MSM_VISITOR_ARG_SIZE,1), MSM_VISITOR_HELPER_EXECUTE, ~) -#undef MSM_VISITOR_HELPER_EXECUTE -#undef MSM_VISITOR_HELPER_EXECUTE_SUB - private: - typedef typename StateType::accept_sig::type visitor_fct; - typedef std::vector<visitor_fct> visitors; - - visitors m_state_visitors; - }; - - template <class StateType,class Enable=int> - struct deferred_msg_queue_helper - { - void clear(){} - }; - template <class StateType> - struct deferred_msg_queue_helper<StateType, - typename ::boost::enable_if< - typename ::boost::msm::back::has_fsm_deferred_events<StateType>::type,int >::type> - { - public: - deferred_msg_queue_helper():m_deferred_events_queue(){} - void clear() - { - m_deferred_events_queue.clear(); - } - deferred_events_queue_t m_deferred_events_queue; - }; - - public: - // tags - typedef int composite_tag; - - // in case someone needs to know - typedef HistoryPolicy history_policy; - - struct InitEvent { }; - struct ExitEvent { }; - // flag handling - struct Flag_AND - { - typedef std::logical_and<bool> type; - }; - struct Flag_OR - { - typedef std::logical_or<bool> type; - }; - typedef typename Derived::BaseAllStates BaseState; - typedef Derived ConcreteSM; - - // if the front-end fsm provides an initial_event typedef, replace InitEvent by this one - typedef typename ::boost::mpl::eval_if< - typename has_initial_event<Derived>::type, - get_initial_event<Derived>, - ::boost::mpl::identity<InitEvent> - >::type fsm_initial_event; - - // if the front-end fsm provides an exit_event typedef, replace ExitEvent by this one - typedef typename ::boost::mpl::eval_if< - typename has_final_event<Derived>::type, - get_final_event<Derived>, - ::boost::mpl::identity<ExitEvent> - >::type fsm_final_event; - - template <class ExitPoint> - struct exit_pt : public ExitPoint - { - // tags - typedef ExitPoint wrapped_exit; - typedef int pseudo_exit; - typedef library_sm owner; - typedef int no_automatic_create; - typedef typename - ExitPoint::event Event; - typedef ::boost::function<execute_return (Event const&)> - forwarding_function; - - // forward event to the higher-level FSM - template <class ForwardEvent> - void forward_event(ForwardEvent const& incomingEvent) - { - // use helper to forward or not - ForwardHelper< ::boost::is_convertible<ForwardEvent,Event>::value>::helper(incomingEvent,m_forward); - } - void set_forward_fct(::boost::function<execute_return (Event const&)> fct) - { - m_forward = fct; - } - exit_pt():m_forward(){} - // by assignments, we keep our forwarding functor unchanged as our containing SM did not change - template <class RHS> - exit_pt(RHS&):m_forward(){} - exit_pt<ExitPoint>& operator= (const exit_pt<ExitPoint>& ) - { - return *this; - } - private: - forwarding_function m_forward; - - // using partial specialization instead of enable_if because of VC8 bug - template <bool OwnEvent, int Dummy=0> - struct ForwardHelper - { - template <class ForwardEvent> - static void helper(ForwardEvent const& ,forwarding_function& ) - { - // Not our event, assert - BOOST_ASSERT(false); - } - }; - template <int Dummy> - struct ForwardHelper<true,Dummy> - { - template <class ForwardEvent> - static void helper(ForwardEvent const& incomingEvent,forwarding_function& forward_fct) - { - // call if handler set, if not, this state is simply a terminate state - if (forward_fct) - forward_fct(incomingEvent); - } - }; - - }; - template <class EntryPoint> - struct entry_pt : public EntryPoint - { - // tags - typedef EntryPoint wrapped_entry; - typedef int pseudo_entry; - typedef library_sm owner; - typedef int no_automatic_create; - }; - template <class EntryPoint> - struct direct : public EntryPoint - { - // tags - typedef EntryPoint wrapped_entry; - typedef int explicit_entry_state; - typedef library_sm owner; - typedef int no_automatic_create; - }; - typedef typename get_number_of_regions<typename Derived::initial_state>::type nr_regions; - // Template used to form rows in the transition table - template< - typename ROW - > - struct row_ - { - //typedef typename ROW::Source T1; - typedef typename make_entry<typename ROW::Source,library_sm>::type T1; - typedef typename make_exit<typename ROW::Target,library_sm>::type T2; - typedef typename ROW::Evt transition_event; - // if the source is an exit pseudo state, then - // current_state_type becomes the result of get_owner - // meaning the containing SM from which the exit occurs - typedef typename ::boost::mpl::eval_if< - typename has_pseudo_exit<T1>::type, - get_owner<T1,library_sm>, - ::boost::mpl::identity<typename ROW::Source> >::type current_state_type; - - // if Target is a sequence, then we have a fork and expect a sequence of explicit_entry - // else if Target is an explicit_entry, next_state_type becomes the result of get_owner - // meaning the containing SM if the row is "outside" the containing SM or else the explicit_entry state itself - typedef typename ::boost::mpl::eval_if< - typename ::boost::mpl::is_sequence<T2>::type, - get_fork_owner<T2,library_sm>, - ::boost::mpl::eval_if< - typename has_no_automatic_create<T2>::type, - get_owner<T2,library_sm>, - ::boost::mpl::identity<T2> > - >::type next_state_type; - - // if a guard condition is here, call it to check that the event is accepted - static bool check_guard(library_sm& fsm,transition_event const& evt) - { - if ( ROW::guard_call(fsm,evt, - ::boost::fusion::at_key<current_state_type>(fsm.m_substate_list), - ::boost::fusion::at_key<next_state_type>(fsm.m_substate_list), - fsm.m_substate_list ) ) - return true; - return false; - } - // Take the transition action and return the next state. - static HandledEnum execute(library_sm& fsm, int region_index, int state, transition_event const& evt) - { - - BOOST_STATIC_CONSTANT(int, current_state = (get_state_id<stt,current_state_type>::type::value)); - BOOST_STATIC_CONSTANT(int, next_state = (get_state_id<stt,next_state_type>::type::value)); - BOOST_ASSERT(state == (current_state)); - // if T1 is an exit pseudo state, then take the transition only if the pseudo exit state is active - if (has_pseudo_exit<T1>::type::value && - !is_exit_state_active<T1,get_owner<T1,library_sm> >(fsm)) - { - return HANDLED_FALSE; - } - if (!check_guard(fsm,evt)) - { - // guard rejected the event, we stay in the current one - return HANDLED_GUARD_REJECT; - } - fsm.m_states[region_index] = active_state_switching::after_guard(current_state,next_state); - - // the guard condition has already been checked - execute_exit<current_state_type> - (::boost::fusion::at_key<current_state_type>(fsm.m_substate_list),evt,fsm); - fsm.m_states[region_index] = active_state_switching::after_exit(current_state,next_state); - - // then call the action method - HandledEnum res = ROW::action_call(fsm,evt, - ::boost::fusion::at_key<current_state_type>(fsm.m_substate_list), - ::boost::fusion::at_key<next_state_type>(fsm.m_substate_list), - fsm.m_substate_list); - fsm.m_states[region_index] = active_state_switching::after_action(current_state,next_state); - - // and finally the entry method of the new current state - convert_event_and_execute_entry<next_state_type,T2> - (::boost::fusion::at_key<next_state_type>(fsm.m_substate_list),evt,fsm); - fsm.m_states[region_index] = active_state_switching::after_entry(current_state,next_state); - return res; - } - }; - - // row having only a guard condition - template< - typename ROW - > - struct g_row_ - { - //typedef typename ROW::Source T1; - typedef typename make_entry<typename ROW::Source,library_sm>::type T1; - typedef typename make_exit<typename ROW::Target,library_sm>::type T2; - typedef typename ROW::Evt transition_event; - // if the source is an exit pseudo state, then - // current_state_type becomes the result of get_owner - // meaning the containing SM from which the exit occurs - typedef typename ::boost::mpl::eval_if< - typename has_pseudo_exit<T1>::type, - get_owner<T1,library_sm>, - ::boost::mpl::identity<typename ROW::Source> >::type current_state_type; - - // if Target is a sequence, then we have a fork and expect a sequence of explicit_entry - // else if Target is an explicit_entry, next_state_type becomes the result of get_owner - // meaning the containing SM if the row is "outside" the containing SM or else the explicit_entry state itself - typedef typename ::boost::mpl::eval_if< - typename ::boost::mpl::is_sequence<T2>::type, - get_fork_owner<T2,library_sm>, - ::boost::mpl::eval_if< - typename has_no_automatic_create<T2>::type, - get_owner<T2,library_sm>, - ::boost::mpl::identity<T2> > - >::type next_state_type; - - // if a guard condition is defined, call it to check that the event is accepted - static bool check_guard(library_sm& fsm,transition_event const& evt) - { - if ( ROW::guard_call(fsm,evt, - ::boost::fusion::at_key<current_state_type>(fsm.m_substate_list), - ::boost::fusion::at_key<next_state_type>(fsm.m_substate_list), - fsm.m_substate_list )) - return true; - return false; - } - // Take the transition action and return the next state. - static HandledEnum execute(library_sm& fsm, int region_index, int state, transition_event const& evt) - { - BOOST_STATIC_CONSTANT(int, current_state = (get_state_id<stt,current_state_type>::type::value)); - BOOST_STATIC_CONSTANT(int, next_state = (get_state_id<stt,next_state_type>::type::value)); - BOOST_ASSERT(state == (current_state)); - // if T1 is an exit pseudo state, then take the transition only if the pseudo exit state is active - if (has_pseudo_exit<T1>::type::value && - !is_exit_state_active<T1,get_owner<T1,library_sm> >(fsm)) - { - return HANDLED_FALSE; - } - if (!check_guard(fsm,evt)) - { - // guard rejected the event, we stay in the current one - return HANDLED_GUARD_REJECT; - } - fsm.m_states[region_index] = active_state_switching::after_guard(current_state,next_state); - - // the guard condition has already been checked - execute_exit<current_state_type> - (::boost::fusion::at_key<current_state_type>(fsm.m_substate_list),evt,fsm); - fsm.m_states[region_index] = active_state_switching::after_exit(current_state,next_state); - fsm.m_states[region_index] = active_state_switching::after_action(current_state,next_state); - - // and finally the entry method of the new current state - convert_event_and_execute_entry<next_state_type,T2> - (::boost::fusion::at_key<next_state_type>(fsm.m_substate_list),evt,fsm); - fsm.m_states[region_index] = active_state_switching::after_entry(current_state,next_state); - return HANDLED_TRUE; - } - }; - - // row having only an action method - template< - typename ROW - > - struct a_row_ - { - //typedef typename ROW::Source T1; - typedef typename make_entry<typename ROW::Source,library_sm>::type T1; - typedef typename make_exit<typename ROW::Target,library_sm>::type T2; - typedef typename ROW::Evt transition_event; - // if the source is an exit pseudo state, then - // current_state_type becomes the result of get_owner - // meaning the containing SM from which the exit occurs - typedef typename ::boost::mpl::eval_if< - typename has_pseudo_exit<T1>::type, - get_owner<T1,library_sm>, - ::boost::mpl::identity<typename ROW::Source> >::type current_state_type; - - // if Target is a sequence, then we have a fork and expect a sequence of explicit_entry - // else if Target is an explicit_entry, next_state_type becomes the result of get_owner - // meaning the containing SM if the row is "outside" the containing SM or else the explicit_entry state itself - typedef typename ::boost::mpl::eval_if< - typename ::boost::mpl::is_sequence<T2>::type, - get_fork_owner<T2,library_sm>, - ::boost::mpl::eval_if< - typename has_no_automatic_create<T2>::type, - get_owner<T2,library_sm>, - ::boost::mpl::identity<T2> > - >::type next_state_type; - - // Take the transition action and return the next state. - static HandledEnum execute(library_sm& fsm, int region_index, int state, transition_event const& evt) - { - BOOST_STATIC_CONSTANT(int, current_state = (get_state_id<stt,current_state_type>::type::value)); - BOOST_STATIC_CONSTANT(int, next_state = (get_state_id<stt,next_state_type>::type::value)); - BOOST_ASSERT(state == (current_state)); - - // if T1 is an exit pseudo state, then take the transition only if the pseudo exit state is active - if (has_pseudo_exit<T1>::type::value && - !is_exit_state_active<T1,get_owner<T1,library_sm> >(fsm)) - { - return HANDLED_FALSE; - } - fsm.m_states[region_index] = active_state_switching::after_guard(current_state,next_state); - - // no need to check the guard condition - // first call the exit method of the current state - execute_exit<current_state_type> - (::boost::fusion::at_key<current_state_type>(fsm.m_substate_list),evt,fsm); - fsm.m_states[region_index] = active_state_switching::after_exit(current_state,next_state); - - // then call the action method - HandledEnum res = ROW::action_call(fsm,evt, - ::boost::fusion::at_key<current_state_type>(fsm.m_substate_list), - ::boost::fusion::at_key<next_state_type>(fsm.m_substate_list), - fsm.m_substate_list); - fsm.m_states[region_index] = active_state_switching::after_action(current_state,next_state); - - // and finally the entry method of the new current state - convert_event_and_execute_entry<next_state_type,T2> - (::boost::fusion::at_key<next_state_type>(fsm.m_substate_list),evt,fsm); - fsm.m_states[region_index] = active_state_switching::after_entry(current_state,next_state); - return res; - } - }; - - // row having no guard condition or action, simply transitions - template< - typename ROW - > - struct _row_ - { - //typedef typename ROW::Source T1; - typedef typename make_entry<typename ROW::Source,library_sm>::type T1; - typedef typename make_exit<typename ROW::Target,library_sm>::type T2; - typedef typename ROW::Evt transition_event; - // if the source is an exit pseudo state, then - // current_state_type becomes the result of get_owner - // meaning the containing SM from which the exit occurs - typedef typename ::boost::mpl::eval_if< - typename has_pseudo_exit<T1>::type, - get_owner<T1,library_sm>, - ::boost::mpl::identity<typename ROW::Source> >::type current_state_type; - - // if Target is a sequence, then we have a fork and expect a sequence of explicit_entry - // else if Target is an explicit_entry, next_state_type becomes the result of get_owner - // meaning the containing SM if the row is "outside" the containing SM or else the explicit_entry state itself - typedef typename ::boost::mpl::eval_if< - typename ::boost::mpl::is_sequence<T2>::type, - get_fork_owner<T2,library_sm>, - ::boost::mpl::eval_if< - typename has_no_automatic_create<T2>::type, - get_owner<T2,library_sm>, - ::boost::mpl::identity<T2> > - >::type next_state_type; - - // Take the transition action and return the next state. - static HandledEnum execute(library_sm& fsm, int region_index, int state, transition_event const& evt) - { - BOOST_STATIC_CONSTANT(int, current_state = (get_state_id<stt,current_state_type>::type::value)); - BOOST_STATIC_CONSTANT(int, next_state = (get_state_id<stt,next_state_type>::type::value)); - BOOST_ASSERT(state == (current_state)); - - // if T1 is an exit pseudo state, then take the transition only if the pseudo exit state is active - if (has_pseudo_exit<T1>::type::value && - !is_exit_state_active<T1,get_owner<T1,library_sm> >(fsm)) - { - return HANDLED_FALSE; - } - fsm.m_states[region_index] = active_state_switching::after_guard(current_state,next_state); - - // first call the exit method of the current state - execute_exit<current_state_type> - (::boost::fusion::at_key<current_state_type>(fsm.m_substate_list),evt,fsm); - fsm.m_states[region_index] = active_state_switching::after_exit(current_state,next_state); - fsm.m_states[region_index] = active_state_switching::after_action(current_state,next_state); - - - // and finally the entry method of the new current state - convert_event_and_execute_entry<next_state_type,T2> - (::boost::fusion::at_key<next_state_type>(fsm.m_substate_list),evt,fsm); - fsm.m_states[region_index] = active_state_switching::after_entry(current_state,next_state); - return HANDLED_TRUE; - } - }; - // "i" rows are rows for internal transitions - template< - typename ROW - > - struct irow_ - { - typedef typename make_entry<typename ROW::Source,library_sm>::type T1; - typedef typename make_exit<typename ROW::Target,library_sm>::type T2; - typedef typename ROW::Evt transition_event; - typedef typename ROW::Source current_state_type; - typedef T2 next_state_type; - - // if a guard condition is here, call it to check that the event is accepted - static bool check_guard(library_sm& fsm,transition_event const& evt) - { - if ( ROW::guard_call(fsm,evt, - ::boost::fusion::at_key<current_state_type>(fsm.m_substate_list), - ::boost::fusion::at_key<next_state_type>(fsm.m_substate_list), - fsm.m_substate_list)) - return true; - return false; - } - // Take the transition action and return the next state. - static HandledEnum execute(library_sm& fsm, int , int state, transition_event const& evt) - { - - BOOST_STATIC_CONSTANT(int, current_state = (get_state_id<stt,current_state_type>::type::value)); - BOOST_ASSERT(state == (current_state)); - if (!check_guard(fsm,evt)) - { - // guard rejected the event, we stay in the current one - return HANDLED_GUARD_REJECT; - } - - // call the action method - HandledEnum res = ROW::action_call(fsm,evt, - ::boost::fusion::at_key<current_state_type>(fsm.m_substate_list), - ::boost::fusion::at_key<next_state_type>(fsm.m_substate_list), - fsm.m_substate_list); - return res; - } - }; - - // row having only a guard condition - template< - typename ROW - > - struct g_irow_ - { - typedef typename make_entry<typename ROW::Source,library_sm>::type T1; - typedef typename make_exit<typename ROW::Target,library_sm>::type T2; - typedef typename ROW::Evt transition_event; - typedef typename ROW::Source current_state_type; - typedef T2 next_state_type; - - // if a guard condition is defined, call it to check that the event is accepted - static bool check_guard(library_sm& fsm,transition_event const& evt) - { - if ( ROW::guard_call(fsm,evt, - ::boost::fusion::at_key<current_state_type>(fsm.m_substate_list), - ::boost::fusion::at_key<next_state_type>(fsm.m_substate_list), - fsm.m_substate_list) ) - return true; - return false; - } - // Take the transition action and return the next state. - static HandledEnum execute(library_sm& fsm, int , int state, transition_event const& evt) - { - BOOST_STATIC_CONSTANT(int, current_state = (get_state_id<stt,current_state_type>::type::value)); - BOOST_ASSERT(state == (current_state)); - if (!check_guard(fsm,evt)) - { - // guard rejected the event, we stay in the current one - return HANDLED_GUARD_REJECT; - } - return HANDLED_TRUE; - } - }; - - // row having only an action method - template< - typename ROW - > - struct a_irow_ - { - typedef typename make_entry<typename ROW::Source,library_sm>::type T1; - typedef typename make_exit<typename ROW::Target,library_sm>::type T2; - - typedef typename ROW::Evt transition_event; - typedef typename ROW::Source current_state_type; - typedef T2 next_state_type; - - // Take the transition action and return the next state. - static HandledEnum execute(library_sm& fsm, int , int state, transition_event const& evt) - { - BOOST_STATIC_CONSTANT(int, current_state = (get_state_id<stt,current_state_type>::type::value)); - BOOST_ASSERT(state == (current_state)); - - // call the action method - HandledEnum res = ROW::action_call(fsm,evt, - ::boost::fusion::at_key<current_state_type>(fsm.m_substate_list), - ::boost::fusion::at_key<next_state_type>(fsm.m_substate_list), - fsm.m_substate_list); - - return res; - } - }; - // row simply ignoring the event - template< - typename ROW - > - struct _irow_ - { - typedef typename make_entry<typename ROW::Source,library_sm>::type T1; - typedef typename make_exit<typename ROW::Target,library_sm>::type T2; - typedef typename ROW::Evt transition_event; - typedef typename ROW::Source current_state_type; - typedef T2 next_state_type; - - // Take the transition action and return the next state. - static HandledEnum execute(library_sm& , int , int state, transition_event const& ) - { - BOOST_STATIC_CONSTANT(int, current_state = (get_state_id<stt,current_state_type>::type::value)); - BOOST_ASSERT(state == (current_state)); - return HANDLED_TRUE; - } - }; - // transitions internal to this state machine (no substate involved) - template< - typename ROW, - typename StateType - > - struct internal_ - { - typedef StateType current_state_type; - typedef StateType next_state_type; - typedef typename ROW::Evt transition_event; - - // if a guard condition is here, call it to check that the event is accepted - static bool check_guard(library_sm& fsm,transition_event const& evt) - { - if ( ROW::guard_call(fsm,evt, - ::boost::fusion::at_key<StateType>(fsm.m_substate_list), - ::boost::fusion::at_key<StateType>(fsm.m_substate_list), - fsm.m_substate_list) ) - return true; - return false; - } - // Take the transition action and return the next state. - static HandledEnum execute(library_sm& fsm, int , int , transition_event const& evt) - { - if (!check_guard(fsm,evt)) - { - // guard rejected the event, we stay in the current one - return HANDLED_GUARD_REJECT; - } - - // then call the action method - HandledEnum res = ROW::action_call(fsm,evt, - ::boost::fusion::at_key<StateType>(fsm.m_substate_list), - ::boost::fusion::at_key<StateType>(fsm.m_substate_list), - fsm.m_substate_list); - return res; - } - }; - template< - typename ROW - > - struct internal_ <ROW,library_sm> - { - typedef library_sm current_state_type; - typedef library_sm next_state_type; - typedef typename ROW::Evt transition_event; - - // if a guard condition is here, call it to check that the event is accepted - static bool check_guard(library_sm& fsm,transition_event const& evt) - { - if ( ROW::guard_call(fsm,evt, - fsm, - fsm, - fsm.m_substate_list) ) - return true; - return false; - } - // Take the transition action and return the next state. - static HandledEnum execute(library_sm& fsm, int , int , transition_event const& evt) - { - if (!check_guard(fsm,evt)) - { - // guard rejected the event, we stay in the current one - return HANDLED_GUARD_REJECT; - } - - // then call the action method - HandledEnum res = ROW::action_call(fsm,evt, - fsm, - fsm, - fsm.m_substate_list); - return res; - } - }; - - template< - typename ROW, - typename StateType - > - struct a_internal_ - { - typedef StateType current_state_type; - typedef StateType next_state_type; - typedef typename ROW::Evt transition_event; - - // Take the transition action and return the next state. - static HandledEnum execute(library_sm& fsm, int, int, transition_event const& evt) - { - // then call the action method - HandledEnum res = ROW::action_call(fsm,evt, - ::boost::fusion::at_key<StateType>(fsm.m_substate_list), - ::boost::fusion::at_key<StateType>(fsm.m_substate_list), - fsm.m_substate_list); - return res; - } - }; - template< - typename ROW - > - struct a_internal_ <ROW,library_sm> - { - typedef library_sm current_state_type; - typedef library_sm next_state_type; - typedef typename ROW::Evt transition_event; - - // Take the transition action and return the next state. - static HandledEnum execute(library_sm& fsm, int, int, transition_event const& evt) - { - // then call the action method - HandledEnum res = ROW::action_call(fsm,evt, - fsm, - fsm, - fsm.m_substate_list); - return res; - } - }; - template< - typename ROW, - typename StateType - > - struct g_internal_ - { - typedef StateType current_state_type; - typedef StateType next_state_type; - typedef typename ROW::Evt transition_event; - - // if a guard condition is here, call it to check that the event is accepted - static bool check_guard(library_sm& fsm,transition_event const& evt) - { - if ( ROW::guard_call(fsm,evt, - ::boost::fusion::at_key<StateType>(fsm.m_substate_list), - ::boost::fusion::at_key<StateType>(fsm.m_substate_list), - fsm.m_substate_list) ) - return true; - return false; - } - // Take the transition action and return the next state. - static HandledEnum execute(library_sm& fsm, int, int, transition_event const& evt) - { - if (!check_guard(fsm,evt)) - { - // guard rejected the event, we stay in the current one - return HANDLED_GUARD_REJECT; - } - return HANDLED_TRUE; - } - }; - template< - typename ROW - > - struct g_internal_ <ROW,library_sm> - { - typedef library_sm current_state_type; - typedef library_sm next_state_type; - typedef typename ROW::Evt transition_event; - - // if a guard condition is here, call it to check that the event is accepted - static bool check_guard(library_sm& fsm,transition_event const& evt) - { - if ( ROW::guard_call(fsm,evt, - fsm, - fsm, - fsm.m_substate_list) ) - return true; - return false; - } - // Take the transition action and return the next state. - static HandledEnum execute(library_sm& fsm, int, int, transition_event const& evt) - { - if (!check_guard(fsm,evt)) - { - // guard rejected the event, we stay in the current one - return HANDLED_GUARD_REJECT; - } - return HANDLED_TRUE; - } - }; - template< - typename ROW, - typename StateType - > - struct _internal_ - { - typedef StateType current_state_type; - typedef StateType next_state_type; - typedef typename ROW::Evt transition_event; - static HandledEnum execute(library_sm& , int , int , transition_event const& ) - { - return HANDLED_TRUE; - } - }; - template< - typename ROW - > - struct _internal_ <ROW,library_sm> - { - typedef library_sm current_state_type; - typedef library_sm next_state_type; - typedef typename ROW::Evt transition_event; - static HandledEnum execute(library_sm& , int , int , transition_event const& ) - { - return HANDLED_TRUE; - } - }; - // Template used to form forwarding rows in the transition table for every row of a composite SM - template< - typename T1 - , class Evt - > - struct frow - { - typedef T1 current_state_type; - typedef T1 next_state_type; - typedef Evt transition_event; - // tag to find out if a row is a forwarding row - typedef int is_frow; - - // Take the transition action and return the next state. - static HandledEnum execute(library_sm& fsm, int region_index, int , transition_event const& evt) - { - // false as second parameter because this event is forwarded from outer fsm - execute_return res = - (::boost::fusion::at_key<current_state_type>(fsm.m_substate_list)).process_event_internal(evt,false); - fsm.m_states[region_index]=get_state_id<stt,T1>::type::value; - return res; - } - // helper metafunctions used by dispatch table and give the frow a new event - // (used to avoid double entries in a table because of base events) - template <class NewEvent> - struct replace_event - { - typedef frow<T1,NewEvent> type; - }; - }; - - template <class Tag, class Transition,class StateType> - struct create_backend_stt - { - }; - template <class Transition,class StateType> - struct create_backend_stt<g_row_tag,Transition,StateType> - { - typedef g_row_<Transition> type; - }; - template <class Transition,class StateType> - struct create_backend_stt<a_row_tag,Transition,StateType> - { - typedef a_row_<Transition> type; - }; - template <class Transition,class StateType> - struct create_backend_stt<_row_tag,Transition,StateType> - { - typedef _row_<Transition> type; - }; - template <class Transition,class StateType> - struct create_backend_stt<row_tag,Transition,StateType> - { - typedef row_<Transition> type; - }; - // internal transitions - template <class Transition,class StateType> - struct create_backend_stt<g_irow_tag,Transition,StateType> - { - typedef g_irow_<Transition> type; - }; - template <class Transition,class StateType> - struct create_backend_stt<a_irow_tag,Transition,StateType> - { - typedef a_irow_<Transition> type; - }; - template <class Transition,class StateType> - struct create_backend_stt<irow_tag,Transition,StateType> - { - typedef irow_<Transition> type; - }; - template <class Transition,class StateType> - struct create_backend_stt<_irow_tag,Transition,StateType> - { - typedef _irow_<Transition> type; - }; - template <class Transition,class StateType> - struct create_backend_stt<sm_a_i_row_tag,Transition,StateType> - { - typedef a_internal_<Transition,StateType> type; - }; - template <class Transition,class StateType> - struct create_backend_stt<sm_g_i_row_tag,Transition,StateType> - { - typedef g_internal_<Transition,StateType> type; - }; - template <class Transition,class StateType> - struct create_backend_stt<sm_i_row_tag,Transition,StateType> - { - typedef internal_<Transition,StateType> type; - }; - template <class Transition,class StateType> - struct create_backend_stt<sm__i_row_tag,Transition,StateType> - { - typedef _internal_<Transition,StateType> type; - }; - template <class Transition,class StateType=void> - struct make_row_tag - { - typedef typename create_backend_stt<typename Transition::row_type_tag,Transition,StateType>::type type; - }; - - // add to the stt the initial states which could be missing (if not being involved in a transition) - template <class BaseType, class stt_simulated = typename BaseType::transition_table> - struct create_real_stt - { - //typedef typename BaseType::transition_table stt_simulated; - typedef typename ::boost::mpl::fold< - stt_simulated,mpl::vector0<>, - ::boost::mpl::push_back< ::boost::mpl::placeholders::_1, - make_row_tag< ::boost::mpl::placeholders::_2 , BaseType > > - >::type type; - }; - - template <class Table,class Intermediate,class StateType> - struct add_forwarding_row_helper - { - typedef typename generate_event_set<Table>::type all_events; - typedef typename ::boost::mpl::fold< - all_events, Intermediate, - ::boost::mpl::push_back< ::boost::mpl::placeholders::_1, - frow<StateType, ::boost::mpl::placeholders::_2> > >::type type; - }; - // gets the transition table from a composite and make from it a forwarding row - template <class StateType,class IsComposite> - struct get_internal_transition_table - { - // first get the table of a composite - typedef typename recursive_get_transition_table<StateType>::type original_table; - - // we now look for the events the composite has in its internal transitions - // the internal ones are searched recursively in sub-sub... states - // we go recursively because our states can also have internal tables or substates etc. - typedef typename recursive_get_internal_transition_table<StateType, ::boost::mpl::true_>::type recursive_istt; - typedef typename ::boost::mpl::fold< - recursive_istt,::boost::mpl::vector0<>, - ::boost::mpl::push_back< ::boost::mpl::placeholders::_1, - make_row_tag< ::boost::mpl::placeholders::_2 , StateType> > - >::type recursive_istt_with_tag; - - typedef typename ::boost::mpl::insert_range< original_table, typename ::boost::mpl::end<original_table>::type, - recursive_istt_with_tag>::type table_with_all_events; - - // and add for every event a forwarding row - typedef typename ::boost::mpl::eval_if< - typename CompilePolicy::add_forwarding_rows, - add_forwarding_row_helper<table_with_all_events,::boost::mpl::vector0<>,StateType>, - ::boost::mpl::identity< ::boost::mpl::vector0<> > - >::type type; - }; - template <class StateType> - struct get_internal_transition_table<StateType, ::boost::mpl::false_ > - { - typedef typename create_real_stt<StateType, typename StateType::internal_transition_table >::type type; - }; - // typedefs used internally - typedef typename create_real_stt<Derived>::type real_transition_table; - typedef typename create_stt<library_sm>::type stt; - typedef typename get_initial_states<typename Derived::initial_state>::type initial_states; - typedef typename generate_state_set<stt>::type state_list; - typedef typename HistoryPolicy::template apply<nr_regions::value>::type concrete_history; - - typedef typename ::boost::fusion::result_of::as_set<state_list>::type substate_list; - typedef typename ::boost::msm::back::generate_event_set< - typename create_real_stt<library_sm, typename library_sm::internal_transition_table >::type - >::type processable_events_internal_table; - - // extends the transition table with rows from composite states - template <class Composite> - struct extend_table - { - // add the init states - //typedef typename create_stt<Composite>::type stt; - typedef typename Composite::stt Stt; - - // add the internal events defined in the internal_transition_table - // Note: these are added first because they must have a lesser prio - // than the deeper transitions in the sub regions - // table made of a stt + internal transitions of composite - typedef typename ::boost::mpl::fold< - typename Composite::internal_transition_table,::boost::mpl::vector0<>, - ::boost::mpl::push_back< ::boost::mpl::placeholders::_1, - make_row_tag< ::boost::mpl::placeholders::_2 , Composite> > - >::type internal_stt; - - typedef typename ::boost::mpl::insert_range< - Stt, - typename ::boost::mpl::end<Stt>::type, - internal_stt - //typename get_internal_transition_table<Composite, ::boost::mpl::true_ >::type - >::type stt_plus_internal; - - // for every state, add its transition table (if any) - // transformed as frow - typedef typename ::boost::mpl::fold<state_list,stt_plus_internal, - ::boost::mpl::insert_range< - ::boost::mpl::placeholders::_1, - ::boost::mpl::end< ::boost::mpl::placeholders::_1>, - get_internal_transition_table< - ::boost::mpl::placeholders::_2, - is_composite_state< ::boost::mpl::placeholders::_2> > > - >::type type; - }; - // extend the table with tables from composite states - typedef typename extend_table<library_sm>::type complete_table; - // build a sequence of regions - typedef typename get_regions_as_sequence<typename Derived::initial_state>::type seq_initial_states; - // Member functions - - // start the state machine (calls entry of the initial state) - void start() - { - // reinitialize our list of currently active states with the ones defined in Derived::initial_state - ::boost::mpl::for_each< seq_initial_states, ::boost::msm::wrap<mpl::placeholders::_1> > - (init_states(m_states)); - // call on_entry on this SM - (static_cast<Derived*>(this))->on_entry(fsm_initial_event(),*this); - ::boost::mpl::for_each<initial_states, boost::msm::wrap<mpl::placeholders::_1> > - (call_init<fsm_initial_event>(fsm_initial_event(),this)); - // give a chance to handle an anonymous (eventless) transition - handle_eventless_transitions_helper<library_sm> eventless_helper(this,true); - eventless_helper.process_completion_event(); - } - - // start the state machine (calls entry of the initial state passing incomingEvent to on_entry's) - template <class Event> - void start(Event const& incomingEvent) - { - // reinitialize our list of currently active states with the ones defined in Derived::initial_state - ::boost::mpl::for_each< seq_initial_states, ::boost::msm::wrap<mpl::placeholders::_1> > - (init_states(m_states)); - // call on_entry on this SM - (static_cast<Derived*>(this))->on_entry(incomingEvent,*this); - ::boost::mpl::for_each<initial_states, boost::msm::wrap<mpl::placeholders::_1> > - (call_init<Event>(incomingEvent,this)); - // give a chance to handle an anonymous (eventless) transition - handle_eventless_transitions_helper<library_sm> eventless_helper(this,true); - eventless_helper.process_completion_event(); - } - - // stop the state machine (calls exit of the current state) - void stop() - { - do_exit(fsm_final_event(),*this); - } - - // stop the state machine (calls exit of the current state passing finalEvent to on_exit's) - template <class Event> - void stop(Event const& finalEvent) - { - do_exit(finalEvent,*this); - } - - // Main function used by clients of the derived FSM to make transitions. - template<class Event> - execute_return process_event(Event const& evt) - { - return process_event_internal(evt,true); - } - - template <class EventType> - void enqueue_event_helper(EventType const& evt, ::boost::mpl::false_ const &) - { - execute_return (library_sm::*pf) (EventType const& evt) = - &library_sm::process_event; - - transition_fct f = ::boost::bind(pf,this,evt); - m_events_queue.m_events_queue.push_back(f); - } - template <class EventType> - void enqueue_event_helper(EventType const& , ::boost::mpl::true_ const &) - { - // no queue - } - - void execute_queued_events_helper(::boost::mpl::false_ const &) - { - while(!m_events_queue.m_events_queue.empty()) - { - transition_fct to_call = m_events_queue.m_events_queue.front(); - m_events_queue.m_events_queue.pop_front(); - to_call(); - } - } - void execute_queued_events_helper(::boost::mpl::true_ const &) - { - // no queue required - } - void execute_single_queued_event_helper(::boost::mpl::false_ const &) - { - transition_fct to_call = m_events_queue.m_events_queue.front(); - m_events_queue.m_events_queue.pop_front(); - to_call(); - } - void execute_single_queued_event_helper(::boost::mpl::true_ const &) - { - // no queue required - } - // enqueues an event in the message queue - // call execute_queued_events to process all queued events. - // Be careful if you do this during event processing, the event will be processed immediately - // and not kept in the queue - template <class EventType> - void enqueue_event(EventType const& evt) - { - enqueue_event_helper<EventType>(evt, typename is_no_message_queue<library_sm>::type()); - } - - // empty the queue and process events - void execute_queued_events() - { - execute_queued_events_helper(typename is_no_message_queue<library_sm>::type()); - } - void execute_single_queued_event() - { - execute_single_queued_event_helper(typename is_no_message_queue<library_sm>::type()); - } - typename events_queue_t::size_type get_message_queue_size() const - { - return m_events_queue.m_events_queue.size(); - } - - events_queue_t& get_message_queue() - { - return m_events_queue.m_events_queue; - } - - const events_queue_t& get_message_queue() const - { - return m_events_queue.m_events_queue; - } - - void clear_deferred_queue() - { - m_deferred_events_queue.clear(); - } - - deferred_events_queue_t& get_deferred_queue() - { - return m_deferred_events_queue.m_deferred_events_queue; - } - - const deferred_events_queue_t& get_deferred_queue() const - { - return m_deferred_events_queue.m_deferred_events_queue; - } - - // Getter that returns the current state of the FSM - const int* current_state() const - { - return this->m_states; - } - - template <class Archive> - struct serialize_state - { - serialize_state(Archive& ar):ar_(ar){} - - template<typename T> - typename ::boost::enable_if< - typename ::boost::mpl::or_< - typename has_do_serialize<T>::type, - typename is_composite_state<T>::type - >::type - ,void - >::type - operator()(T& t) const - { - ar_ & t; - } - template<typename T> - typename ::boost::disable_if< - typename ::boost::mpl::or_< - typename has_do_serialize<T>::type, - typename is_composite_state<T>::type - >::type - ,void - >::type - operator()(T&) const - { - // no state to serialize - } - Archive& ar_; - }; - - template<class Archive> - void serialize(Archive & ar, const unsigned int) - { - // invoke serialization of the base class - (serialize_state<Archive>(ar))(boost::serialization::base_object<Derived>(*this)); - // now our attributes - ar & m_states; - // queues cannot be serialized => skip - ar & m_history; - ar & m_event_processing; - ar & m_is_included; - // visitors cannot be serialized => skip - ::boost::fusion::for_each(m_substate_list, serialize_state<Archive>(ar)); - } - - // linearly search for the state with the given id - struct get_state_id_helper - { - get_state_id_helper(int id,const BaseState** res,const library_sm* self_): - result_state(res),searched_id(id),self(self_) {} - - template <class StateType> - void operator()(boost::msm::wrap<StateType> const&) - { - // look for the state id until found - BOOST_STATIC_CONSTANT(int, id = (get_state_id<stt,StateType>::value)); - if (!*result_state && (id == searched_id)) - { - *result_state = &::boost::fusion::at_key<StateType>(self->m_substate_list); - } - } - const BaseState** result_state; - int searched_id; - const library_sm* self; - }; - // return the state whose id is passed or 0 if not found - // caution if you need this, you probably need polymorphic states - // complexity: O(number of states) - BaseState* get_state_by_id(int id) - { - const BaseState* result_state=0; - ::boost::mpl::for_each<state_list, - ::boost::msm::wrap< ::boost::mpl::placeholders::_1> > (get_state_id_helper(id,&result_state,this)); - return const_cast<BaseState*>(result_state); - } - const BaseState* get_state_by_id(int id) const - { - const BaseState* result_state=0; - ::boost::mpl::for_each<state_list, - ::boost::msm::wrap< ::boost::mpl::placeholders::_1> > (get_state_id_helper(id,&result_state,this)); - return result_state; - } - // true if the sm is used in another sm - bool is_contained() const - { - return m_is_included; - } - // get the history policy class - concrete_history& get_history() - { - return m_history; - } - concrete_history const& get_history() const - { - return m_history; - } - // get a state (const version) - // as a pointer - template <class State> - typename ::boost::enable_if<typename ::boost::is_pointer<State>::type,State >::type - get_state(::boost::msm::back::dummy<0> = 0) const - { - return const_cast<State > - (& - (::boost::fusion::at_key< - typename ::boost::remove_const<typename ::boost::remove_pointer<State>::type>::type>(m_substate_list))); - } - // as a reference - template <class State> - typename ::boost::enable_if<typename ::boost::is_reference<State>::type,State >::type - get_state(::boost::msm::back::dummy<1> = 0) const - { - return const_cast<State > - ( ::boost::fusion::at_key< - typename ::boost::remove_const<typename ::boost::remove_reference<State>::type>::type>(m_substate_list) ); - } - // get a state (non const version) - // as a pointer - template <class State> - typename ::boost::enable_if<typename ::boost::is_pointer<State>::type,State >::type - get_state(::boost::msm::back::dummy<0> = 0) - { - return &(static_cast<typename boost::add_reference<typename ::boost::remove_pointer<State>::type>::type > - (::boost::fusion::at_key<typename ::boost::remove_pointer<State>::type>(m_substate_list))); - } - // as a reference - template <class State> - typename ::boost::enable_if<typename ::boost::is_reference<State>::type,State >::type - get_state(::boost::msm::back::dummy<1> = 0) - { - return ::boost::fusion::at_key<typename ::boost::remove_reference<State>::type>(m_substate_list); - } - // checks if a flag is active using the BinaryOp as folding function - template <class Flag,class BinaryOp> - bool is_flag_active() const - { - flag_handler* flags_entries = get_entries_for_flag<Flag>(); - bool res = (*flags_entries[ m_states[0] ])(*this); - for (int i = 1; i < nr_regions::value ; ++i) - { - res = typename BinaryOp::type() (res,(*flags_entries[ m_states[i] ])(*this)); - } - return res; - } - // checks if a flag is active using no binary op if 1 region, or OR if > 1 regions - template <class Flag> - bool is_flag_active() const - { - return FlagHelper<Flag,(nr_regions::value>1)>::helper(*this,get_entries_for_flag<Flag>()); - } - // visit the currently active states (if these are defined as visitable - // by implementing accept) - void visit_current_states() - { - for (int i=0; i<nr_regions::value;++i) - { - m_visitors.execute(m_states[i]); - } - } -#define MSM_VISIT_STATE_SUB(z, n, unused) ARG ## n vis ## n -#define MSM_VISIT_STATE_EXECUTE(z, n, unused) \ - template <BOOST_PP_ENUM_PARAMS(n, class ARG)> \ - void visit_current_states(BOOST_PP_ENUM(n, MSM_VISIT_STATE_SUB, ~ ) ) \ - { \ - for (int i=0; i<nr_regions::value;++i) \ - { \ - m_visitors.execute(m_states[i],BOOST_PP_ENUM_PARAMS(n,vis)); \ - } \ - } - BOOST_PP_REPEAT_FROM_TO(1,BOOST_PP_ADD(BOOST_MSM_VISITOR_ARG_SIZE,1), MSM_VISIT_STATE_EXECUTE, ~) -#undef MSM_VISIT_STATE_EXECUTE -#undef MSM_VISIT_STATE_SUB - - // puts the given event into the deferred queue - template <class Event> - void defer_event(Event const& e) - { - // to call this function, you need either a state with a deferred_events typedef - // or that the fsm provides the activate_deferred_events typedef - BOOST_MPL_ASSERT(( has_fsm_deferred_events<library_sm> )); - execute_return (library_sm::*pf) (Event const& evt)= &library_sm::process_event; - Event temp (e); - ::boost::function<execute_return () > f= ::boost::bind(pf, this,temp); - post_deferred_event(f); - } - - protected: // interface for the derived class - - // helper used to fill the initial states - struct init_states - { - init_states(int* const init):m_initial_states(init),m_index(-1){} - - // History initializer function object, used with mpl::for_each - template <class State> - void operator()(::boost::msm::wrap<State> const&) - { - m_initial_states[++m_index]=get_state_id<stt,State>::type::value; - } - int* const m_initial_states; - int m_index; - }; - public: - struct update_state - { - update_state(substate_list& to_overwrite_):to_overwrite(&to_overwrite_){} - template<typename StateType> - void operator()(StateType const& astate) const - { - ::boost::fusion::at_key<StateType>(*to_overwrite)=astate; - } - substate_list* to_overwrite; - }; - template <class Expr> - void set_states(Expr const& expr) - { - ::boost::fusion::for_each( - ::boost::fusion::as_vector(FoldToList()(expr, boost::fusion::nil())),update_state(this->m_substate_list)); - } - - // Construct with the default initial states - state_machine<A0,A1,A2,A3,A4 >() - :Derived() - ,m_events_queue() - ,m_deferred_events_queue() - ,m_history() - ,m_event_processing(false) - ,m_is_included(false) - ,m_visitors() - ,m_substate_list() - { - // initialize our list of states with the ones defined in Derived::initial_state - ::boost::mpl::for_each< seq_initial_states, ::boost::msm::wrap<mpl::placeholders::_1> > - (init_states(m_states)); - m_history.set_initial_states(m_states); - // create states - fill_states(this); - } - template <class Expr> - state_machine<A0,A1,A2,A3,A4 > - (Expr const& expr,typename ::boost::enable_if<typename ::boost::proto::is_expr<Expr>::type >::type* =0) - :Derived() - ,m_events_queue() - ,m_deferred_events_queue() - ,m_history() - ,m_event_processing(false) - ,m_is_included(false) - ,m_visitors() - ,m_substate_list() - { - BOOST_MPL_ASSERT_MSG( - ( ::boost::proto::matches<Expr, FoldToList>::value), - THE_STATES_EXPRESSION_PASSED_DOES_NOT_MATCH_GRAMMAR, - (FoldToList)); - - // initialize our list of states with the ones defined in Derived::initial_state - ::boost::mpl::for_each< seq_initial_states, ::boost::msm::wrap<mpl::placeholders::_1> > - (init_states(m_states)); - m_history.set_initial_states(m_states); - // create states - set_states(expr); - fill_states(this); - } - // Construct with the default initial states and some default argument(s) -#define MSM_CONSTRUCTOR_HELPER_EXECUTE_SUB(z, n, unused) ARG ## n t ## n -#define MSM_CONSTRUCTOR_HELPER_EXECUTE(z, n, unused) \ - template <BOOST_PP_ENUM_PARAMS(n, class ARG)> \ - state_machine<A0,A1,A2,A3,A4 \ - >(BOOST_PP_ENUM(n, MSM_CONSTRUCTOR_HELPER_EXECUTE_SUB, ~ ), \ - typename ::boost::disable_if<typename ::boost::proto::is_expr<ARG0>::type >::type* =0 ) \ - :Derived(BOOST_PP_ENUM_PARAMS(n,t)) \ - ,m_events_queue() \ - ,m_deferred_events_queue() \ - ,m_history() \ - ,m_event_processing(false) \ - ,m_is_included(false) \ - ,m_visitors() \ - ,m_substate_list() \ - { \ - ::boost::mpl::for_each< seq_initial_states, ::boost::msm::wrap<mpl::placeholders::_1> > \ - (init_states(m_states)); \ - m_history.set_initial_states(m_states); \ - fill_states(this); \ - } \ - template <class Expr,BOOST_PP_ENUM_PARAMS(n, class ARG)> \ - state_machine<A0,A1,A2,A3,A4 \ - >(Expr const& expr,BOOST_PP_ENUM(n, MSM_CONSTRUCTOR_HELPER_EXECUTE_SUB, ~ ), \ - typename ::boost::enable_if<typename ::boost::proto::is_expr<Expr>::type >::type* =0 ) \ - :Derived(BOOST_PP_ENUM_PARAMS(n,t)) \ - ,m_events_queue() \ - ,m_deferred_events_queue() \ - ,m_history() \ - ,m_event_processing(false) \ - ,m_is_included(false) \ - ,m_visitors() \ - ,m_substate_list() \ - { \ - BOOST_MPL_ASSERT_MSG( \ - ( ::boost::proto::matches<Expr, FoldToList>::value), \ - THE_STATES_EXPRESSION_PASSED_DOES_NOT_MATCH_GRAMMAR, \ - (FoldToList)); \ - ::boost::mpl::for_each< seq_initial_states, ::boost::msm::wrap<mpl::placeholders::_1> > \ - (init_states(m_states)); \ - m_history.set_initial_states(m_states); \ - set_states(expr); \ - fill_states(this); \ - } - - BOOST_PP_REPEAT_FROM_TO(1,BOOST_PP_ADD(BOOST_MSM_CONSTRUCTOR_ARG_SIZE,1), MSM_CONSTRUCTOR_HELPER_EXECUTE, ~) -#undef MSM_CONSTRUCTOR_HELPER_EXECUTE -#undef MSM_CONSTRUCTOR_HELPER_EXECUTE_SUB - - - - // assignment operator using the copy policy to decide if non_copyable, shallow or deep copying is necessary - library_sm& operator= (library_sm const& rhs) - { - if (this != &rhs) - { - Derived::operator=(rhs); - do_copy(rhs); - } - return *this; - } - state_machine<A0,A1,A2,A3,A4> - (library_sm const& rhs) - : Derived(rhs) - { - if (this != &rhs) - { - // initialize our list of states with the ones defined in Derived::initial_state - fill_states(this); - do_copy(rhs); - } - } - - // the following 2 functions handle the terminate/interrupt states handling - // if one of these states is found, the first one is used - template <class Event> - bool is_event_handling_blocked_helper( ::boost::mpl::true_ const &) - { - // if the state machine is terminated, do not handle any event - if (is_flag_active< ::boost::msm::TerminateFlag>()) - return true; - // if the state machine is interrupted, do not handle any event - // unless the event is the end interrupt event - if ( is_flag_active< ::boost::msm::InterruptedFlag>() && - !is_flag_active< ::boost::msm::EndInterruptFlag<Event> >()) - return true; - return false; - } - // otherwise simple handling, no flag => continue - template <class Event> - bool is_event_handling_blocked_helper( ::boost::mpl::false_ const &) - { - // no terminate/interrupt states detected - return false; - } - // the following functions handle pre/post-process handling of a message queue - template <class StateType,class EventType> - bool do_pre_msg_queue_helper(EventType const&, ::boost::mpl::true_ const &) - { - // no message queue needed - return true; - } - template <class StateType,class EventType> - bool do_pre_msg_queue_helper(EventType const& evt, ::boost::mpl::false_ const &) - { - execute_return (library_sm::*pf) (EventType const& evt) = - &library_sm::process_event; - // if we are already processing an event - if (m_event_processing) - { - // event has to be put into the queue - transition_fct f = ::boost::bind(pf,this,evt); - m_events_queue.m_events_queue.push_back(f); - return false; - } - // event can be handled, processing - m_event_processing = true; - return true; - } - void do_post_msg_queue_helper( ::boost::mpl::true_ const &) - { - // no message queue needed - } - void do_post_msg_queue_helper( ::boost::mpl::false_ const &) - { - m_event_processing = false; - process_message_queue(this); - } - // the following 2 functions handle the processing either with a try/catch protection or without - template <class StateType,class EventType> - HandledEnum do_process_helper(EventType const& evt, ::boost::mpl::true_ const &, bool is_direct_call) - { - return this->do_process_event(evt,is_direct_call); - } - template <class StateType,class EventType> - HandledEnum do_process_helper(EventType const& evt, ::boost::mpl::false_ const &, bool is_direct_call) - { - // when compiling without exception support there is no formal parameter "e" in the catch handler. - // Declaring a local variable here does not hurt and will be "used" to make the code in the handler - // compilable although the code will never be executed. - std::exception e; - BOOST_TRY - { - return this->do_process_event(evt,is_direct_call); - } - BOOST_CATCH (std::exception& e) - { - // give a chance to the concrete state machine to handle - this->exception_caught(evt,*this,e); - } - BOOST_CATCH_END - return HANDLED_TRUE; - } - // handling of deferred events - // if none is found in the SM, take the following empty main version - template <class StateType, class Enable = int> - struct handle_defer_helper - { - handle_defer_helper(deferred_msg_queue_helper<library_sm>& ){} - void do_pre_handle_deferred() - { - } - - void do_post_handle_deferred(HandledEnum) - { - } - }; - // otherwise the standard version handling the deferred events - template <class StateType> - struct handle_defer_helper - <StateType, typename enable_if< typename ::boost::msm::back::has_fsm_deferred_events<StateType>::type,int >::type> - { - handle_defer_helper(deferred_msg_queue_helper<library_sm>& a_queue): - events_queue(a_queue),next_deferred_event(){} - void do_pre_handle_deferred() - { - } - - void do_post_handle_deferred(HandledEnum handled) - { - if (handled == HANDLED_TRUE) - { - // a transition has been taken, it makes sense again to try processing waiting deferred events - // reset all events to not tested - for (std::size_t i = 0; i < events_queue.m_deferred_events_queue.size(); ++i) - { - events_queue.m_deferred_events_queue[i].second=false; - } - // test first event - if (!events_queue.m_deferred_events_queue.empty()) - { - deferred_fct next = events_queue.m_deferred_events_queue.front().first; - events_queue.m_deferred_events_queue.pop_front(); - next(); - } - } - else - { - // look for next deferred event, if any - typename deferred_events_queue_t::iterator it = - std::find_if(events_queue.m_deferred_events_queue.begin(), - events_queue.m_deferred_events_queue.end(), - boost::bind(&std::pair<deferred_fct,bool>::second, _1) == false); - if (it != events_queue.m_deferred_events_queue.end()) - { - (*it).second = true; - deferred_fct next = (*it).first; - events_queue.m_deferred_events_queue.erase(it); - next(); - } - } - } - - private: - deferred_msg_queue_helper<library_sm>& events_queue; - deferred_fct next_deferred_event; - }; - - // handling of eventless transitions - // if none is found in the SM, nothing to do - template <class StateType, class Enable = void> - struct handle_eventless_transitions_helper - { - handle_eventless_transitions_helper(library_sm* , bool ){} - void process_completion_event(){} - }; - // otherwise - template <class StateType> - struct handle_eventless_transitions_helper - <StateType, typename enable_if< typename ::boost::msm::back::has_fsm_eventless_transition<StateType>::type >::type> - { - handle_eventless_transitions_helper(library_sm* self_, bool handled_):self(self_),handled(handled_){} - void process_completion_event() - { - typedef typename ::boost::mpl::deref< - typename ::boost::mpl::begin< - typename find_completion_events<StateType>::type - >::type - >::type first_completion_event; - if (handled) - { - self->process_event(first_completion_event() ); - } - } - - private: - library_sm* self; - bool handled; - }; - - // helper class called in case the event to process has been found in the fsm's internal stt and is therefore processable - template<class Event> - struct process_fsm_internal_table - { - typedef typename ::boost::mpl::has_key<processable_events_internal_table,Event>::type is_event_processable; - - // forward to the correct do_process - static void process(Event const& evt,library_sm* self_,HandledEnum& result) - { - do_process(evt,self_,result,is_event_processable()); - } - private: - // the event is processable, let's try! - static void do_process(Event const& evt,library_sm* self_,HandledEnum& result, ::boost::mpl::true_) - { - if (result != HANDLED_TRUE) - { - typedef dispatch_table<library_sm,complete_table,Event,CompilePolicy> table; - HandledEnum res_internal = table::instance.entries[0](*self_, 0, self_->m_states[0], evt); - result = (HandledEnum)((int)result | (int)res_internal); - } - } - // version doing nothing if the event is not in the internal stt and we can save ourselves the time trying to process - static void do_process(Event const& ,library_sm* ,HandledEnum& , ::boost::mpl::false_) - { - // do nothing - } - }; - - template <class StateType,class Enable=void> - struct region_processing_helper - { - public: - region_processing_helper(library_sm* self_,HandledEnum& result_) - :self(self_),result(result_){} - template<class Event> - void process(Event const& evt) - { - // use this table as if it came directly from the user - typedef dispatch_table<library_sm,complete_table,Event,CompilePolicy> table; - // +1 because index 0 is reserved for this fsm - HandledEnum res = - table::instance.entries[self->m_states[0]+1]( - *self, 0, self->m_states[0], evt); - result = (HandledEnum)((int)result | (int)res); - // process the event in the internal table of this fsm if the event is processable (present in the table) - process_fsm_internal_table<Event>::process(evt,self,result); - } - library_sm* self; - HandledEnum& result; - }; - // version with visitors - template <class StateType> - struct region_processing_helper<StateType,typename ::boost::enable_if< - ::boost::mpl::is_sequence<typename StateType::initial_state> >::type> - { - private: - // process event in one region - template <class region_id,int Dummy=0> - struct In - { - template<class Event> - static void process(Event const& evt,library_sm* self_,HandledEnum& result_) - { - // use this table as if it came directly from the user - typedef dispatch_table<library_sm,complete_table,Event,CompilePolicy> table; - // +1 because index 0 is reserved for this fsm - HandledEnum res = - table::instance.entries[self_->m_states[region_id::value]+1]( - *self_, region_id::value , self_->m_states[region_id::value], evt); - result_ = (HandledEnum)((int)result_ | (int)res); - In< ::boost::mpl::int_<region_id::value+1> >::process(evt,self_,result_); - } - }; - template <int Dummy> - struct In< ::boost::mpl::int_<nr_regions::value>,Dummy> - { - // end of processing - template<class Event> - static void process(Event const& evt,library_sm* self_,HandledEnum& result_) - { - // process the event in the internal table of this fsm if the event is processable (present in the table) - process_fsm_internal_table<Event>::process(evt,self_,result_); - } - }; - public: - region_processing_helper(library_sm* self_,HandledEnum& result_) - :self(self_),result(result_){} - template<class Event> - void process(Event const& evt) - { - In< ::boost::mpl::int_<0> >::process(evt,self,result); - } - - library_sm* self; - HandledEnum& result; - }; - - // Main function used internally to make transitions - // Can only be called for internally (for example in an action method) generated events. - template<class Event> - execute_return process_event_internal(Event const& evt, bool is_direct_call) - { - HandledEnum ret_handled=HANDLED_FALSE; - // if the state machine has terminate or interrupt flags, check them, otherwise skip - if (is_event_handling_blocked_helper<Event> - ( ::boost::mpl::bool_<has_fsm_blocking_states<library_sm>::type::value>() ) ) - return HANDLED_TRUE; - // if a message queue is needed and processing is on the way - if (!do_pre_msg_queue_helper<Event> - (evt,::boost::mpl::bool_<is_no_message_queue<library_sm>::type::value>()) ) - { - // wait for the end of current processing - return HANDLED_TRUE; - } - else - { - // prepare the next deferred event for handling - // if one defer is found in the SM, otherwise skip - handle_defer_helper<library_sm> defer_helper(m_deferred_events_queue); - defer_helper.do_pre_handle_deferred(); - // process event - HandledEnum handled = this->do_process_helper<Event> - (evt,::boost::mpl::bool_<is_no_exception_thrown<library_sm>::type::value>(),is_direct_call); - if (handled) - { - ret_handled = handled; - } - - // process completion transitions BEFORE any other event in the pool (UML Standard 2.3 15.3.14) - handle_eventless_transitions_helper<library_sm> eventless_helper(this,(handled == HANDLED_TRUE)); - eventless_helper.process_completion_event(); - - // after handling, take care of the deferred events - defer_helper.do_post_handle_deferred(handled); - - // now check if some events were generated in a transition and was not handled - // because of another processing, and if yes, start handling them - do_post_msg_queue_helper(::boost::mpl::bool_<is_no_message_queue<library_sm>::type::value>()); - - return ret_handled; - } - } - - // minimum event processing without exceptions, queues, etc. - template<class Event> - HandledEnum do_process_event(Event const& evt, bool is_direct_call) - { - HandledEnum handled = HANDLED_FALSE; - // dispatch the event to every region - region_processing_helper<Derived> helper(this,handled); - helper.process(evt); - - // if the event has not been handled and we have orthogonal zones, then - // generate an error on every active state - // for state machine states contained in other state machines, do not handle - // but let the containing sm handle the error, unless the event was generated in this fsm - // (by calling process_event on this fsm object, is_direct_call == true) - // completion events do not produce an error - if ( (!is_contained() || is_direct_call) && !handled && !is_completion_event<Event>::type::value) - { - for (int i=0; i<nr_regions::value;++i) - { - this->no_transition(evt,*this,this->m_states[i]); - } - } - return handled; - } - - // default row arguments for the compilers which accept this - template <class Event> - bool no_guard(Event const&){return true;} - template <class Event> - void no_action(Event const&){} - -#ifndef BOOST_NO_RTTI - HandledEnum process_any_event( ::boost::any const& evt); -#endif - -private: - // composite accept implementation. First calls accept on the composite, then accept on all its active states. - void composite_accept() - { - this->accept(); - this->visit_current_states(); - } - -#define MSM_COMPOSITE_ACCEPT_SUB(z, n, unused) ARG ## n vis ## n -#define MSM_COMPOSITE_ACCEPT_SUB2(z, n, unused) boost::ref( vis ## n ) -#define MSM_COMPOSITE_ACCEPT_EXECUTE(z, n, unused) \ - template <BOOST_PP_ENUM_PARAMS(n, class ARG)> \ - void composite_accept(BOOST_PP_ENUM(n, MSM_COMPOSITE_ACCEPT_SUB, ~ ) ) \ - { \ - this->accept(BOOST_PP_ENUM_PARAMS(n,vis)); \ - this->visit_current_states(BOOST_PP_ENUM(n,MSM_COMPOSITE_ACCEPT_SUB2, ~)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,BOOST_PP_ADD(BOOST_MSM_VISITOR_ARG_SIZE,1), MSM_COMPOSITE_ACCEPT_EXECUTE, ~) -#undef MSM_COMPOSITE_ACCEPT_EXECUTE -#undef MSM_COMPOSITE_ACCEPT_SUB -#undef MSM_COMPOSITE_ACCEPT_SUB2 - - // helper used to call the init states at the start of the state machine - template <class Event> - struct call_init - { - call_init(Event const& an_event,library_sm* self_): - evt(an_event),self(self_){} - template <class State> - void operator()(boost::msm::wrap<State> const&) - { - execute_entry(::boost::fusion::at_key<State>(self->m_substate_list),evt,*self); - } - private: - Event const& evt; - library_sm* self; - }; - // helper for flag handling. Uses OR by default on orthogonal zones. - template <class Flag,bool orthogonalStates> - struct FlagHelper - { - static bool helper(library_sm const& sm,flag_handler* ) - { - // by default we use OR to accumulate the flags - return sm.is_flag_active<Flag,Flag_OR>(); - } - }; - template <class Flag> - struct FlagHelper<Flag,false> - { - static bool helper(library_sm const& sm,flag_handler* flags_entries) - { - // just one active state, so we can call operator[] with 0 - return flags_entries[sm.current_state()[0]](sm); - } - }; - // handling of flag - // defines a true and false functions plus a forwarding one for composite states - template <class StateType,class Flag> - struct FlagHandler - { - static bool flag_true(library_sm const& ) - { - return true; - } - static bool flag_false(library_sm const& ) - { - return false; - } - static bool forward(library_sm const& fsm) - { - return ::boost::fusion::at_key<StateType>(fsm.m_substate_list).template is_flag_active<Flag>(); - } - }; - template <class Flag> - struct init_flags - { - private: - // helper function, helps hiding the forward function for non-state machines states. - template <class T> - void helper (flag_handler* an_entry,int offset, ::boost::mpl::true_ const & ) - { - // composite => forward - an_entry[offset] = &FlagHandler<T,Flag>::forward; - } - template <class T> - void helper (flag_handler* an_entry,int offset, ::boost::mpl::false_ const & ) - { - // default no flag - an_entry[offset] = &FlagHandler<T,Flag>::flag_false; - } - // attributes - flag_handler* entries; - - public: - init_flags(flag_handler* entries_) - : entries(entries_) - {} - - // Flags initializer function object, used with mpl::for_each - template <class StateType> - void operator()( ::boost::msm::wrap<StateType> const& ) - { - typedef typename get_flag_list<StateType>::type flags; - typedef typename ::boost::mpl::contains<flags,Flag >::type found; - - BOOST_STATIC_CONSTANT(int, state_id = (get_state_id<stt,StateType>::type::value)); - if (found::type::value) - { - // the type defined the flag => true - entries[state_id] = &FlagHandler<StateType,Flag>::flag_true; - } - else - { - // false or forward - typedef typename ::boost::mpl::and_< - typename is_composite_state<StateType>::type, - typename ::boost::mpl::not_< - typename has_non_forwarding_flag<Flag>::type>::type >::type composite_no_forward; - - helper<StateType>(entries,state_id,::boost::mpl::bool_<composite_no_forward::type::value>()); - } - } - }; - // maintains for every flag a static array containing the flag value for every state - template <class Flag> - flag_handler* get_entries_for_flag() const - { - BOOST_STATIC_CONSTANT(int, max_state = (mpl::size<state_list>::value)); - - static flag_handler flags_entries[max_state]; - // build a state list - ::boost::mpl::for_each<state_list, boost::msm::wrap< ::boost::mpl::placeholders::_1> > - (init_flags<Flag>(flags_entries)); - return flags_entries; - } - - // helper used to create a state using the correct constructor - template <class State, class Enable=void> - struct create_state_helper - { - static void set_sm(library_sm* ) - { - // state doesn't need its sm - } - }; - // create a state requiring a pointer to the state machine - template <class State> - struct create_state_helper<State,typename boost::enable_if<typename State::needs_sm >::type> - { - static void set_sm(library_sm* sm) - { - // create and set the fsm - ::boost::fusion::at_key<State>(sm->m_substate_list).set_sm_ptr(sm); - } - }; - // main unspecialized helper class - template <class StateType,int ARGS> - struct visitor_args; - -#define MSM_VISITOR_ARGS_SUB(z, n, unused) BOOST_PP_CAT(_,BOOST_PP_ADD(n,1)) -#define MSM_VISITOR_ARGS_TYPEDEF_SUB(z, n, unused) typename StateType::accept_sig::argument ## n - -#define MSM_VISITOR_ARGS_EXECUTE(z, n, unused) \ - template <class StateType> \ - struct visitor_args<StateType,n> \ - { \ - template <class State> \ - static typename enable_if_c<!is_composite_state<State>::value,void >::type \ - helper (library_sm* sm, \ - int id,StateType& astate) \ - { \ - sm->m_visitors.insert(id, boost::bind(&StateType::accept, \ - ::boost::ref(astate) BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM(n, MSM_VISITOR_ARGS_SUB, ~) )); \ - } \ - template <class State> \ - static typename enable_if_c<is_composite_state<State>::value,void >::type \ - helper (library_sm* sm, \ - int id,StateType& astate) \ - { \ - void (StateType::*caccept)(BOOST_PP_ENUM(n, MSM_VISITOR_ARGS_TYPEDEF_SUB, ~ ) ) \ - = &StateType::composite_accept; \ - sm->m_visitors.insert(id, boost::bind(caccept, \ - ::boost::ref(astate) BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM(n, MSM_VISITOR_ARGS_SUB, ~) )); \ - } \ -}; -BOOST_PP_REPEAT(BOOST_PP_ADD(BOOST_MSM_VISITOR_ARG_SIZE,1), MSM_VISITOR_ARGS_EXECUTE, ~) -#undef MSM_VISITOR_ARGS_EXECUTE -#undef MSM_VISITOR_ARGS_SUB - -// the IBM compiler seems to have problems with nested classes -// the same seems to apply to the Apple version of gcc 4.0.1 (just in case we do for < 4.1) -// and also to MS VC < 8 -#if defined (__IBMCPP__) || (__GNUC__ == 4 && __GNUC_MINOR__ < 1) || (defined(_MSC_VER) && (_MSC_VER < 1400)) - public: -#endif - template<class ContainingSM> - void set_containing_sm(ContainingSM* sm) - { - m_is_included=true; - ::boost::fusion::for_each(m_substate_list,add_state<ContainingSM>(this,sm)); - } -#if defined (__IBMCPP__) || (__GNUC__ == 4 && __GNUC_MINOR__ < 1) || (defined(_MSC_VER) && (_MSC_VER < 1400)) - private: -#endif - // A function object for use with mpl::for_each that stuffs - // states into the state list. - template<class ContainingSM> - struct add_state - { - add_state(library_sm* self_,ContainingSM* sm) - : self(self_),containing_sm(sm){} - - // State is a sub fsm with exit pseudo states and gets a pointer to this fsm, so it can build a callback - template <class StateType> - typename ::boost::enable_if< - typename is_composite_state<StateType>::type,void >::type - new_state_helper(boost::msm::back::dummy<0> = 0) const - { - ::boost::fusion::at_key<StateType>(self->m_substate_list).set_containing_sm(containing_sm); - } - // State is a sub fsm without exit pseudo states and does not get a callback to this fsm - // or state is a normal state and needs nothing except creation - template <class StateType> - typename ::boost::enable_if< - typename boost::mpl::and_<typename boost::mpl::not_ - <typename is_composite_state<StateType>::type>::type, - typename boost::mpl::not_ - <typename is_pseudo_exit<StateType>::type>::type - >::type,void>::type - new_state_helper( ::boost::msm::back::dummy<1> = 0) const - { - //nothing to do - } - // state is exit pseudo state and gets callback to target fsm - template <class StateType> - typename ::boost::enable_if<typename is_pseudo_exit<StateType>::type,void >::type - new_state_helper( ::boost::msm::back::dummy<2> = 0) const - { - execute_return (ContainingSM::*pf) (typename StateType::event const& evt)= - &ContainingSM::process_event; - ::boost::function<execute_return (typename StateType::event const&)> fct = - ::boost::bind(pf,containing_sm,_1); - ::boost::fusion::at_key<StateType>(self->m_substate_list).set_forward_fct(fct); - } - // for every defined state in the sm - template <class State> - void operator()( State const&) const - { - //create a new state with the defined id and type - BOOST_STATIC_CONSTANT(int, state_id = (get_state_id<stt,State>::value)); - - this->new_state_helper<State>(), - create_state_helper<State>::set_sm(self); - // create a visitor callback - visitor_helper(state_id,::boost::fusion::at_key<State>(self->m_substate_list), - ::boost::mpl::bool_<has_accept_sig<State>::type::value>()); - } - private: - // support possible use of a visitor if accept_sig is defined - template <class StateType> - void visitor_helper(int id,StateType& astate, ::boost::mpl::true_ const & ) const - { - visitor_args<StateType,StateType::accept_sig::args_number>:: - template helper<StateType>(self,id,astate); - } - template <class StateType> - void visitor_helper(int ,StateType& , ::boost::mpl::false_ const &) const - { - // nothing to do - } - - library_sm* self; - ContainingSM* containing_sm; - }; - - // helper used to copy every state if needed - struct copy_helper - { - copy_helper(library_sm* sm): - m_sm(sm){} - template <class StateType> - void operator()( ::boost::msm::wrap<StateType> const& ) - { - BOOST_STATIC_CONSTANT(int, state_id = (get_state_id<stt,StateType>::type::value)); - // possibly also set the visitor - visitor_helper<StateType>(state_id); - - // and for states that keep a pointer to the fsm, reset the pointer - create_state_helper<StateType>::set_sm(m_sm); - } - template <class StateType> - typename ::boost::enable_if<typename has_accept_sig<StateType>::type,void >::type - visitor_helper(int id) const - { - visitor_args<StateType,StateType::accept_sig::args_number>::template helper<StateType> - (m_sm,id,::boost::fusion::at_key<StateType>(m_sm->m_substate_list)); - } - template <class StateType> - typename ::boost::disable_if<typename has_accept_sig<StateType>::type,void >::type - visitor_helper(int) const - { - // nothing to do - } - - library_sm* m_sm; - }; - // helper to copy the active states attribute - template <class region_id,int Dummy=0> - struct region_copy_helper - { - static void do_copy(library_sm* self_,library_sm const& rhs) - { - self_->m_states[region_id::value] = rhs.m_states[region_id::value]; - region_copy_helper< ::boost::mpl::int_<region_id::value+1> >::do_copy(self_,rhs); - } - }; - template <int Dummy> - struct region_copy_helper< ::boost::mpl::int_<nr_regions::value>,Dummy> - { - // end of processing - static void do_copy(library_sm*,library_sm const& ){} - }; - // copy functions for deep copy (no need of a 2nd version for NoCopy as noncopyable handles it) - void do_copy (library_sm const& rhs, - ::boost::msm::back::dummy<0> = 0) - { - // deep copy simply assigns the data - region_copy_helper< ::boost::mpl::int_<0> >::do_copy(this,rhs); - m_events_queue = rhs.m_events_queue; - m_deferred_events_queue = rhs.m_deferred_events_queue; - m_history = rhs.m_history; - m_event_processing = rhs.m_event_processing; - m_is_included = rhs.m_is_included; - m_substate_list = rhs.m_substate_list; - // except for the states themselves, which get duplicated - - ::boost::mpl::for_each<state_list, ::boost::msm::wrap< ::boost::mpl::placeholders::_1> > - (copy_helper(this)); - } - - // helper used to call the correct entry/exit method - // unfortunately in O(number of states in the sub-sm) but should be better than a virtual call - template<class Event,bool is_entry> - struct entry_exit_helper - { - entry_exit_helper(int id,Event const& e,library_sm* self_): - state_id(id),evt(e),self(self_){} - // helper for entry actions - template <class IsEntry,class State> - typename ::boost::enable_if<typename IsEntry::type,void >::type - helper( ::boost::msm::back::dummy<0> = 0) - { - BOOST_STATIC_CONSTANT(int, id = (get_state_id<stt,State>::value)); - if (id == state_id) - { - execute_entry<State>(::boost::fusion::at_key<State>(self->m_substate_list),evt,*self); - } - } - // helper for exit actions - template <class IsEntry,class State> - typename boost::disable_if<typename IsEntry::type,void >::type - helper( ::boost::msm::back::dummy<1> = 0) - { - BOOST_STATIC_CONSTANT(int, id = (get_state_id<stt,State>::value)); - if (id == state_id) - { - execute_exit<State>(::boost::fusion::at_key<State>(self->m_substate_list),evt,*self); - } - } - // iterates through all states to find the one to be activated - template <class State> - void operator()( ::boost::msm::wrap<State> const&) - { - entry_exit_helper<Event,is_entry>::template helper< ::boost::mpl::bool_<is_entry>,State >(); - } - private: - int state_id; - Event const& evt; - library_sm* self; - }; - - // helper to start the fsm - template <class region_id,int Dummy=0> - struct region_start_helper - { - template<class Event> - static void do_start(library_sm* self_,Event const& incomingEvent) - { - //forward the event for handling by sub state machines - ::boost::mpl::for_each<state_list, ::boost::msm::wrap< ::boost::mpl::placeholders::_1> > - (entry_exit_helper<Event,true>(self_->m_states[region_id::value],incomingEvent,self_)); - region_start_helper - < ::boost::mpl::int_<region_id::value+1> >::do_start(self_,incomingEvent); - } - }; - template <int Dummy> - struct region_start_helper< ::boost::mpl::int_<nr_regions::value>,Dummy> - { - // end of processing - template<class Event> - static void do_start(library_sm*,Event const& ){} - }; - // start for states machines which are themselves embedded in other state machines (composites) - template <class Event> - void internal_start(Event const& incomingEvent) - { - region_start_helper< ::boost::mpl::int_<0> >::do_start(this,incomingEvent); - // give a chance to handle an anonymous (eventless) transition - handle_eventless_transitions_helper<library_sm> eventless_helper(this,true); - eventless_helper.process_completion_event(); - } - - template <class StateType> - struct find_region_id - { - template <int region,int Dummy=0> - struct In - { - enum {region_index=region}; - }; - // if the user provides no region, find it! - template<int Dummy> - struct In<-1,Dummy> - { - typedef typename build_orthogonal_regions< - library_sm, - initial_states - >::type all_regions; - enum {region_index= find_region_index<all_regions,StateType>::value }; - }; - enum {region_index = In<StateType::zone_index>::region_index }; - }; - // helper used to set the correct state as active state upon entry into a fsm - struct direct_event_start_helper - { - direct_event_start_helper(library_sm* self_):self(self_){} - // this variant is for the standard case, entry due to activation of the containing FSM - template <class EventType,class FsmType> - typename ::boost::disable_if<typename has_direct_entry<EventType>::type,void>::type - operator()(EventType const& evt,FsmType& fsm, ::boost::msm::back::dummy<0> = 0) - { - (static_cast<Derived*>(self))->on_entry(evt,fsm); - self->internal_start(evt); - } - - // this variant is for the direct entry case (just one entry, not a sequence of entries) - template <class EventType,class FsmType> - typename ::boost::enable_if< - typename ::boost::mpl::and_< - typename ::boost::mpl::not_< typename is_pseudo_entry< - typename EventType::active_state>::type >::type, - typename ::boost::mpl::and_<typename has_direct_entry<EventType>::type, - typename ::boost::mpl::not_<typename ::boost::mpl::is_sequence - <typename EventType::active_state>::type >::type - >::type>::type,void - >::type - operator()(EventType const& evt,FsmType& fsm, ::boost::msm::back::dummy<1> = 0) - { - (static_cast<Derived*>(self))->on_entry(evt,fsm); - int state_id = get_state_id<stt,typename EventType::active_state::wrapped_entry>::value; - BOOST_STATIC_ASSERT(find_region_id<typename EventType::active_state::wrapped_entry>::region_index >= 0); - BOOST_STATIC_ASSERT(find_region_id<typename EventType::active_state::wrapped_entry>::region_index < nr_regions::value); - // just set the correct zone, the others will be default/history initialized - self->m_states[find_region_id<typename EventType::active_state::wrapped_entry>::region_index] = state_id; - self->internal_start(evt.m_event); - } - - // this variant is for the fork entry case (a sequence on entries) - template <class EventType,class FsmType> - typename ::boost::enable_if< - typename ::boost::mpl::and_< - typename ::boost::mpl::not_< - typename is_pseudo_entry<typename EventType::active_state>::type >::type, - typename ::boost::mpl::and_<typename has_direct_entry<EventType>::type, - typename ::boost::mpl::is_sequence< - typename EventType::active_state>::type - >::type>::type,void - >::type - operator()(EventType const& evt,FsmType& fsm, ::boost::msm::back::dummy<2> = 0) - { - (static_cast<Derived*>(self))->on_entry(evt,fsm); - ::boost::mpl::for_each<typename EventType::active_state, - ::boost::msm::wrap< ::boost::mpl::placeholders::_1> > - (fork_helper<EventType>(self,evt)); - // set the correct zones, the others (if any) will be default/history initialized - self->internal_start(evt.m_event); - } - - // this variant is for the pseudo state entry case - template <class EventType,class FsmType> - typename ::boost::enable_if< - typename is_pseudo_entry<typename EventType::active_state >::type,void - >::type - operator()(EventType const& evt,FsmType& fsm, ::boost::msm::back::dummy<3> = 0) - { - // entry on the FSM - (static_cast<Derived*>(self))->on_entry(evt,fsm); - int state_id = get_state_id<stt,typename EventType::active_state::wrapped_entry>::value; - BOOST_STATIC_ASSERT(find_region_id<typename EventType::active_state::wrapped_entry>::region_index >= 0); - BOOST_STATIC_ASSERT(find_region_id<typename EventType::active_state::wrapped_entry>::region_index < nr_regions::value); - // given region starts with the entry pseudo state as active state - self->m_states[find_region_id<typename EventType::active_state::wrapped_entry>::region_index] = state_id; - self->internal_start(evt.m_event); - // and we process the transition in the zone of the newly active state - // (entry pseudo states are, according to UML, a state connecting 1 transition outside to 1 inside - self->process_event(evt.m_event); - } - private: - // helper for the fork case, does almost like the direct entry - library_sm* self; - template <class EventType> - struct fork_helper - { - fork_helper(library_sm* self_,EventType const& evt_): - helper_self(self_),helper_evt(evt_){} - template <class StateType> - void operator()( ::boost::msm::wrap<StateType> const& ) - { - int state_id = get_state_id<stt,typename StateType::wrapped_entry>::value; - BOOST_STATIC_ASSERT(find_region_id<typename StateType::wrapped_entry>::region_index >= 0); - BOOST_STATIC_ASSERT(find_region_id<typename StateType::wrapped_entry>::region_index < nr_regions::value); - helper_self->m_states[find_region_id<typename StateType::wrapped_entry>::region_index] = state_id; - } - private: - library_sm* helper_self; - EventType const& helper_evt; - }; - }; - - // helper for entry - template <class region_id,int Dummy=0> - struct region_entry_exit_helper - { - template<class Event> - static void do_entry(library_sm* self_,Event const& incomingEvent) - { - self_->m_states[region_id::value] = - self_->m_history.history_entry(incomingEvent)[region_id::value]; - region_entry_exit_helper - < ::boost::mpl::int_<region_id::value+1> >::do_entry(self_,incomingEvent); - } - template<class Event> - static void do_exit(library_sm* self_,Event const& incomingEvent) - { - ::boost::mpl::for_each<state_list, ::boost::msm::wrap< ::boost::mpl::placeholders::_1> > - (entry_exit_helper<Event,false>(self_->m_states[region_id::value],incomingEvent,self_)); - region_entry_exit_helper - < ::boost::mpl::int_<region_id::value+1> >::do_exit(self_,incomingEvent); - } - }; - template <int Dummy> - struct region_entry_exit_helper< ::boost::mpl::int_<nr_regions::value>,Dummy> - { - // end of processing - template<class Event> - static void do_entry(library_sm*,Event const& ){} - template<class Event> - static void do_exit(library_sm*,Event const& ){} - }; - // entry/exit for states machines which are themselves embedded in other state machines (composites) - template <class Event,class FsmType> - void do_entry(Event const& incomingEvent,FsmType& fsm) - { - // by default we activate the history/init states, can be overwritten by direct_event_start_helper - region_entry_exit_helper< ::boost::mpl::int_<0> >::do_entry(this,incomingEvent); - // block immediate handling of events - m_event_processing = true; - // if the event is generating a direct entry/fork, set the current state(s) to the direct state(s) - direct_event_start_helper(this)(incomingEvent,fsm); - // handle messages which were generated and blocked in the init calls - m_event_processing = false; - // look for deferred events waiting - handle_defer_helper<library_sm> defer_helper(m_deferred_events_queue); - defer_helper.do_post_handle_deferred(HANDLED_TRUE); - process_message_queue(this); - } - template <class Event,class FsmType> - void do_exit(Event const& incomingEvent,FsmType& fsm) - { - // first recursively exit the sub machines - // forward the event for handling by sub state machines - region_entry_exit_helper< ::boost::mpl::int_<0> >::do_exit(this,incomingEvent); - // then call our own exit - (static_cast<Derived*>(this))->on_exit(incomingEvent,fsm); - // give the history a chance to handle this (or not). - m_history.history_exit(this->m_states); - // history decides what happens with deferred events - if (!m_history.process_deferred_events(incomingEvent)) - { - clear_deferred_queue(); - } - } - - // the IBM and VC<8 compilers seem to have problems with the friend declaration of dispatch_table -#if defined (__IBMCPP__) || (defined(_MSC_VER) && (_MSC_VER < 1400)) - public: -#endif - // no transition for event. - template <class Event> - static HandledEnum call_no_transition(library_sm& , int , int , Event const& ) - { - return HANDLED_FALSE; - } - // no transition for event for internal transitions (not an error). - template <class Event> - static HandledEnum call_no_transition_internal(library_sm& , int , int , Event const& ) - { - //// reject to give others a chance to handle - //return HANDLED_GUARD_REJECT; - return HANDLED_FALSE; - } - // called for deferred events. Address set in the dispatch_table at init - template <class Event> - static HandledEnum defer_transition(library_sm& fsm, int , int , Event const& e) - { - fsm.defer_event(e); - return HANDLED_DEFERRED; - } - // called for completion events. Default address set in the dispatch_table at init - // prevents no-transition detection for completion events - template <class Event> - static HandledEnum default_eventless_transition(library_sm&, int, int , Event const&) - { - return HANDLED_FALSE; - } -#if defined (__IBMCPP__) || (defined(_MSC_VER) && (_MSC_VER < 1400)) - private: -#endif - // puts a deferred event in the queue - void post_deferred_event(deferred_fct& deferred) - { - m_deferred_events_queue.m_deferred_events_queue.push_back(std::make_pair(deferred,true)); - } - // removes one event from the message queue and processes it - template <class StateType> - void process_message_queue(StateType*, - typename ::boost::disable_if<typename is_no_message_queue<StateType>::type,void >::type* = 0) - { - if (!m_events_queue.m_events_queue.empty()) - { - transition_fct to_call = m_events_queue.m_events_queue.front(); - m_events_queue.m_events_queue.pop_front(); - to_call(); - } - } - template <class StateType> - void process_message_queue(StateType*, - typename ::boost::enable_if<typename is_no_message_queue<StateType>::type,void >::type* = 0) - { - // nothing to process - } - // helper function. In cases where the event is wrapped (target is a direct entry states) - // we want to send only the real event to on_entry, not the wrapper. - template <class EventType> - static - typename boost::enable_if<typename has_direct_entry<EventType>::type,typename EventType::contained_event const& >::type - remove_direct_entry_event_wrapper(EventType const& evt,boost::msm::back::dummy<0> = 0) - { - return evt.m_event; - } - template <class EventType> - static typename boost::disable_if<typename has_direct_entry<EventType>::type,EventType const& >::type - remove_direct_entry_event_wrapper(EventType const& evt,boost::msm::back::dummy<1> = 0) - { - // identity. No wrapper - return evt; - } - // calls the entry/exit or on_entry/on_exit depending on the state type - // (avoids calling virtually) - // variant for FSMs - template <class StateType,class EventType,class FsmType> - static - typename boost::enable_if<typename is_composite_state<StateType>::type,void >::type - execute_entry(StateType& astate,EventType const& evt,FsmType& fsm,boost::msm::back::dummy<0> = 0) - { - // calls on_entry on the fsm then handles direct entries, fork, entry pseudo state - astate.do_entry(evt,fsm); - } - // variant for states - template <class StateType,class EventType,class FsmType> - static - typename ::boost::disable_if< - typename ::boost::mpl::or_<typename is_composite_state<StateType>::type, - typename is_pseudo_exit<StateType>::type >::type,void >::type - execute_entry(StateType& astate,EventType const& evt,FsmType& fsm, ::boost::msm::back::dummy<1> = 0) - { - // simple call to on_entry - astate.on_entry(remove_direct_entry_event_wrapper(evt),fsm); - } - // variant for exit pseudo states - template <class StateType,class EventType,class FsmType> - static - typename ::boost::enable_if<typename is_pseudo_exit<StateType>::type,void >::type - execute_entry(StateType& astate,EventType const& evt,FsmType& fsm, ::boost::msm::back::dummy<2> = 0) - { - // calls on_entry on the state then forward the event to the transition which should be defined inside the - // contained fsm - astate.on_entry(evt,fsm); - astate.forward_event(evt); - } - template <class StateType,class EventType,class FsmType> - static - typename ::boost::enable_if<typename is_composite_state<StateType>::type,void >::type - execute_exit(StateType& astate,EventType const& evt,FsmType& fsm, ::boost::msm::back::dummy<0> = 0) - { - astate.do_exit(evt,fsm); - } - template <class StateType,class EventType,class FsmType> - static - typename ::boost::disable_if<typename is_composite_state<StateType>::type,void >::type - execute_exit(StateType& astate,EventType const& evt,FsmType& fsm, ::boost::msm::back::dummy<1> = 0) - { - // simple call to on_exit - astate.on_exit(evt,fsm); - } - - // helper allowing special handling of direct entries / fork - template <class StateType,class TargetType,class EventType,class FsmType> - static - typename ::boost::disable_if< - typename ::boost::mpl::or_<typename has_explicit_entry_state<TargetType>::type, - ::boost::mpl::is_sequence<TargetType> >::type,void>::type - convert_event_and_execute_entry(StateType& astate,EventType const& evt, FsmType& fsm, ::boost::msm::back::dummy<1> = 0) - { - // if the target is a normal state, do the standard entry handling - execute_entry<StateType>(astate,evt,fsm); - } - template <class StateType,class TargetType,class EventType,class FsmType> - static - typename ::boost::enable_if< - typename ::boost::mpl::or_<typename has_explicit_entry_state<TargetType>::type, - ::boost::mpl::is_sequence<TargetType> >::type,void >::type - convert_event_and_execute_entry(StateType& astate,EventType const& evt, FsmType& fsm, ::boost::msm::back::dummy<0> = 0) - { - // for the direct entry, pack the event in a wrapper so that we handle it differently during fsm entry - execute_entry(astate,msm::back::direct_entry_event<TargetType,EventType>(evt),fsm); - } - - // creates all the states - template <class ContainingSM> - void fill_states(ContainingSM* containing_sm=0) - { - // checks that regions are truly orthogonal - FsmCheckPolicy::template check_orthogonality<library_sm>(); - // checks that all states are reachable - FsmCheckPolicy::template check_unreachable_states<library_sm>(); - - BOOST_STATIC_CONSTANT(int, max_state = (mpl::size<state_list>::value)); - // allocate the place without reallocation - m_visitors.fill_visitors(max_state); - ::boost::fusion::for_each(m_substate_list,add_state<ContainingSM>(this,containing_sm)); - - } - -private: - template <class StateType,class Enable=void> - struct msg_queue_helper - { - public: - msg_queue_helper():m_events_queue(){} - events_queue_t m_events_queue; - }; - template <class StateType> - struct msg_queue_helper<StateType, - typename ::boost::enable_if<typename is_no_message_queue<StateType>::type >::type> - { - }; - - template <class Fsm,class Stt, class Event, class Compile> - friend struct dispatch_table; - - // data members - int m_states[nr_regions::value]; - msg_queue_helper<library_sm> m_events_queue; - deferred_msg_queue_helper - <library_sm> m_deferred_events_queue; - concrete_history m_history; - bool m_event_processing; - bool m_is_included; - visitor_fct_helper<BaseState> m_visitors; - substate_list m_substate_list; - - -}; - -} } }// boost::msm::back -#endif //BOOST_MSM_BACK_STATEMACHINE_H - diff --git a/contrib/restricted/boost/boost/msm/back/tools.hpp b/contrib/restricted/boost/boost/msm/back/tools.hpp deleted file mode 100644 index 2b6248e55e1..00000000000 --- a/contrib/restricted/boost/boost/msm/back/tools.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_BACK_TOOLS_H -#define BOOST_MSM_BACK_TOOLS_H - - -#include <string> -#include <iostream> -#include <boost/msm/back/common_types.hpp> -#include <boost/msm/back/metafunctions.hpp> - -namespace boost { namespace msm { namespace back -{ - -// fills the array passed in with the state names in the correct order -// the array must be big enough. To know the needed size, use mpl::size -// on fsm::generate_state_set -template <class stt> -struct fill_state_names -{ - fill_state_names(char const** names):m_names(names){} - template <class StateType> - void operator()(boost::msm::wrap<StateType> const&) - { - m_names[get_state_id<stt,StateType>::value]= typeid(StateType).name(); - } -private: - char const** m_names; -}; - -// fills the typeid-generated name of the given state in the string passed as argument -template <class stt> -struct get_state_name -{ - get_state_name(std::string& name_to_fill, int state_id):m_name(name_to_fill),m_state_id(state_id){} - template <class StateType> - void operator()(boost::msm::wrap<StateType> const&) - { - if (get_state_id<stt,StateType>::value == m_state_id) - { - m_name = typeid(StateType).name(); - } - } -private: - std::string& m_name; - int m_state_id; -}; - -// displays the typeid of the given Type -struct display_type -{ - template <class Type> - void operator()(boost::msm::wrap<Type> const&) - { - std::cout << typeid(Type).name() << std::endl; - } -}; - -} } }//boost::msm::back -#endif //BOOST_MSM_BACK_TOOLS_H diff --git a/contrib/restricted/boost/boost/msm/common.hpp b/contrib/restricted/boost/boost/msm/common.hpp deleted file mode 100644 index 6a80b82275d..00000000000 --- a/contrib/restricted/boost/boost/msm/common.hpp +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_COMMON_H -#define BOOST_MSM_COMMON_H - -namespace boost { namespace msm -{ -// wrapper for mpl::for_each as showed in the C++ Template Metaprogramming ch. 9 -template <class T> -struct wrap{}; - -// tag to use in grammars where states are seen (init_<<, states_<<...) -struct state_tag{}; - -} } // boost::msm -#endif //BOOST_MSM_COMMON_H - diff --git a/contrib/restricted/boost/boost/msm/event_traits.hpp b/contrib/restricted/boost/boost/msm/event_traits.hpp deleted file mode 100644 index 4b2350594f5..00000000000 --- a/contrib/restricted/boost/boost/msm/event_traits.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_EVENT_TRAITS_H -#define BOOST_MSM_EVENT_TRAITS_H - -#include <boost/any.hpp> -#include <boost/mpl/bool.hpp> - -namespace boost { namespace msm -{ - -template< typename Event > -struct is_kleene_event -{ - // default: no event is a kleene event (kleene: matches any event in a transitions) - typedef ::boost::mpl::false_ type; -}; - -// add this way in this namespace specializations for events which you want to use as kleene -// requirement: a copy-constructor matching the events which will be converted to this kleene -template<> -struct is_kleene_event< boost::any > -{ - typedef ::boost::mpl::true_ type; -}; - -} } // boost::msm -#endif //BOOST_MSM_EVENT_TRAITS_H diff --git a/contrib/restricted/boost/boost/msm/front/common_states.hpp b/contrib/restricted/boost/boost/msm/front/common_states.hpp deleted file mode 100644 index daf8d670265..00000000000 --- a/contrib/restricted/boost/boost/msm/front/common_states.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_COMMON_STATES_H -#define BOOST_MSM_FRONT_COMMON_STATES_H - -#include <boost/mpl/int.hpp> -#include <boost/mpl/vector.hpp> -#include <boost/fusion/container/map.hpp> -#include <boost/fusion/include/at_c.hpp> -#include <boost/type_traits/add_const.hpp> -#include <boost/msm/front/detail/common_states.hpp> - -namespace boost { namespace msm { namespace front -{ -// default base: non-polymorphic, not visitable -struct default_base_state -{ - ~default_base_state(){} -}; -// default polymorphic base state. Derive all states from it to get polymorphic behavior -struct polymorphic_state -{ - virtual ~polymorphic_state() {} -}; - -}}} - -#endif //BOOST_MSM_FRONT_COMMON_STATES_H - diff --git a/contrib/restricted/boost/boost/msm/front/completion_event.hpp b/contrib/restricted/boost/boost/msm/front/completion_event.hpp deleted file mode 100644 index 9820e9acf51..00000000000 --- a/contrib/restricted/boost/boost/msm/front/completion_event.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_COMMON_COMPLETION_EVENT_H -#define BOOST_MSM_FRONT_COMMON_COMPLETION_EVENT_H - -namespace boost { namespace msm { namespace front -{ - - struct none - { - // make every event convertible to none. - // to support standard-conform implementation of pseudo exits. - none(){} - template <class Event> - none(Event const&){} - - typedef int completion_event; - }; - -}}} - -#endif //BOOST_MSM_FRONT_COMMON_COMPLETION_EVENT_H - diff --git a/contrib/restricted/boost/boost/msm/front/detail/common_states.hpp b/contrib/restricted/boost/boost/msm/front/detail/common_states.hpp deleted file mode 100644 index 0d770d9ab79..00000000000 --- a/contrib/restricted/boost/boost/msm/front/detail/common_states.hpp +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_DETAILS_COMMON_STATES_H -#define BOOST_MSM_FRONT_DETAILS_COMMON_STATES_H - -#include <boost/mpl/int.hpp> - -#include <boost/mpl/vector.hpp> -#include <boost/fusion/container/map.hpp> -#include <boost/fusion/include/at_key.hpp> -#include <boost/type_traits/add_const.hpp> - -namespace boost { namespace msm { namespace front {namespace detail -{ -template <class Attributes= ::boost::fusion::map<> > -struct inherit_attributes -{ - inherit_attributes():m_attributes(){} - inherit_attributes(Attributes const& the_attributes):m_attributes(the_attributes){} - // on the fly attribute creation capability - typedef Attributes attributes_type; - template <class Index> - typename ::boost::fusion::result_of::at_key<attributes_type, - Index>::type - get_attribute(Index const&) - { - return ::boost::fusion::at_key<Index>(m_attributes); - } - - template <class Index> - typename ::boost::add_const< - typename ::boost::fusion::result_of::at_key<attributes_type, - Index>::type>::type - get_attribute(Index const&)const - { - return const_cast< - typename ::boost::add_const< - typename ::boost::fusion::result_of::at_key< attributes_type, - Index >::type>::type> - (::boost::fusion::at_key<Index>(m_attributes)); - } - -private: - // attributes - Attributes m_attributes; -}; - -// the interface for all states. Defines entry and exit functions. Overwrite to implement for any state needing it. -template<class USERBASE,class Attributes= ::boost::fusion::map<> > -struct state_base : public inherit_attributes<Attributes>, USERBASE -{ - typedef USERBASE user_state_base; - typedef Attributes attributes_type; - - // empty implementation for the states not wishing to define an entry condition - // will not be called polymorphic way - template <class Event,class FSM> - void on_entry(Event const& ,FSM&){} - template <class Event,class FSM> - void on_exit(Event const&,FSM& ){} - // default (empty) transition table; - typedef ::boost::mpl::vector0<> internal_transition_table; - typedef ::boost::mpl::vector0<> transition_table; -}; - -}}}} - -#endif //BOOST_MSM_FRONT_DETAILS_COMMON_STATES_H - diff --git a/contrib/restricted/boost/boost/msm/front/detail/row2_helper.hpp b/contrib/restricted/boost/boost/msm/front/detail/row2_helper.hpp deleted file mode 100644 index 7db4949ef50..00000000000 --- a/contrib/restricted/boost/boost/msm/front/detail/row2_helper.hpp +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_ROW2_HELPER_HPP -#define BOOST_MSM_ROW2_HELPER_HPP - -#include <boost/mpl/bool.hpp> -#include <boost/fusion/include/at_key.hpp> - -namespace boost { namespace msm { namespace front -{ - namespace detail - { - template< - typename CalledForAction - , typename Event - , void (CalledForAction::*action)(Event const&) - > - struct row2_action_helper - { - template <class FSM,class Evt,class SourceState,class TargetState, class AllStates> - static void call_helper(FSM&,Evt const& evt,SourceState&,TargetState&, - AllStates& all_states,::boost::mpl::false_ const &) - { - // in this front-end, we don't need to know source and target states - ( ::boost::fusion::at_key<CalledForAction>(all_states).*action)(evt); - } - template <class FSM,class Evt,class SourceState,class TargetState, class AllStates> - static void call_helper(FSM& fsm,Evt const& evt,SourceState&,TargetState&,AllStates&, - ::boost::mpl::true_ const &) - { - // in this front-end, we don't need to know source and target states - (fsm.*action)(evt); - } - }; - - template< - typename CalledForGuard - , typename Event - , bool (CalledForGuard::*guard)(Event const&) - > - struct row2_guard_helper - { - template <class FSM,class Evt,class SourceState,class TargetState,class AllStates> - static bool call_helper(FSM&,Evt const& evt,SourceState&,TargetState&, - AllStates& all_states, ::boost::mpl::false_ const &) - { - // in this front-end, we don't need to know source and target states - return ( ::boost::fusion::at_key<CalledForGuard>(all_states).*guard)(evt); - } - template <class FSM,class Evt,class SourceState,class TargetState,class AllStates> - static bool call_helper(FSM& fsm,Evt const& evt,SourceState&,TargetState&, - AllStates&,::boost::mpl::true_ const &) - { - // in this front-end, we don't need to know source and target states - return (fsm.*guard)(evt); - } - }; - } - -}}} - -#endif //BOOST_MSM_ROW2_HELPER_HPP - diff --git a/contrib/restricted/boost/boost/msm/front/euml/algorithm.hpp b/contrib/restricted/boost/boost/msm/front/euml/algorithm.hpp deleted file mode 100644 index b4bd5086d56..00000000000 --- a/contrib/restricted/boost/boost/msm/front/euml/algorithm.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_EUML_ALGORITHM_H -#define BOOST_MSM_FRONT_EUML_ALGORITHM_H - -#include <boost/msm/front/euml/iteration.hpp> -#include <boost/msm/front/euml/querying.hpp> -#include <boost/msm/front/euml/transformation.hpp> - - -#endif //BOOST_MSM_FRONT_EUML_ALGORITHM_H diff --git a/contrib/restricted/boost/boost/msm/front/euml/common.hpp b/contrib/restricted/boost/boost/msm/front/euml/common.hpp deleted file mode 100644 index fff03d6dca0..00000000000 --- a/contrib/restricted/boost/boost/msm/front/euml/common.hpp +++ /dev/null @@ -1,2714 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_EUML_COMMON_H -#define BOOST_MSM_FRONT_EUML_COMMON_H - -#include <boost/config.hpp> -#include <boost/msm/proto_config.hpp> - -#include <iterator> -#include <utility> - -#include <boost/proto/core.hpp> -#include <boost/proto/transform.hpp> - -#include <boost/utility/enable_if.hpp> -#include <boost/type_traits/is_same.hpp> -#include <boost/type_traits/remove_reference.hpp> -#include <boost/type_traits/add_const.hpp> - -#include <boost/mpl/vector.hpp> -#include <boost/mpl/set.hpp> -#include <boost/mpl/has_key.hpp> -#include <boost/mpl/int.hpp> -#include <boost/mpl/less_equal.hpp> - -#if BOOST_VERSION >= 104000 -#include <boost/mpl/string.hpp> -#endif - -#include <boost/fusion/container/vector.hpp> -#include <boost/fusion/include/at_c.hpp> -#include <boost/fusion/include/make_map.hpp> -#include <boost/fusion/include/pair.hpp> -#include <boost/fusion/include/as_vector.hpp> -#include <boost/fusion/include/pair.hpp> -#include <boost/fusion/include/is_sequence.hpp> - -#include <boost/type_traits/remove_reference.hpp> - -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/arithmetic/sub.hpp> -#include <boost/preprocessor/punctuation/comma_if.hpp> -#include <boost/preprocessor/control/expr_if.hpp> -#include <boost/preprocessor/punctuation/comma.hpp> -#include <boost/preprocessor/arithmetic/add.hpp> -#include <boost/preprocessor/cat.hpp> -#include <boost/preprocessor/comparison/less.hpp> -#include <boost/preprocessor/arithmetic/dec.hpp> -#include <boost/preprocessor/repetition/repeat_from_to.hpp> -#include <boost/preprocessor/cat.hpp> - -#include <boost/msm/msm_grammar.hpp> -#include <boost/msm/active_state_switching_policies.hpp> -#include <boost/msm/event_traits.hpp> -#include <boost/msm/front/functor_row.hpp> - -namespace proto = boost::proto; - -BOOST_MPL_HAS_XXX_TRAIT_DEF(tag_type) -BOOST_MPL_HAS_XXX_TRAIT_DEF(action_name) -BOOST_MPL_HAS_XXX_TRAIT_DEF(not_intern_euml_state) - -namespace boost { namespace msm { namespace front { namespace euml -{ -template <class T> -struct get_iterator -{ - typedef typename T::iterator type; -}; -template <class T> -struct get_reverse_iterator -{ - typedef typename T::reverse_iterator type; -}; -template <class T> -struct get_reference -{ - typedef typename T::reference type; -}; -template <class T> -struct get_size_type -{ - typedef typename T::size_type type; -}; -template <class T> -struct get_value_type -{ - typedef typename T::value_type type; -}; -template <class T> -struct get_first_type -{ - typedef typename T::first_type type; -}; -template <class T> -struct get_second_type -{ - typedef typename T::second_type type; -}; -template <class T> -struct get_action_tag_type -{ - typedef typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type type; -}; -template <class T> -struct get_state_action_tag_type -{ - typedef typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type type; -}; - -template <class T,class EVT,class FSM,class SourceState,class TargetState> -struct get_result_type -{ - typedef typename T::template transition_action_result<EVT,FSM,SourceState,TargetState>::type type; -}; -template <class T,class Event,class FSM,class STATE> -struct get_result_type2 -{ - typedef typename T::template state_action_result<Event,FSM,STATE>::type type; -}; -template<class SEQ> -struct get_sequence -{ - typedef typename SEQ::sequence type; -}; - -template <class T> -struct get_attributes_type -{ - typedef typename T::attributes_type type; -}; - -template <class T> -struct get_euml_tag_type -{ - typedef typename T::euml_tag_type type; -}; - -template <class T,class Arg1=void,class Arg2=void,class Arg3=void,class Arg4=void,class Arg5=void -#ifdef BOOST_MSVC -,class Arg6=void -#endif -> -struct get_fct -{ - typedef typename T::template In<Arg1,Arg2,Arg3,Arg4,Arg5 -#ifdef BOOST_MSVC -,Arg6 -#endif ->::type type; -}; - -// used to differentiate between different types of euml_state's -template <class T,class Enable=void> -struct get_state_name -{ - typedef T type; -}; - -template <class T> -struct get_state_name<T,typename ::boost::enable_if<has_not_intern_euml_state<T> >::type> -{ - typedef typename T::In::type type; -}; - -template <class T> -struct get_action_name -{ - typedef typename T::action_name type; -}; -template <class T> -struct get_event_name -{ - typedef typename T::event_name type; -}; - -template <class EVT> -struct euml_event: proto::extends<typename proto::terminal<event_tag>::type, EVT, boost::msm::sm_domain> -{ - typedef event_tag euml_tag_type; - typedef EVT event_name; - using proto::extends<typename proto::terminal<event_tag>::type, EVT, boost::msm::sm_domain>::operator=; - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef EVT type; - }; -}; - -template <class STATE> -struct euml_state_intern: proto::extends<typename proto::terminal< boost::msm::state_tag>::type, STATE, boost::msm::state_domain> -{ - typedef state_tag euml_tag_type; - using proto::extends<typename proto::terminal<state_tag>::type, STATE, boost::msm::state_domain>::operator=; - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif - > - struct In - { - typedef STATE type; - }; -}; -template <class STATE> -struct euml_state: proto::extends<typename proto::terminal< boost::msm::state_tag>::type, STATE, boost::msm::state_domain> -{ - typedef state_tag euml_tag_type; - typedef int not_intern_euml_state; - using proto::extends<typename proto::terminal<state_tag>::type, STATE, boost::msm::state_domain>::operator=; - struct In - { - typedef STATE type; - }; -}; -template <class ACTION> -struct euml_action: proto::extends<typename proto::terminal<action_tag>::type, ACTION, boost::msm::sm_domain> -{ - typedef action_tag euml_tag_type; - typedef ACTION action_name; - using proto::extends<typename proto::terminal<action_tag>::type, ACTION, boost::msm::sm_domain>::operator=; - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef ACTION type; - }; -}; -template <class FLAG> -struct euml_flag: proto::extends<typename proto::terminal<flag_tag>::type, FLAG, boost::msm::sm_domain> -{ - typedef flag_tag euml_tag_type; - using proto::extends<typename proto::terminal<flag_tag>::type, FLAG, boost::msm::sm_domain>::operator=; - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef FLAG type; - }; -}; - -template <class CONFIG> -struct euml_config: proto::extends<typename proto::terminal<config_tag>::type, CONFIG, boost::msm::sm_domain> -{ - typedef config_tag euml_tag_type; - using proto::extends<typename proto::terminal<config_tag>::type, CONFIG, boost::msm::sm_domain>::operator=; - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef CONFIG type; - }; -}; - -struct No_Exception : euml_config<No_Exception> -{ - typedef int no_exception_thrown; - No_Exception(){} -}; -struct No_Msg_Queue : euml_config<No_Msg_Queue> -{ - typedef int no_message_queue; - No_Msg_Queue(){} -}; -struct Deferred_Events : euml_config<Deferred_Events> -{ - typedef int activate_deferred_events; - Deferred_Events(){} -}; -No_Exception const no_exception=No_Exception(); -No_Msg_Queue const no_msg_queue=No_Msg_Queue(); -Deferred_Events const deferred_events=Deferred_Events(); - -struct ActiveStateSwitchBeforeTransition : euml_config<ActiveStateSwitchBeforeTransition> -{ - typedef boost::msm::active_state_switch_before_transition active_state_switch_policy; - ActiveStateSwitchBeforeTransition(){} -}; -ActiveStateSwitchBeforeTransition const switch_active_before_transition = ActiveStateSwitchBeforeTransition(); - -struct ActiveStateSwitchAfterExit : euml_config<ActiveStateSwitchAfterExit> -{ - typedef boost::msm::active_state_switch_after_exit active_state_switch_policy; - ActiveStateSwitchAfterExit(){} -}; -ActiveStateSwitchAfterExit const switch_active_after_exit = ActiveStateSwitchAfterExit(); - -struct ActiveStateSwitchAfterAction : euml_config<ActiveStateSwitchAfterAction> -{ - typedef boost::msm::active_state_switch_after_transition_action active_state_switch_policy; - ActiveStateSwitchAfterAction(){} -}; -ActiveStateSwitchAfterAction const switch_active_after_action = ActiveStateSwitchAfterAction(); - - -struct invalid_type{}; -struct make_invalid_type -{ - typedef invalid_type type; -}; - -template <class ROW> -struct make_vector_one_row -{ - typedef boost::mpl::vector<ROW> type; -}; -template <class T> -T make_T(T t) {return t;} - -struct make_vector_no_row -{ - typedef boost::mpl::vector0<> type; -}; - -struct NoAction : euml_action<NoAction> -{ - NoAction(){} - // return value if used inside a state action (entry/exit) - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef bool type; - }; - // return value if used inside a transition (action/guard) - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef bool type; - }; - // this functor can be used in both modes, state action and transition action - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class Event,class FSM,class STATE> - bool operator()(Event const&,FSM&,STATE& ) - { - // does nothing - return true; - } - template <class EVT,class FSM,class SourceState,class TargetState> - bool operator()(EVT const& ,FSM& ,SourceState& ,TargetState&)const - { - // does nothing - return true; - } -}; -NoAction const no_action = NoAction(); - -struct fsm_artefact_tag {}; -template <class Index=void> -struct GetSource_ : euml_action<GetSource_<Index> > -{ - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::fusion::result_of::at_key<typename SourceState::attributes_type, - Index >::type type; - }; - typedef ::boost::mpl::set<action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& ,FSM& ,SourceState& src,TargetState&)const - { - return src.get_attribute(Index()); - } -}; -template<> -struct GetSource_<void> : euml_action<GetSource_<void> > -{ - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef SourceState& type; - }; - typedef ::boost::mpl::set<action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& , FSM&,SourceState& src,TargetState& )const - { - return src; - } -}; -struct GetSource_Helper: proto::extends< proto::terminal<fsm_artefact_tag>::type, GetSource_Helper, boost::msm::sm_domain> -{ - GetSource_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef GetSource_<Arg1> type; - }; -}; -GetSource_Helper const source_ = GetSource_Helper(); - -template <class Index=void> -struct GetTarget_ : euml_action<GetTarget_<Index> > -{ - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::fusion::result_of::at_key<typename TargetState::attributes_type, - Index >::type type; - }; - typedef ::boost::mpl::set<action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& ,FSM& ,SourceState& ,TargetState& tgt)const - { - return tgt.get_attribute(Index()); - } -}; -template<> -struct GetTarget_<void> : euml_action<GetTarget_<void> > -{ - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef TargetState& type; - }; - typedef ::boost::mpl::set<action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& , FSM&,SourceState& ,TargetState& tgt)const - { - return tgt; - } -}; -struct GetTarget_Helper: proto::extends< proto::terminal<fsm_artefact_tag>::type, GetTarget_Helper, boost::msm::sm_domain> -{ - GetTarget_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef GetTarget_<Arg1> type; - }; -}; -GetTarget_Helper const target_ = GetTarget_Helper(); - -template <class Index=void> -struct GetState_ : euml_action<GetState_<Index> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::fusion::result_of::at_key<typename STATE::attributes_type, - Index >::type type; - }; - typedef ::boost::mpl::set<state_action_tag> tag_type; - - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const&,FSM& ,STATE& state ) - { - return state.get_attribute(Index()); - } -}; -template<> -struct GetState_<void> : euml_action<GetState_<void> > -{ - using euml_action<GetState_ >::operator=; - - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef STATE& type; - }; - typedef ::boost::mpl::set<state_action_tag> tag_type; - - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const&,FSM& ,STATE& state ) - { - return state; - } -}; -struct GetState_Helper: proto::extends< proto::terminal<fsm_artefact_tag>::type, GetState_Helper, boost::msm::sm_domain> -{ - GetState_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef GetState_<Arg1> type; - }; -}; -GetState_Helper const state_ = GetState_Helper(); - -template <class Index=void> -struct GetEvent_ : euml_action<GetEvent_<Index> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::add_const< - typename ::boost::fusion::result_of::at_key<typename Event::attributes_type, - Index >::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::add_const< - typename ::boost::fusion::result_of::at_key<typename EVT::attributes_type, - Index >::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& ,STATE& ) - { - return evt.get_attribute(Index()); - } - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt ,FSM& ,SourceState& ,TargetState&)const - { - return evt.get_attribute(Index()); - } -}; -template <> -struct GetEvent_<void> : euml_action<GetEvent_<void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef Event const& type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef EVT const& type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& ,STATE& ) - { - return evt; - } - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt ,FSM& ,SourceState& ,TargetState&)const - { - return evt; - } -}; -struct GetEvent_Helper: proto::extends< proto::terminal<fsm_artefact_tag>::type, GetEvent_Helper, boost::msm::sm_domain> -{ - GetEvent_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef GetEvent_<Arg1> type; - }; -}; -GetEvent_Helper const event_ = GetEvent_Helper(); - -template <class Index=void> -struct GetFsm_ : euml_action<GetFsm_<Index> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::fusion::result_of::at_key<typename FSM::attributes_type, - Index >::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::fusion::result_of::at_key<typename FSM::attributes_type, - Index >::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const&,FSM& fsm,STATE& ) - { - return fsm.get_attribute(Index()); - } - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& ,FSM& fsm,SourceState& ,TargetState&)const - { - return fsm.get_attribute(Index()); - } -}; -template<> -struct GetFsm_<void> : euml_action<GetFsm_<void> > -{ - using euml_action<GetFsm_>::operator=; - - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef FSM& type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef FSM& type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const&,FSM& fsm,STATE& ) - { - return fsm; - } - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& ,FSM& fsm,SourceState& ,TargetState&)const - { - return fsm; - } -}; -struct GetFsm_Helper: proto::extends< proto::terminal<fsm_artefact_tag>::type, GetFsm_Helper, boost::msm::sm_domain> -{ - GetFsm_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef GetFsm_<Arg1> type; - }; -}; -GetFsm_Helper const fsm_ = GetFsm_Helper(); - -template <class StateName,class Param1> -struct SubState_ : euml_action<SubState_<StateName, Param1> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef StateName& type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef StateName& type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - StateName& operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Param1()(evt,fsm,src,tgt)).template get_state<StateName&>(); - } - template <class Event,class FSM,class STATE> - StateName& operator()(Event const& evt,FSM& fsm,STATE& state)const - { - return (Param1()(evt,fsm,state)).template get_state<StateName&>(); - } -}; -template <class StateName> -struct SubState_ <StateName,void> - : euml_action<SubState_<StateName, void > > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef StateName& type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef StateName& type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - StateName& operator()(EVT const&,FSM& fsm,SourceState& ,TargetState& )const - { - return fsm.template get_state<StateName&>(); - } - template <class Event,class FSM,class STATE> - StateName& operator()(Event const& ,FSM& fsm,STATE& )const - { - return fsm.template get_state<StateName&>(); - } -}; - -struct SubState_Helper: proto::extends< proto::terminal<fsm_artefact_tag>::type, SubState_Helper, boost::msm::sm_domain> -{ - SubState_Helper(){} - using proto::extends< proto::terminal<fsm_artefact_tag>::type, SubState_Helper, boost::msm::sm_domain>::operator=; - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef SubState_<Arg1,Arg2> type; - }; -}; -SubState_Helper const substate_ = SubState_Helper(); - -template <class Target,class Index> -struct GetAttribute_ : euml_action<GetAttribute_<Target, Index> > -{ - using euml_action<GetAttribute_<Target,Index> >::operator=; - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename - ::boost::fusion::result_of::at_key< - typename get_attributes_type< - typename ::boost::remove_reference< - typename get_result_type2<Target,Event,FSM,STATE>::type>::type>::type, - Index >::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename - ::boost::fusion::result_of::at_key< - typename get_attributes_type< - typename ::boost::remove_reference< - typename get_result_type<Target,EVT,FSM,SourceState,TargetState>::type>::type>::type, - Index >::type type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Target::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Target()(evt,fsm,src,tgt)).get_attribute(Index()); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Target::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Target()(evt,fsm,state)).get_attribute(Index()); - } -}; - -struct GetAttribute_Helper: proto::extends< proto::terminal<fsm_artefact_tag>::type, GetAttribute_Helper, boost::msm::sm_domain> -{ - GetAttribute_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef GetAttribute_<Arg1,Arg2> type; - }; -}; -GetAttribute_Helper const attribute_ = GetAttribute_Helper(); - -template <class Index> -struct Source_ : euml_action<Source_<Index> > -{ - using euml_action<Source_<Index> >::operator=; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename - ::boost::fusion::result_of::at_key<typename SourceState::attributes_type, - Index >::type type; - }; - typedef ::boost::mpl::set<action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& , FSM&,SourceState& src,TargetState& )const - { - return src.get_attribute(Index()); - } -}; -template <class Index> -struct Target_ : euml_action<Target_<Index> > -{ - using euml_action<Target_<Index> >::operator=; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename - ::boost::fusion::result_of::at_key<typename TargetState::attributes_type, - Index >::type type; - }; - typedef ::boost::mpl::set<action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& ,FSM& ,SourceState& ,TargetState& tgt)const - { - return tgt.get_attribute(Index()); - } -}; -template <class Index> -struct State_ : euml_action<State_<Index> > -{ - using euml_action<State_<Index> >::operator=; - - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename - ::boost::fusion::result_of::at_key<typename STATE::attributes_type, - Index >::type type; - }; - typedef ::boost::mpl::set<state_action_tag> tag_type; - - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const&,FSM& ,STATE& state ) - { - return state.get_attribute(Index()); - } -}; -template <class Index> -struct Event_ : euml_action<Event_<Index> > -{ - using euml_action<Event_<Index> >::operator=; - - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::add_const< - typename ::boost::fusion::result_of::at_key<typename Event::attributes_type, - Index >::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::add_const< - typename ::boost::fusion::result_of::at_key<typename EVT::attributes_type, - Index >::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& ,STATE& ) - { - return evt.get_attribute(Index()); - } - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt ,FSM& ,SourceState& ,TargetState&)const - { - return evt.get_attribute(Index()); - } -}; -template <class StateType,class Index> -struct State_Attribute_ : euml_action<State_Attribute_<StateType,Index> > -{ - using euml_action<State_Attribute_<StateType,Index> >::operator=; - - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename - ::boost::fusion::result_of::at_key<typename StateType::attributes_type, - Index >::type type; - }; - typedef ::boost::mpl::set<state_action_tag> tag_type; - - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const&,FSM& fsm,STATE& ) - { - return fsm.template get_state<StateType&>().get_attribute(Index()); - } -}; - -template <class Index> -struct Fsm_ : euml_action<Fsm_<Index> > -{ - using euml_action<Fsm_<Index> >::operator=; - - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename - ::boost::fusion::result_of::at_key<typename FSM::attributes_type, - Index >::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename - ::boost::fusion::result_of::at_key<typename FSM::attributes_type, - Index >::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const&,FSM& fsm,STATE& ) - { - return fsm.get_attribute(Index()); - } - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& ,FSM& fsm,SourceState& ,TargetState&)const - { - return fsm.get_attribute(Index()); - } -}; - -struct True_ : euml::euml_action<True_> -{ - using euml_action<True_>::operator=; - True_(){} - - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef bool type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef bool type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - bool operator()(EVT const&,FSM&,SourceState& ,TargetState& ) - { - return true; - } - template <class Event,class FSM,class STATE> - bool operator()(Event const&,FSM&,STATE& ) - { - return true; - } -}; -True_ const true_ = True_(); - -struct False_ : euml::euml_action<False_> -{ - using euml_action<False_>::operator=; - False_(){} - - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef bool type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef bool type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - bool operator()(EVT const&,FSM&,SourceState& ,TargetState& ) - { - return false; - } - template <class Event,class FSM,class STATE> - bool operator()(Event const&,FSM&,STATE& ) - { - return false; - } -}; -False_ const false_ = False_(); - -template <int Val> -struct Int_ : euml_action<Int_<Val> > -{ - using euml_action<Int_<Val> >::operator=; - typedef ::boost::mpl::int_<Val> value_type; - enum {value = Val}; - - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef int type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef int type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - int operator()(EVT const& , FSM& ,SourceState& ,TargetState& ) - { - return Val; - } - template <class Event,class FSM,class STATE> - int operator()(Event const& ,FSM& ,STATE& ) - { - return Val; - } -}; - -template <char Val> -struct Char_ : euml_action<Char_<Val> > -{ - using euml_action<Char_<Val> >::operator=; - - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef char type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef char type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - char operator()(EVT const& , FSM& ,SourceState& ,TargetState& ) - { - return Val; - } - template <class Event,class FSM,class STATE> - char operator()(Event const& ,FSM& ,STATE& ) - { - return Val; - } -}; - -template <size_t Val> -struct Size_t_ : euml_action<Size_t_<Val> > -{ - using euml_action<Size_t_<Val> >::operator=; - - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef size_t type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef size_t type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - size_t operator()(EVT const& , FSM& ,SourceState& ,TargetState& ) - { - return Val; - } - template <class Event,class FSM,class STATE> - size_t operator()(Event const& ,FSM& ,STATE& ) - { - return Val; - } -}; - -#if BOOST_VERSION >= 104000 - -template <class T> -struct String_ : euml_action<String_<T> > -{ - using euml_action<String_<T> >::operator=; - - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef char const* type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef char const* type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - char const* operator()(EVT const& , FSM& ,SourceState& ,TargetState& ) - { - return ::boost::mpl::c_str<T>::value; - } - template <class Event,class FSM,class STATE> - char const* operator()(Event const& ,FSM& ,STATE& ) - { - return ::boost::mpl::c_str<T>::value; - } -}; -#endif - - -template <class T> -struct Predicate_ : euml_action<Predicate_<T> > -{ - using euml_action<Predicate_<T> >::operator=; - - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef T type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef T type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - T operator()(EVT const& , FSM& ,SourceState& ,TargetState& ) - { - return T(); - } - template <class Event,class FSM,class STATE> - T operator()(Event const& ,FSM& ,STATE& ) - { - return T(); - } -}; - -template <class ToProcessEvt,class Param1, class Param2, class Param3, class Param4> -struct Process_ : euml_action<Process_<ToProcessEvt, Param1, Param2, Param3, Param4> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Param1()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); - (Param2()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); - (Param3()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); - (Param4()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state)const - { - (Param1()(evt,fsm,state)).process_event(ToProcessEvt()); - (Param2()(evt,fsm,state)).process_event(ToProcessEvt()); - (Param3()(evt,fsm,state)).process_event(ToProcessEvt()); - (Param4()(evt,fsm,state)).process_event(ToProcessEvt()); - } -}; -template <class ToProcessEvt> -struct Process_ <ToProcessEvt,void,void,void,void> - : euml_action<Process_<ToProcessEvt, void, void, void, void > > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const&,FSM& fsm,SourceState& ,TargetState& )const - { - fsm.process_event(ToProcessEvt()); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& ,FSM& fsm,STATE& )const - { - fsm.process_event(ToProcessEvt()); - } -}; - -template <class ToProcessEvt,class Param1> -struct Process_ <ToProcessEvt,Param1,void,void,void> - : euml_action<Process_<ToProcessEvt, Param1, void, void, void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Param1()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state)const - { - (Param1()(evt,fsm,state)).process_event(ToProcessEvt()); - } -}; - -template <class ToProcessEvt,class Param1, class Param2> -struct Process_ <ToProcessEvt,Param1,Param2,void,void> - : euml_action<Process_<ToProcessEvt, Param1, Param2, void, void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Param1()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); - (Param2()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state)const - { - (Param1()(evt,fsm,state)).process_event(ToProcessEvt()); - (Param2()(evt,fsm,state)).process_event(ToProcessEvt()); - } -}; - -template <class ToProcessEvt,class Param1, class Param2, class Param3> -struct Process_ <ToProcessEvt,Param1,Param2,Param3,void> - : euml_action<Process_<ToProcessEvt, Param1, Param2, Param3, void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Param1()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); - (Param2()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); - (Param3()(evt,fsm,src,tgt)).process_event(ToProcessEvt()); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state)const - { - (Param1()(evt,fsm,state)).process_event(ToProcessEvt()); - (Param2()(evt,fsm,state)).process_event(ToProcessEvt()); - (Param3()(evt,fsm,state)).process_event(ToProcessEvt()); - } -}; - -//version for process_(event_) -template <> -struct Process_ <GetEvent_<void>,void,void,void,void> - : euml_action<Process_<GetEvent_<void>, void, void, void, void > > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt,FSM& fsm,SourceState& ,TargetState& )const - { - fsm.process_event(evt); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& )const - { - fsm.process_event(evt); - } -}; - -struct process_tag {}; -struct Process_Helper: proto::extends< proto::terminal<process_tag>::type, Process_Helper, boost::msm::sm_domain> -{ - Process_Helper(){} - using proto::extends< proto::terminal<process_tag>::type, Process_Helper, boost::msm::sm_domain>::operator=; - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Process_<Arg1,Arg2,Arg3,Arg4,Arg5> type; - }; -}; -Process_Helper const process_ = Process_Helper(); - -template <class Param1, class Param2, class Param3, class Param4> -struct Reprocess_ : euml_action<Reprocess_<Param1, Param2, Param3, Param4> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Param1()(evt,fsm,src,tgt)).process_event(evt); - (Param2()(evt,fsm,src,tgt)).process_event(evt); - (Param3()(evt,fsm,src,tgt)).process_event(evt); - (Param4()(evt,fsm,src,tgt)).process_event(evt); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state)const - { - (Param1()(evt,fsm,state)).process_event(evt); - (Param2()(evt,fsm,state)).process_event(evt); - (Param3()(evt,fsm,state)).process_event(evt); - (Param4()(evt,fsm,state)).process_event(evt); - } -}; -template <> -struct Reprocess_ <void,void,void,void> - : euml_action<Reprocess_<void, void, void, void > > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt,FSM& fsm,SourceState& ,TargetState& )const - { - fsm.process_event(evt); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& )const - { - fsm.process_event(evt); - } -}; - -template <class Param1> -struct Reprocess_ <Param1,void,void,void> - : euml_action<Reprocess_<Param1, void, void, void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Param1()(evt,fsm,src,tgt)).process_event(evt); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state)const - { - (Param1()(evt,fsm,state)).process_event(evt); - } -}; - -template <class Param1, class Param2> -struct Reprocess_ <Param1,Param2,void,void> - : euml_action<Reprocess_<Param1, Param2, void, void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Param1()(evt,fsm,src,tgt)).process_event(evt); - (Param2()(evt,fsm,src,tgt)).process_event(evt); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state)const - { - (Param1()(evt,fsm,state)).process_event(evt); - (Param2()(evt,fsm,state)).process_event(evt); - } -}; - -template <class Param1, class Param2, class Param3> -struct Reprocess_ <Param1,Param2,Param3,void> - : euml_action<Reprocess_<Param1, Param2, Param3, void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Param1()(evt,fsm,src,tgt)).process_event(evt); - (Param2()(evt,fsm,src,tgt)).process_event(evt); - (Param3()(evt,fsm,src,tgt)).process_event(evt); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state)const - { - (Param1()(evt,fsm,state)).process_event(evt); - (Param2()(evt,fsm,state)).process_event(evt); - (Param3()(evt,fsm,state)).process_event(evt); - } -}; -struct reprocess_tag {}; -struct Reprocess_Helper: proto::extends< proto::terminal<reprocess_tag>::type, Reprocess_Helper, boost::msm::sm_domain> -{ - Reprocess_Helper(){} - using proto::extends< proto::terminal<reprocess_tag>::type, Reprocess_Helper, boost::msm::sm_domain>::operator=; - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Reprocess_<Arg1,Arg2,Arg3,Arg4> type; - }; -}; -Reprocess_Helper const reprocess_ = Reprocess_Helper(); - -template <class ToProcessEvt,class Value,class Param1, class Param2, class Param3> -struct Process2_ : euml_action<Process2_<ToProcessEvt,Value, Param1, Param2, Param3> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Param1()(evt,fsm,src,tgt)).process_event(ToProcessEvt(Value()(evt,fsm,src,tgt))); - (Param2()(evt,fsm,src,tgt)).process_event(ToProcessEvt(Value()(evt,fsm,src,tgt))); - (Param3()(evt,fsm,src,tgt)).process_event(ToProcessEvt(Value()(evt,fsm,src,tgt))); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state)const - { - (Param1()(evt,fsm,state)).process_event(ToProcessEvt(Value()(evt,fsm,state))); - (Param2()(evt,fsm,state)).process_event(ToProcessEvt(Value()(evt,fsm,state))); - (Param3()(evt,fsm,state)).process_event(ToProcessEvt(Value()(evt,fsm,state))); - } -}; - -template <class ToProcessEvt,class Value> -struct Process2_ <ToProcessEvt,Value,void,void,void> - : euml_action<Process2_<ToProcessEvt,Value, void, void, void > > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const - { - fsm.process_event(ToProcessEvt(Value()(evt,fsm,src,tgt))); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state)const - { - fsm.process_event(ToProcessEvt(Value()(evt,fsm,state))); - } -}; - -template <class ToProcessEvt,class Value,class Param1> -struct Process2_ <ToProcessEvt,Value,Param1,void,void> - : euml_action<Process2_<ToProcessEvt,Value, Param1, void, void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Param1()(evt,fsm,src,tgt)).process_event(ToProcessEvt(Value()(evt,fsm,src,tgt))); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state)const - { - (Param1()(evt,fsm,state)).process_event(ToProcessEvt(Value()(evt,fsm,state))); - } -}; - -template <class ToProcessEvt,class Value,class Param1, class Param2> -struct Process2_ <ToProcessEvt,Value,Param1,Param2,void> - : euml_action<Process2_<ToProcessEvt,Value, Param1, Param2, void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Param1()(evt,fsm,src,tgt)).process_event(ToProcessEvt(Value()(evt,fsm,src,tgt))); - (Param2()(evt,fsm,src,tgt)).process_event(ToProcessEvt(Value()(evt,fsm,src,tgt))); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state)const - { - (Param1()(evt,fsm,state)).process_event(ToProcessEvt(Value()(evt,fsm,state))); - (Param2()(evt,fsm,state)).process_event(ToProcessEvt(Value()(evt,fsm,state))); - } -}; - -struct process2_tag {}; -struct Process2_Helper : proto::extends< proto::terminal<process2_tag>::type, Process2_Helper, boost::msm::sm_domain> -{ - Process2_Helper(){} - using proto::extends< proto::terminal<process2_tag>::type, Process2_Helper, boost::msm::sm_domain>::operator=; - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Process2_<Arg1,Arg2,Arg3,Arg4,Arg5> type; - }; -}; -Process2_Helper const process2_ = Process2_Helper(); - -template <class Flag,class Param1=void, class Enable=void > -struct Get_Flag_ : euml_action<Get_Flag_<Flag,Param1,Enable> > {}; - -template <class Flag,class Param1> -struct Get_Flag_ <Flag,Param1 - , typename ::boost::enable_if<typename ::boost::is_same<Param1,void>::type >::type> - : euml_action<Get_Flag_<Flag, Param1> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef bool type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef bool type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - bool operator()(EVT const&,FSM& fsm,SourceState& ,TargetState& )const - { - return fsm.template is_flag_active<Flag>(); - } - template <class Event,class FSM,class STATE> - bool operator()(Event const& ,FSM& fsm,STATE& )const - { - return fsm.template is_flag_active<Flag>(); - } -}; - -template <class Flag,class Param1> -struct Get_Flag_ <Flag,Param1 - , typename ::boost::disable_if< - typename ::boost::is_same<Param1,void>::type - >::type> - : euml_action<Get_Flag_<Flag, Param1> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef bool type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef bool type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - bool operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Param1()(evt,fsm,src,tgt)).template is_flag_active<Flag>(); - } - template <class Event,class FSM,class STATE> - bool operator()(Event const& evt,FSM& fsm,STATE& state)const - { - return (Param1()(evt,fsm,state)).template is_flag_active<Flag>(); - } -}; - -struct Get_Flag_Helper: proto::extends< proto::terminal<fsm_artefact_tag>::type, Get_Flag_Helper, boost::msm::sm_domain> -{ - Get_Flag_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Get_Flag_<Arg1,Arg2> type; - }; -}; -Get_Flag_Helper const is_flag_ = Get_Flag_Helper(); - -// deferring an event -struct DeferEvent_ : euml_action< DeferEvent_ > -{ - typedef ::boost::mpl::set<action_tag> tag_type; - // mark as deferring to avoid stack overflows in certain conditions - typedef int deferring_action; - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt,FSM& fsm,SourceState& ,TargetState& ) const - { - fsm.defer_event(evt); - } -}; -struct Defer_Helper : proto::extends< proto::terminal<fsm_artefact_tag>::type, Defer_Helper, boost::msm::sm_domain> -{ - Defer_Helper(){} - using proto::extends< proto::terminal<fsm_artefact_tag>::type, Defer_Helper, boost::msm::sm_domain>::operator=; - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef DeferEvent_ type; - }; -}; -Defer_Helper const defer_ = Defer_Helper(); - -struct explicit_tag {}; -struct Explicit_Helper : proto::extends< proto::terminal<explicit_tag>::type, Explicit_Helper, boost::msm::sm_domain> -{ - Explicit_Helper(){} - using proto::extends< proto::terminal<explicit_tag>::type, Explicit_Helper, boost::msm::sm_domain>::operator=; - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef typename Arg1::template direct<Arg2> type; - }; -}; -Explicit_Helper const explicit_ = Explicit_Helper(); - -struct entry_pt_tag {}; -struct Entry_Pt_Helper : proto::extends< proto::terminal<entry_pt_tag>::type, Entry_Pt_Helper, boost::msm::sm_domain> -{ - Entry_Pt_Helper(){} - using proto::extends< proto::terminal<entry_pt_tag>::type, Entry_Pt_Helper, boost::msm::sm_domain>::operator=; - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef typename Arg1::template entry_pt<Arg2> type; - }; -}; -Entry_Pt_Helper const entry_pt_ = Entry_Pt_Helper(); - -struct exit_pt_tag {}; -struct Exit_Pt_Helper : proto::extends< proto::terminal<exit_pt_tag>::type, Exit_Pt_Helper, boost::msm::sm_domain> -{ - Exit_Pt_Helper(){} - using proto::extends< proto::terminal<exit_pt_tag>::type, Exit_Pt_Helper, boost::msm::sm_domain>::operator=; - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef typename Arg1::template exit_pt<Arg2> type; - }; -}; -Exit_Pt_Helper const exit_pt_ = Exit_Pt_Helper(); - -#ifdef BOOST_MSVC -#define BOOST_MSM_EUML_FUNCTION(functor,function,function_name,result_trans,result_state) \ - template <class Param1=void , class Param2=void , class Param3=void , class Param4=void, \ - class Param5=void,class Param6=void,class Enable=void > \ - struct functor : euml_action<functor<Param1,Param2,Param3,Param4,Param5,Param6,Enable> > {}; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5, class Param6> \ - struct functor<Param1,Param2,Param3,Param4,Param5,Param6, \ - typename ::boost::enable_if<typename ::boost::is_same<Param1,void>::type>::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5,Param6> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type \ - operator()(EVT const& , FSM& ,SourceState& ,TargetState& )const { \ - return function ();} \ - template <class Event,class FSM,class STATE> \ - typename state_action_result<Event,FSM,STATE>::type \ - operator()(Event const& ,FSM& ,STATE& )const { \ - return function ();} }; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5,class Param6> \ - struct functor<Param1,Param2,Param3,Param4,Param5,Param6, \ - typename ::boost::disable_if<typename ::boost::mpl::or_< \ - typename ::boost::is_same<Param1,void>::type,typename ::boost::mpl::not_< \ - typename ::boost::is_same<Param2,void>::type>::type>::type >::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5,Param6> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return function (Param1()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return function (Param1()(evt,fsm,state));} }; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5,class Param6> \ - struct functor<Param1,Param2,Param3,Param4,Param5,Param6, \ - typename ::boost::disable_if<typename ::boost::mpl::or_< \ - typename ::boost::is_same<Param2,void>::type,typename ::boost::mpl::not_< \ - typename ::boost::is_same<Param3,void>::type>::type>::type >::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5,Param6> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return function (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return function (Param1()(evt,fsm,state),Param2()(evt,fsm,state));} }; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5,class Param6> \ - struct functor<Param1,Param2,Param3,Param4,Param5,Param6, \ - typename ::boost::disable_if<typename ::boost::mpl::or_< \ - typename ::boost::is_same<Param3,void>::type,typename ::boost::mpl::not_< \ - typename ::boost::is_same<Param4,void>::type>::type>::type >::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5,Param6> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return function (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return function (Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state));} }; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5,class Param6> \ - struct functor<Param1,Param2,Param3,Param4,Param5,Param6, \ - typename ::boost::disable_if<typename ::boost::mpl::or_< \ - typename ::boost::is_same<Param4,void>::type,typename ::boost::mpl::not_< \ - typename ::boost::is_same<Param5,void>::type>::type>::type >::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5,Param6> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return function (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ - ,Param4()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return function (Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ - ,Param4()(evt,fsm,state));} }; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5,class Param6> \ - struct functor<Param1,Param2,Param3,Param4,Param5,Param6, \ - typename ::boost::disable_if<typename ::boost::mpl::or_< \ - typename ::boost::is_same<Param5,void>::type,typename ::boost::mpl::not_< \ - typename ::boost::is_same<Param6,void>::type>::type>::type >::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5,Param6> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return function (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ - ,Param4()(evt,fsm,src,tgt),Param5()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return function (Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ - ,Param4()(evt,fsm,state),Param5()(evt,fsm,state));} }; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5,class Param6> \ - struct functor<Param1,Param2,Param3,Param4,Param5,Param6, \ - typename ::boost::disable_if<typename ::boost::is_same<Param6,void>::type>::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5,Param6> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return function (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ - ,Param4()(evt,fsm,src,tgt),Param5()(evt,fsm,src,tgt),Param6()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return function (Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ - ,Param4()(evt,fsm,state),Param5()(evt,fsm,state),Param6()(evt,fsm,state));} }; \ - struct function_name ## tag{}; \ - struct functor ## Helper : proto::extends< proto::terminal< function_name ## tag >::type, \ - functor ## Helper , boost::msm::sm_domain> { functor ## Helper(){} \ - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5,class Arg6> \ - struct In {typedef functor <Arg1,Arg2,Arg3,Arg4,Arg5,Arg6> type;}; }; \ - functor ## Helper const function_name = functor ## Helper (); - -#define BOOST_MSM_EUML_METHOD(functor,function,function_name,result_trans,result_state) \ - template <class Param1=void , class Param2=void , class Param3=void , class Param4=void, \ - class Param5=void,class Param6=void,class Enable=void > \ - struct functor : euml_action<functor<Param1,Param2,Param3,Param4,Param5,Param6,Enable> > {}; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5, class Param6> \ - struct functor<Param1,Param2,Param3,Param4,Param5,Param6, \ - typename ::boost::enable_if<typename ::boost::is_same<Param2,void>::type>::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5,Param6> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return (Param1()(evt,fsm,src,tgt)).function();} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return (Param1()(evt,fsm,state)).function();} }; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5,class Param6> \ - struct functor<Param1,Param2,Param3,Param4,Param5,Param6, \ - typename ::boost::disable_if<typename ::boost::mpl::or_< \ - typename ::boost::is_same<Param2,void>::type,typename ::boost::mpl::not_< \ - typename ::boost::is_same<Param3,void>::type>::type>::type >::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5,Param6> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return (Param1()(evt,fsm,src,tgt)).function(Param2()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return (Param1()(evt,fsm,state)).function(Param2()(evt,fsm,state));} }; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5,class Param6> \ - struct functor<Param1,Param2,Param3,Param4,Param5,Param6, \ - typename ::boost::disable_if<typename ::boost::mpl::or_< \ - typename ::boost::is_same<Param3,void>::type,typename ::boost::mpl::not_< \ - typename ::boost::is_same<Param4,void>::type>::type>::type >::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5,Param6> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return (Param1()(evt,fsm,src,tgt)).function(Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return (Param1()(evt,fsm,state)).function(Param2()(evt,fsm,state),Param3()(evt,fsm,state));} }; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5,class Param6> \ - struct functor<Param1,Param2,Param3,Param4,Param5,Param6, \ - typename ::boost::disable_if<typename ::boost::mpl::or_< \ - typename ::boost::is_same<Param4,void>::type,typename ::boost::mpl::not_< \ - typename ::boost::is_same<Param5,void>::type>::type>::type >::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5,Param6> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return (Param1()(evt,fsm,src,tgt)).function(Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ - ,Param4()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return (Param1()(evt,fsm,state)).function(Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ - ,Param4()(evt,fsm,state));} }; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5,class Param6> \ - struct functor<Param1,Param2,Param3,Param4,Param5,Param6, \ - typename ::boost::disable_if<typename ::boost::mpl::or_< \ - typename ::boost::is_same<Param5,void>::type,typename ::boost::mpl::not_< \ - typename ::boost::is_same<Param6,void>::type>::type>::type >::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5,Param6> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return (Param1()(evt,fsm,src,tgt)).function(Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ - ,Param4()(evt,fsm,src,tgt),Param5()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return (Param1()(evt,fsm,state)).function(Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ - ,Param4()(evt,fsm,state),Param5()(evt,fsm,state));} }; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5,class Param6> \ - struct functor<Param1,Param2,Param3,Param4,Param5,Param6, \ - typename ::boost::disable_if<typename ::boost::is_same<Param6,void>::type>::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5,Param6> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return (Param1()(evt,fsm,src,tgt)).function(Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ - ,Param4()(evt,fsm,src,tgt),Param5()(evt,fsm,src,tgt),Param6()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return (Param1()(evt,fsm,state)).function(Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ - ,Param4()(evt,fsm,state),Param5()(evt,fsm,state),Param6()(evt,fsm,state));} }; \ - struct function_name ## tag{}; \ - struct functor ## Helper : proto::extends< proto::terminal< function_name ## tag >::type, \ - functor ## Helper , boost::msm::sm_domain> { functor ## Helper(){} \ - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5,class Arg6> \ - struct In {typedef functor <Arg1,Arg2,Arg3,Arg4,Arg5,Arg6> type;}; }; \ - functor ## Helper const function_name = functor ## Helper (); - -#else - -#define BOOST_MSM_EUML_FUNCTION(functor,function,function_name,result_trans,result_state) \ - template <class Param1=void , class Param2=void , class Param3=void , class Param4=void, \ - class Param5=void,class Enable=void > \ - struct functor : euml_action<functor<Param1,Param2,Param3,Param4,Param5,Enable> > {}; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5> \ - struct functor<Param1,Param2,Param3,Param4,Param5, \ - typename ::boost::disable_if<typename ::boost::mpl::or_< \ - typename ::boost::is_same<Param1,void>::type,typename ::boost::mpl::not_< \ - typename ::boost::is_same<Param2,void>::type>::type>::type >::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return function (Param1()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return function (Param1()(evt,fsm,state));} }; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5> \ - struct functor<Param1,Param2,Param3,Param4,Param5, \ - typename ::boost::disable_if<typename ::boost::mpl::or_< \ - typename ::boost::is_same<Param2,void>::type,typename ::boost::mpl::not_< \ - typename ::boost::is_same<Param3,void>::type>::type>::type >::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return function (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return function (Param1()(evt,fsm,state),Param2()(evt,fsm,state));} }; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5> \ - struct functor<Param1,Param2,Param3,Param4,Param5, \ - typename ::boost::disable_if<typename ::boost::mpl::or_< \ - typename ::boost::is_same<Param3,void>::type,typename ::boost::mpl::not_< \ - typename ::boost::is_same<Param4,void>::type>::type>::type >::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return function (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return function (Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state));} }; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5> \ - struct functor<Param1,Param2,Param3,Param4,Param5, \ - typename ::boost::disable_if<typename ::boost::mpl::or_< \ - typename ::boost::is_same<Param4,void>::type,typename ::boost::mpl::not_< \ - typename ::boost::is_same<Param5,void>::type>::type>::type >::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return function (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ - ,Param4()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return function (Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ - ,Param4()(evt,fsm,state));} }; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5> \ - struct functor<Param1,Param2,Param3,Param4,Param5, \ - typename ::boost::disable_if<typename ::boost::is_same<Param5,void>::type>::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return function (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ - ,Param4()(evt,fsm,src,tgt),Param5()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return function (Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ - ,Param4()(evt,fsm,state),Param5()(evt,fsm,state));} }; \ - struct function_name ## tag{}; \ - struct functor ## Helper : proto::extends< proto::terminal< function_name ## tag >::type, \ - functor ## Helper , boost::msm::sm_domain> { functor ## Helper(){} \ - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5> \ - struct In {typedef functor <Arg1,Arg2,Arg3,Arg4,Arg5> type;}; }; \ - functor ## Helper const function_name = functor ## Helper (); - -#define BOOST_MSM_EUML_METHOD(functor,function,function_name,result_trans,result_state) \ - template <class Param1=void , class Param2=void , class Param3=void , class Param4=void, \ - class Param5=void,class Enable=void > \ - struct functor : euml_action<functor<Param1,Param2,Param3,Param4,Param5,Enable> > {}; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5> \ - struct functor<Param1,Param2,Param3,Param4,Param5, \ - typename ::boost::enable_if<typename ::boost::is_same<Param2,void>::type>::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return (Param1()(evt,fsm,src,tgt)).function();} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return (Param1()(evt,fsm,state)).function();} }; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5> \ - struct functor<Param1,Param2,Param3,Param4,Param5, \ - typename ::boost::disable_if<typename ::boost::mpl::or_< \ - typename ::boost::is_same<Param2,void>::type,typename ::boost::mpl::not_< \ - typename ::boost::is_same<Param3,void>::type>::type>::type >::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return (Param1()(evt,fsm,src,tgt)).function(Param2()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return (Param1()(evt,fsm,state)).function(Param2()(evt,fsm,state));} }; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5> \ - struct functor<Param1,Param2,Param3,Param4,Param5, \ - typename ::boost::disable_if<typename ::boost::mpl::or_< \ - typename ::boost::is_same<Param3,void>::type,typename ::boost::mpl::not_< \ - typename ::boost::is_same<Param4,void>::type>::type>::type >::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return (Param1()(evt,fsm,src,tgt)).function(Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return (Param1()(evt,fsm,state)).function(Param2()(evt,fsm,state),Param3()(evt,fsm,state));} }; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5> \ - struct functor<Param1,Param2,Param3,Param4,Param5, \ - typename ::boost::disable_if<typename ::boost::mpl::or_< \ - typename ::boost::is_same<Param4,void>::type,typename ::boost::mpl::not_< \ - typename ::boost::is_same<Param5,void>::type>::type>::type >::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return (Param1()(evt,fsm,src,tgt)).function(Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ - ,Param4()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return (Param1()(evt,fsm,state)).function(Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ - ,Param4()(evt,fsm,state));} }; \ - template <class Param1, class Param2, class Param3, class Param4, class Param5> \ - struct functor<Param1,Param2,Param3,Param4,Param5, \ - typename ::boost::disable_if<typename ::boost::is_same<Param5,void>::type>::type> \ - : euml_action<functor<Param1,Param2,Param3,Param4,Param5> > { \ - template <class Event,class FSM,class STATE > struct state_action_result { \ - typedef result_state type;} ; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - struct transition_action_result { typedef result_trans type;}; \ - typedef ::boost::mpl::set<boost::msm::front::state_action_tag,boost::msm::front::action_tag> tag_type; \ - template <class EVT,class FSM,class SourceState,class TargetState> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::action_tag>::type, \ - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type \ - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const { \ - return (Param1()(evt,fsm,src,tgt)).function(Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt) \ - ,Param4()(evt,fsm,src,tgt),Param5()(evt,fsm,src,tgt));} \ - template <class Event,class FSM,class STATE> \ - typename ::boost::enable_if<typename ::boost::mpl::has_key< \ - typename Param1::tag_type,boost::msm::front::state_action_tag>::type, \ - typename state_action_result<Event,FSM,STATE>::type >::type \ - operator()(Event const& evt,FSM& fsm,STATE& state )const { \ - return (Param1()(evt,fsm,state)).function(Param2()(evt,fsm,state),Param3()(evt,fsm,state) \ - ,Param4()(evt,fsm,state),Param5()(evt,fsm,state));} }; \ - struct function_name ## tag{}; \ - struct functor ## Helper : proto::extends< proto::terminal< function_name ## tag >::type, \ - functor ## Helper , boost::msm::sm_domain> { functor ## Helper(){} \ - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5> \ - struct In {typedef functor <Arg1,Arg2,Arg3,Arg4,Arg5> type;}; }; \ - functor ## Helper const function_name = functor ## Helper (); - -#endif - -#define RESULT_TYPE2_PARAM1 typename get_result_type2<Param1,Event,FSM,STATE>::type -#define RESULT_TYPE_PARAM1 typename get_result_type<Param1,EVT,FSM,SourceState,TargetState>::type -#define RESULT_TYPE2_PARAM2 typename get_result_type2<Param2,Event,FSM,STATE>::type -#define RESULT_TYPE_PARAM2 typename get_result_type<Param2,EVT,FSM,SourceState,TargetState>::type -#define RESULT_TYPE2_PARAM3 typename get_result_type2<Param3,Event,FSM,STATE>::type -#define RESULT_TYPE_PARAM3 typename get_result_type<Param3,EVT,FSM,SourceState,TargetState>::type -#define RESULT_TYPE2_PARAM4 typename get_result_type2<Param4,Event,FSM,STATE>::type -#define RESULT_TYPE_PARAM4 typename get_result_type<Param4,EVT,FSM,SourceState,TargetState>::type -#define RESULT_TYPE2_PARAM5 typename get_result_type2<Param5,Event,FSM,STATE>::type -#define RESULT_TYPE_PARAM5 typename get_result_type<Param5,EVT,FSM,SourceState,TargetState>::type -#define RESULT_TYPE2_PARAM6 typename get_result_type2<Param6,Event,FSM,STATE>::type -#define RESULT_TYPE_PARAM6 typename get_result_type<Param6,EVT,FSM,SourceState,TargetState>::type - - -#define RESULT_TYPE2_DIFF_TYPE_ITER_TRAITS_PARAM1 typename std::iterator_traits<typename get_result_type2<Param1,Event,FSM,STATE>::type>::difference_type -#define RESULT_TYPE_DIFF_TYPE_ITER_TRAITS_PARAM1 typename std::iterator_traits<typename get_result_type<Param1,EVT,FSM,SourceState,TargetState>::type>::difference_type - -#define RESULT_TYPE2_REMOVE_REF_PARAM1 typename ::boost::remove_reference<typename get_result_type2<Param1,Event,FSM,STATE>::type>::type -#define RESULT_TYPE_REMOVE_REF_PARAM1 typename ::boost::remove_reference<typename get_result_type<Param1,EVT,FSM,SourceState,TargetState>::type>::type - -#define RESULT_TYPE2_PAIR_REMOVE_REF_PARAM1 std::pair<RESULT_TYPE2_REMOVE_REF_PARAM1,RESULT_TYPE2_REMOVE_REF_PARAM1> -#define RESULT_TYPE_PAIR_REMOVE_REF_PARAM1 std::pair<RESULT_TYPE_REMOVE_REF_PARAM1,RESULT_TYPE_REMOVE_REF_PARAM1> - -#define RESULT_TYPE2_GET_REF_REMOVE_REF_PARAM1 typename get_reference<typename ::boost::remove_reference<typename get_result_type2<Param1,Event,FSM,STATE>::type>::type>::type -#define RESULT_TYPE_GET_REF_REMOVE_REF_PARAM1 typename get_reference<typename ::boost::remove_reference<typename get_result_type<Param1,EVT,FSM,SourceState,TargetState>::type>::type>::type - -#define RESULT_TYPE2_GET_ITERATOR_REMOVE_REF_PARAM1 typename get_iterator<typename ::boost::remove_reference<typename get_result_type2<Param1,Event,FSM,STATE>::type>::type>::type -#define RESULT_TYPE_GET_ITERATOR_REMOVE_REF_PARAM1 typename get_iterator<typename ::boost::remove_reference<typename get_result_type<Param1,EVT,FSM,SourceState,TargetState>::type>::type>::type - -#define RESULT_TYPE2_GET_REV_ITERATOR_REMOVE_REF_PARAM1 typename get_reverse_iterator<typename ::boost::remove_reference<typename get_result_type2<Param1,Event,FSM,STATE>::type>::type>::type -#define RESULT_TYPE_GET_REV_ITERATOR_REMOVE_REF_PARAM1 typename get_reverse_iterator<typename ::boost::remove_reference<typename get_result_type<Param1,EVT,FSM,SourceState,TargetState>::type>::type>::type - -#define RESULT_TYPE2_GET_SIZE_TYPE_REMOVE_REF_PARAM1 typename get_size_type<typename ::boost::remove_reference<typename get_result_type2<Param1,Event,FSM,STATE>::type>::type>::type -#define RESULT_TYPE_GET_SIZE_TYPE_REMOVE_REF_PARAM1 typename get_size_type<typename ::boost::remove_reference<typename get_result_type<Param1,EVT,FSM,SourceState,TargetState>::type>::type>::type - -#define BOOST_MSM_EUML_ACTION(instance_name) \ - struct instance_name ## _impl; \ - struct instance_name ## _helper : boost::msm::front::euml::euml_action<instance_name ## _impl> \ - { \ - instance_name ## _helper(){} \ - typedef instance_name ## _impl action_name; \ - }; \ - static instance_name ## _helper instance_name; \ - struct instance_name ## _impl : instance_name ## _helper - -#define BOOST_MSM_EUML_DECLARE_ACTION(instance_name) \ - struct instance_name ; \ - struct instance_name ## _helper : boost::msm::front::euml::euml_action<instance_name > \ - { \ - instance_name ## _helper(){} \ - typedef instance_name action_name; \ - }; \ - struct instance_name : instance_name ## _helper - - -#define BOOST_MSM_EUML_EVENT(instance_name) \ - struct instance_name ## _helper : boost::msm::front::euml::euml_event<instance_name ## _helper>{ \ - instance_name ## _helper(){} \ - instance_name ## _helper const& operator()() const {return *this;} }; \ - static instance_name ## _helper instance_name; - -// an event matching any event -struct kleene_ : boost::msm::front::euml::euml_event<kleene_>, public boost::any -{ - kleene_() : boost::any(){} - template<typename ValueType> - kleene_(const ValueType & v) : boost::any(v){} -}; -static kleene_ kleene; - -#define BOOST_MSM_EUML_DECLARE_EVENT(instance_name) \ - struct instance_name : boost::msm::front::euml::euml_event<instance_name >{ \ - instance_name(){} \ - instance_name const& operator()() const {return *this;} }; - -#define MSM_EUML_CONCAT(param1,param2) param1 -#define MSM_EUML_EVENT_INSTANCE_HELPER_EXECUTE1(z, n, unused) ARG ## n arg ## n -#define MSM_EUML_EVENT_INSTANCE_HELPER_EXECUTE2(z, n, unused) arg ## n -#define MSM_EUML_EVENT_INSTANCE_HELPER_ATTRIBUTE_MAP_ENTRY(z, n, unused) \ - typename boost::fusion::result_of::first< \ - typename ::boost::remove_reference< \ - typename boost::fusion::result_of::at_c<T, BOOST_PP_CAT( , n)>::type>::type>::type \ - -#define MSM_EUML_EVENT_HELPER_GET_ATTRIBUTE(z, n, unused) \ - get_attribute( \ - typename boost::fusion::result_of::first< \ - typename ::boost::remove_reference< \ - typename boost::fusion::result_of::at_c<T, n>::type>::type>::type())=arg ## n; - -#define MSM_EUML_EVENT_HELPER_CONSTRUCTORS(z, n, mytuple) \ - template <BOOST_PP_ENUM_PARAMS(n, class ARG)> \ - BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 0, mytuple) , _helper)(BOOST_PP_ENUM(n, MSM_EUML_EVENT_INSTANCE_HELPER_EXECUTE1, ~ )): \ - BOOST_PP_TUPLE_ELEM(2, 1, mytuple)(){ \ - init(BOOST_PP_ENUM(n, MSM_EUML_EVENT_INSTANCE_HELPER_EXECUTE2, ~ ),attribute_vec());} - -#define MSM_EUML_EVENT_INSTANCE_HELPER_ATTRIBUTE_MAP(z, n, unused) \ - template <BOOST_PP_ENUM_PARAMS(n, class ARG),class T> \ - void init(BOOST_PP_ENUM(n, MSM_EUML_EVENT_INSTANCE_HELPER_EXECUTE1, ~ ), \ - T,typename ::boost::enable_if< typename boost::mpl::eval_if< typename ::boost::fusion::traits::is_sequence<T>::type,size_helper<T,n>,::boost::mpl::false_>::type,void >::type* =0) \ - { \ - BOOST_PP_REPEAT_FROM_TO(0,n , \ - MSM_EUML_EVENT_HELPER_GET_ATTRIBUTE, ~) \ - } - -#define MSM_EUML_EVENT_INSTANCE_HELPER_OPERATOR_IMPL(z, n, instance) \ - template <BOOST_PP_ENUM_PARAMS(n, class ARG)> \ - BOOST_PP_CAT(instance,_helper) operator() \ - (BOOST_PP_ENUM(n, MSM_EUML_EVENT_INSTANCE_HELPER_EXECUTE1, ~ ))const{ \ - return BOOST_PP_CAT(instance,_helper) (BOOST_PP_ENUM(n, MSM_EUML_EVENT_INSTANCE_HELPER_EXECUTE2, ~ ));} - -#if defined(FUSION_MAX_MAP_SIZE) - -#define BOOST_MSM_EUML_EVENT_WITH_ATTRIBUTES(instance_name, attributes_name) \ - struct instance_name ## _helper : \ - boost::msm::front::euml::euml_event<instance_name ## _helper> , public attributes_name \ - { \ - template <class T,int checked_size> struct size_helper \ - { \ - typedef typename ::boost::mpl::less_equal< \ - typename ::boost::fusion::result_of::size<T>::type, \ - ::boost::mpl::int_<checked_size> >::type type; \ - }; \ - BOOST_PP_CAT(instance_name,_helper()) : attributes_name(){} \ - typedef attributes_name::attributes_type attribute_map; \ - typedef ::boost::fusion::result_of::as_vector<attribute_map>::type attribute_vec; \ - BOOST_PP_REPEAT_FROM_TO(1,BOOST_PP_ADD(FUSION_MAX_MAP_SIZE ,1), \ - MSM_EUML_EVENT_HELPER_CONSTRUCTORS, (instance_name,attributes_name)) \ - BOOST_PP_REPEAT_FROM_TO(1,BOOST_PP_ADD(FUSION_MAX_MAP_SIZE ,1), \ - MSM_EUML_EVENT_INSTANCE_HELPER_ATTRIBUTE_MAP, ~) \ - BOOST_PP_CAT(instance_name,_helper) operator()(){ \ - return BOOST_PP_CAT(instance_name,_helper)();} \ - BOOST_PP_REPEAT_FROM_TO(1,BOOST_PP_ADD(FUSION_MAX_MAP_SIZE ,1), \ - MSM_EUML_EVENT_INSTANCE_HELPER_OPERATOR_IMPL, instance_name) \ - }; \ - static instance_name ## _helper instance_name; - -#else - -#define BOOST_MSM_EUML_EVENT_WITH_ATTRIBUTES(instance_name, attributes_name) \ - struct instance_name ## _helper : \ - boost::msm::front::euml::euml_event<instance_name ## _helper> , public attributes_name \ - { \ - template <class T,int checked_size> struct size_helper \ - { \ - typedef typename ::boost::mpl::less_equal< \ - typename ::boost::fusion::result_of::size<T>::type, \ - ::boost::mpl::int_<checked_size> >::type type; \ - }; \ - BOOST_PP_CAT(instance_name,_helper()) : attributes_name(){} \ - typedef attributes_name::attributes_type attribute_map; \ - typedef ::boost::fusion::result_of::as_vector<attribute_map>::type attribute_vec; \ - BOOST_PP_REPEAT_FROM_TO(1,BOOST_PP_ADD(10 ,1), \ - MSM_EUML_EVENT_HELPER_CONSTRUCTORS, (instance_name,attributes_name)) \ - BOOST_PP_REPEAT_FROM_TO(1,BOOST_PP_ADD(10 ,1), \ - MSM_EUML_EVENT_INSTANCE_HELPER_ATTRIBUTE_MAP, ~) \ - BOOST_PP_CAT(instance_name,_helper) operator()(){ \ - return BOOST_PP_CAT(instance_name,_helper)();} \ - BOOST_PP_REPEAT_FROM_TO(1,BOOST_PP_ADD(10 ,1), \ - MSM_EUML_EVENT_INSTANCE_HELPER_OPERATOR_IMPL, instance_name) \ - }; \ - static instance_name ## _helper instance_name; - -#endif - -#define BOOST_MSM_EUML_EVENT_NAME(instance_name) instance_name ## _helper - -#define BOOST_MSM_EUML_FLAG_NAME(instance_name) instance_name ## _helper - -#define BOOST_MSM_EUML_FLAG(instance_name) \ - struct instance_name ## _helper : boost::msm::front::euml::euml_flag<instance_name ## _helper>{}; \ - static instance_name ## _helper instance_name; - -#define BOOST_MSM_EUML_DECLARE_FLAG(instance_name) \ - struct instance_name : boost::msm::front::euml::euml_flag<instance_name >{}; - -#define BOOST_MSM_EUML_STATE_NAME(instance_name) instance_name ## _helper - -#define BOOST_MSM_EUML_BUILD_STT_HELPER build_stt( -#define BOOST_MSM_EUML_BUILD_INTERNAL_STT_HELPER build_internal_stt( -#define BOOST_MSM_EUML_BUILD_STT_HELPER2(expr) expr) -#define BOOST_MSM_EUML_ENTRY_STATE_HELPER(expr) ,expr - - -#define BOOST_MSM_EUML_ATTRIBUTES(expr,instance_name) \ - typedef BOOST_TYPEOF(build_attributes expr) instance_name; - -// following macros declare a state type but do not create an instance -#define BOOST_MSM_EUML_DECLARE_STATE(expr,instance_name) \ - struct instance_name ## tag{}; \ - typedef BOOST_TYPEOF(build_state<instance_name ## tag> expr) instance_name; - -#define BOOST_MSM_EUML_DECLARE_INTERRUPT_STATE(expr,instance_name) \ - struct instance_name ## tag{}; \ - typedef BOOST_TYPEOF(build_interrupt_state<instance_name ## tag> expr) instance_name; - -#define BOOST_MSM_EUML_DECLARE_TERMINATE_STATE(expr,instance_name) \ - struct instance_name ## tag{}; \ - typedef BOOST_TYPEOF(build_terminate_state<instance_name ## tag> expr) instance_name; - -#define BOOST_MSM_EUML_DECLARE_EXPLICIT_ENTRY_STATE(region,expr,instance_name) \ - struct instance_name ## tag{}; \ - typedef BOOST_TYPEOF(build_explicit_entry_state<instance_name ## tag BOOST_MSM_EUML_ENTRY_STATE_HELPER(region) > expr) instance_name; - -#define BOOST_MSM_EUML_DECLARE_ENTRY_STATE(region,expr,instance_name) \ - struct instance_name ## tag{}; \ - typedef BOOST_TYPEOF(build_entry_state<instance_name ## tag BOOST_MSM_EUML_ENTRY_STATE_HELPER(region) > expr) instance_name; - -#define BOOST_MSM_EUML_DECLARE_EXIT_STATE(expr,instance_name) \ - struct instance_name ## tag{}; \ - typedef BOOST_TYPEOF(build_exit_state<instance_name ## tag> expr) instance_name; - -#define BOOST_MSM_EUML_DECLARE_STATE_MACHINE(expr,instance_name) \ - struct instance_name ## tag{}; \ - typedef BOOST_TYPEOF(build_sm<instance_name ## tag> expr) instance_name; - -#define BOOST_MSM_EUML_DECLARE_TRANSITION_TABLE(expr,instance_name) \ - typedef int using_declared_table; \ - typedef BOOST_TYPEOF(BOOST_MSM_EUML_BUILD_STT_HELPER BOOST_MSM_EUML_BUILD_STT_HELPER2(expr)) instance_name; - -#define BOOST_MSM_EUML_DECLARE_INTERNAL_TRANSITION_TABLE(expr) \ - typedef BOOST_TYPEOF( \ - BOOST_MSM_EUML_BUILD_INTERNAL_STT_HELPER BOOST_MSM_EUML_BUILD_STT_HELPER2(expr)) internal_transition_table; - -// following macros declare a state type and create an instance -#define BOOST_MSM_EUML_STATE(expr,instance_name) \ - struct instance_name ## tag{}; \ - typedef BOOST_TYPEOF(build_state<instance_name ## tag> expr) instance_name ## _helper; \ - static instance_name ## _helper instance_name; - -#define BOOST_MSM_EUML_INTERRUPT_STATE(expr,instance_name) \ - struct instance_name ## tag{}; \ - typedef BOOST_TYPEOF(build_interrupt_state<instance_name ## tag> expr) instance_name ## _helper; \ - static instance_name ## _helper instance_name; - -#define BOOST_MSM_EUML_TERMINATE_STATE(expr,instance_name) \ - struct instance_name ## tag{}; \ - typedef BOOST_TYPEOF(build_terminate_state<instance_name ## tag> expr) instance_name ## _helper; \ - static instance_name ## _helper instance_name; - -#define BOOST_MSM_EUML_EXPLICIT_ENTRY_STATE(region,expr,instance_name) \ - struct instance_name ## tag{}; \ - typedef BOOST_TYPEOF(build_explicit_entry_state<instance_name ## tag BOOST_MSM_EUML_ENTRY_STATE_HELPER(region) > expr) instance_name ## _helper; \ - static instance_name ## _helper instance_name; - -#define BOOST_MSM_EUML_ENTRY_STATE(region,expr,instance_name) \ - struct instance_name ## tag{}; \ - typedef BOOST_TYPEOF(build_entry_state<instance_name ## tag BOOST_MSM_EUML_ENTRY_STATE_HELPER(region) > expr) instance_name ## _helper; \ - static instance_name ## _helper instance_name; - -#define BOOST_MSM_EUML_EXIT_STATE(expr,instance_name) \ - struct instance_name ## tag{}; \ - typedef BOOST_TYPEOF(build_exit_state<instance_name ## tag> expr) instance_name ## _helper; \ - static instance_name ## _helper instance_name; - - -#ifndef BOOST_MSVC - -#define BOOST_MSM_EUML_TRANSITION_TABLE(expr,instance_name) \ - typedef BOOST_TYPEOF(BOOST_MSM_EUML_BUILD_STT_HELPER BOOST_MSM_EUML_BUILD_STT_HELPER2(expr)) instance_name ## _def; \ - struct instance_name ## _helper : public instance_name ## _def{instance_name ## _helper(){}}; \ - static instance_name ## _helper instance_name; - -#define BOOST_MSM_EUML_INTERNAL_TRANSITION_TABLE(expr,instance_name) \ - typedef BOOST_TYPEOF(BOOST_MSM_EUML_BUILD_INTERNAL_STT_HELPER BOOST_MSM_EUML_BUILD_STT_HELPER2(expr)) instance_name ## _def; \ - struct instance_name ## _helper : public instance_name ## _def{instance_name ## _helper(){}}; \ - static instance_name ## _helper instance_name; - -#else - -#define BOOST_MSM_EUML_TRANSITION_TABLE(expr,instance_name) \ - struct instance_name ## _helper : \ - public BOOST_TYPEOF(BOOST_MSM_EUML_BUILD_STT_HELPER BOOST_MSM_EUML_BUILD_STT_HELPER2(expr)) \ - {instance_name ## _helper(){}} ; \ - static instance_name ## _helper instance_name; - -#define BOOST_MSM_EUML_INTERNAL_TRANSITION_TABLE(expr,instance_name) \ - struct instance_name ## _helper : \ - public BOOST_TYPEOF(BOOST_MSM_EUML_BUILD_INTERNAL_STT_HELPER BOOST_MSM_EUML_BUILD_STT_HELPER2(expr)) \ - {instance_name ## _helper(){}} ; \ - static instance_name ## _helper instance_name; - -#endif - -}}}} // boost::msm::front::euml - -namespace boost { namespace msm{ - template<> - struct is_kleene_event< boost::msm::front::euml::kleene_ > - { - typedef ::boost::mpl::true_ type; - }; -}} - -#endif // BOOST_MSM_FRONT_EUML_COMMON_H diff --git a/contrib/restricted/boost/boost/msm/front/euml/container.hpp b/contrib/restricted/boost/boost/msm/front/euml/container.hpp deleted file mode 100644 index 56546cff843..00000000000 --- a/contrib/restricted/boost/boost/msm/front/euml/container.hpp +++ /dev/null @@ -1,4068 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_EUML_CONTAINER_H -#define BOOST_MSM_FRONT_EUML_CONTAINER_H - -#include <utility> -#include <boost/msm/front/euml/common.hpp> -#include <boost/utility/enable_if.hpp> -#include <boost/mpl/has_key.hpp> -#include <boost/mpl/set.hpp> -#include <boost/mpl/not.hpp> -#include <boost/msm/front/euml/operator.hpp> -#include <boost/type_traits.hpp> - -BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator_category) - -namespace boost { namespace msm { namespace front { namespace euml -{ - -template <class T> -struct Front_ : euml_action<Front_<T> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_reference< - typename ::boost::remove_reference< - typename get_result_type2<T,Event,FSM,STATE>::type>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_reference< - typename ::boost::remove_reference< - typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T()(evt,fsm,src,tgt)).front(); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T()(evt,fsm,state)).front(); - } -}; - -struct front_tag {}; -struct Front_Helper: proto::extends< proto::terminal<front_tag>::type, Front_Helper, boost::msm::sm_domain> -{ - Front_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Front_<Arg1> type; - }; -}; -Front_Helper const front_; - -template <class T> -struct Back_ : euml_action<Back_<T> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_reference< - typename ::boost::remove_reference< - typename get_result_type2<T,Event,FSM,STATE>::type>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_reference< - typename ::boost::remove_reference< - typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T()(evt,fsm,src,tgt)).back(); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T()(evt,fsm,state)).back(); - } -}; - -struct back_tag {}; -struct Back_Helper: proto::extends< proto::terminal<back_tag>::type, Back_Helper, boost::msm::sm_domain> -{ - Back_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Back_<Arg1> type; - }; -}; -Back_Helper const back_; - -template <class T> -struct Begin_ : euml_action<Begin_<T> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_iterator< - typename ::boost::remove_reference< - typename get_result_type2<T,Event,FSM,STATE>::type>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_iterator< - typename ::boost::remove_reference< - typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T()(evt,fsm,src,tgt)).begin(); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T()(evt,fsm,state)).begin(); - } -}; - -struct begin_tag {}; -struct Begin_Helper: proto::extends< proto::terminal<begin_tag>::type, Begin_Helper, boost::msm::sm_domain> -{ - Begin_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Begin_<Arg1> type; - }; -}; -Begin_Helper const begin_; - -template <class T> -struct End_ : euml_action<End_<T> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_iterator< - typename ::boost::remove_reference< - typename get_result_type2<T,Event,FSM,STATE>::type>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_iterator< - typename ::boost::remove_reference< - typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T()(evt,fsm,src,tgt)).end(); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T()(evt,fsm,state)).end(); - } -}; -struct end_tag {}; -struct End_Helper: proto::extends< proto::terminal<end_tag>::type, End_Helper, boost::msm::sm_domain> -{ - End_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef End_<Arg1> type; - }; -}; -End_Helper const end_; - -template <class T> -struct RBegin_ : euml_action<RBegin_<T> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_reverse_iterator< - typename ::boost::remove_reference< - typename get_result_type2<T,Event,FSM,STATE>::type>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_reverse_iterator< - typename ::boost::remove_reference< - typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T()(evt,fsm,src,tgt)).rbegin(); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T()(evt,fsm,state)).rbegin(); - } -}; - -struct rbegin_tag {}; -struct RBegin_Helper: proto::extends< proto::terminal<rbegin_tag>::type, RBegin_Helper, boost::msm::sm_domain> -{ - RBegin_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef RBegin_<Arg1> type; - }; -}; -RBegin_Helper const rbegin_; - -template <class T> -struct REnd_ : euml_action<REnd_<T> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_reverse_iterator< - typename ::boost::remove_reference< - typename get_result_type2<T,Event,FSM,STATE>::type>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_reverse_iterator< - typename ::boost::remove_reference< - typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T()(evt,fsm,src,tgt)).rend(); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T()(evt,fsm,state)).rend(); - } -}; -struct rend_tag {}; -struct REnd_Helper: proto::extends< proto::terminal<rend_tag>::type, REnd_Helper, boost::msm::sm_domain> -{ - REnd_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef REnd_<Arg1> type; - }; -}; -REnd_Helper const rend_; - -template <class Container,class Element> -struct Push_Back_ : euml_action<Push_Back_<Container,Element> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).push_back(Element()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).push_back(Element()(evt,fsm,state)); - } -}; -struct push_back_tag {}; -struct Push_Back_Helper: proto::extends< proto::terminal<push_back_tag>::type, Push_Back_Helper, boost::msm::sm_domain> -{ - Push_Back_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Push_Back_<Arg1,Arg2> type; - }; -}; -Push_Back_Helper const push_back_; - -template <class Container> -struct Pop_Back_ : euml_action<Pop_Back_<Container> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).pop_back(); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).pop_back(); - } -}; -struct pop_back_tag {}; -struct Pop_Back_Helper: proto::extends< proto::terminal<pop_back_tag>::type, Pop_Back_Helper, boost::msm::sm_domain> -{ - Pop_Back_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Pop_Back_<Arg1> type; - }; -}; -Pop_Back_Helper const pop_back_; - -template <class Container,class Element> -struct Push_Front_ : euml_action<Push_Front_<Container,Element> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).push_front(Element()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).push_front(Element()(evt,fsm,state)); - } -}; -struct push_front_tag {}; -struct Push_Front_Helper: proto::extends< proto::terminal<push_front_tag>::type, Push_Front_Helper, boost::msm::sm_domain> -{ - Push_Front_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Push_Front_<Arg1,Arg2> type; - }; -}; -Push_Front_Helper const push_front_; - -template <class Container> -struct Pop_Front_ : euml_action<Pop_Front_<Container> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).pop_front(); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).pop_front(); - } -}; -struct pop_front_tag {}; -struct Pop_Front_Helper: proto::extends< proto::terminal<pop_front_tag>::type, Pop_Front_Helper, boost::msm::sm_domain> -{ - Pop_Front_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Pop_Front_<Arg1> type; - }; -}; -Pop_Front_Helper const pop_front_; - -template <class Container> -struct Clear_ : euml_action<Clear_<Container> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).clear(); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).clear(); - } -}; -struct clear_tag {}; -struct Clear_Helper: proto::extends< proto::terminal<clear_tag>::type, Clear_Helper, boost::msm::sm_domain> -{ - Clear_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Clear_<Arg1> type; - }; -}; -Clear_Helper const clear_; - -template <class Container> -struct ListReverse_ : euml_action<ListReverse_<Container> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).reverse(); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).reverse(); - } -}; -struct list_reverse_tag {}; -struct ListReverse_Helper: proto::extends< proto::terminal<list_reverse_tag>::type, ListReverse_Helper, boost::msm::sm_domain> -{ - ListReverse_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef ListReverse_<Arg1> type; - }; -}; -ListReverse_Helper const list_reverse_; - -template <class Container, class Predicate, class Enable=void> -struct ListUnique_ : euml_action<ListUnique_<Container,Predicate,Enable> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).unique(); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).unique(); - } -}; -template <class Container, class Predicate > -struct ListUnique_<Container,Predicate, - typename ::boost::disable_if<typename ::boost::is_same<Predicate,void>::type >::type> - : euml_action<ListUnique_<Container,Predicate> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).unique(Predicate()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).unique(Predicate()(evt,fsm,state)); - } -}; -struct list_unique_tag {}; -struct ListUnique_Helper: proto::extends< proto::terminal<list_unique_tag>::type, ListUnique_Helper, boost::msm::sm_domain> -{ - ListUnique_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef ListUnique_<Arg1,Arg2> type; - }; -}; -ListUnique_Helper const list_unique_; - -template <class Container, class Predicate, class Enable=void> -struct ListSort_ : euml_action<ListSort_<Container,Predicate,Enable> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).sort(); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).sort(); - } -}; -template <class Container, class Predicate > -struct ListSort_<Container,Predicate, - typename ::boost::disable_if<typename ::boost::is_same<Predicate,void>::type >::type> - : euml_action<ListSort_<Container,Predicate> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).sort(Predicate()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).sort(Predicate()(evt,fsm,state)); - } -}; -struct list_sort_tag {}; -struct ListSort_Helper: proto::extends< proto::terminal<list_sort_tag>::type, ListSort_Helper, boost::msm::sm_domain> -{ - ListSort_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef ListSort_<Arg1,Arg2> type; - }; -}; -ListSort_Helper const list_sort_; - -template <class Container> -struct Capacity_ : euml_action<Capacity_<Container> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_size_type< - typename ::boost::remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_size_type< - typename ::boost::remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).capacity(); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).capacity(); - } -}; -struct capacity_tag {}; -struct Capacity_Helper: proto::extends< proto::terminal<capacity_tag>::type, Capacity_Helper, boost::msm::sm_domain> -{ - Capacity_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Capacity_<Arg1> type; - }; -}; -Capacity_Helper const capacity_; - -template <class Container> -struct Size_ : euml_action<Size_<Container> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_size_type< - typename ::boost::remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_size_type< - typename ::boost::remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).size(); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).size(); - } -}; -struct size_tag {}; -struct Size_Helper: proto::extends< proto::terminal<size_tag>::type, Size_Helper, boost::msm::sm_domain> -{ - Size_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Size_<Arg1> type; - }; -}; -Size_Helper const size_; - -template <class Container> -struct Max_Size_ : euml_action<Max_Size_<Container> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_size_type< - typename ::boost::remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_size_type< - typename ::boost::remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).max_size(); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).max_size(); - } -}; -struct max_size_tag {}; -struct Max_Size_Helper: proto::extends< proto::terminal<max_size_tag>::type, Max_Size_Helper, boost::msm::sm_domain> -{ - Max_Size_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Max_Size_<Arg1> type; - }; -}; -Max_Size_Helper const max_size_; - -template <class Container, class Value> -struct Reserve_ : euml_action<Reserve_<Container,Value> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).reserve(Value()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).reserve(Value()(evt,fsm,state)); - } -}; -struct reserve_tag {}; -struct Reserve_Helper: proto::extends< proto::terminal<reserve_tag>::type, Reserve_Helper, boost::msm::sm_domain> -{ - Reserve_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Reserve_<Arg1,Arg2> type; - }; -}; -Reserve_Helper const reserve_; - -template <class Container, class Num, class Value ,class Enable=void > -struct Resize_ : euml_action<Resize_<Container,Num,Value> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).resize(Num()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).resize(Num()(evt,fsm,state)); - } -}; -template <class Container, class Num , class Value > -struct Resize_<Container,Num,Value,typename ::boost::disable_if<typename ::boost::is_same<Value,void>::type >::type> - : euml_action<Resize_<Container,Num,Value> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).resize(Num()(evt,fsm,src,tgt),Value()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).resize(Num()(evt,fsm,state),Value()(evt,fsm,state)); - } -}; -struct resize_tag {}; -struct Resize_Helper: proto::extends< proto::terminal<resize_tag>::type, Resize_Helper, boost::msm::sm_domain> -{ - Resize_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Resize_<Arg1,Arg2,Arg3> type; - }; -}; -Resize_Helper const resize_; - -// version for 3 parameters (sequence containers) -template <class Container, class Param1, class Param2, class Param3 > -struct Insert_ : euml_action<Insert_<Container,Param1,Param2,Param3> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).insert(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt), - Param3()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).insert(Param1()(evt,fsm,state),Param2()(evt,fsm,state), - Param3()(evt,fsm,state)); - } -}; -// version for 2 parameters -template <class Container, class Param1, class Param2> -struct Insert_ < Container,Param1,Param2,void> - : euml_action<Insert_<Container,Param1,Param2,void> > -{ - // return value will actually not be correct for set::insert(it1,it2), should be void - // but it's ok as nobody should call an inexistent return type - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_iterator< - typename ::boost::remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_iterator< - typename ::boost::remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - // version for transition + second param not an iterator (meaning that, Container is not an associative container) - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::and_< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename ::boost::mpl::not_< - typename has_iterator_category< - typename Param2::template transition_action_result<EVT,FSM,SourceState,TargetState>::type - >::type - >::type - >::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).insert(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt)); - } - - // version for transition + second param is an iterator (meaning that, Container is an associative container) - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::and_< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename has_iterator_category< - typename Param2::template transition_action_result<EVT,FSM,SourceState,TargetState>::type - >::type - >::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).insert(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt)); - } - - // version for state action + second param not an iterator (meaning that, Container is not an associative container) - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::and_< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename ::boost::mpl::not_< - typename has_iterator_category< - typename Param2::template state_action_result<Event,FSM,STATE>::type - >::type - >::type - >::type, - typename state_action_result<Event,FSM,STATE>::type - >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).insert(Param1()(evt,fsm,state),Param2()(evt,fsm,state)); - } - - // version for state action + second param is an iterator (meaning that, Container is an associative container) - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::and_< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename has_iterator_category< - typename Param2::template state_action_result<Event,FSM,STATE>::type - >::type - >::type, - typename state_action_result<Event,FSM,STATE>::type - >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).insert(Param1()(evt,fsm,state),Param2()(evt,fsm,state)); - } -}; - -// version for 1 parameter (associative containers) -template <class Container, class Param1> -struct Insert_ < Container,Param1,void,void> - : euml_action<Insert_<Container,Param1,void,void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename std::pair< - typename get_iterator< - typename ::boost::remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type>::type,bool> type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename std::pair< - typename get_iterator< - typename ::boost::remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type>::type,bool> type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).insert(Param1()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).insert(Param1()(evt,fsm,state)); - } -}; -struct insert_tag {}; -struct Insert_Helper: proto::extends< proto::terminal<insert_tag>::type, Insert_Helper, boost::msm::sm_domain> -{ - Insert_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Insert_<Arg1,Arg2,Arg3,Arg4> type; - }; -}; -Insert_Helper const insert_; - -template <class Container1,class Container2> -struct Swap_ : euml_action<Swap_<Container1,Container2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container1()(evt,fsm,src,tgt)).swap(Container2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container1()(evt,fsm,state)).swap(Container2()(evt,fsm,state)); - } -}; -struct swap_tag {}; -struct Swap_Helper: proto::extends< proto::terminal<swap_tag>::type, Swap_Helper, boost::msm::sm_domain> -{ - Swap_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Swap_<Arg1,Arg2> type; - }; -}; -Swap_Helper const swap_; - -template <class Container, class Iterator1, class Iterator2 ,class Enable=void > -struct Erase_ : euml_action<Erase_<Container,Iterator1,Iterator2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Iterator1,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Iterator1,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Iterator1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).erase(Iterator1()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Iterator1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).erase(Iterator1()(evt,fsm,state)); - } -}; -template <class Container, class Iterator1 , class Iterator2 > -struct Erase_<Container,Iterator1,Iterator2, - typename ::boost::disable_if<typename ::boost::is_same<Iterator2,void>::type >::type> - : euml_action<Erase_<Container,Iterator1,Iterator2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Iterator1,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Iterator1,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Iterator1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).erase(Iterator1()(evt,fsm,src,tgt),Iterator2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Iterator1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).erase(Iterator1()(evt,fsm,state),Iterator2()(evt,fsm,state)); - } -}; -struct erase_tag {}; -struct Erase_Helper: proto::extends< proto::terminal<erase_tag>::type, Erase_Helper, boost::msm::sm_domain> -{ - Erase_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Erase_<Arg1,Arg2,Arg3> type; - }; -}; -Erase_Helper const erase_; - -template <class Container> -struct Empty_ : euml_action<Empty_<Container> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef bool type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef bool type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).empty(); - } - template <class Event,class FSM,class STATE> - bool operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).empty(); - } -}; -struct empty_tag {}; -struct Empty_Helper: proto::extends< proto::terminal<empty_tag>::type, Empty_Helper, boost::msm::sm_domain> -{ - Empty_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Empty_<Arg1> type; - }; -}; -Empty_Helper const empty_; - -template <class Container,class Element> -struct ListRemove_ : euml_action<ListRemove_<Container,Element> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).remove(Element()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).remove(Element()(evt,fsm,state)); - } -}; -struct list_remove_tag {}; -struct ListRemove_Helper: proto::extends< proto::terminal<list_remove_tag>::type, ListRemove_Helper, boost::msm::sm_domain> -{ - ListRemove_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef ListRemove_<Arg1,Arg2> type; - }; -}; -ListRemove_Helper const list_remove_; - -template <class Container,class Element> -struct ListRemove_If_ : euml_action<ListRemove_If_<Container,Element> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).remove_if(Element()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).remove_if(Element()(evt,fsm,state)); - } -}; -struct list_remove_if_tag {}; -struct ListRemove_If_Helper: proto::extends< proto::terminal<list_remove_if_tag>::type, ListRemove_If_Helper, boost::msm::sm_domain> -{ - ListRemove_If_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef ListRemove_If_<Arg1,Arg2> type; - }; -}; -ListRemove_If_Helper const list_remove_if_; - -template <class Container, class ToMerge, class Predicate, class Enable=void> -struct ListMerge_ : euml_action<ListMerge_<Container,ToMerge,Predicate,Enable> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).merge(ToMerge()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).merge(ToMerge()(evt,fsm,state)); - } -}; -template <class Container, class ToMerge, class Predicate > -struct ListMerge_<Container,ToMerge,Predicate, - typename ::boost::disable_if<typename ::boost::is_same<Predicate,void>::type >::type> - : euml_action<ListMerge_<Container,ToMerge,Predicate> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).merge(ToMerge()(evt,fsm,src,tgt),Predicate()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).merge(ToMerge()(evt,fsm,state),Predicate()(evt,fsm,state)); - } -}; -struct list_merge_tag {}; -struct ListMerge_Helper: proto::extends< proto::terminal<list_merge_tag>::type, ListMerge_Helper, boost::msm::sm_domain> -{ - ListMerge_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef ListMerge_<Arg1,Arg2,Arg3> type; - }; -}; -ListMerge_Helper const list_merge_; - -template <class Container, class Param1, class Param2, class Param3, class Param4 ,class Enable=void > -struct Splice_ : euml_action<Splice_<Container,Param1,Param2,Param3,Param4,Enable> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).splice(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).splice(Param1()(evt,fsm,state),Param2()(evt,fsm,state)); - } -}; -template <class Container, class Param1, class Param2, class Param3, class Param4 > -struct Splice_<Container,Param1,Param2,Param3,Param4, - typename ::boost::disable_if< - typename ::boost::mpl::or_<typename ::boost::is_same<Param3,void>::type, - typename ::boost::mpl::not_< - typename ::boost::is_same<Param4,void>::type>::type>::type >::type> - : euml_action<Splice_<Container,Param1,Param2,Param3,Param4> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).splice(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt), - Param3()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).splice(Param1()(evt,fsm,state),Param2()(evt,fsm,state), - Param3()(evt,fsm,state)); - } -}; -template <class Container, class Param1, class Param2, class Param3, class Param4 > -struct Splice_<Container,Param1,Param2,Param3,Param4, - typename ::boost::disable_if<typename ::boost::is_same<Param4,void>::type >::type> - : euml_action<Splice_<Container,Param1,Param2,Param3,Param4> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).splice(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt), - Param3()(evt,fsm,src,tgt),Param4()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).splice(Param1()(evt,fsm,state),Param2()(evt,fsm,state), - Param3()(evt,fsm,state),Param4()(evt,fsm,state)); - } -}; -struct splice_tag {}; -struct Splice_Helper: proto::extends< proto::terminal<splice_tag>::type, Splice_Helper, boost::msm::sm_domain> -{ - Splice_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Splice_<Arg1,Arg2,Arg3,Arg4,Arg5> type; - }; -}; -Splice_Helper const splice_; - -//template <class Container, class Param1, class Param2, class Param3, class Enable=void > -//struct StringFind_ : euml_action<StringFind_<Container,Param1,Param2,Param3,Enable> > -//{ -//}; -template <class Container,class Param1, class Param2, class Param3> -struct StringFind_ : euml_action<StringFind_<Container,Param1,Param2,Param3> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type::size_type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type::size_type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)). - find(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)). - find(Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state)); - } -}; - -template <class Container,class Param1> -struct StringFind_ < Container,Param1,void,void> - : euml_action<StringFind_<Container,Param1,void,void> > - -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type::size_type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type::size_type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).find(Param1()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).find(Param1()(evt,fsm,state)); - } -}; - -template <class Container,class Param1, class Param2> -struct StringFind_ <Container,Param1,Param2,void> - : euml_action<StringFind_<Container,Param1,Param2,void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type::size_type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type::size_type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).find(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).find(Param1()(evt,fsm,state),Param2()(evt,fsm,state)); - } -}; - -struct string_find_tag {}; -struct StringFind_Helper: proto::extends< proto::terminal<string_find_tag>::type, StringFind_Helper, boost::msm::sm_domain> -{ - StringFind_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef StringFind_<Arg1,Arg2,Arg3,Arg4> type; - }; -}; -StringFind_Helper const string_find_; - -template <class Container, class Param1, class Param2, class Param3, class Enable=void > -struct StringRFind_ : euml_action<StringRFind_<Container,Param1,Param2,Param3,Enable> > -{ -}; - -template <class Container,class Param1, class Param2, class Param3> -struct StringRFind_ < - Container,Param1,Param2,Param3, - typename ::boost::enable_if< - typename ::boost::is_same<Param2,void>::type - >::type - > - : euml_action<StringRFind_<Container,Param1,Param2,Param3> > - -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type::size_type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type::size_type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).rfind(Param1()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).rfind(Param1()(evt,fsm,state)); - } -}; - -template <class Container,class Param1, class Param2, class Param3> -struct StringRFind_ < - Container,Param1,Param2,Param3, - typename ::boost::enable_if< - typename ::boost::mpl::and_< - typename ::boost::is_same<Param3,void>::type, - typename ::boost::mpl::not_< - typename ::boost::is_same<Param2,void>::type - >::type - >::type - >::type - > - : euml_action<StringRFind_<Container,Param1,Param2,Param3> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type::size_type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type::size_type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).rfind(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).rfind(Param1()(evt,fsm,state),Param2()(evt,fsm,state)); - } -}; - -template <class Container,class Param1, class Param2, class Param3> -struct StringRFind_< - Container,Param1,Param2,Param3, - typename ::boost::disable_if< - typename ::boost::is_same<Param3,void>::type - >::type - > - : euml_action<StringRFind_<Container,Param1,Param2,Param3> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type::size_type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type::size_type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)). - rfind(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)). - rfind(Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state)); - } -}; - -struct string_rfind_tag {}; -struct StringRFind_Helper: proto::extends< proto::terminal<string_rfind_tag>::type, StringRFind_Helper, boost::msm::sm_domain> -{ - StringRFind_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef StringRFind_<Arg1,Arg2,Arg3,Arg4> type; - }; -}; -StringRFind_Helper const string_rfind_; - -template <class Container,class Param1, class Param2, class Param3> -struct StringFindFirstOf_ : euml_action<StringFindFirstOf_<Container,Param1,Param2,Param3> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type::size_type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type::size_type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)). - find_first_of(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)). - find_first_of(Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state)); - } -}; -template <class Container,class Param1> -struct StringFindFirstOf_ <Container,Param1,void,void> - : euml_action<StringFindFirstOf_<Container,Param1,void,void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type::size_type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type::size_type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).find_first_of(Param1()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).find_first_of(Param1()(evt,fsm,state)); - } -}; - -template <class Container,class Param1, class Param2> -struct StringFindFirstOf_ <Container,Param1,Param2,void> - : euml_action<StringFindFirstOf_<Container,Param1,Param2,void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type::size_type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type::size_type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).find_first_of(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).find_first_of(Param1()(evt,fsm,state),Param2()(evt,fsm,state)); - } -}; - -struct string_find_first_of_tag {}; -struct StringFindFirstOf_Helper: - proto::extends< proto::terminal<string_find_first_of_tag>::type, StringFindFirstOf_Helper, boost::msm::sm_domain> -{ - StringFindFirstOf_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef StringFindFirstOf_<Arg1,Arg2,Arg3,Arg4> type; - }; -}; -StringFindFirstOf_Helper const string_find_first_of_; - -template <class Container, class Param1, class Param2, class Param3, class Enable=void > -struct StringFindFirstNotOf_ : euml_action<StringFindFirstNotOf_<Container,Param1,Param2,Param3,Enable> > -{ -}; - -template <class Container,class Param1, class Param2, class Param3> -struct StringFindFirstNotOf_ < - Container,Param1,Param2,Param3, - typename ::boost::enable_if< - typename ::boost::is_same<Param2,void>::type - >::type - > - : euml_action<StringFindFirstNotOf_<Container,Param1,Param2,Param3> > - -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type::size_type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type::size_type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).find_first_not_of(Param1()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).find_first_not_of(Param1()(evt,fsm,state)); - } -}; - -template <class Container,class Param1, class Param2, class Param3> -struct StringFindFirstNotOf_ < - Container,Param1,Param2,Param3, - typename ::boost::enable_if< - typename ::boost::mpl::and_< - typename ::boost::is_same<Param3,void>::type, - typename ::boost::mpl::not_< - typename ::boost::is_same<Param2,void>::type - >::type - >::type - >::type - > - : euml_action<StringFindFirstNotOf_<Container,Param1,Param2,Param3> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type::size_type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type::size_type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).find_first_not_of(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).find_first_not_of(Param1()(evt,fsm,state),Param2()(evt,fsm,state)); - } -}; - -template <class Container,class Param1, class Param2, class Param3> -struct StringFindFirstNotOf_< - Container,Param1,Param2,Param3, - typename ::boost::disable_if< - typename ::boost::is_same<Param3,void>::type - >::type - > - : euml_action<StringFindFirstNotOf_<Container,Param1,Param2,Param3> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type::size_type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type::size_type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)). - find_first_not_of(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)). - find_first_not_of(Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state)); - } -}; - -struct string_find_first_not_of_tag {}; -struct StringFindFirstNotOf_Helper: - proto::extends< proto::terminal<string_find_first_not_of_tag>::type, StringFindFirstNotOf_Helper, boost::msm::sm_domain> -{ - StringFindFirstNotOf_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef StringFindFirstNotOf_<Arg1,Arg2,Arg3,Arg4> type; - }; -}; -StringFindFirstNotOf_Helper const string_find_first_not_of_; - -template <class Container, class Param1, class Param2, class Param3, class Enable=void > -struct StringFindLastOf_ : euml_action<StringFindLastOf_<Container,Param1,Param2,Param3,Enable> > -{ -}; - -template <class Container,class Param1, class Param2, class Param3> -struct StringFindLastOf_ < - Container,Param1,Param2,Param3, - typename ::boost::enable_if< - typename ::boost::is_same<Param2,void>::type - >::type - > - : euml_action<StringFindLastOf_<Container,Param1,Param2,Param3> > - -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type::size_type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type::size_type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).find_last_of(Param1()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).find_last_of(Param1()(evt,fsm,state)); - } -}; - -template <class Container,class Param1, class Param2, class Param3> -struct StringFindLastOf_ < - Container,Param1,Param2,Param3, - typename ::boost::enable_if< - typename ::boost::mpl::and_< - typename ::boost::is_same<Param3,void>::type, - typename ::boost::mpl::not_< - typename ::boost::is_same<Param2,void>::type - >::type - >::type - >::type - > - : euml_action<StringFindLastOf_<Container,Param1,Param2,Param3> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type::size_type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type::size_type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).find_last_of(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).find_last_of(Param1()(evt,fsm,state),Param2()(evt,fsm,state)); - } -}; - -template <class Container,class Param1, class Param2, class Param3> -struct StringFindLastOf_< - Container,Param1,Param2,Param3, - typename ::boost::disable_if< - typename ::boost::is_same<Param3,void>::type - >::type - > - : euml_action<StringFindLastOf_<Container,Param1,Param2,Param3> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type::size_type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type::size_type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)). - find_last_of(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)). - find_last_of(Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state)); - } -}; - -struct string_find_last_of_tag {}; -struct StringFindLastOf_Helper: - proto::extends< proto::terminal<string_find_last_of_tag>::type, StringFindLastOf_Helper, boost::msm::sm_domain> -{ - StringFindLastOf_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef StringFindLastOf_<Arg1,Arg2,Arg3,Arg4> type; - }; -}; -StringFindLastOf_Helper const string_find_last_of_; - -template <class Container, class Param1, class Param2, class Param3, class Enable=void > -struct StringFindLastNotOf_ : euml_action<StringFindLastNotOf_<Container,Param1,Param2,Param3,Enable> > -{ -}; - -template <class Container,class Param1, class Param2, class Param3> -struct StringFindLastNotOf_ < - Container,Param1,Param2,Param3, - typename ::boost::enable_if< - typename ::boost::is_same<Param2,void>::type - >::type - > - : euml_action<StringFindLastNotOf_<Container,Param1,Param2,Param3> > - -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type::size_type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type::size_type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).find_last_not_of(Param1()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).find_last_not_of(Param1()(evt,fsm,state)); - } -}; - -template <class Container,class Param1, class Param2, class Param3> -struct StringFindLastNotOf_ < - Container,Param1,Param2,Param3, - typename ::boost::enable_if< - typename ::boost::mpl::and_< - typename ::boost::is_same<Param3,void>::type, - typename ::boost::mpl::not_< - typename ::boost::is_same<Param2,void>::type - >::type - >::type - >::type - > - : euml_action<StringFindLastNotOf_<Container,Param1,Param2,Param3> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type::size_type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type::size_type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).find_last_not_of(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).find_last_not_of(Param1()(evt,fsm,state),Param2()(evt,fsm,state)); - } -}; - -template <class Container,class Param1, class Param2, class Param3> -struct StringFindLastNotOf_< - Container,Param1,Param2,Param3, - typename ::boost::disable_if< - typename ::boost::is_same<Param3,void>::type - >::type - > - : euml_action<StringFindLastNotOf_<Container,Param1,Param2,Param3> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type::size_type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type::size_type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)). - find_last_not_of(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)). - find_last_not_of(Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state)); - } -}; - -struct string_find_last_not_of_tag {}; -struct StringFindLastNotOf_Helper: - proto::extends< proto::terminal<string_find_last_of_tag>::type, StringFindLastNotOf_Helper, boost::msm::sm_domain> -{ - StringFindLastNotOf_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef StringFindLastNotOf_<Arg1,Arg2,Arg3,Arg4> type; - }; -}; -StringFindLastNotOf_Helper const string_find_last_not_of_; - -template <class Container> -struct Npos_ : euml_action<Npos_<Container> > -{ - Npos_(){} - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename Container::size_type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename Container::size_type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return Container::npos; - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return Container::npos; - } -}; - -// version for 2 parameters -template <class Container, class Param1, class Param2> -struct Associative_Erase_ : euml_action<Associative_Erase_<Container,Param1,Param2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).erase(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).erase(Param1()(evt,fsm,state),Param2()(evt,fsm,state)); - } -}; -// version for 1 parameter -template <class Container, class Param1> -struct Associative_Erase_ < Container,Param1,void> - : euml_action<Associative_Erase_<Container,Param1,void> > -{ - // return value will actually not be correct for set::erase(it), should be void - // but it's ok as nobody should call an inexistent return type - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_size_type< - typename ::boost::remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_size_type< - typename ::boost::remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - // version for transition + param is an iterator - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::and_< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename has_iterator_category< - typename Param1::template transition_action_result<EVT,FSM,SourceState,TargetState>::type - >::type - >::type, - void - >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - (Container()(evt,fsm,src,tgt)).erase(Param1()(evt,fsm,src,tgt)); - } - - // version for state action + param is an iterator - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::and_< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename has_iterator_category< - typename Param1::template state_action_result<Event,FSM,STATE>::type - >::type - >::type, - void - >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - (Container()(evt,fsm,state)).erase(Param1()(evt,fsm,state)); - } - - // version for transition + param not an iterator - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::and_< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename ::boost::mpl::not_< - typename has_iterator_category< - typename Param1::template transition_action_result<EVT,FSM,SourceState,TargetState>::type - >::type - >::type - >::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).erase(Param1()(evt,fsm,src,tgt)); - } - - // version for state action + param not an iterator - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::and_< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename ::boost::mpl::not_< - typename has_iterator_category< - typename Param1::template state_action_result<Event,FSM,STATE>::type - >::type - >::type - >::type, - typename state_action_result<Event,FSM,STATE>::type - >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).erase(Param1()(evt,fsm,state)); - } -}; - -struct associative_erase_tag {}; -struct Associative_Erase_Helper: proto::extends< proto::terminal<associative_erase_tag>::type, Associative_Erase_Helper, boost::msm::sm_domain> -{ - Associative_Erase_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Associative_Erase_<Arg1,Arg2,Arg3> type; - }; -}; -Associative_Erase_Helper const associative_erase_; - - -template <class T, class Param> -struct Associative_Find_ : euml_action<Associative_Find_<T,Param> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_iterator< - typename ::boost::remove_reference< - typename get_result_type2<T,Event,FSM,STATE>::type>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_iterator< - typename ::boost::remove_reference< - typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T()(evt,fsm,src,tgt)).find(Param()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T()(evt,fsm,state)).find(Param()(evt,fsm,state)); - } -}; - -struct associative_find_tag {}; -struct Associative_Find_Helper: proto::extends< proto::terminal<associative_find_tag>::type, Associative_Find_Helper, boost::msm::sm_domain> -{ - Associative_Find_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Associative_Find_<Arg1,Arg2> type; - }; -}; -Associative_Find_Helper const associative_find_; - -template <class Container,class Param> -struct AssociativeCount_ : euml_action<AssociativeCount_<Container,Param> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_size_type< - typename ::boost::remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_size_type< - typename ::boost::remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).count(Param()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).count(Param()(evt,fsm,state)); - } -}; -struct associative_count_tag {}; -struct AssociativeCount_Helper: proto::extends< proto::terminal<associative_count_tag>::type, AssociativeCount_Helper, boost::msm::sm_domain> -{ - AssociativeCount_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef AssociativeCount_<Arg1,Arg2> type; - }; -}; -AssociativeCount_Helper const associative_count_; - -template <class T, class Param> -struct Associative_Lower_Bound_ : euml_action<Associative_Lower_Bound_<T,Param> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_iterator< - typename ::boost::remove_reference< - typename get_result_type2<T,Event,FSM,STATE>::type>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_iterator< - typename ::boost::remove_reference< - typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T()(evt,fsm,src,tgt)).lower_bound(Param()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T()(evt,fsm,state)).lower_bound(Param()(evt,fsm,state)); - } -}; - -struct associative_lower_bound_tag {}; -struct Associative_Lower_Bound_Helper: proto::extends< proto::terminal<associative_lower_bound_tag>::type, - Associative_Lower_Bound_Helper, boost::msm::sm_domain> -{ - Associative_Lower_Bound_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Associative_Lower_Bound_<Arg1,Arg2> type; - }; -}; -Associative_Lower_Bound_Helper const associative_lower_bound_; - -template <class T, class Param> -struct Associative_Upper_Bound_ : euml_action<Associative_Upper_Bound_<T,Param> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_iterator< - typename ::boost::remove_reference< - typename get_result_type2<T,Event,FSM,STATE>::type>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_iterator< - typename ::boost::remove_reference< - typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T()(evt,fsm,src,tgt)).upper_bound(Param()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T()(evt,fsm,state)).upper_bound(Param()(evt,fsm,state)); - } -}; - -struct associative_upper_bound_tag {}; -struct Associative_Upper_Bound_Helper: proto::extends< proto::terminal<associative_upper_bound_tag>::type, - Associative_Upper_Bound_Helper, boost::msm::sm_domain> -{ - Associative_Upper_Bound_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Associative_Upper_Bound_<Arg1,Arg2> type; - }; -}; -Associative_Upper_Bound_Helper const associative_upper_bound_; - -template <class T> -struct First_ : euml_action<First_<T> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_first_type< - typename ::boost::remove_reference< - typename get_result_type2<T,Event,FSM,STATE>::type>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_first_type< - typename ::boost::remove_reference< - typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T()(evt,fsm,src,tgt)).first; - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T()(evt,fsm,state)).first; - } -}; - -struct first_tag {}; -struct First_Helper: proto::extends< proto::terminal<first_tag>::type, First_Helper, boost::msm::sm_domain> -{ - First_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef First_<Arg1> type; - }; -}; -First_Helper const first_; - -template <class T> -struct Second_ : euml_action<Second_<T> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_second_type< - typename ::boost::remove_reference< - typename get_result_type2<T,Event,FSM,STATE>::type>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_second_type< - typename ::boost::remove_reference< - typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T()(evt,fsm,src,tgt)).second; - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T()(evt,fsm,state)).second; - } -}; - -struct second_tag {}; -struct Second_Helper: proto::extends< proto::terminal<second_tag>::type, Second_Helper, boost::msm::sm_domain> -{ - Second_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Second_<Arg1> type; - }; -}; -Second_Helper const second_; - -template <class T, class Param> -struct Associative_Equal_Range_ : euml_action<Associative_Equal_Range_<T,Param> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef std::pair< - typename get_iterator< - typename ::boost::remove_reference< - typename get_result_type2<T,Event,FSM,STATE>::type>::type>::type, - typename get_iterator< - typename ::boost::remove_reference< - typename get_result_type2<T,Event,FSM,STATE>::type>::type>::type > type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef std::pair< - typename get_iterator< - typename ::boost::remove_reference< - typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type>::type, - typename get_iterator< - typename ::boost::remove_reference< - typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type>::type > type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T()(evt,fsm,src,tgt)).equal_range(Param()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T()(evt,fsm,state)).equal_range(Param()(evt,fsm,state)); - } -}; - -struct associative_equal_range_tag {}; -struct Associative_Equal_Range_Helper: proto::extends< proto::terminal<associative_equal_range_tag>::type, - Associative_Equal_Range_Helper, boost::msm::sm_domain> -{ - Associative_Equal_Range_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Associative_Equal_Range_<Arg1,Arg2> type; - }; -}; -Associative_Equal_Range_Helper const associative_equal_range_; - -template <class Container,class Param1, class Param2> -struct Substr_ : euml_action<Substr_<Container,Param1,Param2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)). - substr(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)). - substr(Param1()(evt,fsm,state),Param2()(evt,fsm,state)); - } -}; -template <class Container> -struct Substr_ <Container,void,void> - : euml_action<Substr_<Container,void,void> > - -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).substr(); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).substr(); - } -}; - -template <class Container,class Param1> -struct Substr_ < Container,Param1,void> - : euml_action<Substr_<Container,Param1,void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).substr(Param1()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).substr(Param1()(evt,fsm,state)); - } -}; -struct substr_tag {}; -struct Substr_Helper: proto::extends< proto::terminal<substr_tag>::type, Substr_Helper, boost::msm::sm_domain> -{ - Substr_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Substr_<Arg1,Arg2,Arg3> type; - }; -}; -Substr_Helper const substr_; - -template <class Container, class Param1, class Param2, class Param3, class Param4 > -struct StringCompare_ : euml_action<StringCompare_<Container,Param1,Param2,Param3,Param4> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef int type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef int type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).compare(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt), - Param3()(evt,fsm,src,tgt),Param4()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).compare(Param1()(evt,fsm,state),Param2()(evt,fsm,state), - Param3()(evt,fsm,state),Param4()(evt,fsm,state)); - } -}; -template <class Container, class Param1 > -struct StringCompare_<Container,Param1,void,void,void> - : euml_action<StringCompare_<Container,Param1,void,void,void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef int type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef int type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).compare(Param1()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).compare(Param1()(evt,fsm,state)); - } -}; - -template <class Container, class Param1, class Param2> -struct StringCompare_<Container,Param1,Param2,void,void> - : euml_action<StringCompare_<Container,Param1,Param2,void,void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef int type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef int type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).compare(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).compare(Param1()(evt,fsm,state),Param2()(evt,fsm,state)); - } -}; - -template <class Container, class Param1, class Param2, class Param3 > -struct StringCompare_<Container,Param1,Param2,Param3,void> - : euml_action<StringCompare_<Container,Param1,Param2,Param3,void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef int type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef int type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).compare(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt), - Param3()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).compare(Param1()(evt,fsm,state),Param2()(evt,fsm,state), - Param3()(evt,fsm,state)); - } -}; - -struct string_compare_tag {}; -struct StringCompare_Helper: proto::extends< proto::terminal<string_compare_tag>::type, StringCompare_Helper, boost::msm::sm_domain> -{ - StringCompare_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef StringCompare_<Arg1,Arg2,Arg3,Arg4,Arg5> type; - }; -}; -StringCompare_Helper const string_compare_; - -template <class Container, class Param1, class Param2, class Param3 > -struct Append_ : euml_action<Append_<Container,Param1,Param2,Param3> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Container,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).append (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt), - Param3()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).append (Param1()(evt,fsm,state),Param2()(evt,fsm,state), - Param3()(evt,fsm,state)); - } -}; -template <class Container, class Param1> -struct Append_<Container,Param1,void,void> - : euml_action<Append_<Container,Param1,void,void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Container,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).append(Param1()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).append(Param1()(evt,fsm,state)); - } -}; - -template <class Container, class Param1, class Param2 > -struct Append_<Container,Param1,Param2,void> - : euml_action<Append_<Container,Param1,Param2,void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Container,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).append(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).append(Param1()(evt,fsm,state),Param2()(evt,fsm,state)); - } -}; - -struct append_tag {}; -struct Append_Helper: proto::extends< proto::terminal<append_tag>::type, Append_Helper, boost::msm::sm_domain> -{ - Append_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Append_<Arg1,Arg2,Arg3,Arg4> type; - }; -}; -Append_Helper const append_; - -template <class Container, class Param1, class Param2, class Param3, class Param4 > -struct StringInsert_ : euml_action<StringInsert_<Container,Param1,Param2,Param3,Param4> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Container,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).insert(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt), - Param3()(evt,fsm,src,tgt),Param4()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).insert(Param1()(evt,fsm,state),Param2()(evt,fsm,state), - Param3()(evt,fsm,state),Param4()(evt,fsm,state)); - } -}; -template <class Container, class Param1, class Param2> -struct StringInsert_ <Container,Param1,Param2,void,void> - : euml_action<StringInsert_<Container,Param1,Param2,void,void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Container,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).insert(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).insert(Param1()(evt,fsm,state),Param2()(evt,fsm,state)); - } -}; -template <class Container, class Param1, class Param2, class Param3> -struct StringInsert_<Container,Param1,Param2,Param3,void> - : euml_action<StringInsert_<Container,Param1,Param2,Param3,void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Container,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).insert(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt), - Param3()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).insert(Param1()(evt,fsm,state),Param2()(evt,fsm,state), - Param3()(evt,fsm,state)); - } -}; - -struct string_insert_tag {}; -struct StringInsert_Helper: proto::extends< proto::terminal<string_insert_tag>::type, StringInsert_Helper, boost::msm::sm_domain> -{ - StringInsert_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef StringInsert_<Arg1,Arg2,Arg3,Arg4,Arg5> type; - }; -}; -StringInsert_Helper const string_insert_; - -template <class Container,class Param1, class Param2> -struct StringErase_ : euml_action<StringErase_<Container,Param1,Param2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Container,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)). - erase(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)). - erase(Param1()(evt,fsm,state),Param2()(evt,fsm,state)); - } -}; -template <class Container> -struct StringErase_ <Container,void,void> - : euml_action<StringErase_<Container,void,void> > - -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Container,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).erase(); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).erase(); - } -}; - -template <class Container,class Param1> -struct StringErase_ <Container,Param1,void> - : euml_action<StringErase_<Container,Param1,void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Container,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).erase(Param1()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).erase(Param1()(evt,fsm,state)); - } -}; - -struct string_erase_tag {}; -struct StringErase_Helper: proto::extends< proto::terminal<string_erase_tag>::type, StringErase_Helper, boost::msm::sm_domain> -{ - StringErase_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef StringErase_<Arg1,Arg2,Arg3> type; - }; -}; -StringErase_Helper const string_erase_; - -template <class Container, class Param1, class Param2, class Param3 > -struct StringAssign_ : euml_action<StringAssign_<Container,Param1,Param2,Param3> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Container,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).assign (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt), - Param3()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).assign (Param1()(evt,fsm,state),Param2()(evt,fsm,state), - Param3()(evt,fsm,state)); - } -}; -template <class Container,class Param1> -struct StringAssign_ < - Container,Param1,void,void> - : euml_action<StringAssign_<Container,Param1,void,void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Container,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).assign(Param1()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).assign(Param1()(evt,fsm,state)); - } -}; - -template <class Container, class Param1, class Param2 > -struct StringAssign_<Container,Param1,Param2,void> - : euml_action<StringAssign_<Container,Param1,Param2,void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Container,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).assign(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).assign(Param1()(evt,fsm,state),Param2()(evt,fsm,state)); - } -}; -struct assign_tag {}; -struct StringAssign_Helper: proto::extends< proto::terminal<assign_tag>::type, StringAssign_Helper, boost::msm::sm_domain> -{ - StringAssign_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef StringAssign_<Arg1,Arg2,Arg3,Arg4> type; - }; -}; -StringAssign_Helper const string_assign_; - -template <class Container,class Param1, class Param2, class Param3, class Param4> -struct StringReplace_ : euml_action<StringReplace_<Container,Param1,Param2,Param3,Param4> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Container,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).replace (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt), - Param3()(evt,fsm,src,tgt),Param4()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).replace (Param1()(evt,fsm,state),Param2()(evt,fsm,state), - Param3()(evt,fsm,state),Param4()(evt,fsm,state)); - } -}; - -template <class Container,class Param1, class Param2, class Param3> -struct StringReplace_<Container,Param1,Param2,Param3,void> - : euml_action<StringReplace_<Container,Param1,Param2,Param3,void> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Container,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).replace(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt), - Param3()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).replace(Param1()(evt,fsm,state),Param2()(evt,fsm,state), - Param3()(evt,fsm,state)); - } -}; - -struct string_replace_tag {}; -struct StringReplace_Helper: proto::extends< proto::terminal<string_replace_tag>::type, StringReplace_Helper, boost::msm::sm_domain> -{ - StringReplace_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef StringReplace_<Arg1,Arg2,Arg3,Arg4,Arg5> type; - }; -}; -StringReplace_Helper const string_replace_; - -template <class Container> -struct CStr_ : euml_action<CStr_<Container> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::add_const< - typename get_value_type< - typename ::boost::remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type>::type>::type* type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::add_const< - typename get_value_type< - typename ::boost::remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type>::type>::type* type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).c_str(); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).c_str(); - } -}; -struct c_str_tag {}; -struct CStr_Helper: proto::extends< proto::terminal<c_str_tag>::type, CStr_Helper, boost::msm::sm_domain> -{ - CStr_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef CStr_<Arg1> type; - }; -}; -CStr_Helper const c_str_; - -template <class Container> -struct StringData_ : euml_action<StringData_<Container> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::add_const< - typename get_value_type< - typename ::boost::remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type>::type>::type* type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::add_const< - typename get_value_type< - typename ::boost::remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type>::type>::type* type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).data(); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Container::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).data(); - } -}; -struct string_data_tag {}; -struct StringData_Helper: proto::extends< proto::terminal<string_data_tag>::type, StringData_Helper, boost::msm::sm_domain> -{ - StringData_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef StringData_<Arg1> type; - }; -}; -StringData_Helper const string_data_; - -template <class Container, class Param1, class Param2, class Param3, class Enable=void > -struct StringCopy_ : euml_action<StringCopy_<Container,Param1,Param2,Param3,Enable> > -{ -}; - -template <class Container,class Param1, class Param2, class Param3> -struct StringCopy_< - Container,Param1,Param2,Param3, - typename ::boost::enable_if< - typename ::boost::is_same<Param3,void>::type - >::type - > - : euml_action<StringCopy_<Container,Param1,Param2,Param3> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_size_type< - typename ::boost::remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_size_type< - typename ::boost::remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)).copy(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)).copy(Param1()(evt,fsm,state),Param2()(evt,fsm,state)); - } -}; - -template <class Container,class Param1, class Param2, class Param3> -struct StringCopy_< - Container,Param1,Param2,Param3, - typename ::boost::disable_if< - typename ::boost::is_same<Param3,void>::type - >::type - > - : euml_action<StringCopy_<Container,Param1,Param2,Param3> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_size_type< - typename ::boost::remove_reference< - typename get_result_type2<Container,Event,FSM,STATE>::type>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_size_type< - typename ::boost::remove_reference< - typename get_result_type<Container,EVT,FSM,SourceState,TargetState>::type>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (Container()(evt,fsm,src,tgt)). - copy(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename state_action_result<Event,FSM,STATE>::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (Container()(evt,fsm,state)). - copy(Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state)); - } -}; - -struct string_copy_tag {}; -struct StringCopy_Helper: proto::extends< proto::terminal<string_copy_tag>::type, StringCopy_Helper, boost::msm::sm_domain> -{ - StringCopy_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef StringCopy_<Arg1,Arg2,Arg3,Arg4> type; - }; -}; -StringCopy_Helper const string_copy_; - -}}}} - -#endif //BOOST_MSM_FRONT_EUML_CONTAINER_H diff --git a/contrib/restricted/boost/boost/msm/front/euml/euml.hpp b/contrib/restricted/boost/boost/msm/front/euml/euml.hpp deleted file mode 100644 index c52560ed080..00000000000 --- a/contrib/restricted/boost/boost/msm/front/euml/euml.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_EUML_EUML_H -#define BOOST_MSM_FRONT_EUML_EUML_H - -#include <boost/msm/front/euml/common.hpp> -#include <boost/msm/front/euml/operator.hpp> -#include <boost/msm/front/euml/guard_grammar.hpp> -#include <boost/msm/front/euml/state_grammar.hpp> -#include <boost/msm/front/euml/stt_grammar.hpp> -#ifdef BOOST_MSM_EUML_PHOENIX_SUPPORT -#include <boost/msm/front/euml/phoenix_placeholders.hpp> -#endif - -#endif //BOOST_MSM_FRONT_EUML_EUML_H diff --git a/contrib/restricted/boost/boost/msm/front/euml/euml_typeof.hpp b/contrib/restricted/boost/boost/msm/front/euml/euml_typeof.hpp deleted file mode 100644 index d9b8903bca3..00000000000 --- a/contrib/restricted/boost/boost/msm/front/euml/euml_typeof.hpp +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_EUML_TYPEOF_H -#define BOOST_MSM_FRONT_EUML_TYPEOF_H - -#include <boost/typeof/typeof.hpp> - - -#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() - -BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::mpl::vector0, 1) -BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::mpl::vector50, 50) -BOOST_TYPEOF_REGISTER_TYPE(::boost::mpl::na) -BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::fusion::vector, 10) -BOOST_TYPEOF_REGISTER_TYPE(::boost::fusion::void_) -BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::mpl::vector, 20) -BOOST_TYPEOF_REGISTER_TYPE(std::string) -BOOST_TYPEOF_REGISTER_TEMPLATE(::boost::mpl::size_t, (unsigned int)) - -BOOST_TYPEOF_REGISTER_TYPE(::boost::msm::front::default_base_state) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::detail::inherit_attributes, 1) - -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::func_state, 6) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::entry_func_state, (int)(typename)(typename)(typename)(typename)(typename)(typename)) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::explicit_entry_func_state, (int)(typename)(typename)(typename)(typename)(typename)(typename)) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::exit_func_state, 7) - -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::define_flag, 1) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::attribute, 1) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::define_defer, 1) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::define_init, 1) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Source_, (int)) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Target_, (int)) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Current_, (int)) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Event_, (int)) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::State_Attribute_, (typename)(int)) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::State_Machine_, (int)) -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::none) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::Row, 5) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::ActionSequence_, 1) - -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::euml::NoAction) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::And_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Or_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Not_, 1) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::If_Else_, 3) -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::euml::If) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::If_Then_, 2) -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::euml::If_Then) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::While_Do_, 2) -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::euml::While_) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Do_While_, 2) -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::euml::Do_While_) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::For_Loop_, 4) -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::euml::For_Loop_) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Process_, 1) -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::euml::Process_) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Process2_, 2) -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::euml::Process2_) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Get_Flag_, 1) -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::euml::Get_Flag_) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Begin_, 1) -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::euml::Begin_Helper) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::End_, 1) -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::euml::End_Helper) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Deref_, 1) -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::euml::Deref_Helper) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Push_Back_, 2) -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::euml::Push_Back_Helper) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Clear_, 1) -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::euml::Clear_Helper) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Empty_, 1) -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::euml::Empty_Helper) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Find_, 2) -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::euml::Find_Helper) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Npos_, 1) -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::euml::False_) -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::euml::True_) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Int_, (int)) -BOOST_TYPEOF_REGISTER_TYPE(boost::msm::front::euml::Int) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Pre_inc_, 1) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Pre_dec_, 1) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Post_inc_, 1) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Post_dec_, 1) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Plus_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Minus_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Multiplies_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Divides_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Modulus_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Bitwise_And_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Bitwise_Or_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Bitwise_Xor_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Subscript_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Plus_Assign_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Minus_Assign_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Multiplies_Assign_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Divides_Assign_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Modulus_Assign_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::ShiftLeft_Assign_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::ShiftRight_Assign_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::ShiftLeft_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::ShiftRight_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Assign_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Unary_Plus_, 1) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Unary_Minus_, 1) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Less_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::LessEqual_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::Greater_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::GreaterEqual_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::EqualTo_, 2) -BOOST_TYPEOF_REGISTER_TEMPLATE(boost::msm::front::euml::NotEqualTo_, 2) - -#endif //BOOST_MSM_FRONT_EUML_TYPEOF_H diff --git a/contrib/restricted/boost/boost/msm/front/euml/guard_grammar.hpp b/contrib/restricted/boost/boost/msm/front/euml/guard_grammar.hpp deleted file mode 100644 index c8b5fa8b70e..00000000000 --- a/contrib/restricted/boost/boost/msm/front/euml/guard_grammar.hpp +++ /dev/null @@ -1,356 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_EUML_GUARD_GRAMMAR_H -#define BOOST_MSM_FRONT_EUML_GUARD_GRAMMAR_H - -#include <boost/msm/front/euml/common.hpp> -#include <boost/msm/front/euml/operator.hpp> -#include <boost/msm/front/euml/state_grammar.hpp> - -namespace boost { namespace msm { namespace front { namespace euml -{ -struct BuildGuards; -struct BuildActions; - -struct BuildGuardsCases -{ - // The primary template matches nothing: - template<typename Tag> - struct case_ - : proto::not_<proto::_> - {}; -}; -template<> -struct BuildGuardsCases::case_<proto::tag::logical_or> - : proto::when< - proto::logical_or<BuildGuards,BuildGuards >, - Or_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::logical_and> - : proto::when< - proto::logical_and<BuildGuards,BuildGuards >, - And_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::logical_not> - : proto::when< - proto::logical_not<BuildGuards >, - Not_<BuildGuards(proto::_child)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::less> - : proto::when< - proto::less<BuildGuards, BuildGuards >, - Less_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::less_equal> - : proto::when< - proto::less_equal<BuildGuards, BuildGuards >, - LessEqual_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::greater> - : proto::when< - proto::greater<BuildGuards, BuildGuards >, - Greater_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::greater_equal> - : proto::when< - proto::greater_equal<BuildGuards, BuildGuards >, - GreaterEqual_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::equal_to> - : proto::when< - proto::equal_to<BuildGuards, BuildGuards >, - EqualTo_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::not_equal_to> - : proto::when< - proto::not_equal_to<BuildGuards, BuildGuards >, - NotEqualTo_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::pre_inc> - : proto::when< - proto::pre_inc<BuildGuards >, - Pre_inc_<BuildGuards(proto::_child)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::dereference> - : proto::when< - proto::dereference<BuildGuards >, - Deref_<BuildGuards(proto::_child)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::pre_dec> - : proto::when< - proto::pre_dec<BuildGuards >, - Pre_dec_<BuildGuards(proto::_child)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::post_inc> - : proto::when< - proto::post_inc<BuildGuards >, - Post_inc_<BuildGuards(proto::_child)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::post_dec> - : proto::when< - proto::post_dec<BuildGuards >, - Post_dec_<BuildGuards(proto::_child)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::plus> - : proto::when< - proto::plus<BuildGuards,BuildGuards >, - Plus_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::minus> - : proto::when< - proto::minus<BuildGuards,BuildGuards >, - Minus_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::multiplies> - : proto::when< - proto::multiplies<BuildGuards,BuildGuards >, - Multiplies_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::divides> - : proto::when< - proto::divides<BuildGuards,BuildGuards >, - Divides_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::modulus> - : proto::when< - proto::modulus<BuildGuards,BuildGuards >, - Modulus_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::bitwise_and> - : proto::when< - proto::bitwise_and<BuildGuards,BuildGuards >, - Bitwise_And_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::bitwise_or> - : proto::when< - proto::bitwise_or<BuildGuards,BuildGuards >, - Bitwise_Or_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::subscript> - : proto::when< - proto::subscript<BuildGuards,BuildGuards >, - Subscript_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::plus_assign> - : proto::when< - proto::plus_assign<BuildGuards,BuildGuards >, - Plus_Assign_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::minus_assign> - : proto::when< - proto::minus_assign<BuildGuards,BuildGuards >, - Minus_Assign_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::multiplies_assign> - : proto::when< - proto::multiplies_assign<BuildGuards,BuildGuards >, - Multiplies_Assign_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::divides_assign> - : proto::when< - proto::divides_assign<BuildGuards,BuildGuards >, - Divides_Assign_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::modulus_assign> - : proto::when< - proto::modulus_assign<BuildGuards,BuildGuards >, - Modulus_Assign_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::shift_left_assign> - : proto::when< - proto::shift_left_assign<BuildGuards,BuildGuards >, - ShiftLeft_Assign_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::shift_right_assign> - : proto::when< - proto::shift_right_assign<BuildGuards,BuildGuards >, - ShiftRight_Assign_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::shift_left> - : proto::when< - proto::shift_left<BuildGuards,BuildGuards >, - ShiftLeft_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::shift_right> - : proto::when< - proto::shift_right<BuildGuards,BuildGuards >, - ShiftRight_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::assign> - : proto::when< - proto::assign<BuildGuards,BuildGuards >, - Assign_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::bitwise_xor> - : proto::when< - proto::bitwise_xor<BuildGuards,BuildGuards >, - Bitwise_Xor_<BuildGuards(proto::_left),BuildGuards(proto::_right)>() - > -{}; -template<> -struct BuildGuardsCases::case_<proto::tag::negate> - : proto::when< - proto::negate<BuildGuards >, - Unary_Minus_<BuildGuards(proto::_child)>() - > -{}; - -template<> -struct BuildGuardsCases::case_<proto::tag::function> - : proto::or_< - proto::when< - proto::function<proto::terminal<if_tag>,BuildGuards,BuildGuards,BuildGuards >, - If_Else_<BuildGuards(proto::_child_c<1>), - BuildGuards(proto::_child_c<2>), - BuildGuards(proto::_child_c<3>) >() - >, - proto::when< - proto::function<proto::terminal<proto::_> >, - get_fct<proto::_child_c<0> >() - >, - proto::when< - proto::function<proto::terminal<proto::_>,BuildActions >, - get_fct<proto::_child_c<0>,BuildActions(proto::_child_c<1>) >() - >, - proto::when< - proto::function<proto::terminal<proto::_>,BuildActions,BuildActions >, - get_fct<proto::_child_c<0>,BuildActions(proto::_child_c<1>),BuildActions(proto::_child_c<2>) >() - >, - proto::when< - proto::function<proto::terminal<proto::_>,BuildActions,BuildActions,BuildActions >, - get_fct<proto::_child_c<0>,BuildActions(proto::_child_c<1>) - ,BuildActions(proto::_child_c<2>),BuildActions(proto::_child_c<3>) >() - >, - proto::when< - proto::function<proto::terminal<proto::_>,BuildActions,BuildActions,BuildActions,BuildActions >, - get_fct<proto::_child_c<0> - ,BuildActions(proto::_child_c<1>),BuildActions(proto::_child_c<2>) - ,BuildActions(proto::_child_c<3>),BuildActions(proto::_child_c<4>) >() - >, - proto::when< - proto::function<proto::terminal<proto::_>,BuildActions,BuildActions,BuildActions,BuildActions,BuildActions >, - get_fct<proto::_child_c<0> - ,BuildActions(proto::_child_c<1>),BuildActions(proto::_child_c<2>) - ,BuildActions(proto::_child_c<3>),BuildActions(proto::_child_c<4>),BuildActions(proto::_child_c<5>) >() - > -#ifdef BOOST_MSVC - ,proto::when< - proto::function<proto::terminal<proto::_>,BuildActions,BuildActions,BuildActions,BuildActions,BuildActions,BuildActions >, - get_fct<proto::_child_c<0> - ,BuildActions(proto::_child_c<1>),BuildActions(proto::_child_c<2>) - ,BuildActions(proto::_child_c<3>),BuildActions(proto::_child_c<4>) - ,BuildActions(proto::_child_c<5>),BuildActions(proto::_child_c<6>) >() - > -#endif - > -{}; - -template<> -struct BuildGuardsCases::case_<proto::tag::terminal> - : proto::or_< - proto::when < - proto::terminal<action_tag>, - get_action_name<proto::_ >() - >, - proto::when< - proto::terminal<state_tag>, - get_state_name<proto::_>() - >, - proto::when< - proto::terminal<flag_tag>, - proto::_ - >, - proto::when< - proto::terminal<event_tag>, - proto::_ - >, - proto::when< - proto::terminal<fsm_artefact_tag>, - get_fct<proto::_ >() - >, - proto::when< - proto::terminal<proto::_>, - proto::_value - > - > -{}; - -struct BuildGuards - : proto::switch_<BuildGuardsCases> -{}; - -}}}} - -#endif //BOOST_MSM_FRONT_EUML_GUARD_GRAMMAR_H diff --git a/contrib/restricted/boost/boost/msm/front/euml/iteration.hpp b/contrib/restricted/boost/boost/msm/front/euml/iteration.hpp deleted file mode 100644 index 0c253386ed0..00000000000 --- a/contrib/restricted/boost/boost/msm/front/euml/iteration.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_EUML_ITERATION_H -#define BOOST_MSM_FRONT_EUML_ITERATION_H - -#include <algorithm> -#include <numeric> -#include <boost/msm/front/euml/common.hpp> - -namespace boost { namespace msm { namespace front { namespace euml -{ - -BOOST_MSM_EUML_FUNCTION(ForEach_ , std::for_each , for_each_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) -BOOST_MSM_EUML_FUNCTION(Accumulate_ , std::accumulate , accumulate_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) - -}}}} - -#endif //BOOST_MSM_FRONT_EUML_ITERATION_H diff --git a/contrib/restricted/boost/boost/msm/front/euml/operator.hpp b/contrib/restricted/boost/boost/msm/front/euml/operator.hpp deleted file mode 100644 index d976df7a6ce..00000000000 --- a/contrib/restricted/boost/boost/msm/front/euml/operator.hpp +++ /dev/null @@ -1,1566 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_EUML_OPERATOR_H -#define BOOST_MSM_FRONT_EUML_OPERATOR_H - -#include <iterator> -#include <boost/msm/front/euml/common.hpp> -#include <boost/type_traits/remove_reference.hpp> -#include <boost/utility/enable_if.hpp> -#include <boost/mpl/has_key.hpp> -#include <boost/mpl/eval_if.hpp> -#include <boost/mpl/set.hpp> -#include <boost/type_traits.hpp> - -BOOST_MPL_HAS_XXX_TRAIT_DEF(reference) -BOOST_MPL_HAS_XXX_TRAIT_DEF(key_type) - -namespace boost { namespace msm { namespace front { namespace euml -{ - -template <class T1,class T2> -struct Or_ : euml_action<Or_<T1,T2> > -{ - template <class EVT,class FSM,class SourceState,class TargetState> - bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt) - { - return (T1()(evt,fsm,src,tgt) || T2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - bool operator()(Event const& evt,FSM& fsm,STATE& state) - { - return (T1()(evt,fsm,state) || T2()(evt,fsm,state)); - } -}; -template <class T1,class T2> -struct And_ : euml_action<And_<T1,T2> > -{ - template <class EVT,class FSM,class SourceState,class TargetState> - bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt) - { - return (T1()(evt,fsm,src,tgt) && T2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - bool operator()(Event const& evt,FSM& fsm,STATE& state) - { - return (T1()(evt,fsm,state) && T2()(evt,fsm,state)); - } -}; -template <class T1> -struct Not_ : euml_action<Not_<T1> > -{ - template <class EVT,class FSM,class SourceState,class TargetState> - bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt) - { - return !(T1()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - bool operator()(Event const& evt,FSM& fsm,STATE& state) - { - return !(T1()(evt,fsm,state)); - } -}; - -template <class Condition,class Action1,class Action2, class Enable=void > -struct If_Else_ : euml_action<If_Else_<Condition,Action1,Action2,Enable> > {}; - -template <class Condition,class Action1,class Action2> -struct If_Else_<Condition,Action1,Action2 - , typename ::boost::enable_if<typename has_tag_type<Action1>::type >::type> - : euml_action<If_Else_<Condition,Action1,Action2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Action1,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Action1,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Action1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - if (Condition()(evt,fsm,src,tgt)) - { - return Action1()(evt,fsm,src,tgt); - } - return Action2()(evt,fsm,src,tgt); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Action1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - if (Condition()(evt,fsm,state)) - { - return Action1()(evt,fsm,state); - } - return Action2()(evt,fsm,state); - } -}; - -template <class Condition,class Action1,class Action2> -struct If_Else_<Condition,Action1,Action2 - , typename ::boost::disable_if<typename has_tag_type<Action1>::type >::type> - : euml_action<If_Else_<Condition,Action1,Action2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef bool type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef bool type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - if (Condition()(evt,fsm,src,tgt)) - { - return Action1()(evt,fsm,src,tgt); - } - return Action2()(evt,fsm,src,tgt); - } - template <class Event,class FSM,class STATE> - bool operator()(Event const& evt,FSM& fsm,STATE& state )const - { - if (Condition()(evt,fsm,state)) - { - return Action1()(evt,fsm,state); - } - return Action2()(evt,fsm,state); - } -}; - -struct if_tag -{ -}; -struct If : proto::extends<proto::terminal<if_tag>::type, If, boost::msm::sm_domain> -{ - If(){} - using proto::extends< proto::terminal<if_tag>::type, If, boost::msm::sm_domain>::operator=; - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef If_Else_<Arg1,Arg2,Arg3> type; - }; -}; -If const if_then_else_; - -template <class Condition,class Action1, class Enable=void > -struct If_Then_ : euml_action<If_Then_<Condition,Action1,Enable> > {}; - -template <class Condition,class Action1> -struct If_Then_<Condition,Action1 - , typename ::boost::enable_if<typename has_tag_type<Action1>::type >::type> - : euml_action<If_Then_<Condition,Action1> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Action1,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Action1,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Action1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - if (Condition()(evt,fsm,src,tgt)) - { - return Action1()(evt,fsm,src,tgt); - } - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Action1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - if (Condition()(evt,fsm,state)) - { - return Action1()(evt,fsm,state); - } - } -}; - -template <class Condition,class Action1> -struct If_Then_<Condition,Action1 - , typename ::boost::disable_if<typename has_tag_type<Action1>::type >::type> - : euml_action<If_Then_<Condition,Action1> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef bool type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef bool type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - if (Condition()(evt,fsm,src,tgt)) - { - return Action1()(evt,fsm,src,tgt); - } - } - template <class Event,class FSM,class STATE> - bool operator()(Event const& evt,FSM& fsm,STATE& state )const - { - if (Condition()(evt,fsm,state)) - { - return Action1()(evt,fsm,state); - } - } -}; -struct if_then_tag -{ -}; -struct If_Then : proto::extends< proto::terminal<if_then_tag>::type, If_Then, boost::msm::sm_domain> -{ - If_Then(){} - using proto::extends< proto::terminal<if_then_tag>::type, If_Then, boost::msm::sm_domain>::operator=; - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef If_Then_<Arg1,Arg2> type; - }; -}; -If_Then const if_then_; - -template <class Condition,class Body> -struct While_Do_ : euml_action<While_Do_<Condition,Body> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - Body body_; - Condition cond_; - while (cond_(evt,fsm,src,tgt)) - { - body_(evt,fsm,src,tgt); - } - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - Body body_; - Condition cond_; - while (cond_(evt,fsm,state)) - { - body_(evt,fsm,state); - } - } -}; -struct while_do_tag -{ -}; -struct While_Do_Helper : proto::extends< proto::terminal<while_do_tag>::type, While_Do_Helper, boost::msm::sm_domain> -{ - While_Do_Helper(){} - using proto::extends< proto::terminal<while_do_tag>::type, While_Do_Helper, boost::msm::sm_domain>::operator=; - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef While_Do_<Arg1,Arg2> type; - }; -}; -While_Do_Helper const while_; - -template <class Condition,class Body> -struct Do_While_ : euml_action<Do_While_<Condition,Body> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - Condition cond_; - Body body_; - do - { - body_(evt,fsm,src,tgt); - } while (cond_(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - Condition cond_; - Body body_; - do - { - body_(evt,fsm,state); - } while (cond_(evt,fsm,state)); - } -}; -struct do_while_tag -{ -}; -struct Do_While_Helper : proto::extends< proto::terminal<do_while_tag>::type, Do_While_Helper, boost::msm::sm_domain> -{ - Do_While_Helper(){} - using proto::extends< proto::terminal<do_while_tag>::type, Do_While_Helper, boost::msm::sm_domain>::operator=; - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Do_While_<Arg1,Arg2> type; - }; -}; -Do_While_Helper const do_while_; - -template <class Begin,class End,class EndLoop,class Body> -struct For_Loop_ : euml_action<For_Loop_<Begin,End,EndLoop,Body> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - End end_; - EndLoop end_loop_; - Body body_; - for(Begin()(evt,fsm,src,tgt);end_(evt,fsm,src,tgt);end_loop_(evt,fsm,src,tgt)) - { - body_(evt,fsm,src,tgt); - } - } - template <class Event,class FSM,class STATE> - void operator()(Event const& evt,FSM& fsm,STATE& state )const - { - End end_; - EndLoop end_loop_; - Body body_; - for(Begin()(evt,fsm,state);end_(evt,fsm,state);end_loop_(evt,fsm,state)) - { - body_(evt,fsm,state); - } - } -}; -struct for_loop_tag -{ -}; -struct For_Loop_Helper : proto::extends< proto::terminal<for_loop_tag>::type, For_Loop_Helper, boost::msm::sm_domain> -{ - For_Loop_Helper(){} - using proto::extends< proto::terminal<for_loop_tag>::type, For_Loop_Helper, boost::msm::sm_domain>::operator=; - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef For_Loop_<Arg1,Arg2,Arg3,Arg4> type; - }; -}; -For_Loop_Helper const for_; - - - - -template <class T> -struct Deref_ : euml_action<Deref_<T> > -{ - Deref_(){} - using euml_action<Deref_<T> >::operator=; - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::add_reference< - typename std::iterator_traits < - typename ::boost::remove_reference< - typename get_result_type2<T,Event,FSM,STATE>::type>::type>::value_type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::add_reference< - typename std::iterator_traits< - typename ::boost::remove_reference< - typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type - >::value_type - >::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return *(T()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return *(T()(evt,fsm,state)); - } -}; - -template <class T> -struct Pre_inc_ : euml_action<Pre_inc_<T> > -{ - using euml_action<Pre_inc_<T> >::operator=; - - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<T,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return ++T()(evt,fsm,src,tgt); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return ++T()(evt,fsm,state); - } -}; -template <class T> -struct Pre_dec_ : euml_action<Pre_dec_<T> > -{ - using euml_action<Pre_dec_<T> >::operator=; - - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<T,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return --T()(evt,fsm,src,tgt); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return --T()(evt,fsm,state); - } -}; -template <class T> -struct Post_inc_ : euml_action<Post_inc_<T> > -{ - using euml_action<Post_inc_<T> >::operator=; - - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type2<T,Event,FSM,STATE>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return T()(evt,fsm,src,tgt)++; - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return T()(evt,fsm,state)++; - } -}; -template <class T> -struct Post_dec_ : euml_action<Post_dec_<T> > -{ - using euml_action<Post_dec_<T> >::operator=; - - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type2<T,Event,FSM,STATE>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return T()(evt,fsm,src,tgt)--; - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return T()(evt,fsm,state)--; - } -}; - -template <class T1,class T2> -struct Plus_ : euml_action<Plus_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type2<T1,Event,FSM,STATE>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return T1()(evt,fsm,src,tgt)+T2()(evt,fsm,src,tgt); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return T1()(evt,fsm,state)+T2()(evt,fsm,state); - } -}; -template <class T1,class T2> -struct Minus_ : euml_action<Minus_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type2<T1,Event,FSM,STATE>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return T1()(evt,fsm,src,tgt)-T2()(evt,fsm,src,tgt); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return T1()(evt,fsm,state)-T2()(evt,fsm,state); - } -}; -template <class T1,class T2> -struct Multiplies_ : euml_action<Multiplies_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type2<T1,Event,FSM,STATE>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return T1()(evt,fsm,src,tgt)*T2()(evt,fsm,src,tgt); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return T1()(evt,fsm,state)*T2()(evt,fsm,state); - } -}; -template <class T1,class T2> -struct Divides_ : euml_action<Divides_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type2<T1,Event,FSM,STATE>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return T1()(evt,fsm,src,tgt)/T2()(evt,fsm,src,tgt); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return T1()(evt,fsm,state)/T2()(evt,fsm,state); - } -}; -template <class T1,class T2> -struct Modulus_ : euml_action<Modulus_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type2<T1,Event,FSM,STATE>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return T1()(evt,fsm,src,tgt)%T2()(evt,fsm,src,tgt); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return T1()(evt,fsm,state)%T2()(evt,fsm,state); - } -}; -template <class T1,class T2> -struct Bitwise_And_ : euml_action<Bitwise_And_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type2<T1,Event,FSM,STATE>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return T1()(evt,fsm,src,tgt)&T2()(evt,fsm,src,tgt); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return T1()(evt,fsm,state)&T2()(evt,fsm,state); - } -}; -template <class T1,class T2> -struct Bitwise_Or_ : euml_action<Bitwise_Or_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type2<T1,Event,FSM,STATE>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return T1()(evt,fsm,src,tgt)|T2()(evt,fsm,src,tgt); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return T1()(evt,fsm,state)|T2()(evt,fsm,state); - } -}; -template <class T1,class T2> -struct Bitwise_Xor_ : euml_action<Bitwise_Xor_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type2<T1,Event,FSM,STATE>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return T1()(evt,fsm,src,tgt)^T2()(evt,fsm,src,tgt); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return T1()(evt,fsm,state)^T2()(evt,fsm,state); - } -}; -template <class T1,class T2> -struct Subscript_ : euml_action<Subscript_<T1,T2> > -{ - template <class T> - struct get_reference - { - typedef typename T::reference type; - }; - template <class T> - struct get_mapped_type - { - typedef typename T::value_type::second_type& type; - }; - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type2<T1,Event,FSM,STATE>::type>::type container_type; - typedef typename ::boost::mpl::eval_if< - typename has_key_type<container_type>::type, - get_mapped_type<container_type>, - ::boost::mpl::eval_if< - typename ::boost::is_pointer<container_type>::type, - ::boost::add_reference<typename ::boost::remove_pointer<container_type>::type >, - get_reference<container_type> - > - >::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type container_type; - typedef typename ::boost::mpl::eval_if< - typename has_key_type<container_type>::type, - get_mapped_type<container_type>, - ::boost::mpl::eval_if< - typename ::boost::is_pointer<container_type>::type, - ::boost::add_reference<typename ::boost::remove_pointer<container_type>::type >, - get_reference<container_type> - > - >::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return T1()(evt,fsm,src,tgt)[T2()(evt,fsm,src,tgt)]; - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return T1()(evt,fsm,state)[T2()(evt,fsm,state)]; - } -}; -template <class T1,class T2> -struct Plus_Assign_ : euml_action<Plus_Assign_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<T1,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T1()(evt,fsm,src,tgt)+=T2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T1()(evt,fsm,state)+=T2()(evt,fsm,state)); - } -}; -template <class T1,class T2> -struct Minus_Assign_ : euml_action<Minus_Assign_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<T1,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T1()(evt,fsm,src,tgt)-=T2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T1()(evt,fsm,state)-=T2()(evt,fsm,state)); - } -}; -template <class T1,class T2> -struct Multiplies_Assign_ : euml_action<Multiplies_Assign_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<T1,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T1()(evt,fsm,src,tgt)*=T2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T1()(evt,fsm,state)*=T2()(evt,fsm,state)); - } -}; -template <class T1,class T2> -struct Divides_Assign_ : euml_action<Divides_Assign_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<T1,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T1()(evt,fsm,src,tgt)/=T2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T1()(evt,fsm,state)/=T2()(evt,fsm,state)); - } -}; -template <class T1,class T2> -struct Modulus_Assign_ : euml_action<Modulus_Assign_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<T1,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T1()(evt,fsm,src,tgt)%=T2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T1()(evt,fsm,state)%=T2()(evt,fsm,state)); - } -}; -template <class T1,class T2> -struct ShiftLeft_Assign_ : euml_action<ShiftLeft_Assign_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<T1,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T1()(evt,fsm,src,tgt)<<=T2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T1()(evt,fsm,state)<<=T2()(evt,fsm,state)); - } -}; -template <class T1,class T2> -struct ShiftRight_Assign_ : euml_action<ShiftRight_Assign_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<T1,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T1()(evt,fsm,src,tgt)>>=T2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T1()(evt,fsm,state)>>=T2()(evt,fsm,state)); - } -}; -template <class T1,class T2> -struct ShiftLeft_ : euml_action<ShiftLeft_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<T1,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T1()(evt,fsm,src,tgt)<<T2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T1()(evt,fsm,state)<<T2()(evt,fsm,state)); - } -}; -template <class T1,class T2> -struct ShiftRight_ : euml_action<ShiftRight_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<T1,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T1()(evt,fsm,src,tgt)>>T2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T1()(evt,fsm,state)>>T2()(evt,fsm,state)); - } -}; -template <class T1,class T2> -struct Assign_ : euml_action<Assign_<T1,T2> > -{ - using euml_action< Assign_<T1,T2> >::operator=; - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<T1,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T1()(evt,fsm,src,tgt)=T2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return (T1()(evt,fsm,state)=T2()(evt,fsm,state)); - } -}; -template <class T1> -struct Unary_Plus_ : euml_action<Unary_Plus_<T1> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type2<T1,Event,FSM,STATE>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return +T1()(evt,fsm,src,tgt); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return +T1()(evt,fsm,state); - } -}; -template <class T1> -struct Unary_Minus_ : euml_action<Unary_Minus_<T1> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type2<T1,Event,FSM,STATE>::type>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename ::boost::remove_reference< - typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return -(T1()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return -(T1()(evt,fsm,state)); - } -}; -template <class T1,class T2> -struct Less_ : euml_action<Less_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef bool type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef bool type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T1()(evt,fsm,src,tgt) < T2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - bool operator()(Event const& evt,FSM& fsm,STATE& state)const - { - return (T1()(evt,fsm,state) < T2()(evt,fsm,state)); - } -}; -template <class T1,class T2> -struct LessEqual_ : euml_action<LessEqual_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef bool type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef bool type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T1()(evt,fsm,src,tgt) <= T2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - bool operator()(Event const& evt,FSM& fsm,STATE& state)const - { - return (T1()(evt,fsm,state) <= T2()(evt,fsm,state)); - } -}; -template <class T1,class T2> -struct Greater_ : euml_action<Greater_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef bool type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef bool type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T1()(evt,fsm,src,tgt) > T2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - bool operator()(Event const& evt,FSM& fsm,STATE& state)const - { - return (T1()(evt,fsm,state) > T2()(evt,fsm,state)); - } -}; -template <class T1,class T2> -struct GreaterEqual_ : euml_action<GreaterEqual_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef bool type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef bool type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T1()(evt,fsm,src,tgt) >= T2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - bool operator()(Event const& evt,FSM& fsm,STATE& state)const - { - return (T1()(evt,fsm,state) >= T2()(evt,fsm,state)); - } -}; -template <class T1,class T2> -struct EqualTo_ : euml_action<EqualTo_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef bool type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef bool type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T1()(evt,fsm,src,tgt) == T2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - bool operator()(Event const& evt,FSM& fsm,STATE& state)const - { - return (T1()(evt,fsm,state) == T2()(evt,fsm,state)); - } -}; -template <class T1,class T2> -struct NotEqualTo_ : euml_action<NotEqualTo_<T1,T2> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef bool type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef bool type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return (T1()(evt,fsm,src,tgt) != T2()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - bool operator()(Event const& evt,FSM& fsm,STATE& state)const - { - return (T1()(evt,fsm,state) != T2()(evt,fsm,state)); - } -}; - -}}}} - -#endif // BOOST_MSM_FRONT_EUML_OPERATOR_H diff --git a/contrib/restricted/boost/boost/msm/front/euml/phoenix_placeholders.hpp b/contrib/restricted/boost/boost/msm/front/euml/phoenix_placeholders.hpp deleted file mode 100644 index 2c830112c5e..00000000000 --- a/contrib/restricted/boost/boost/msm/front/euml/phoenix_placeholders.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2011 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_EUML_PHOENIX_PLACEHOLDERS_H -#define BOOST_MSM_FRONT_EUML_PHOENIX_PLACEHOLDERS_H - -#include <boost/phoenix/core/argument.hpp> -// provide some meaningful placeholders (instead of arg1...arg4) -namespace boost { namespace msm { namespace front { namespace euml -{ - boost::phoenix::expression::argument<1>::type const _event = {}; - boost::phoenix::expression::argument<2>::type const _fsm = {}; - boost::phoenix::expression::argument<3>::type const _source = {}; - boost::phoenix::expression::argument<4>::type const _target = {}; - // this is for state actions - boost::phoenix::expression::argument<3>::type const _state = {}; -}}}} - -#endif //BOOST_MSM_FRONT_EUML_PHOENIX_PLACEHOLDERS_H diff --git a/contrib/restricted/boost/boost/msm/front/euml/querying.hpp b/contrib/restricted/boost/boost/msm/front/euml/querying.hpp deleted file mode 100644 index 43fc77c0f21..00000000000 --- a/contrib/restricted/boost/boost/msm/front/euml/querying.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_EUML_QUERYING_H -#define BOOST_MSM_FRONT_EUML_QUERYING_H - -#include <algorithm> -#include <boost/msm/front/euml/common.hpp> - -namespace boost { namespace msm { namespace front { namespace euml -{ - -BOOST_MSM_EUML_FUNCTION(Find_ , std::find , find_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(FindIf_ , std::find_if , find_if_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(LowerBound_ , std::lower_bound , lower_bound_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(UpperBound_ , std::upper_bound , upper_bound_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(BinarySearch_ , std::binary_search , binary_search_ , bool , bool ) -BOOST_MSM_EUML_FUNCTION(MinElement_ , std::min_element , min_element_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(MaxElement_ , std::max_element , max_element_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(AdjacentFind_ , std::adjacent_find , adjacent_find_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(FindEnd_ , std::find_end , find_end_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(FindFirstOf_ , std::find_first_of , find_first_of_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(Equal_ , std::equal , equal_ , bool , bool ) -BOOST_MSM_EUML_FUNCTION(Search_ , std::search , search_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(Includes_ , std::includes , includes_ , bool , bool ) -BOOST_MSM_EUML_FUNCTION(LexicographicalCompare_ , std::lexicographical_compare , lexicographical_compare_ , bool , bool ) -BOOST_MSM_EUML_FUNCTION(Count_ , std::count , count_ , RESULT_TYPE_DIFF_TYPE_ITER_TRAITS_PARAM1 , RESULT_TYPE2_DIFF_TYPE_ITER_TRAITS_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(CountIf_ , std::count_if , count_if_ , RESULT_TYPE_DIFF_TYPE_ITER_TRAITS_PARAM1 , RESULT_TYPE2_DIFF_TYPE_ITER_TRAITS_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(Distance_ , std::distance , distance_ , RESULT_TYPE_DIFF_TYPE_ITER_TRAITS_PARAM1 , RESULT_TYPE2_DIFF_TYPE_ITER_TRAITS_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(EqualRange_ , std::equal_range , equal_range_ , RESULT_TYPE_PAIR_REMOVE_REF_PARAM1 , RESULT_TYPE2_PAIR_REMOVE_REF_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(Mismatch_ , std::mismatch , mismatch_ , RESULT_TYPE_PAIR_REMOVE_REF_PARAM1 , RESULT_TYPE2_PAIR_REMOVE_REF_PARAM1 ) - - -}}}} - -#endif //BOOST_MSM_FRONT_EUML_QUERYING_H diff --git a/contrib/restricted/boost/boost/msm/front/euml/state_grammar.hpp b/contrib/restricted/boost/boost/msm/front/euml/state_grammar.hpp deleted file mode 100644 index a9bea10fece..00000000000 --- a/contrib/restricted/boost/boost/msm/front/euml/state_grammar.hpp +++ /dev/null @@ -1,1837 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_EUML_STATE_GRAMMAR_H -#define BOOST_MSM_FRONT_EUML_STATE_GRAMMAR_H - -#ifdef BOOST_MSM_EUML_PHOENIX_SUPPORT -#include <boost/phoenix/core/meta_grammar.hpp> -#endif - -#include <boost/msm/front/euml/common.hpp> -#include <boost/fusion/container/vector.hpp> -#include <boost/fusion/include/pair.hpp> -#include <boost/fusion/include/as_map.hpp> - -#include <boost/mpl/remove_if.hpp> -#include <boost/mpl/eval_if.hpp> -#include <boost/mpl/assert.hpp> - -#include <boost/msm/row_tags.hpp> -#include <boost/msm/front/common_states.hpp> -#include <boost/msm/front/state_machine_def.hpp> -#include <boost/msm/front/euml/operator.hpp> -#include <boost/msm/front/euml/guard_grammar.hpp> - -BOOST_MPL_HAS_XXX_TRAIT_DEF(attribute_tag) -BOOST_MPL_HAS_XXX_TRAIT_DEF(flag_create_tag) -BOOST_MPL_HAS_XXX_TRAIT_DEF(defer_create_tag) -BOOST_MPL_HAS_XXX_TRAIT_DEF(control_configure_tag) - -namespace proto = boost::proto; - -namespace boost { namespace msm { namespace front { namespace euml -{ - -// provides the typedefs and interface. Concrete states derive from it. -template<class StateNameTag, - class EntryFunctor=NoAction, - class ExitFunctor=NoAction, - class Attributes= ::boost::fusion::vector<>, - class Flags = ::boost::mpl::vector0<>, - class Defer = ::boost::mpl::vector0<>, - class BASE = ::boost::msm::front::default_base_state> -struct func_state : public ::boost::msm::front::detail::state_base<BASE,Attributes>, - euml_state_intern<func_state<StateNameTag,EntryFunctor,ExitFunctor,Attributes,Flags,Defer,BASE> > -{ - func_state(){} - // grammar testing - BOOST_MPL_ASSERT_NOT(( boost::is_same<EntryFunctor,invalid_type> )); - BOOST_MPL_ASSERT_NOT(( boost::is_same<ExitFunctor,invalid_type> )); - - typedef StateNameTag state_name_tag; - // flags - typedef Flags flag_list; - typedef ::boost::mpl::vector0<> internal_flag_list; - // deferred events - typedef Defer deferred_events; - - template <class Event,class FSM> - void on_entry(Event const& evt,FSM& fsm) - { - EntryFunctor()(evt,fsm,*this); - } - template <class Event,class FSM> - void on_exit(Event const& evt,FSM& fsm) - { - ExitFunctor()(evt,fsm,*this); - } -}; - -// provides the typedefs and interface. Concrete states derive from it. -template<class StateNameTag, - int ZoneIndex=-1, - class EntryFunctor=NoAction, - class ExitFunctor=NoAction, - class Attributes= ::boost::fusion::vector<>, - class Flags = ::boost::mpl::vector0<>, - class Defer = ::boost::mpl::vector0<>, - class BASE = default_base_state> -struct entry_func_state : public ::boost::msm::front::detail::state_base<BASE,Attributes>, - euml_state_intern<entry_func_state<StateNameTag,ZoneIndex,EntryFunctor,ExitFunctor,Attributes,Flags,Defer,BASE> > -{ - entry_func_state(){} - // grammar testing - BOOST_MPL_ASSERT_NOT(( boost::is_same<EntryFunctor,invalid_type> )); - BOOST_MPL_ASSERT_NOT(( boost::is_same<ExitFunctor,invalid_type> )); - - typedef StateNameTag state_name_tag; - // tags - typedef int pseudo_entry; - enum {zone_index=ZoneIndex}; - typedef int explicit_entry_state; - - // flags - typedef Flags flag_list; - typedef ::boost::mpl::vector0<> internal_flag_list; - // deferred events - typedef Defer deferred_events; - - template <class Event,class FSM> - void on_entry(Event const& evt,FSM& fsm) - { - EntryFunctor()(evt,fsm,*this); - } - template <class Event,class FSM> - void on_exit(Event const& evt,FSM& fsm) - { - ExitFunctor()(evt,fsm,*this); - } -}; -// provides the typedefs and interface. Concrete states derive from it. -template<class StateNameTag, - int ZoneIndex=-1, - class EntryFunctor=NoAction, - class ExitFunctor=NoAction, - class Attributes= ::boost::fusion::vector<>, - class Flags = ::boost::mpl::vector0<>, - class Defer = ::boost::mpl::vector0<>, - class BASE = default_base_state> -struct explicit_entry_func_state : public ::boost::msm::front::detail::state_base<BASE,Attributes>, - public ::boost::msm::front::explicit_entry<ZoneIndex>, - euml_state_intern<explicit_entry_func_state<StateNameTag, - ZoneIndex,EntryFunctor,ExitFunctor,Attributes,Flags,Defer,BASE> > -{ - explicit_entry_func_state(){} - // grammar testing - BOOST_MPL_ASSERT_NOT(( boost::is_same<EntryFunctor,invalid_type> )); - BOOST_MPL_ASSERT_NOT(( boost::is_same<ExitFunctor,invalid_type> )); - - typedef StateNameTag state_name_tag; - // flags - typedef Flags flag_list; - typedef ::boost::mpl::vector0<> internal_flag_list; - // deferred events - typedef Defer deferred_events; - - template <class Event,class FSM> - void on_entry(Event const& evt,FSM& fsm) - { - EntryFunctor()(evt,fsm,*this); - } - template <class Event,class FSM> - void on_exit(Event const& evt,FSM& fsm) - { - ExitFunctor()(evt,fsm,*this); - } -}; - -// provides the typedefs and interface. Concrete states derive from it. -template<class StateNameTag, - class Event, - class EntryFunctor=NoAction, - class ExitFunctor=NoAction, - class Attributes= ::boost::fusion::vector<>, - class Flags = ::boost::mpl::vector0<>, - class Defer = ::boost::mpl::vector0<>, - class BASE = default_base_state> -struct exit_func_state : public ::boost::msm::front::detail::state_base<BASE,Attributes>, - euml_state_intern<exit_func_state<StateNameTag,Event,EntryFunctor,ExitFunctor,Attributes,Flags,Defer,BASE> > -{ - exit_func_state(){} - // grammar testing - BOOST_MPL_ASSERT_NOT(( boost::is_same<EntryFunctor,invalid_type> )); - BOOST_MPL_ASSERT_NOT(( boost::is_same<ExitFunctor,invalid_type> )); - - typedef StateNameTag state_name_tag; - // tags - typedef Event event; - typedef BASE Base; - typedef int pseudo_exit; - - // flags - typedef Flags flag_list; - typedef ::boost::mpl::vector0<> internal_flag_list; - // deferred events - typedef Defer deferred_events; - - template <class Evt,class FSM> - void on_entry(Evt const& evt,FSM& fsm) - { - EntryFunctor()(evt,fsm,*this); - } - template <class Evt,class FSM> - void on_exit(Evt const& evt,FSM& fsm) - { - ExitFunctor()(evt,fsm,*this); - } -}; - -struct BuildActions; -struct BuildGuards; - -struct BuildActionSequence - : proto::or_< - proto::when < - BuildActions, - ActionSequence_<make_vector_one_row<BuildActions(proto::_)>()>() - >, - proto::when < - proto::comma<BuildActions,BuildActions >, - ActionSequence_<boost::mpl::push_back< - make_vector_one_row<BuildActions(proto::_left)>(), - BuildActions(proto::_right)>()>() - >, - proto::when < - proto::comma<BuildActionSequence,BuildActions >, - ActionSequence_<boost::mpl::push_back< - get_sequence<BuildActionSequence(proto::_left) >(), - BuildActions(proto::_right) >() >() - > - > -{}; - -#ifdef BOOST_MSM_EUML_PHOENIX_SUPPORT -struct CustomPhoenixGrammar - : proto::switch_<CustomPhoenixGrammar> -{ - template <typename Tag, typename Dummy = void> - struct case_ - : proto::and_< - proto::not_<BuildGuards> , - proto::not_<BuildActionSequence>, - boost::phoenix::meta_grammar::case_<Tag> - > - {}; -}; -#endif - -struct GuardGrammar - : proto::or_< -#ifdef BOOST_MSM_EUML_PHOENIX_SUPPORT - proto::when< - CustomPhoenixGrammar , - proto::_ - >, -#endif - proto::when< - BuildGuards , - BuildGuards - > - > - {}; - -struct ActionGrammar - : proto::or_< -#ifdef BOOST_MSM_EUML_PHOENIX_SUPPORT - proto::when< - CustomPhoenixGrammar , - proto::_ - >, -#endif - proto::when< - BuildActionSequence , - BuildActionSequence - > - > - {}; - -struct BuildActionsCases -{ - // The primary template matches nothing: - template<typename Tag> - struct case_ - : proto::not_<proto::_> - {}; -}; - -template<> -struct BuildActionsCases::case_<proto::tag::pre_inc> - : proto::when< - proto::pre_inc<BuildActions >, - Pre_inc_< BuildActions(proto::_child)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::pre_dec> - : proto::when< - proto::pre_dec<BuildActions >, - Pre_dec_< BuildActions(proto::_child)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::post_inc> - : proto::when< - proto::post_inc<BuildActions >, - Post_inc_< BuildActions(proto::_child)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::post_dec> - : proto::when< - proto::post_dec<BuildActions >, - Post_dec_< BuildActions(proto::_child)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::dereference> - : proto::when< - proto::dereference<BuildActions >, - Deref_< BuildActions(proto::_child)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::plus> - : proto::when< - proto::plus<BuildActions,BuildActions >, - Plus_<BuildActions(proto::_left),BuildActions(proto::_right)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::minus> - : proto::when< - proto::minus<BuildActions,BuildActions >, - Minus_<BuildActions(proto::_left),BuildActions(proto::_right)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::multiplies> - : proto::when< - proto::multiplies<BuildActions,BuildActions >, - Multiplies_<BuildActions(proto::_left),BuildActions(proto::_right)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::divides> - : proto::when< - proto::divides<BuildActions,BuildActions >, - Divides_<BuildActions(proto::_left),BuildActions(proto::_right)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::modulus> - : proto::when< - proto::modulus<BuildActions,BuildActions >, - Modulus_<BuildActions(proto::_left),BuildActions(proto::_right)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::bitwise_and> - : proto::when< - proto::bitwise_and<BuildActions,BuildActions >, - Bitwise_And_<BuildActions(proto::_left),BuildActions(proto::_right)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::bitwise_or> - : proto::when< - proto::bitwise_or<BuildActions,BuildActions >, - Bitwise_Or_<BuildActions(proto::_left),BuildActions(proto::_right)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::bitwise_xor> - : proto::when< - proto::bitwise_xor<BuildActions,BuildActions >, - Bitwise_Xor_<BuildActions(proto::_left),BuildActions(proto::_right)>() - > -{}; - -template<> -struct BuildActionsCases::case_<proto::tag::plus_assign> - : proto::when< - proto::plus_assign<BuildActions,BuildActions >, - Plus_Assign_< BuildActions(proto::_left),BuildActions(proto::_right)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::minus_assign> - : proto::when< - proto::minus_assign<BuildActions,BuildActions >, - Minus_Assign_<BuildActions(proto::_left),BuildActions(proto::_right)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::multiplies_assign> - : proto::when< - proto::multiplies_assign<BuildActions,BuildActions >, - Multiplies_Assign_< BuildActions(proto::_left),BuildActions(proto::_right)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::divides_assign> - : proto::when< - proto::divides_assign<BuildActions,BuildActions >, - Divides_Assign_< BuildActions(proto::_left),BuildActions(proto::_right)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::modulus_assign> - : proto::when< - proto::modulus_assign<BuildActions,BuildActions >, - Modulus_Assign_< BuildActions(proto::_left),BuildActions(proto::_right)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::shift_left_assign> - : proto::when< - proto::shift_left_assign<BuildActions,BuildActions >, - ShiftLeft_Assign_< BuildActions(proto::_left),BuildActions(proto::_right)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::shift_right_assign> - : proto::when< - proto::shift_right_assign<BuildActions,BuildActions >, - ShiftRight_Assign_< BuildActions(proto::_left),BuildActions(proto::_right)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::shift_left> - : proto::when< - proto::shift_left<BuildActions,BuildActions >, - ShiftLeft_< BuildActions(proto::_left),BuildActions(proto::_right)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::shift_right> - : proto::when< - proto::shift_right<BuildActions,BuildActions >, - ShiftRight_< BuildActions(proto::_left),BuildActions(proto::_right)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::assign> - : proto::when< - proto::assign<BuildActions,BuildActions >, - Assign_< BuildActions(proto::_left),BuildActions(proto::_right)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::subscript> - : proto::when< - proto::subscript<BuildActions,BuildActions >, - Subscript_< BuildActions(proto::_left),BuildActions(proto::_right)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::unary_plus> - : proto::when< - proto::unary_plus<BuildActions >, - Unary_Plus_< BuildActions(proto::_child)>() - > -{}; -template<> -struct BuildActionsCases::case_<proto::tag::negate> - : proto::when< - proto::negate<BuildActions >, - Unary_Minus_< BuildActions(proto::_child)>() - > -{}; - -template<> -struct BuildActionsCases::case_<proto::tag::function> - : proto::or_< - proto::when< - proto::function<proto::terminal<if_tag>,BuildGuards,BuildActionSequence,BuildActionSequence >, - If_Else_<BuildGuards(proto::_child_c<1>), - BuildActionSequence(proto::_child_c<2>), - BuildActionSequence(proto::_child_c<3>) >() - >, - proto::when< - proto::function<proto::terminal<if_then_tag>,BuildGuards,BuildActionSequence >, - If_Then_<BuildGuards(proto::_child_c<1>), - BuildActionSequence(proto::_child_c<2>)>() - >, - proto::when< - proto::function<proto::terminal<while_do_tag>,BuildGuards,BuildActionSequence >, - While_Do_<BuildGuards(proto::_child_c<1>), - BuildActionSequence(proto::_child_c<2>) >() - >, - proto::when< - proto::function<proto::terminal<do_while_tag>,BuildGuards,BuildActionSequence >, - Do_While_<BuildGuards(proto::_child_c<1>), - BuildActionSequence(proto::_child_c<2>) >() - >, - proto::when< - proto::function<proto::terminal<for_loop_tag>, - BuildActionSequence,BuildGuards,BuildActionSequence,BuildActionSequence>, - For_Loop_<BuildActionSequence(proto::_child_c<1>), - BuildGuards(proto::_child_c<2>), - BuildActionSequence(proto::_child_c<3>), - BuildActionSequence(proto::_child_c<4>) >() - >, - proto::or_< - proto::when< - proto::function<proto::terminal<proto::_>,BuildActions >, - get_fct<proto::_child_c<0>,BuildActions(proto::_child_c<1>) >() - >, - proto::when< - proto::function<proto::terminal<proto::_> >, - get_fct<proto::_child_c<0> >() - >, - proto::when< - proto::function<proto::terminal<proto::_>,BuildActions,BuildActions >, - get_fct<proto::_child_c<0>,BuildActions(proto::_child_c<1>),BuildActions(proto::_child_c<2>) >() - >, - proto::when< - proto::function<proto::terminal<proto::_>,BuildActions,BuildActions,BuildActions >, - get_fct<proto::_child_c<0>,BuildActions(proto::_child_c<1>) - ,BuildActions(proto::_child_c<2>),BuildActions(proto::_child_c<3>) >() - >, - proto::when< - proto::function<proto::terminal<proto::_>,BuildActions,BuildActions,BuildActions,BuildActions >, - get_fct<proto::_child_c<0> - ,BuildActions(proto::_child_c<1>),BuildActions(proto::_child_c<2>) - ,BuildActions(proto::_child_c<3>),BuildActions(proto::_child_c<4>) >() - >, - proto::when< - proto::function<proto::terminal<proto::_>,BuildActions,BuildActions,BuildActions,BuildActions,BuildActions >, - get_fct<proto::_child_c<0> - ,BuildActions(proto::_child_c<1>),BuildActions(proto::_child_c<2>) - ,BuildActions(proto::_child_c<3>),BuildActions(proto::_child_c<4>) - ,BuildActions(proto::_child_c<5>) >() - > -#ifdef BOOST_MSVC - ,proto::when< - proto::function<proto::terminal<proto::_>,BuildActions,BuildActions,BuildActions,BuildActions,BuildActions,BuildActions >, - get_fct<proto::_child_c<0> - ,BuildActions(proto::_child_c<1>),BuildActions(proto::_child_c<2>) - ,BuildActions(proto::_child_c<3>),BuildActions(proto::_child_c<4>) - ,BuildActions(proto::_child_c<5>),BuildActions(proto::_child_c<6>) >() - > -#endif - > - > -{}; - -template<> -struct BuildActionsCases::case_<proto::tag::terminal> - : proto::or_< - proto::when< - proto::terminal<action_tag>, - get_action_name<proto::_ >() - >, - proto::when< - proto::terminal<state_tag>, - get_state_name<proto::_>() - >, - proto::when< - proto::terminal<flag_tag>, - proto::_ - >, - proto::when< - proto::terminal<event_tag>, - proto::_ - >, - proto::when< - proto::terminal<fsm_artefact_tag>, - get_fct<proto::_ >() - >, - proto::when< - proto::terminal<proto::_>, - proto::_value - > - > -{}; -struct BuildActions - : proto::switch_<BuildActionsCases> -{}; - -// attributes building -#define BOOST_MSM_EUML_DECLARE_ATTRIBUTE(attr_type,attr_name) \ -struct attr_name ## _ \ - : proto::extends< proto::terminal< ::boost::msm::front::action_tag>::type, attr_name ## _, boost::msm::sm_domain> \ - {typedef attr_name ## _ action_name; \ - typedef ::boost::fusion::pair<attr_name ## _,attr_type> attribute_type; \ - attr_name ## _ (){} \ - }; \ -attr_name ## _ const attr_name = attr_name ## _(); - -struct make_attributes_tag -{ - typedef int attribute_tag; -}; - -template <class T> -struct get_attribute_type -{ - typedef typename T::attribute_type type; -}; -template <class Seq> -struct transform_to_fusion_pair -{ - typedef typename ::boost::mpl::fold< - Seq,::boost::mpl::vector<>, - ::boost::mpl::push_back< ::boost::mpl::placeholders::_1, - get_attribute_type< ::boost::mpl::placeholders::_2> > - >::type type; -}; - -template<class X = proto::is_proto_expr> -struct attribute -{ - BOOST_PROTO_BASIC_EXTENDS( - proto::terminal<make_attributes_tag>::type - , attribute - , boost::msm::sm_domain - ) - typedef ::boost::fusion::pair<int,int> attribute_type; -}; - -attribute<> const attributes_ = {{{}}}; - attribute<> const no_attributes_ = {{{}}}; - - struct BuildAttributesHelper - : proto::make< - ::boost::mpl::pop_front< - proto::fold_tree< - proto::_ - , ::boost::fusion::vector<>() - , ::boost::mpl::push_back<proto::_state, - ::boost::mpl::if_< has_attribute_tag< proto::_value>, - proto::_value, - get_attribute_type<proto::_> > - >() - > - > - > - {}; - -struct BuildAttributes - : proto::make< - ::boost::mpl::if_< - has_attribute_tag< ::boost::mpl::deref< ::boost::mpl::prior< ::boost::mpl::end< BuildAttributesHelper > > > >, - ::boost::fusion::result_of::as_map< ::boost::mpl::pop_back< BuildAttributesHelper > >, - ::boost::fusion::result_of::as_map< BuildAttributesHelper > > - > -{}; - -// helper to build a mpl::vector from a << list - struct BuildMplVectorHelper - : proto::make< - ::boost::mpl::pop_front< - proto::fold_tree< - proto::_ - , ::boost::mpl::vector0<>() - , ::boost::mpl::push_back<proto::_state, proto::_>() - > - > - > - {}; - -// flags building -struct BuildFlags - : proto::make< - ::boost::mpl::remove_if< - BuildMplVectorHelper, - ::boost::mpl::not_< ::boost::is_same<get_euml_tag_type< ::boost::mpl::placeholders::_ >, flag_tag > > - > - > -{}; - -struct control_configure_tag {}; - -// configuration building -struct make_configure_tag -{ - typedef int control_configure_tag; -}; - -template<class X = proto::is_proto_expr> -struct configure -{ - typedef not_euml_tag euml_tag_type; - BOOST_PROTO_BASIC_EXTENDS( - proto::terminal<make_configure_tag>::type - , configure - , boost::msm::sm_domain - ) -}; - - configure<> const configure_ = {{{}}}; - configure<> const no_configure_ = {{{}}}; - -struct BuildConfigure - : proto::make< - ::boost::mpl::remove_if< - BuildMplVectorHelper, - ::boost::mpl::not_< ::boost::is_same<get_euml_tag_type< ::boost::mpl::placeholders::_ >, config_tag > > - > - > -{}; - -struct BuildDeferred - : proto::make< - ::boost::mpl::remove_if< - BuildMplVectorHelper, - ::boost::mpl::not_< ::boost::is_same<get_euml_tag_type< ::boost::mpl::placeholders::_ >, event_tag > > - > - > -{}; - -template<class X = proto::is_proto_expr> -struct define_init -{ - typedef int defer_create_tag; - BOOST_PROTO_BASIC_EXTENDS( - proto::terminal<state_tag>::type - , define_init - , boost::msm::sm_domain - ) -}; - -define_init<> const init_ = {{{}}}; -struct BuildInit - : proto::make< - ::boost::mpl::pop_front< - proto::fold_tree< - proto::_ - , ::boost::mpl::vector0<>() - , ::boost::mpl::push_back<proto::_state, proto::_>() - > - > - > - {}; - -template <class StateNameTag,class Expr1,class Expr2,class Attr,class Configure,class BASE> -inline -func_state< -StateNameTag, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type, -typename boost::result_of<BuildFlags(Configure)>::type, -typename boost::result_of<BuildDeferred(Configure)>::type, -BASE -> -build_state(Expr1 const& ,Expr2 const& , Attr const&, Configure const&, BASE ) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - typedef typename boost::result_of<BuildFlags(Configure)>::type flags_type; - typedef typename boost::result_of<BuildDeferred(Configure)>::type deferred_type; - return func_state<StateNameTag,entry_action,exit_action,attributes_type,flags_type,deferred_type,BASE>(); -} - -template <class StateNameTag,class Expr1,class Expr2,class Attr,class Configure> -inline -func_state< -StateNameTag, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type, -typename boost::result_of<BuildFlags(Configure)>::type, -typename boost::result_of<BuildDeferred(Configure)>::type -> -build_state(Expr1 const& ,Expr2 const& ,Attr const&, Configure const&) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - typedef typename boost::result_of<BuildFlags(Configure)>::type flags_type; - typedef typename boost::result_of<BuildDeferred(Configure)>::type deferred_type; - return func_state<StateNameTag,entry_action,exit_action,attributes_type,flags_type,deferred_type>(); -} - -template <class StateNameTag,class Expr1,class Expr2,class Attr> -inline -func_state< -StateNameTag, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type -> -build_state(Expr1 const& ,Expr2 const& ,Attr const&) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - return func_state<StateNameTag,entry_action,exit_action,attributes_type>(); -} - -template <class StateNameTag,class Expr1,class Expr2> -inline -func_state< -StateNameTag, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type -> -build_state(Expr1 const& ,Expr2 const& ) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - return func_state<StateNameTag,entry_action,exit_action>(); -} - -template <class StateNameTag,class Expr1> -inline -func_state< -StateNameTag, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -NoAction -> -build_state(Expr1 const& ) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - return func_state<StateNameTag,entry_action,NoAction>(); -} -template<class StateNameTag> -inline -func_state< -StateNameTag, -NoAction, -NoAction -> -build_state() -{ - return func_state<StateNameTag,NoAction,NoAction>(); -} - -// provides the typedefs and interface. Concrete states derive from it. -template<class StateNameTag, - class STT, - class Init, - class EntryFunctor=NoAction, - class ExitFunctor=NoAction, - class Attributes= ::boost::fusion::vector<>, - class Flags = ::boost::mpl::vector0<>, - class Defer = ::boost::mpl::vector0<>, - class Configuration = ::boost::mpl::vector0<>, - class NoTransitionFunctor = NoAction, - class OnExceptionFunctor = NoAction, - class BASE = ::boost::msm::front::default_base_state> -struct func_state_machine : public ::boost::msm::front::detail::state_base<BASE,Attributes>, - euml_state_intern<func_state_machine<StateNameTag,STT,Init,EntryFunctor,ExitFunctor,Attributes,Flags, - Defer,NoTransitionFunctor,OnExceptionFunctor,BASE> > -{ - func_state_machine(){} - // grammar testing - BOOST_MPL_ASSERT_NOT(( boost::is_same<EntryFunctor,invalid_type> )); - BOOST_MPL_ASSERT_NOT(( boost::is_same<ExitFunctor,invalid_type> )); - BOOST_MPL_ASSERT_NOT(( boost::is_same<NoTransitionFunctor,invalid_type> )); - BOOST_MPL_ASSERT_NOT(( boost::is_same<OnExceptionFunctor,invalid_type> )); - BOOST_MPL_ASSERT_NOT(( boost::is_same<STT,invalid_type> )); - - // flags - typedef StateNameTag state_name_tag; - typedef Flags flag_list; - typedef ::boost::mpl::vector0<> internal_flag_list; - // deferred events - typedef Defer deferred_events; - // customization (message queue, exceptions) - typedef Configuration configuration; - - - typedef BASE BaseAllStates; - typedef STT transition_table; - // the initial state of the player SM. Must be defined - typedef Init initial_state; - - template <class Event,class FSM> - void on_entry(Event const& evt,FSM& fsm) - { - EntryFunctor()(evt,fsm,*this); - } - template <class Event,class FSM> - void on_exit(Event const& evt,FSM& fsm) - { - ExitFunctor()(evt,fsm,*this); - } -protected: - // Default no-transition handler. Can be replaced in the Derived SM class. - template <class FSM,class Event> - void no_transition(Event const& evt,FSM& fsm,int state) - { - NoTransitionFunctor()(evt,fsm,state); - } - // default exception handler. Can be replaced in the Derived SM class. - template <class FSM,class Event> - void exception_caught (Event const& evt,FSM& fsm,std::exception& e) - { - OnExceptionFunctor()(evt,fsm,e); - } -}; - -template <class StateNameTag,class STT,class Init> -inline -func_state_machine< -StateNameTag, -STT, -typename boost::result_of<BuildInit(Init)>::type -> -build_sm(STT ,Init) -{ - typedef typename boost::result_of<BuildInit(Init)>::type init_type; - return func_state_machine<StateNameTag,STT,init_type>(); -} - -template <class StateNameTag,class STT,class Init,class Expr1> -inline -func_state_machine< -StateNameTag, -STT, -typename boost::result_of<BuildInit(Init)>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type -> -build_sm(STT ,Init , Expr1 const&) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<BuildInit(Init)>::type init_type; - return func_state_machine<StateNameTag,STT,init_type,entry_action>(); -} - -template <class StateNameTag,class STT,class Init,class Expr1,class Expr2> -inline -func_state_machine< -StateNameTag, -STT, -typename boost::result_of<BuildInit(Init)>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type -> -build_sm(STT ,Init , Expr1 const& ,Expr2 const& ) -{ - typedef typename boost::result_of<BuildInit(Init)>::type init_type; - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - return func_state_machine<StateNameTag,STT,init_type,entry_action,exit_action>(); -} - -template <class StateNameTag,class STT,class Init,class Expr1,class Expr2,class Attr> -inline -func_state_machine< -StateNameTag, -STT, -typename boost::result_of<BuildInit(Init)>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type -> -build_sm(STT ,Init , Expr1 const& ,Expr2 const& ,Attr const&) -{ - typedef typename boost::result_of<BuildInit(Init)>::type init_type; - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - return func_state_machine<StateNameTag,STT,init_type,entry_action,exit_action,attributes_type>(); -} - -template <class StateNameTag,class STT,class Init,class Expr1,class Expr2,class Attr,class Configure> -inline -func_state_machine< -StateNameTag, -STT, -typename boost::result_of<BuildInit(Init)>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type, -typename boost::result_of<BuildFlags(Configure)>::type, -typename boost::result_of<BuildDeferred(Configure)>::type, -typename boost::result_of<BuildConfigure(Configure)>::type -> -build_sm(STT ,Init , Expr1 const& ,Expr2 const& , Attr const&, Configure const& ) -{ - typedef typename boost::result_of<BuildInit(Init)>::type init_type; - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - typedef typename boost::result_of<BuildFlags(Configure)>::type flags_type; - typedef typename boost::result_of<BuildDeferred(Configure)>::type deferred_type; - typedef typename boost::result_of<BuildConfigure(Configure)>::type config_type; - return func_state_machine<StateNameTag,STT,init_type,entry_action,exit_action,attributes_type,flags_type, - deferred_type,config_type>(); - -} - -template <class StateNameTag,class STT,class Init,class Expr1,class Expr2,class Attr,class Configure,class Expr3> -inline -func_state_machine< -StateNameTag, -STT, -typename boost::result_of<BuildInit(Init)>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type, -typename boost::result_of<BuildFlags(Configure)>::type, -typename boost::result_of<BuildDeferred(Configure)>::type, -typename boost::result_of<BuildConfigure(Configure)>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr3,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr3)>, - make_invalid_type>::type -> -build_sm(STT ,Init , Expr1 const& ,Expr2 const& ,Attr const&, Configure const&, Expr3 const& ) -{ - typedef typename boost::result_of<BuildInit(Init)>::type init_type; - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<ActionGrammar(Expr3)>::type no_transition_action; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - typedef typename boost::result_of<BuildFlags(Configure)>::type flags_type; - typedef typename boost::result_of<BuildDeferred(Configure)>::type deferred_type; - typedef typename boost::result_of<BuildConfigure(Configure)>::type config_type; - return func_state_machine<StateNameTag,STT,init_type,entry_action,exit_action,attributes_type,flags_type,deferred_type, - config_type,no_transition_action>(); -} - -template <class StateNameTag,class STT,class Init,class Expr1,class Expr2,class Attr,class Configure,class Expr3,class Expr4> -inline -func_state_machine< -StateNameTag, -STT, -typename boost::result_of<BuildInit(Init)>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type, -typename boost::result_of<BuildFlags(Configure)>::type, -typename boost::result_of<BuildDeferred(Configure)>::type, -typename boost::result_of<BuildConfigure(Configure)>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr3,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr3)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr4,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr4)>, - make_invalid_type>::type -> -build_sm(STT ,Init , Expr1 const& ,Expr2 const& , Attr const&, Configure const&, Expr3 const&, Expr4 const& ) -{ - typedef typename boost::result_of<BuildInit(Init)>::type init_type; - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildFlags(Configure)>::type flags_type; - typedef typename boost::result_of<BuildDeferred(Configure)>::type deferred_type; - typedef typename boost::result_of<BuildConfigure(Configure)>::type config_type; - typedef typename boost::result_of<ActionGrammar(Expr3)>::type no_transition_action; - typedef typename boost::result_of<ActionGrammar(Expr4)>::type on_exception_action; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - return func_state_machine<StateNameTag,STT,init_type,entry_action,exit_action,attributes_type,flags_type,deferred_type, - config_type,no_transition_action,on_exception_action>(); -} - -template <class StateNameTag,class STT,class Init,class Expr1,class Expr2,class Attr,class Configure,class Expr3,class Expr4,class BASE> -inline -func_state_machine< -StateNameTag, -STT, -typename boost::result_of<BuildInit(Init)>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type, -typename boost::result_of<BuildFlags(Configure)>::type, -typename boost::result_of<BuildDeferred(Configure)>::type, -typename boost::result_of<BuildConfigure(Configure)>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr3,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr3)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr4,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr4)>, - make_invalid_type>::type, -BASE -> -build_sm(STT ,Init , Expr1 const& ,Expr2 const& ,Attr const& , Configure const&, Expr3 const&, Expr4 const& , BASE ) -{ - typedef typename boost::result_of<BuildInit(Init)>::type init_type; - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildFlags(Configure)>::type flags_type; - typedef typename boost::result_of<BuildDeferred(Configure)>::type deferred_type; - typedef typename boost::result_of<BuildConfigure(Configure)>::type config_type; - typedef typename boost::result_of<ActionGrammar(Expr3)>::type no_transition_action; - typedef typename boost::result_of<ActionGrammar(Expr4)>::type on_exception_action; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - return func_state_machine<StateNameTag,STT,init_type,entry_action,exit_action,attributes_type,flags_type,deferred_type, - config_type,no_transition_action,on_exception_action,BASE>(); -} - -template <class Expr> -inline -::boost::msm::front::detail::inherit_attributes<typename boost::result_of<BuildAttributes(Expr)>::type> -build_attributes (Expr const&) -{ - return ::boost::msm::front::detail::inherit_attributes<typename boost::result_of<BuildAttributes(Expr)>::type> (); -} - -template <class StateNameTag,class Expr1,class Expr2,class Attr,class Configure,class BASE> -inline -func_state< -StateNameTag, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type, -typename ::boost::mpl::push_back< typename boost::result_of<BuildFlags(Configure)>::type, - ::boost::msm::TerminateFlag>::type, -typename boost::result_of<BuildDeferred(Configure)>::type, -BASE -> -build_terminate_state(Expr1 const& ,Expr2 const& , Attr const&, Configure const&, BASE ) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename ::boost::mpl::push_back< - typename boost::result_of<BuildFlags(Configure)>::type, - ::boost::msm::TerminateFlag >::type flags_type; - typedef typename boost::result_of<BuildDeferred(Configure)>::type deferred_type; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - return func_state<StateNameTag,entry_action,exit_action,attributes_type,flags_type,deferred_type,BASE>(); -} - -template <class StateNameTag,class Expr1,class Expr2,class Attr,class Configure> -inline -func_state< -StateNameTag, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type, -typename ::boost::mpl::push_back< typename boost::result_of<BuildFlags(Configure)>::type, - ::boost::msm::TerminateFlag>::type, -typename boost::result_of<BuildDeferred(Configure)>::type -> -build_terminate_state(Expr1 const& ,Expr2 const& ,Attr const&, Configure const&) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename ::boost::mpl::push_back< - typename boost::result_of<BuildFlags(Configure)>::type, - ::boost::msm::TerminateFlag >::type flags_type; - typedef typename boost::result_of<BuildDeferred(Configure)>::type deferred_type; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - - return func_state<StateNameTag,entry_action,exit_action,attributes_type,flags_type,deferred_type>(); -} - -template <class StateNameTag,class Expr1,class Expr2,class Attr> -inline -func_state< -StateNameTag, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type, -::boost::mpl::vector<boost::msm::TerminateFlag> -> -build_terminate_state(Expr1 const& ,Expr2 const& ,Attr const&) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - return func_state<StateNameTag,entry_action,exit_action,attributes_type, ::boost::mpl::vector< ::boost::msm::TerminateFlag> >(); -} - -template <class StateNameTag,class Expr1,class Expr2> -inline -func_state< -StateNameTag, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -::boost::fusion::vector<>, -::boost::mpl::vector<boost::msm::TerminateFlag> -> -build_terminate_state(Expr1 const& ,Expr2 const& ) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - return func_state<StateNameTag,entry_action,exit_action, - ::boost::fusion::vector<>, ::boost::mpl::vector< ::boost::msm::TerminateFlag> >(); -} - -template <class StateNameTag,class Expr1> -inline -func_state< -StateNameTag, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -NoAction, -::boost::fusion::vector<>, -::boost::mpl::vector<boost::msm::TerminateFlag> -> -build_terminate_state(Expr1 const& ) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - return func_state<StateNameTag,entry_action,NoAction,::boost::fusion::vector<>,::boost::mpl::vector<boost::msm::TerminateFlag> >(); -} -template<class StateNameTag> -inline -func_state< -StateNameTag, -NoAction, -NoAction, -::boost::fusion::vector<>, -::boost::mpl::vector<boost::msm::TerminateFlag> -> -build_terminate_state() -{ - return func_state<StateNameTag,NoAction,NoAction,::boost::fusion::vector<>,::boost::mpl::vector<boost::msm::TerminateFlag> >(); -} - -template <class StateNameTag,class Expr1,class Expr2,class Attr,class Configure,class BASE,class EndInterruptEvent> -inline -func_state< -StateNameTag, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type, -typename ::boost::mpl::push_back< - typename ::boost::mpl::push_back< typename boost::result_of<BuildFlags(Configure)>::type, - ::boost::msm::InterruptedFlag>::type, - boost::msm::EndInterruptFlag<EndInterruptEvent> - >::type, -typename boost::result_of<BuildDeferred(Configure)>::type, -BASE -> -build_interrupt_state(EndInterruptEvent const&,Expr1 const& ,Expr2 const& , Attr const&, Configure const&, BASE ) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - typedef typename ::boost::mpl::push_back< - typename ::boost::mpl::push_back< - typename boost::result_of<BuildFlags(Configure)>::type, - ::boost::msm::InterruptedFlag>::type, - boost::msm::EndInterruptFlag<EndInterruptEvent> - >::type flags_type; - typedef typename boost::result_of<BuildDeferred(Configure)>::type deferred_type; - return func_state<StateNameTag,entry_action,exit_action,attributes_type,flags_type,deferred_type,BASE>(); -} - -template <class StateNameTag,class Expr1,class Expr2,class Attr,class Configure,class EndInterruptEvent> -inline -func_state< -StateNameTag, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type, -typename ::boost::mpl::push_back< - typename ::boost::mpl::push_back< typename boost::result_of<BuildFlags(Configure)>::type, - ::boost::msm::InterruptedFlag>::type, - boost::msm::EndInterruptFlag<EndInterruptEvent> - >::type, -typename boost::result_of<BuildDeferred(Configure)>::type -> -build_interrupt_state(EndInterruptEvent const&,Expr1 const& ,Expr2 const& ,Attr const&, Configure const&) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - - typedef typename ::boost::mpl::push_back< - typename ::boost::mpl::push_back< - typename boost::result_of<BuildFlags(Configure)>::type, - ::boost::msm::InterruptedFlag>::type, - boost::msm::EndInterruptFlag<EndInterruptEvent> - >::type flags_type; - typedef typename boost::result_of<BuildDeferred(Configure)>::type deferred_type; - - return func_state<StateNameTag,entry_action,exit_action,attributes_type,flags_type,deferred_type>(); -} - -template <class StateNameTag,class Expr1,class Expr2,class Attr,class EndInterruptEvent> -inline -func_state< -StateNameTag, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type, -::boost::mpl::vector<boost::msm::InterruptedFlag, boost::msm::EndInterruptFlag<EndInterruptEvent> > -> -build_interrupt_state(EndInterruptEvent const&,Expr1 const& ,Expr2 const& ,Attr const&) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - return func_state<StateNameTag,entry_action,exit_action,attributes_type, - ::boost::mpl::vector< boost::msm::InterruptedFlag, boost::msm::EndInterruptFlag<EndInterruptEvent> > >(); -} - -template <class StateNameTag,class Expr1,class Expr2,class EndInterruptEvent> -inline -func_state< -StateNameTag, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -::boost::fusion::vector<>, -::boost::mpl::vector<boost::msm::InterruptedFlag, boost::msm::EndInterruptFlag<EndInterruptEvent> > -> -build_interrupt_state(EndInterruptEvent const&,Expr1 const& ,Expr2 const& ) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - return func_state<StateNameTag,entry_action,exit_action, - ::boost::fusion::vector<>, - ::boost::mpl::vector< boost::msm::InterruptedFlag, boost::msm::EndInterruptFlag<EndInterruptEvent> > >(); -} - -template <class StateNameTag,class Expr1,class EndInterruptEvent> -inline -func_state< -StateNameTag, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -NoAction, -::boost::fusion::vector<>, -::boost::mpl::vector<boost::msm::InterruptedFlag, boost::msm::EndInterruptFlag<EndInterruptEvent> > -> -build_interrupt_state(EndInterruptEvent const&, Expr1 const&) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - return func_state<StateNameTag,entry_action,NoAction, ::boost::fusion::vector<>, - ::boost::mpl::vector<boost::msm::InterruptedFlag, boost::msm::EndInterruptFlag<EndInterruptEvent> > >(); -} - -template <class StateNameTag,class EndInterruptEvent> -inline -func_state< -StateNameTag, -NoAction, -NoAction, -::boost::fusion::vector<>, -::boost::mpl::vector<boost::msm::InterruptedFlag, boost::msm::EndInterruptFlag<EndInterruptEvent> > -> -build_interrupt_state(EndInterruptEvent const&) -{ - return func_state<StateNameTag,NoAction,NoAction, ::boost::fusion::vector<>, - ::boost::mpl::vector<boost::msm::InterruptedFlag, boost::msm::EndInterruptFlag<EndInterruptEvent> > >(); -} - -template <class StateNameTag,int ZoneIndex,class Expr1,class Expr2,class Attr,class Configure,class BASE> -inline -entry_func_state< -StateNameTag, -ZoneIndex, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type, -typename boost::result_of<BuildFlags(Configure)>::type, -typename boost::result_of<BuildDeferred(Configure)>::type, -BASE -> -build_entry_state(Expr1 const& ,Expr2 const& , Attr const&, Configure const&, BASE ) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildFlags(Configure)>::type flags_type; - typedef typename boost::result_of<BuildDeferred(Configure)>::type deferred_type; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - return entry_func_state<StateNameTag,ZoneIndex,entry_action,exit_action,attributes_type,flags_type,deferred_type,BASE>(); -} - -template <class StateNameTag,int ZoneIndex,class Expr1,class Expr2,class Attr,class Configure> -inline -entry_func_state< -StateNameTag, -ZoneIndex, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type, -typename boost::result_of<BuildFlags(Configure)>::type, -typename boost::result_of<BuildDeferred(Configure)>::type -> -build_entry_state(Expr1 const& ,Expr2 const& ,Attr const&, Configure const&) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildFlags(Configure)>::type flags_type; - typedef typename boost::result_of<BuildDeferred(Configure)>::type deferred_type; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - return entry_func_state<StateNameTag,ZoneIndex,entry_action,exit_action,attributes_type,flags_type,deferred_type>(); -} - -template <class StateNameTag,int ZoneIndex,class Expr1,class Expr2,class Attr> -inline -entry_func_state< -StateNameTag, -ZoneIndex, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type -> -build_entry_state(Expr1 const& ,Expr2 const& ,Attr const&) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - return entry_func_state<StateNameTag,ZoneIndex,entry_action,exit_action,attributes_type>(); -} - -template <class StateNameTag,int ZoneIndex,class Expr1,class Expr2> -inline -entry_func_state< -StateNameTag, -ZoneIndex, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type -> -build_entry_state(Expr1 const& ,Expr2 const& ) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - return entry_func_state<StateNameTag,ZoneIndex,entry_action,exit_action>(); -} - -template <class StateNameTag,int ZoneIndex,class Expr1> -inline -entry_func_state< -StateNameTag, -ZoneIndex, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -NoAction -> -build_entry_state(Expr1 const& ) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - return entry_func_state<StateNameTag,ZoneIndex,entry_action,NoAction>(); -} - -template <class StateNameTag,int ZoneIndex> -inline -entry_func_state< -StateNameTag, -ZoneIndex, -NoAction, -NoAction -> -build_entry_state() -{ - return entry_func_state<StateNameTag,ZoneIndex,NoAction,NoAction>(); -} - -template <class StateNameTag,class Event,class Expr1,class Expr2,class Attr,class Configure,class BASE> -inline -exit_func_state< -StateNameTag, -Event, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type, -typename boost::result_of<BuildFlags(Configure)>::type, -typename boost::result_of<BuildDeferred(Configure)>::type, -BASE -> -build_exit_state(Event const&,Expr1 const& ,Expr2 const& , Attr const&, Configure const&, BASE ) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildFlags(Configure)>::type flags_type; - typedef typename boost::result_of<BuildDeferred(Configure)>::type deferred_type; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - return exit_func_state<StateNameTag,Event,entry_action,exit_action,attributes_type,flags_type,deferred_type,BASE>(); -} - -template <class StateNameTag,class Event,class Expr1,class Expr2,class Attr,class Configure> -inline -exit_func_state< -StateNameTag, -Event, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type, -typename boost::result_of<BuildFlags(Configure)>::type, -typename boost::result_of<BuildDeferred(Configure)>::type -> -build_exit_state(Event const&,Expr1 const& ,Expr2 const& ,Attr const&, Configure const&) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildFlags(Configure)>::type flags_type; - typedef typename boost::result_of<BuildDeferred(Configure)>::type deferred_type; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - return exit_func_state<StateNameTag,Event,entry_action,exit_action,attributes_type,flags_type,deferred_type>(); -} - -template <class StateNameTag,class Event,class Expr1,class Expr2,class Attr> -inline -exit_func_state< -StateNameTag, -Event, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type -> -build_exit_state(Event const&,Expr1 const& ,Expr2 const& ,Attr const&) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - return exit_func_state<StateNameTag,Event,entry_action,exit_action,attributes_type>(); -} - -template <class StateNameTag,class Event,class Expr1,class Expr2> -inline -exit_func_state< -StateNameTag, -Event, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type -> -build_exit_state(Event const&,Expr1 const& ,Expr2 const& ) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - return exit_func_state<StateNameTag,Event,entry_action,exit_action>(); -} - -template <class StateNameTag,class Event,class Expr1> -inline -exit_func_state< -StateNameTag, -Event, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -NoAction -> -build_exit_state(Event const&, Expr1 const& ) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - return exit_func_state<StateNameTag,Event,entry_action,NoAction>(); -} - -template <class StateNameTag,class Event> -inline -exit_func_state< -StateNameTag, -Event, -NoAction, -NoAction -> -build_exit_state(Event const&) -{ - return exit_func_state<StateNameTag,Event,NoAction,NoAction>(); -} - -template <class StateNameTag,int ZoneIndex,class Expr1,class Expr2,class Attr,class Configure,class BASE> -inline -explicit_entry_func_state< -StateNameTag, -ZoneIndex, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type, -typename boost::result_of<BuildFlags(Configure)>::type, -typename boost::result_of<BuildDeferred(Configure)>::type, -BASE -> -build_explicit_entry_state(Expr1 const& ,Expr2 const& , Attr const&, Configure const&, BASE ) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildFlags(Configure)>::type flags_type; - typedef typename boost::result_of<BuildDeferred(Configure)>::type deferred_type; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - return explicit_entry_func_state<StateNameTag,ZoneIndex,entry_action,exit_action,attributes_type,flags_type,deferred_type,BASE>(); -} - -template <class StateNameTag,int ZoneIndex,class Expr1,class Expr2,class Attr,class Configure> -inline -explicit_entry_func_state< -StateNameTag, -ZoneIndex, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type, -typename boost::result_of<BuildFlags(Configure)>::type, -typename boost::result_of<BuildDeferred(Configure)>::type -> -build_explicit_entry_state(Expr1 const& ,Expr2 const& ,Attr const&, Configure const&) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildFlags(Configure)>::type flags_type; - typedef typename boost::result_of<BuildDeferred(Configure)>::type deferred_type; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - return explicit_entry_func_state<StateNameTag,ZoneIndex,entry_action,exit_action,attributes_type,flags_type,deferred_type>(); -} - -template <class StateNameTag,int ZoneIndex,class Expr1,class Expr2,class Attr> -inline -explicit_entry_func_state< -StateNameTag, -ZoneIndex, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type, -typename boost::result_of<BuildAttributes(Attr)>::type -> -build_explicit_entry_state(Expr1 const& ,Expr2 const& ,Attr const&) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - typedef typename boost::result_of<BuildAttributes(Attr)>::type attributes_type; - return explicit_entry_func_state<StateNameTag,ZoneIndex,entry_action,exit_action,attributes_type>(); -} - -template <class StateNameTag,int ZoneIndex,class Expr1,class Expr2> -inline -explicit_entry_func_state< -StateNameTag, -ZoneIndex, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr2,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr2)>, - make_invalid_type>::type -> -build_explicit_entry_state(Expr1 const& ,Expr2 const& ) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - typedef typename boost::result_of<ActionGrammar(Expr2)>::type exit_action; - return explicit_entry_func_state<StateNameTag,ZoneIndex,entry_action,exit_action>(); -} - -template <class StateNameTag,int ZoneIndex,class Expr1> -inline -explicit_entry_func_state< -StateNameTag, -ZoneIndex, -typename ::boost::mpl::eval_if< - typename proto::matches<Expr1,ActionGrammar>::type, - boost::result_of<ActionGrammar(Expr1)>, - make_invalid_type>::type, -NoAction -> -build_explicit_entry_state(Expr1 const& ) -{ - typedef typename boost::result_of<ActionGrammar(Expr1)>::type entry_action; - return explicit_entry_func_state<StateNameTag,ZoneIndex,entry_action,NoAction>(); -} - -template <class StateNameTag,int ZoneIndex> -inline -explicit_entry_func_state< -StateNameTag, -ZoneIndex, -NoAction, -NoAction -> -build_explicit_entry_state() -{ - return explicit_entry_func_state<StateNameTag,ZoneIndex,NoAction,NoAction>(); -} - - - -}}}} - -#endif //BOOST_MSM_FRONT_EUML_STATE_GRAMMAR_H - diff --git a/contrib/restricted/boost/boost/msm/front/euml/stl.hpp b/contrib/restricted/boost/boost/msm/front/euml/stl.hpp deleted file mode 100644 index 313d7cb31aa..00000000000 --- a/contrib/restricted/boost/boost/msm/front/euml/stl.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_EUML_STL_H -#define BOOST_MSM_FRONT_EUML_STL_H - -#include <boost/msm/front/euml/container.hpp> -#include <boost/msm/front/euml/algorithm.hpp> - -#endif //BOOST_MSM_FRONT_EUML_STL_H diff --git a/contrib/restricted/boost/boost/msm/front/euml/stt_grammar.hpp b/contrib/restricted/boost/boost/msm/front/euml/stt_grammar.hpp deleted file mode 100644 index 592364b8950..00000000000 --- a/contrib/restricted/boost/boost/msm/front/euml/stt_grammar.hpp +++ /dev/null @@ -1,280 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_EUML_STT_GRAMMAR_H -#define BOOST_MSM_FRONT_EUML_STT_GRAMMAR_H - -#include <boost/msm/front/euml/common.hpp> -#include <boost/mpl/vector.hpp> -#include <boost/mpl/eval_if.hpp> - -#include <boost/msm/front/euml/operator.hpp> -#include <boost/msm/front/euml/guard_grammar.hpp> -#include <boost/msm/front/euml/state_grammar.hpp> - -namespace proto = boost::proto; - -namespace boost { namespace msm { namespace front { namespace euml -{ - -template <class SOURCE,class EVENT,class TARGET,class ACTION=none,class GUARD=none> -struct TempRow -{ - typedef SOURCE Source; - typedef EVENT Evt; - typedef TARGET Target; - typedef ACTION Action; - typedef GUARD Guard; -}; - -template <class TEMP_ROW> -struct convert_to_row -{ - typedef Row<typename TEMP_ROW::Source,typename TEMP_ROW::Evt,typename TEMP_ROW::Target, - typename TEMP_ROW::Action,typename TEMP_ROW::Guard> type; -}; -template <class TEMP_ROW> -struct convert_to_internal_row -{ - typedef Internal<typename TEMP_ROW::Evt, - typename TEMP_ROW::Action,typename TEMP_ROW::Guard> type; -}; -// explicit + fork + entry point + exit point grammar -struct BuildEntry - : proto::or_< - proto::when< - proto::function<proto::terminal<proto::_>,proto::terminal<state_tag>,proto::terminal<state_tag> >, - get_fct<proto::_child_c<0>,get_state_name<proto::_child_c<1>() >(),get_state_name<proto::_child_c<2>() >() >() - > - > -{}; - -// row grammar -struct BuildNextStates - : proto::or_< - proto::when< - proto::terminal<state_tag>, - get_state_name<proto::_>() - >, - proto::when< - BuildEntry, - BuildEntry - >, - proto::when< - proto::comma<BuildEntry,BuildEntry >, - ::boost::mpl::push_back< - make_vector_one_row<BuildEntry(proto::_left)>(), - BuildEntry(proto::_right)>() - >, - proto::when < - proto::comma<BuildNextStates,BuildEntry >, - ::boost::mpl::push_back< - BuildNextStates(proto::_left), - BuildEntry(proto::_right) >() - > - > -{}; - -template <class EventGuard,class ActionClass> -struct fusion_event_action_guard -{ - typedef TempRow<none,typename EventGuard::Evt,none,typename ActionClass::Action,typename EventGuard::Guard> type; -}; - -template <class SourceGuard,class ActionClass> -struct fusion_source_action_guard -{ - typedef TempRow<typename SourceGuard::Source,none,none,typename ActionClass::Action,typename SourceGuard::Guard> type; -}; - -template <class SourceClass,class EventClass> -struct fusion_source_event_action_guard -{ - typedef TempRow<typename SourceClass::Source,typename EventClass::Evt, - none,typename EventClass::Action,typename EventClass::Guard> type; -}; -template <class Left,class Right> -struct fusion_left_right -{ - typedef TempRow<typename Right::Source,typename Right::Evt,typename Left::Target - ,typename Right::Action,typename Right::Guard> type; -}; - -struct BuildEventPlusGuard - : proto::or_< - proto::when< - proto::subscript<proto::terminal<event_tag>, GuardGrammar >, - TempRow<none,proto::_left,none,none, GuardGrammar(proto::_right)>(proto::_right) - > - > - {}; - -struct BuildSourceState - : proto::or_< - proto::when< - proto::terminal<state_tag>, - get_state_name<proto::_>() - >, - proto::when< - BuildEntry, - BuildEntry - > - > -{}; - -struct BuildSourcePlusGuard - : proto::when< - proto::subscript<BuildSourceState,GuardGrammar >, - TempRow<BuildSourceState(proto::_left),none,none,none,GuardGrammar(proto::_right)>(proto::_right) - > -{}; - -struct BuildEvent - : proto::or_< - // just event without guard/action - proto::when< - proto::terminal<event_tag>, - TempRow<none,proto::_,none>() > - // event / action - , proto::when< - proto::divides<proto::terminal<event_tag>,ActionGrammar >, - TempRow<none,proto::_left,none,ActionGrammar(proto::_right) >(proto::_right) > - // event [ guard ] - , proto::when< - proto::subscript<proto::terminal<event_tag>,GuardGrammar >, - TempRow<none,proto::_left,none,none,GuardGrammar(proto::_right)>(proto::_right) > - // event [ guard ] / action - , proto::when< - proto::divides<BuildEventPlusGuard, ActionGrammar>, - fusion_event_action_guard<BuildEventPlusGuard(proto::_left), - TempRow<none,none,none,ActionGrammar(proto::_right)>(proto::_right) - >() - > - > -{}; -struct BuildSource - : proto::or_< - // after == if just state without event or guard/action - proto::when< - BuildSourceState, - TempRow<BuildSourceState(proto::_),none,none>() > - // == source / action - , proto::when< - proto::divides<BuildSourceState,ActionGrammar >, - TempRow<BuildSourceState(proto::_left),none,none,ActionGrammar(proto::_right) >(proto::_right) > - // == source [ guard ] - , proto::when< - proto::subscript<BuildSourceState,GuardGrammar >, - TempRow<BuildSourceState(proto::_left),none,none,none,GuardGrammar(proto::_right)>(proto::_right) > - // == source [ guard ] / action - , proto::when< - proto::divides<BuildSourcePlusGuard, - ActionGrammar >, - fusion_source_action_guard<BuildSourcePlusGuard(proto::_left), - TempRow<none,none,none,ActionGrammar(proto::_right)>(proto::_right) - >() - > - > -{}; - -struct BuildRight - : proto::or_< - proto::when< - proto::plus<BuildSource,BuildEvent >, - fusion_source_event_action_guard<BuildSource(proto::_left),BuildEvent(proto::_right)>() - >, - proto::when< - BuildSource, - BuildSource - > - > -{}; - -struct BuildRow - : proto::or_< - // grammar 1 - proto::when< - proto::equal_to<BuildNextStates,BuildRight >, - convert_to_row< - fusion_left_right<TempRow<none,none,BuildNextStates(proto::_left)>,BuildRight(proto::_right)> >() - >, - // internal events - proto::when< - BuildRight, - convert_to_row< - fusion_left_right<TempRow<none,none,none>,BuildRight(proto::_)> >() - >, - // grammar 2 - proto::when< - proto::equal_to<BuildRight,BuildNextStates>, - convert_to_row< - fusion_left_right<TempRow<none,none,BuildNextStates(proto::_right)>,BuildRight(proto::_left)> >() - > - > -{}; - -// stt grammar -struct BuildStt - : proto::or_< - proto::when< - proto::comma<BuildStt,BuildStt>, - boost::mpl::push_back<BuildStt(proto::_left),BuildRow(proto::_right)>() - >, - proto::when < - BuildRow, - make_vector_one_row<BuildRow(proto::_)>() - > - > -{}; - -template <class Expr> -typename ::boost::mpl::eval_if< - typename proto::matches<Expr,BuildStt>::type, - boost::result_of<BuildStt(Expr)>, - make_invalid_type>::type -build_stt(Expr const&) -{ - return typename boost::result_of<BuildStt(Expr)>::type(); -} - -// internal stt grammar -struct BuildInternalRow - : proto::when< - BuildEvent, - convert_to_internal_row< - fusion_left_right<TempRow<none,none,none>,BuildEvent(proto::_)> >() - > -{}; -struct BuildInternalStt - : proto::or_< - proto::when< - proto::comma<BuildInternalStt,BuildInternalStt>, - boost::mpl::push_back<BuildInternalStt(proto::_left),BuildInternalRow(proto::_right)>() - >, - proto::when < - BuildInternalRow, - make_vector_one_row<BuildInternalRow(proto::_)>() - > - > -{}; - -template <class Expr> -typename ::boost::mpl::eval_if< - typename proto::matches<Expr,BuildInternalStt>::type, - boost::result_of<BuildInternalStt(Expr)>, - make_invalid_type>::type -build_internal_stt(Expr const&) -{ - return typename boost::result_of<BuildInternalStt(Expr)>::type(); -} - - -}}}} -#endif //BOOST_MSM_FRONT_EUML_STT_GRAMMAR_H diff --git a/contrib/restricted/boost/boost/msm/front/euml/transformation.hpp b/contrib/restricted/boost/boost/msm/front/euml/transformation.hpp deleted file mode 100644 index 2fb4bc01c8e..00000000000 --- a/contrib/restricted/boost/boost/msm/front/euml/transformation.hpp +++ /dev/null @@ -1,335 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_EUML_TRANSFORMATION_H -#define BOOST_MSM_FRONT_EUML_TRANSFORMATION_H - -#include <algorithm> -#include <boost/msm/front/euml/common.hpp> - -namespace boost { namespace msm { namespace front { namespace euml -{ -#ifdef __STL_CONFIG_H -BOOST_MSM_EUML_FUNCTION(FillN_ , std::fill_n , fill_n_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(Rotate_ , std::rotate , rotate_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(GenerateN_ , std::generate_n , generate_n_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) - -#else -BOOST_MSM_EUML_FUNCTION(FillN_ , std::fill_n , fill_n_ , void , void ) -BOOST_MSM_EUML_FUNCTION(Rotate_ , std::rotate , rotate_ , void , void ) -BOOST_MSM_EUML_FUNCTION(GenerateN_ , std::generate_n , generate_n_ , void , void ) -#endif - -BOOST_MSM_EUML_FUNCTION(Copy_ , std::copy , copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) -BOOST_MSM_EUML_FUNCTION(CopyBackward_ , std::copy_backward , copy_backward_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) -BOOST_MSM_EUML_FUNCTION(Reverse_ , std::reverse , reverse_ , void , void ) -BOOST_MSM_EUML_FUNCTION(ReverseCopy_ , std::reverse_copy , reverse_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) -BOOST_MSM_EUML_FUNCTION(Remove_ , std::remove , remove_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(RemoveIf_ , std::remove_if , remove_if_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(RemoveCopy_ , std::remove_copy , remove_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) -BOOST_MSM_EUML_FUNCTION(RemoveCopyIf_ , std::remove_copy_if , remove_copy_if_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) -BOOST_MSM_EUML_FUNCTION(Fill_ , std::fill , fill_ , void , void ) -BOOST_MSM_EUML_FUNCTION(Generate_ , std::generate , generate_ , void , void ) -BOOST_MSM_EUML_FUNCTION(Unique_ , std::unique , unique_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(UniqueCopy_ , std::unique_copy , unique_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) -BOOST_MSM_EUML_FUNCTION(RandomShuffle_ , std::random_shuffle , random_shuffle_ , void , void ) -BOOST_MSM_EUML_FUNCTION(RotateCopy_ , std::rotate_copy , rotate_copy_ , RESULT_TYPE_PARAM4 , RESULT_TYPE2_PARAM4 ) -BOOST_MSM_EUML_FUNCTION(Partition_ , std::partition , partition_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(StablePartition_ , std::stable_partition , stable_partition_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) -BOOST_MSM_EUML_FUNCTION(Sort_ , std::sort , sort_ , void , void ) -BOOST_MSM_EUML_FUNCTION(StableSort_ , std::stable_sort , stable_sort_ , void , void ) -BOOST_MSM_EUML_FUNCTION(PartialSort_ , std::partial_sort , partial_sort_ , void , void ) -BOOST_MSM_EUML_FUNCTION(PartialSortCopy_ , std::partial_sort_copy , partial_sort_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) -BOOST_MSM_EUML_FUNCTION(NthElement_ , std::nth_element , nth_element_ , void , void ) -BOOST_MSM_EUML_FUNCTION(Merge_ , std::merge , merge_ , RESULT_TYPE_PARAM5 , RESULT_TYPE2_PARAM5 ) -BOOST_MSM_EUML_FUNCTION(InplaceMerge_ , std::inplace_merge , inplace_merge_ , void , void ) -BOOST_MSM_EUML_FUNCTION(SetUnion_ , std::set_union , set_union_ , RESULT_TYPE_PARAM5 , RESULT_TYPE2_PARAM5 ) -BOOST_MSM_EUML_FUNCTION(PushHeap_ , std::push_heap , push_heap_ , void , void ) -BOOST_MSM_EUML_FUNCTION(PopHeap_ , std::pop_heap , pop_heap_ , void , void ) -BOOST_MSM_EUML_FUNCTION(MakeHeap_ , std::make_heap , make_heap_ , void , void ) -BOOST_MSM_EUML_FUNCTION(SortHeap_ , std::sort_heap , sort_heap_ , void , void ) -BOOST_MSM_EUML_FUNCTION(NextPermutation_ , std::next_permutation , next_permutation_ , bool , bool ) -BOOST_MSM_EUML_FUNCTION(PrevPermutation_ , std::prev_permutation , prev_permutation_ , bool , bool ) -BOOST_MSM_EUML_FUNCTION(InnerProduct_ , std::inner_product , inner_product_ , RESULT_TYPE_PARAM4 , RESULT_TYPE2_PARAM4 ) -BOOST_MSM_EUML_FUNCTION(PartialSum_ , std::partial_sum , partial_sum_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) -BOOST_MSM_EUML_FUNCTION(AdjacentDifference_ , std::adjacent_difference , adjacent_difference_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) -BOOST_MSM_EUML_FUNCTION(Replace_ , std::replace , replace_ , void , void ) -BOOST_MSM_EUML_FUNCTION(ReplaceIf_ , std::replace_if , replace_if_ , void , void ) -BOOST_MSM_EUML_FUNCTION(ReplaceCopy_ , std::replace_copy , replace_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) -BOOST_MSM_EUML_FUNCTION(ReplaceCopyIf_ , std::replace_copy_if , replace_copy_if_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) - - - -template <class T> -struct BackInserter_ : euml_action<BackInserter_<T> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef std::back_insert_iterator< - typename ::boost::remove_reference< - typename get_result_type2<T,Event,FSM,STATE>::type>::type> type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef std::back_insert_iterator< - typename ::boost::remove_reference< - typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type> type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return std::back_inserter(T()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return std::back_inserter(T()(evt,fsm,state)); - } -}; - -struct back_inserter_tag {}; -struct BackInserter_Helper: proto::extends< proto::terminal<back_inserter_tag>::type, BackInserter_Helper, boost::msm::sm_domain> -{ - BackInserter_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef BackInserter_<Arg1> type; - }; -}; -BackInserter_Helper const back_inserter_; - -template <class T> -struct FrontInserter_ : euml_action<FrontInserter_<T> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef std::front_insert_iterator< - typename ::boost::remove_reference< - typename get_result_type2<T,Event,FSM,STATE>::type>::type> type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef std::front_insert_iterator< - typename ::boost::remove_reference< - typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type> type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return std::front_inserter(T()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return std::front_inserter(T()(evt,fsm,state)); - } -}; - -struct front_inserter_tag {}; -struct FrontInserter_Helper: proto::extends< proto::terminal<front_inserter_tag>::type, FrontInserter_Helper, boost::msm::sm_domain> -{ - FrontInserter_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef FrontInserter_<Arg1> type; - }; -}; -FrontInserter_Helper const front_inserter_; - -template <class T,class Pos> -struct Inserter_ : euml_action<Inserter_<T,Pos> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef std::insert_iterator< - typename ::boost::remove_reference< - typename get_result_type2<T,Event,FSM,STATE>::type>::type> type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef std::insert_iterator< - typename ::boost::remove_reference< - typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type> type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return std::inserter(T()(evt,fsm,src,tgt),Pos()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename T::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return std::inserter(T()(evt,fsm,state),Pos()(evt,fsm,state)); - } -}; - -struct inserter_tag {}; -struct Inserter_Helper: proto::extends< proto::terminal<inserter_tag>::type, Inserter_Helper, boost::msm::sm_domain> -{ - Inserter_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Inserter_<Arg1,Arg2> type; - }; -}; -Inserter_Helper const inserter_; - -template <class Param1, class Param2, class Param3, class Param4, class Param5, class Enable=void > -struct Transform_ : euml_action<Transform_<Param1,Param2,Param3,Param4,Param5,Enable> > -{ -}; - -template <class Param1, class Param2, class Param3, class Param4, class Param5> -struct Transform_<Param1,Param2,Param3,Param4,Param5, - typename ::boost::enable_if<typename ::boost::is_same<Param5,void>::type >::type> - : euml_action<Transform_<Param1,Param2,Param3,Param4,Param5> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Param3,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Param3,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Param1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return std::transform(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt), - Param4()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Param1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return std::transform(Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state), - Param4()(evt,fsm,state)); - } -}; - -template <class Param1, class Param2, class Param3, class Param4, class Param5> -struct Transform_<Param1,Param2,Param3,Param4,Param5, - typename ::boost::disable_if<typename ::boost::is_same<Param5,void>::type >::type> - : euml_action<Transform_<Param1,Param2,Param3,Param4,Param5> > -{ - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef typename get_result_type2<Param4,Event,FSM,STATE>::type type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef typename get_result_type<Param4,EVT,FSM,SourceState,TargetState>::type type; - }; - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class SourceState,class TargetState> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Param1::tag_type,action_tag>::type, - typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type - operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const - { - return std::transform (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt), - Param4()(evt,fsm,src,tgt),Param5()(evt,fsm,src,tgt)); - } - template <class Event,class FSM,class STATE> - typename ::boost::enable_if< - typename ::boost::mpl::has_key< - typename Param1::tag_type,state_action_tag>::type, - typename state_action_result<Event,FSM,STATE>::type >::type - operator()(Event const& evt,FSM& fsm,STATE& state )const - { - return std::transform (Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state), - Param4()(evt,fsm,state),Param5()(evt,fsm,state)); - } -}; -struct transform_tag {}; -struct Transform_Helper: proto::extends< proto::terminal<transform_tag>::type, Transform_Helper, boost::msm::sm_domain> -{ - Transform_Helper(){} - template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5 -#ifdef BOOST_MSVC - ,class Arg6 -#endif -> - struct In - { - typedef Transform_<Arg1,Arg2,Arg3,Arg4,Arg5> type; - }; -}; -Transform_Helper const transform_; - -}}}} - -#endif //BOOST_MSM_FRONT_EUML_TRANSFORMATION_H diff --git a/contrib/restricted/boost/boost/msm/front/functor_row.hpp b/contrib/restricted/boost/boost/msm/front/functor_row.hpp deleted file mode 100644 index e542451f4f0..00000000000 --- a/contrib/restricted/boost/boost/msm/front/functor_row.hpp +++ /dev/null @@ -1,356 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_FUNCTOR_ROW_H -#define BOOST_MSM_FRONT_FUNCTOR_ROW_H - -#include <boost/mpl/set.hpp> -#include <boost/mpl/for_each.hpp> -#include <boost/mpl/has_xxx.hpp> -#include <boost/mpl/count_if.hpp> - -#include <boost/typeof/typeof.hpp> - -#include <boost/msm/back/common_types.hpp> -#include <boost/msm/row_tags.hpp> -#include <boost/msm/common.hpp> -#include <boost/msm/front/completion_event.hpp> - -#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() - -BOOST_MPL_HAS_XXX_TRAIT_DEF(deferring_action) -BOOST_MPL_HAS_XXX_TRAIT_DEF(some_deferring_actions) - -namespace boost { namespace msm { namespace front -{ - template <class Func,class Enable=void> - struct get_functor_return_value - { - static const ::boost::msm::back::HandledEnum value = ::boost::msm::back::HANDLED_TRUE; - }; - template <class Func> - struct get_functor_return_value<Func, - typename ::boost::enable_if< - typename has_deferring_action<Func>::type - >::type - > - { - static const ::boost::msm::back::HandledEnum value = ::boost::msm::back::HANDLED_DEFERRED; - }; - // for sequences - template <class Func> - struct get_functor_return_value<Func, - typename ::boost::enable_if< - typename has_some_deferring_actions<Func>::type - >::type - > - { - static const ::boost::msm::back::HandledEnum value = - (Func::some_deferring_actions::value ? ::boost::msm::back::HANDLED_DEFERRED : ::boost::msm::back::HANDLED_TRUE ); - }; - template <class SOURCE,class EVENT,class TARGET,class ACTION=none,class GUARD=none> - struct Row - { - typedef SOURCE Source; - typedef EVENT Evt; - typedef TARGET Target; - typedef ACTION Action; - typedef GUARD Guard; - // action plus guard - typedef row_tag row_type_tag; - template <class EVT,class FSM,class SourceState,class TargetState,class AllStates> - static ::boost::msm::back::HandledEnum action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) - { - // create functor, call it - Action()(evt,fsm,src,tgt); - return get_functor_return_value<Action>::value; - } - template <class EVT,class FSM,class SourceState,class TargetState,class AllStates> - static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt,AllStates&) - { - // create functor, call it - return Guard()(evt,fsm,src,tgt); - } - }; - - template<class SOURCE,class EVENT,class TARGET> - struct Row<SOURCE,EVENT,TARGET,none,none> - { - typedef SOURCE Source; - typedef EVENT Evt; - typedef TARGET Target; - typedef none Action; - typedef none Guard; - // no action, no guard - typedef _row_tag row_type_tag; - }; - template<class SOURCE,class EVENT,class TARGET,class ACTION> - struct Row<SOURCE,EVENT,TARGET,ACTION,none> - { - typedef SOURCE Source; - typedef EVENT Evt; - typedef TARGET Target; - typedef ACTION Action; - typedef none Guard; - // no guard - typedef a_row_tag row_type_tag; - template <class EVT,class FSM,class SourceState,class TargetState,class AllStates> - static ::boost::msm::back::HandledEnum action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) - { - // create functor, call it - Action()(evt,fsm,src,tgt); - return get_functor_return_value<Action>::value; - } - }; - template<class SOURCE,class EVENT,class TARGET,class GUARD> - struct Row<SOURCE,EVENT,TARGET,none,GUARD> - { - typedef SOURCE Source; - typedef EVENT Evt; - typedef TARGET Target; - typedef none Action; - typedef GUARD Guard; - // no action - typedef g_row_tag row_type_tag; - template <class EVT,class FSM,class SourceState,class TargetState,class AllStates> - static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) - { - // create functor, call it - return Guard()(evt,fsm,src,tgt); - } - }; - // internal transitions - template<class SOURCE,class EVENT,class ACTION> - struct Row<SOURCE,EVENT,none,ACTION,none> - { - typedef SOURCE Source; - typedef EVENT Evt; - typedef Source Target; - typedef ACTION Action; - typedef none Guard; - // no guard - typedef a_irow_tag row_type_tag; - template <class EVT,class FSM,class SourceState,class TargetState,class AllStates> - static ::boost::msm::back::HandledEnum action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) - { - // create functor, call it - Action()(evt,fsm,src,tgt); - return get_functor_return_value<Action>::value; - } - }; - template<class SOURCE,class EVENT,class GUARD> - struct Row<SOURCE,EVENT,none,none,GUARD> - { - typedef SOURCE Source; - typedef EVENT Evt; - typedef Source Target; - typedef none Action; - typedef GUARD Guard; - // no action - typedef g_irow_tag row_type_tag; - template <class EVT,class FSM,class SourceState,class TargetState,class AllStates> - static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) - { - // create functor, call it - return Guard()(evt,fsm,src,tgt); - } - }; - template<class SOURCE,class EVENT,class ACTION,class GUARD> - struct Row<SOURCE,EVENT,none,ACTION,GUARD> - { - typedef SOURCE Source; - typedef EVENT Evt; - typedef Source Target; - typedef ACTION Action; - typedef GUARD Guard; - // action + guard - typedef irow_tag row_type_tag; - template <class EVT,class FSM,class SourceState,class TargetState,class AllStates> - static ::boost::msm::back::HandledEnum action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) - { - // create functor, call it - Action()(evt,fsm,src,tgt); - return get_functor_return_value<Action>::value; - } - template <class EVT,class FSM,class SourceState,class TargetState,class AllStates> - static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) - { - // create functor, call it - return Guard()(evt,fsm,src,tgt); - } - }; - template<class SOURCE,class EVENT> - struct Row<SOURCE,EVENT,none,none,none> - { - typedef SOURCE Source; - typedef EVENT Evt; - typedef Source Target; - typedef none Action; - typedef none Guard; - // no action, no guard - typedef _irow_tag row_type_tag; - }; - template<class TGT> - struct get_row_target - { - typedef typename TGT::Target type; - }; - - template <class EVENT,class ACTION=none,class GUARD=none> - struct Internal - { - typedef EVENT Evt; - typedef ACTION Action; - typedef GUARD Guard; - // action plus guard - typedef sm_i_row_tag row_type_tag; - template <class EVT,class FSM,class SourceState,class TargetState,class AllStates> - static ::boost::msm::back::HandledEnum action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) - { - // create functor, call it - Action()(evt,fsm,src,tgt); - return get_functor_return_value<Action>::value; - } - template <class EVT,class FSM,class SourceState,class TargetState,class AllStates> - static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) - { - // create functor, call it - return Guard()(evt,fsm,src,tgt); - } - }; - - template<class EVENT,class ACTION> - struct Internal<EVENT,ACTION,none> - { - typedef EVENT Evt; - typedef ACTION Action; - typedef none Guard; - // no guard - typedef sm_a_i_row_tag row_type_tag; - template <class EVT,class FSM,class SourceState,class TargetState,class AllStates> - static ::boost::msm::back::HandledEnum action_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) - { - // create functor, call it - Action()(evt,fsm,src,tgt); - return get_functor_return_value<Action>::value; - } - }; - template<class EVENT,class GUARD> - struct Internal<EVENT,none,GUARD> - { - typedef EVENT Evt; - typedef none Action; - typedef GUARD Guard; - // no action - typedef sm_g_i_row_tag row_type_tag; - template <class EVT,class FSM,class SourceState,class TargetState,class AllStates> - static bool guard_call(FSM& fsm,EVT const& evt,SourceState& src,TargetState& tgt, AllStates&) - { - // create functor, call it - return Guard()(evt,fsm,src,tgt); - } - }; - template<class EVENT> - struct Internal<EVENT,none,none> - { - typedef EVENT Evt; - typedef none Action; - typedef none Guard; - // no action, no guard - typedef sm__i_row_tag row_type_tag; - }; - struct event_tag{}; - struct action_tag{}; - struct state_action_tag{}; - struct flag_tag{}; - struct config_tag{}; - struct not_euml_tag{}; - - template <class Sequence> - struct ActionSequence_ - { - typedef Sequence sequence; - // if one functor of the sequence defers events, the complete sequence does - typedef ::boost::mpl::bool_< - ::boost::mpl::count_if<sequence, - has_deferring_action< ::boost::mpl::placeholders::_1 > - >::value != 0> some_deferring_actions; - - template <class Event,class FSM,class STATE > - struct state_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class STATE> - struct Call - { - Call(EVT const& evt,FSM& fsm,STATE& state): - evt_(evt),fsm_(fsm),state_(state){} - template <class FCT> - void operator()(::boost::msm::wrap<FCT> const& ) - { - FCT()(evt_,fsm_,state_); - } - private: - EVT const& evt_; - FSM& fsm_; - STATE& state_; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct transition_action_result - { - typedef void type; - }; - template <class EVT,class FSM,class SourceState,class TargetState> - struct Call2 - { - Call2(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt): - evt_(evt),fsm_(fsm),src_(src),tgt_(tgt){} - template <class FCT> - void operator()(::boost::msm::wrap<FCT> const& ) - { - FCT()(evt_,fsm_,src_,tgt_); - } - private: - EVT const & evt_; - FSM& fsm_; - SourceState& src_; - TargetState& tgt_; - }; - - typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type; - - template <class EVT,class FSM,class STATE> - void operator()(EVT const& evt,FSM& fsm,STATE& state) - { - mpl::for_each<Sequence,boost::msm::wrap< ::boost::mpl::placeholders::_1> > - (Call<EVT,FSM,STATE>(evt,fsm,state)); - } - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt) - { - mpl::for_each<Sequence,boost::msm::wrap< ::boost::mpl::placeholders::_1> > - (Call2<EVT,FSM,SourceState,TargetState>(evt,fsm,src,tgt)); - } - }; - - // functor pre-defined for basic functionality - struct Defer - { - // mark as deferring to avoid stack overflows in certain conditions - typedef int deferring_action; - template <class EVT,class FSM,class SourceState,class TargetState> - void operator()(EVT const& evt,FSM& fsm,SourceState& ,TargetState& ) const - { - fsm.defer_event(evt); - } - }; -}}} -#endif //BOOST_MSM_FRONT_FUNCTOR_ROW_H diff --git a/contrib/restricted/boost/boost/msm/front/internal_row.hpp b/contrib/restricted/boost/boost/msm/front/internal_row.hpp deleted file mode 100644 index 947bbfdf803..00000000000 --- a/contrib/restricted/boost/boost/msm/front/internal_row.hpp +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_INTERNAL_ROW_HPP -#define BOOST_MSM_INTERNAL_ROW_HPP - -#include <boost/type_traits/is_base_of.hpp> -#include <boost/mpl/bool.hpp> -#include <boost/fusion/include/at_key.hpp> -#include <boost/msm/back/common_types.hpp> -#include <boost/msm/row_tags.hpp> -#include <boost/msm/front/detail/row2_helper.hpp> - -namespace boost { namespace msm { namespace front -{ - template< - class Event - , typename CalledForAction - , void (CalledForAction::*action)(Event const&) - > - struct a_internal - { - typedef sm_a_i_row_tag row_type_tag; - typedef Event Evt; - template <class FSM,class SourceState,class TargetState,class AllStates> - static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, - AllStates& all_states) - { - // in this front-end, we don't need to know source and target states - ::boost::msm::front::detail::row2_action_helper<CalledForAction,Event,action>::call_helper - (fsm,evt,src,tgt,all_states, - ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>()); - return ::boost::msm::back::HANDLED_TRUE; - } - }; - - template< - class Event - , typename CalledForAction - , void (CalledForAction::*action)(Event const&) - , typename CalledForGuard - , bool (CalledForGuard::*guard)(Event const&) - > - struct internal - { - typedef sm_i_row_tag row_type_tag; - typedef Event Evt; - template <class FSM,class SourceState,class TargetState,class AllStates> - static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, - AllStates& all_states) - { - // in this front-end, we don't need to know source and target states - ::boost::msm::front::detail::row2_action_helper<CalledForAction,Event,action>::call_helper - (fsm,evt,src,tgt,all_states, - ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>()); - return ::boost::msm::back::HANDLED_TRUE; - } - template <class FSM,class SourceState,class TargetState,class AllStates> - static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, - AllStates& all_states) - { - // in this front-end, we don't need to know source and target states - return ::boost::msm::front::detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper - (fsm,evt,src,tgt,all_states, - ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>()); - } - }; - template< - class Event - , typename CalledForGuard - , bool (CalledForGuard::*guard)(Event const&) - > - struct g_internal - { - typedef sm_g_i_row_tag row_type_tag; - typedef Event Evt; - template <class FSM,class SourceState,class TargetState,class AllStates> - static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, - AllStates& all_states) - { - // in this front-end, we don't need to know source and target states - return ::boost::msm::front::detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper - (fsm,evt,src,tgt,all_states, - ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>()); - } - }; - template< - class Event - > - struct _internal - { - typedef sm__i_row_tag row_type_tag; - typedef Event Evt; - }; -}}} - -#endif //BOOST_MSM_INTERNAL_ROW_HPP - diff --git a/contrib/restricted/boost/boost/msm/front/row2.hpp b/contrib/restricted/boost/boost/msm/front/row2.hpp deleted file mode 100644 index 46465858e94..00000000000 --- a/contrib/restricted/boost/boost/msm/front/row2.hpp +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_ROW2_HPP -#define BOOST_MSM_ROW2_HPP - -#include <boost/type_traits/is_base_of.hpp> -#include <boost/mpl/bool.hpp> -#include <boost/fusion/include/at_key.hpp> -#include <boost/msm/back/common_types.hpp> -#include <boost/msm/row_tags.hpp> -#include <boost/msm/front/detail/row2_helper.hpp> - -namespace boost { namespace msm { namespace front -{ - template< - typename T1 - , class Event - , typename T2 - > - struct _row2 - { - typedef _row_tag row_type_tag; - typedef T1 Source; - typedef T2 Target; - typedef Event Evt; - }; - - template< - typename T1 - , class Event - , typename T2 - , typename CalledForAction - , void (CalledForAction::*action)(Event const&) - > - struct a_row2 - { - typedef a_row_tag row_type_tag; - typedef T1 Source; - typedef T2 Target; - typedef Event Evt; - template <class FSM,class SourceState,class TargetState,class AllStates> - static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, - AllStates& all_states) - { - // in this front-end, we don't need to know source and target states - ::boost::msm::front::detail::row2_action_helper<CalledForAction,Event,action>::template call_helper - (fsm,evt,src,tgt,all_states, - ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>()); - return ::boost::msm::back::HANDLED_TRUE; - } - }; - - template< - typename T1 - , class Event - , typename T2 - , typename CalledForAction - , void (CalledForAction::*action)(Event const&) - , typename CalledForGuard - , bool (CalledForGuard::*guard)(Event const&) - > - struct row2 - { - typedef row_tag row_type_tag; - typedef T1 Source; - typedef T2 Target; - typedef Event Evt; - template <class FSM,class SourceState,class TargetState, class AllStates> - static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, - AllStates& all_states) - { - // in this front-end, we don't need to know source and target states - ::boost::msm::front::detail::row2_action_helper<CalledForAction,Event,action>::call_helper - (fsm,evt,src,tgt,all_states, - ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>()); - return ::boost::msm::back::HANDLED_TRUE; - } - template <class FSM,class SourceState,class TargetState,class AllStates> - static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, - AllStates& all_states) - { - // in this front-end, we don't need to know source and target states - return ::boost::msm::front::detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper - (fsm,evt,src,tgt,all_states, - ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>()); - } - }; - template< - typename T1 - , class Event - , typename T2 - , typename CalledForGuard - , bool (CalledForGuard::*guard)(Event const&) - > - struct g_row2 - { - typedef g_row_tag row_type_tag; - typedef T1 Source; - typedef T2 Target; - typedef Event Evt; - template <class FSM,class SourceState,class TargetState,class AllStates> - static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, - AllStates& all_states) - { - // in this front-end, we don't need to know source and target states - return ::boost::msm::front::detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper - (fsm,evt,src,tgt,all_states, - ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>()); - } - }; - // internal transitions - template< - typename T1 - , class Event - , typename CalledForAction - , void (CalledForAction::*action)(Event const&) - > - struct a_irow2 - { - typedef a_irow_tag row_type_tag; - typedef T1 Source; - typedef T1 Target; - typedef Event Evt; - template <class FSM,class SourceState,class TargetState,class AllStates> - static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, - AllStates& all_states) - { - // in this front-end, we don't need to know source and target states - ::boost::msm::front::detail::row2_action_helper<CalledForAction,Event,action>::call_helper - (fsm,evt,src,tgt,all_states, - ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>()); - return ::boost::msm::back::HANDLED_TRUE; - } - }; - - template< - typename T1 - , class Event - , typename CalledForAction - , void (CalledForAction::*action)(Event const&) - , typename CalledForGuard - , bool (CalledForGuard::*guard)(Event const&) - > - struct irow2 - { - typedef irow_tag row_type_tag; - typedef T1 Source; - typedef T1 Target; - typedef Event Evt; - template <class FSM,class SourceState,class TargetState,class AllStates> - static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, - AllStates& all_states) - { - // in this front-end, we don't need to know source and target states - ::boost::msm::front::detail::row2_action_helper<CalledForAction,Event,action>::call_helper - (fsm,evt,src,tgt,all_states, - ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>()); - return ::boost::msm::back::HANDLED_TRUE; - } - template <class FSM,class SourceState,class TargetState,class AllStates> - static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, - AllStates& all_states) - { - // in this front-end, we don't need to know source and target states - return ::boost::msm::front::detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper - (fsm,evt,src,tgt,all_states, - ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>()); - } - }; - template< - typename T1 - , class Event - , typename CalledForGuard - , bool (CalledForGuard::*guard)(Event const&) - > - struct g_irow2 - { - typedef g_irow_tag row_type_tag; - typedef T1 Source; - typedef T1 Target; - typedef Event Evt; - template <class FSM,class SourceState,class TargetState,class AllStates> - static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, - AllStates& all_states) - { - // in this front-end, we don't need to know source and target states - return ::boost::msm::front::detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper - (fsm,evt,src,tgt,all_states, - ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>()); - } - }; - -}}} - -#endif //BOOST_MSM_ROW2_HPP - diff --git a/contrib/restricted/boost/boost/msm/front/state_machine_def.hpp b/contrib/restricted/boost/boost/msm/front/state_machine_def.hpp deleted file mode 100644 index f890a983a30..00000000000 --- a/contrib/restricted/boost/boost/msm/front/state_machine_def.hpp +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_STATEMACHINE_DEF_H -#define BOOST_MSM_FRONT_STATEMACHINE_DEF_H - -#include <exception> -#include <boost/assert.hpp> - -#include <boost/mpl/vector.hpp> - -#include <boost/msm/row_tags.hpp> -#include <boost/msm/back/common_types.hpp> -#include <boost/msm/front/states.hpp> -#include <boost/msm/front/completion_event.hpp> -#include <boost/msm/front/common_states.hpp> - -namespace boost { namespace msm { namespace front -{ - -template<class Derived,class BaseState = default_base_state> -struct state_machine_def : public boost::msm::front::detail::state_base<BaseState> -{ - // tags - // default: no flag - typedef ::boost::mpl::vector0<> flag_list; - typedef ::boost::mpl::vector0<> internal_flag_list; - //default: no deferred events - typedef ::boost::mpl::vector0<> deferred_events; - // customization (message queue, exceptions) - typedef ::boost::mpl::vector0<> configuration; - - typedef BaseState BaseAllStates; - template< - typename T1 - , class Event - , typename T2 - , void (Derived::*action)(Event const&) - > - struct a_row - { - typedef a_row_tag row_type_tag; - typedef T1 Source; - typedef T2 Target; - typedef Event Evt; - template <class FSM,class SourceState,class TargetState,class AllStates> - static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState&,TargetState&, AllStates&) - { - // in this front-end, we don't need to know source and target states - (fsm.*action)(evt); - return ::boost::msm::back::HANDLED_TRUE; - } - }; - - template< - typename T1 - , class Event - , typename T2 - > - struct _row - { - typedef _row_tag row_type_tag; - typedef T1 Source; - typedef T2 Target; - typedef Event Evt; - }; - - template< - typename T1 - , class Event - , typename T2 - , void (Derived::*action)(Event const&) - , bool (Derived::*guard)(Event const&) - > - struct row - { - typedef row_tag row_type_tag; - typedef T1 Source; - typedef T2 Target; - typedef Event Evt; - template <class FSM,class SourceState,class TargetState, class AllStates> - static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState&,TargetState&,AllStates&) - { - // in this front-end, we don't need to know source and target states - (fsm.*action)(evt); - return ::boost::msm::back::HANDLED_TRUE; - } - template <class FSM,class SourceState,class TargetState,class AllStates> - static bool guard_call(FSM& fsm,Event const& evt,SourceState&,TargetState&,AllStates&) - { - // in this front-end, we don't need to know source and target states - return (fsm.*guard)(evt); - } - }; - template< - typename T1 - , class Event - , typename T2 - , bool (Derived::*guard)(Event const&) - > - struct g_row - { - typedef g_row_tag row_type_tag; - typedef T1 Source; - typedef T2 Target; - typedef Event Evt; - template <class FSM,class SourceState,class TargetState,class AllStates> - static bool guard_call(FSM& fsm,Event const& evt,SourceState&,TargetState&,AllStates&) - { - // in this front-end, we don't need to know source and target states - return (fsm.*guard)(evt); - } - }; - // internal transitions - template< - typename T1 - , class Event - , void (Derived::*action)(Event const&) - > - struct a_irow - { - typedef a_irow_tag row_type_tag; - typedef T1 Source; - typedef T1 Target; - typedef Event Evt; - template <class FSM,class SourceState,class TargetState,class AllStates> - static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState&,TargetState&,AllStates&) - { - // in this front-end, we don't need to know source and target states - (fsm.*action)(evt); - return ::boost::msm::back::HANDLED_TRUE; - } - }; - - template< - typename T1 - , class Event - , void (Derived::*action)(Event const&) - , bool (Derived::*guard)(Event const&) - > - struct irow - { - typedef irow_tag row_type_tag; - typedef T1 Source; - typedef T1 Target; - typedef Event Evt; - template <class FSM,class SourceState,class TargetState,class AllStates> - static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState&,TargetState&,AllStates&) - { - // in this front-end, we don't need to know source and target states - (fsm.*action)(evt); - return ::boost::msm::back::HANDLED_TRUE; - } - template <class FSM,class SourceState,class TargetState,class AllStates> - static bool guard_call(FSM& fsm,Event const& evt,SourceState&,TargetState&,AllStates&) - { - // in this front-end, we don't need to know source and target states - return (fsm.*guard)(evt); - } - }; - template< - typename T1 - , class Event - , bool (Derived::*guard)(Event const&) - > - struct g_irow - { - typedef g_irow_tag row_type_tag; - typedef T1 Source; - typedef T1 Target; - typedef Event Evt; - template <class FSM,class SourceState,class TargetState,class AllStates> - static bool guard_call(FSM& fsm,Event const& evt,SourceState&,TargetState&,AllStates&) - { - // in this front-end, we don't need to know source and target states - return (fsm.*guard)(evt); - } - }; - // internal row withou action or guard. Does nothing except forcing the event to be ignored. - template< - typename T1 - , class Event - > - struct _irow - { - typedef _irow_tag row_type_tag; - typedef T1 Source; - typedef T1 Target; - typedef Event Evt; - }; -protected: - // Default no-transition handler. Can be replaced in the Derived SM class. - template <class FSM,class Event> - void no_transition(Event const& ,FSM&, int ) - { - BOOST_ASSERT(false); - } - // default exception handler. Can be replaced in the Derived SM class. - template <class FSM,class Event> - void exception_caught (Event const&,FSM&,std::exception& ) - { - BOOST_ASSERT(false); - } -}; - - -} } }// boost::msm::front -#endif //BOOST_MSM_FRONT_STATEMACHINE_DEF_H - diff --git a/contrib/restricted/boost/boost/msm/front/states.hpp b/contrib/restricted/boost/boost/msm/front/states.hpp deleted file mode 100644 index 73f8169da27..00000000000 --- a/contrib/restricted/boost/boost/msm/front/states.hpp +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_FRONT_STATES_H -#define BOOST_MSM_FRONT_STATES_H - -#include <boost/mpl/bool.hpp> -#include <boost/mpl/vector.hpp> -#include <boost/msm/front/common_states.hpp> -#include <boost/msm/row_tags.hpp> -#include <boost/msm/back/metafunctions.hpp> - -namespace boost { namespace msm { namespace front -{ - -struct no_sm_ptr -{ - // tags - typedef ::boost::mpl::bool_<false> needs_sm; -}; -struct sm_ptr -{ - // tags - typedef ::boost::mpl::bool_<true> needs_sm; -}; -// kept for backward compatibility -struct NoSMPtr -{ - // tags - typedef ::boost::mpl::bool_<false> needs_sm; -}; -struct SMPtr -{ - // tags - typedef ::boost::mpl::bool_<true> needs_sm; -}; - -// provides the typedefs and interface. Concrete states derive from it. -// template argument: pointer-to-fsm policy -template<class BASE = default_base_state,class SMPtrPolicy = no_sm_ptr> -struct state : public boost::msm::front::detail::state_base<BASE>, SMPtrPolicy -{ - // tags - // default: no flag - typedef ::boost::mpl::vector0<> flag_list; - typedef ::boost::mpl::vector0<> internal_flag_list; - //default: no deferred events - typedef ::boost::mpl::vector0<> deferred_events; -}; - -// terminate state simply defines the TerminateFlag flag -// template argument: pointer-to-fsm policy -template<class BASE = default_base_state,class SMPtrPolicy = no_sm_ptr> -struct terminate_state : public boost::msm::front::detail::state_base<BASE>, SMPtrPolicy -{ - // tags - typedef ::boost::mpl::vector0<> flag_list; - typedef ::boost::mpl::vector< boost::msm::TerminateFlag> internal_flag_list; - //default: no deferred events - typedef ::boost::mpl::vector0<> deferred_events; -}; - -// terminate state simply defines the InterruptedFlag and EndInterruptFlag<EndInterruptEvent> flags -// template argument: event which ends the interrupt -// template argument: pointer-to-fsm policy -template <class EndInterruptEvent,class BASE = default_base_state,class SMPtrPolicy = no_sm_ptr> -struct interrupt_state : public boost::msm::front::detail::state_base<BASE>, SMPtrPolicy -{ - // tags - typedef ::boost::mpl::vector0<> flag_list; - typedef typename boost::msm::back::build_interrupt_state_flag_list< - typename boost::msm::back::get_interrupt_events<EndInterruptEvent>::type - >::type internal_flag_list; - - //default: no deferred events - typedef ::boost::mpl::vector0<> deferred_events; -}; - -// not a state but a bunch of extra typedefs to handle direct entry into a composite state. To be derived from -// template argument: zone index of this state -template <int ZoneIndex=-1> -struct explicit_entry -{ - typedef int explicit_entry_state; - enum {zone_index=ZoneIndex}; -}; - -// to be derived from. Makes a type an entry (pseudo) state. Actually an almost full-fledged state -// template argument: containing composite -// template argument: zone index of this state -// template argument: pointer-to-fsm policy -template<int ZoneIndex=-1,class BASE = default_base_state,class SMPtrPolicy = no_sm_ptr> -struct entry_pseudo_state - : public boost::msm::front::detail::state_base<BASE>,SMPtrPolicy -{ - // tags - typedef int pseudo_entry; - enum {zone_index=ZoneIndex}; - typedef int explicit_entry_state; - // default: no flag - typedef ::boost::mpl::vector0<> flag_list; - typedef ::boost::mpl::vector0<> internal_flag_list; - //default: no deferred events - typedef ::boost::mpl::vector0<> deferred_events; -}; - -// to be derived from. Makes a state an exit (pseudo) state. Actually an almost full-fledged state -// template argument: event to forward -// template argument: pointer-to-fsm policy -template<class Event,class BASE = default_base_state,class SMPtrPolicy = no_sm_ptr> -struct exit_pseudo_state : public boost::msm::front::detail::state_base<BASE> , SMPtrPolicy -{ - typedef Event event; - typedef BASE Base; - typedef SMPtrPolicy PtrPolicy; - typedef int pseudo_exit; - - // default: no flag - typedef ::boost::mpl::vector0<> flag_list; - typedef ::boost::mpl::vector0<> internal_flag_list; - //default: no deferred events - typedef ::boost::mpl::vector0<> deferred_events; -}; - -}}} - -#endif //BOOST_MSM_FRONT_STATES_H - diff --git a/contrib/restricted/boost/boost/msm/mpl_graph/adjacency_list_graph.hpp b/contrib/restricted/boost/boost/msm/mpl_graph/adjacency_list_graph.hpp deleted file mode 100644 index 668e023262a..00000000000 --- a/contrib/restricted/boost/boost/msm/mpl_graph/adjacency_list_graph.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2008-2010 Gordon Woodhull -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_MPL_GRAPH_ADJACENCY_LIST_GRAPH_HPP_INCLUDED -#define BOOST_MSM_MPL_GRAPH_ADJACENCY_LIST_GRAPH_HPP_INCLUDED - -// graph implementation based on an adjacency list -// sequence< pair< source_vertex, sequence< pair<edge, target_vertex> > > > - -// adjacency_list_graph labels such a sequence as manipulable by the metafunctions -// in the corresponding implementation header detail/adjacency_list_graph.ipp -// to produce the metadata structures needed by mpl_graph.hpp - -// the public interface -#include <boost/msm/mpl_graph/mpl_graph.hpp> - -// the implementation -#include <boost/msm/mpl_graph/detail/adjacency_list_graph.ipp> - -namespace boost { -namespace msm { -namespace mpl_graph { - -template<typename AdjacencyList> -struct adjacency_list_graph { - typedef detail::adjacency_list_tag representation; - typedef AdjacencyList data; -}; - -} -} -} - -#endif // BOOST_MSM_MPL_GRAPH_ADJACENCY_LIST_GRAPH_HPP_INCLUDED diff --git a/contrib/restricted/boost/boost/msm/mpl_graph/breadth_first_search.hpp b/contrib/restricted/boost/boost/msm/mpl_graph/breadth_first_search.hpp deleted file mode 100644 index f80a037de92..00000000000 --- a/contrib/restricted/boost/boost/msm/mpl_graph/breadth_first_search.hpp +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright 2008-2010 Gordon Woodhull -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_MPL_GRAPH_BREADTH_FIRST_SEARCH_HPP_INCLUDED -#define BOOST_MSM_MPL_GRAPH_BREADTH_FIRST_SEARCH_HPP_INCLUDED - -#include <boost/msm/mpl_graph/mpl_graph.hpp> - -#include <boost/mpl/has_key.hpp> -#include <boost/mpl/insert.hpp> -#include <boost/mpl/pair.hpp> -#include <boost/mpl/map.hpp> -#include <boost/mpl/has_key.hpp> -#include <boost/mpl/pop_front.hpp> -#include <boost/mpl/empty.hpp> -#include <boost/mpl/remove.hpp> - -#include "search_colors.hpp" - -namespace boost { -namespace msm { -namespace mpl_graph { - -// bfs takes a visitor which has all the bgl-like metafunctions encapsulated in an -// "operations" member class, and also a state. the operations are expected to return a new state -struct bfs_default_visitor_operations { - template<typename Vertex, typename Graph, typename State> - struct initialize_vertex { - typedef State type; - }; - - template<typename Vertex, typename Graph, typename State> - struct discover_vertex { - typedef State type; - }; - - template<typename Vertex, typename Graph, typename State> - struct examine_vertex { - typedef State type; - }; - - template<typename Vertex, typename Graph, typename State> - struct examine_edge { - typedef State type; - }; - - template<typename Edge, typename Graph, typename State> - struct tree_edge { - typedef State type; - }; - - template<typename Edge, typename Graph, typename State> - struct non_tree_edge { - typedef State type; - }; - - template<typename Edge, typename Graph, typename State> - struct gray_target { - typedef State type; - }; - - template<typename Edge, typename Graph, typename State> - struct black_target { - typedef State type; - }; - - template<typename Vertex, typename Graph, typename State> - struct finish_vertex { - typedef State type; - }; -}; - -namespace detail { - -template<typename Graph, typename VisitorOps, typename VCQState, typename Edge> -struct bfs_run_queue_examine_edge { - typedef typename VisitorOps::template examine_edge<Edge, Graph, typename mpl::at_c<VCQState, 0>::type>::type visitor_state; - typedef typename mpl::at_c<VCQState, 1>::type color_state; - typedef typename mpl::at_c<VCQState, 2>::type vertex_queue; - - typedef typename mpl::if_<typename boost::is_same<typename search_color_map_ops::template get_color<typename mpl_graph::target<Edge, Graph>::type, color_state>::type, search_colors::White>::type, - // unseen target: tree edge, discover target, paint it gray, and enqueue - mpl::vector<typename VisitorOps::template discover_vertex<typename mpl_graph::target<Edge, Graph>::type, Graph, - typename VisitorOps::template tree_edge<Edge, Graph, visitor_state>::type>::type, - typename search_color_map_ops::template set_color<typename mpl_graph::target<Edge, Graph>::type, search_colors::Gray, color_state>::type, - typename mpl::push_back<vertex_queue, typename mpl_graph::target<Edge, Graph>::type >::type >, - // seen - mpl::vector<typename mpl::if_<typename boost::is_same<typename search_color_map_ops::template get_color<mpl_graph::target<Edge, Graph>, color_state>, - search_colors::Gray>::type, - typename VisitorOps::template gray_target<Edge, Graph, visitor_state>::type, - typename VisitorOps::template black_target<Edge, Graph, visitor_state>::type>::type, - color_state, - vertex_queue> - >::type type; -}; - -// runs bfs on a queue, passing the new queue forward on recursion -// returns pair<visitor_state, color_state> -template<typename Graph, typename VertexQueue, typename VisitorOps, typename VisitorState, typename ColorMap> -struct bfs_run_queue { - // enter vertex - typedef typename mpl::front<VertexQueue>::type Vertex; - typedef typename mpl::pop_front<VertexQueue>::type Tail; - typedef typename VisitorOps::template examine_vertex<Vertex, Graph, VisitorState>::type examined_state; - - // loop over out edges - typedef typename mpl::template - fold<typename mpl_graph::out_edges<Vertex, Graph>::type, - mpl::vector<examined_state, ColorMap, Tail>, - bfs_run_queue_examine_edge<Graph, VisitorOps, mpl::_1, mpl::_2> - >::type did_edges; - - typedef typename VisitorOps::template - finish_vertex<Vertex, Graph, typename mpl::at_c<did_edges, 0>::type>::type - finished_vertex; - // does map insert always overwrite? i seem to remember this not working on msvc once - typedef typename search_color_map_ops::template - set_color<Vertex, search_colors::Black, typename mpl::at_c<did_edges, 1>::type>::type - colored_vertex; - typedef typename mpl::at_c<did_edges, 2>::type queued_targets; - - typedef typename - mpl::if_<typename mpl::empty<queued_targets>::type, - mpl::pair<finished_vertex, colored_vertex>, - bfs_run_queue<Graph, queued_targets, - VisitorOps, finished_vertex, - colored_vertex> >::type::type type; -}; - -} // namespace detail - -template<typename Graph, typename VisitorOps, typename VisitorState, - typename Vertex, - typename ColorMap = create_search_color_map::type > -struct breadth_first_search { - typedef typename VisitorOps::template - discover_vertex<Vertex, Graph, VisitorState>::type - discovered_state; - typedef typename search_color_map_ops::template - set_color<Vertex, search_colors::Gray, ColorMap>::type - discovered_colors; - typedef typename detail:: - bfs_run_queue<Graph, mpl::vector<Vertex>, - VisitorOps, discovered_state, - discovered_colors>::type type; -}; - -template<typename Graph, typename VisitorOps, typename VisitorState, - typename FirstVertex = typename mpl::front<typename mpl_graph::vertices<Graph>::type>::type, - typename ColorMap = create_search_color_map::type> -struct breadth_first_search_all : // visit "first" first, then visit any still white - mpl::fold<typename mpl_graph::vertices<Graph>::type, - typename breadth_first_search<Graph, VisitorOps, VisitorState, FirstVertex, ColorMap>::type, - mpl::if_<boost::is_same<search_color_map_ops::template get_color<mpl::_2, mpl::second<mpl::_1> >, - search_colors::White>, - breadth_first_search<Graph, VisitorOps, mpl::first<mpl::_1>, - mpl::_2, mpl::second<mpl::_1> >, - mpl::_1> > -{}; - -} // namespace mpl_graph -} // namespace msm -} // namespace boost - - -#endif // BOOST_MSM_MPL_GRAPH_BREADTH_FIRST_SEARCH_HPP_INCLUDED diff --git a/contrib/restricted/boost/boost/msm/mpl_graph/depth_first_search.hpp b/contrib/restricted/boost/boost/msm/mpl_graph/depth_first_search.hpp deleted file mode 100644 index 05bff9bee3a..00000000000 --- a/contrib/restricted/boost/boost/msm/mpl_graph/depth_first_search.hpp +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2008-2010 Gordon Woodhull -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_MPL_GRAPH_DEPTH_FIRST_SEARCH_HPP_INCLUDED -#define BOOST_MSM_MPL_GRAPH_DEPTH_FIRST_SEARCH_HPP_INCLUDED - -#include <boost/msm/mpl_graph/mpl_graph.hpp> - -#include <boost/mpl/has_key.hpp> -#include <boost/mpl/insert.hpp> -#include <boost/mpl/pair.hpp> -#include <boost/mpl/map.hpp> -#include <boost/mpl/has_key.hpp> - -#include "search_colors.hpp" - -namespace boost { -namespace msm { -namespace mpl_graph { - -// dfs takes a visitor which has all the bgl-like metafunctions encapsulated in an -// "operations" member class, and also a state. the operations are expected to return a new state -// in addition, the visitor operations are expected to update the colors of vertices -// and need to support a new metafunction get_color<Vertex, State> - -struct dfs_default_visitor_operations { - template<typename Vertex, typename Graph, typename State> - struct initialize_vertex { - typedef State type; - }; - - template<typename Vertex, typename Graph, typename State> - struct discover_vertex { - typedef State type; - }; - - template<typename Vertex, typename Graph, typename State> - struct finish_vertex { - typedef State type; - }; - - template<typename Edge, typename Graph, typename State> - struct tree_edge { - typedef State type; - }; - - template<typename Edge, typename Graph, typename State> - struct back_edge { - typedef State type; - }; - - template<typename Edge, typename Graph, typename State> - struct forward_or_cross_edge { - typedef State type; - }; -}; - -// requires IncidenceGraph -// returns pair<VisitorState, ColorState> -template<typename Graph, typename VisitorOps, typename VisitorState, - typename Vertex, - typename ColorState = create_search_color_map::type > -struct depth_first_search { - // enter vertex - typedef typename VisitorOps::template - discover_vertex<Vertex, Graph, VisitorState>::type - discovered_state; - typedef typename search_color_map_ops::template - set_color<Vertex, search_colors::Gray, ColorState>::type - discovered_colors; - - // loop over out edges - typedef typename - mpl::fold<typename mpl_graph::out_edges<Vertex, Graph>::type, - mpl::pair<discovered_state, discovered_colors>, - mpl::if_<boost::is_same<search_color_map_ops::get_color<mpl_graph::target<mpl::_2, Graph>, mpl::second<mpl::_1> >, - search_colors::White>, - // unseen target: recurse - depth_first_search<Graph, - VisitorOps, typename VisitorOps::template tree_edge<mpl::_2, Graph, mpl::first<mpl::_1> >, - mpl_graph::target<mpl::_2, Graph>, - mpl::second<mpl::_1> >, - // seen: back or forward edge - mpl::pair<mpl::if_<boost::is_same<typename search_color_map_ops::template - get_color<mpl_graph::target<mpl::_2, Graph>, mpl::second<mpl::_1 > >, - search_colors::Gray>, - typename VisitorOps::template back_edge<mpl::_2, Graph, mpl::first<mpl::_1> >, - typename VisitorOps::template forward_or_cross_edge<mpl::_2, Graph, mpl::first<mpl::_1> > >, // Black - mpl::second<mpl::_1> > > - >::type after_outedges; - - // leave vertex, and done! - typedef mpl::pair<typename VisitorOps::template finish_vertex<Vertex, Graph, typename mpl::first<after_outedges>::type >::type, - typename search_color_map_ops::template set_color<Vertex, search_colors::Black, typename mpl::second<after_outedges>::type>::type> type; -}; - -// requires IncidenceGraph, VertexListGraph -template<typename Graph, typename VisitorOps, typename VisitorState, - typename FirstVertex = typename mpl::front<typename mpl_graph::vertices<Graph>::type>::type, - typename ColorState = create_search_color_map::type> -struct depth_first_search_all : // visit first then rest - mpl::fold<typename mpl_graph::vertices<Graph>::type, - typename depth_first_search<Graph, - VisitorOps, VisitorState, - FirstVertex, - ColorState>::type, - mpl::if_<boost::is_same<search_color_map_ops::get_color<mpl::_2, mpl::second<mpl::_1> >, - search_colors::White>, // visit any yet unvisited - depth_first_search<Graph, - VisitorOps, mpl::first<mpl::_1>, - mpl::_2, - mpl::second<mpl::_1> >, - mpl::_1> > -{}; - -} // namespace mpl_graph -} // namespace msm -} // namespace boost - - -#endif // BOOST_MSM_MPL_GRAPH_DEPTH_FIRST_SEARCH_HPP_INCLUDED diff --git a/contrib/restricted/boost/boost/msm/mpl_graph/detail/adjacency_list_graph.ipp b/contrib/restricted/boost/boost/msm/mpl_graph/detail/adjacency_list_graph.ipp deleted file mode 100644 index 0ad785b8adf..00000000000 --- a/contrib/restricted/boost/boost/msm/mpl_graph/detail/adjacency_list_graph.ipp +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright 2008-2010 Gordon Woodhull -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_MPL_GRAPH_DETAIL_ADJACENCY_LIST_GRAPH_IPP_INCLUDED -#define BOOST_MSM_MPL_GRAPH_DETAIL_ADJACENCY_LIST_GRAPH_IPP_INCLUDED - -// implementation of a graph declared in adjacency list format -// sequence< pair< source_vertex, sequence< pair<edge, target_vertex> > > > - -#include <boost/msm/mpl_graph/mpl_utils.hpp> -#include <boost/msm/mpl_graph/detail/incidence_list_graph.ipp> - -#include <boost/mpl/copy.hpp> -#include <boost/mpl/inserter.hpp> -#include <boost/mpl/map.hpp> -#include <boost/mpl/insert.hpp> -#include <boost/mpl/fold.hpp> -#include <boost/mpl/pair.hpp> -#include <boost/mpl/at.hpp> -#include <boost/mpl/push_back.hpp> - -namespace boost { -namespace msm { -namespace mpl_graph { -namespace detail { - -// tag identifying graph implementation as adjacency list (not defined) -struct adjacency_list_tag; - -// outs map is really just the same data with the sequences turned into maps -// it might make sense to make another adjacency_map implementation for that case -template<typename AdjacencyList> -struct produce_al_outs_map : - mpl::reverse_fold<AdjacencyList, - mpl::map<>, - mpl::insert<mpl::_1, - mpl::pair<mpl::first<mpl::_2>, mpl_utils::as_map<mpl::second<mpl::_2> > > > > -{}; - -// Edge->Target map for a Source for out_*, degree -template<typename Source, typename GraphData> -struct produce_out_map<adjacency_list_tag, Source, GraphData> : - mpl::at<typename produce_al_outs_map<GraphData>::type, Source> -{}; - -template<typename InsMap, typename Source, typename Adjacencies> -struct produce_in_adjacencies : - mpl::reverse_fold<Adjacencies, - InsMap, - mpl::insert<mpl::_1, - mpl::pair<mpl::second<mpl::_2>, - mpl::insert<mpl_utils::at_or_default<mpl::_1, mpl::second<mpl::_2>, mpl::map<> >, - mpl::pair<mpl::first<mpl::_2>, Source> > > > > -{}; - -template<typename AdjacencyList> -struct produce_al_ins_map : - mpl::reverse_fold<AdjacencyList, - mpl::map<>, - produce_in_adjacencies<mpl::_1, mpl::first<mpl::_2>, mpl::second<mpl::_2> > > -{}; - -// Edge->Source map for a Target for in_*, degree -template<typename Target, typename GraphData> -struct produce_in_map<adjacency_list_tag, Target, GraphData> : - mpl::at<typename produce_al_ins_map<GraphData>::type, Target> -{}; - -// for everything else to do with edges, -// just produce an incidence list and forward to that graph implementation -// (produce_out_map could, and produce_in_map probably should, be implemented this way too) -template<typename Incidences, typename Source, typename Adjacencies> -struct produce_adjacencies_incidences : // adjacencies' - mpl::reverse_fold<Adjacencies, - Incidences, - mpl::push_back<mpl::_1, - mpl::vector3<mpl::first<mpl::_2>, Source, mpl::second<mpl::_2> > > > -{}; - -template<typename AdjacencyList> -struct produce_incidence_list_from_adjacency_list : - mpl::reverse_fold<AdjacencyList, - mpl::vector<>, - produce_adjacencies_incidences<mpl::_1, mpl::first<mpl::_2>, mpl::second<mpl::_2> > > -{}; - - -// Edge->pair<Source,Target> map for source, target -template<typename GraphData> -struct produce_edge_st_map<adjacency_list_tag, GraphData> : - produce_edge_st_map<incidence_list_tag, - typename produce_incidence_list_from_adjacency_list<GraphData>::type> -{}; - - -// adjacency list supports zero-degree vertices, which incidence list does not -template<typename VertexSet, typename Adjacencies> -struct insert_adjacencies_targets : // adjacencies' - mpl::reverse_fold<Adjacencies, - VertexSet, - mpl::insert<mpl::_1, mpl::second<mpl::_2> > > -{}; - -template<typename GraphData> -struct produce_vertex_set<adjacency_list_tag, GraphData> : - mpl::reverse_fold<GraphData, - mpl::set<>, - insert_adjacencies_targets<mpl::insert<mpl::_1, mpl::first<mpl::_2> >, - mpl::second<mpl::_2> > > -{}; - - -// Edge set for EdgeListGraph -template<typename GraphData> -struct produce_edge_set<adjacency_list_tag, GraphData> : - produce_edge_set<incidence_list_tag, - typename produce_incidence_list_from_adjacency_list<GraphData>::type> -{}; - - -} // namespaces -} -} -} - -#endif // BOOST_MSM_MPL_GRAPH_DETAIL_ADJACENCY_LIST_GRAPH_IPP_INCLUDED - diff --git a/contrib/restricted/boost/boost/msm/mpl_graph/detail/graph_implementation_interface.ipp b/contrib/restricted/boost/boost/msm/mpl_graph/detail/graph_implementation_interface.ipp deleted file mode 100644 index e657fd55d78..00000000000 --- a/contrib/restricted/boost/boost/msm/mpl_graph/detail/graph_implementation_interface.ipp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2008-2010 Gordon Woodhull -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_MPL_GRAPH_DETAIL_GRAPH_IMPLEMENTATION_INTERFACE_IPP_INCLUDED -#define BOOST_MSM_MPL_GRAPH_DETAIL_GRAPH_IMPLEMENTATION_INTERFACE_IPP_INCLUDED - -// forward definitions of the producer metafunctions that need to be specialized for -// each graph representation - -namespace boost { -namespace msm { -namespace mpl_graph { -namespace detail { - - // Edge->Target map for a Source for out_*, degree - template<typename RepresentationTag, typename Source, typename GraphData> - struct produce_out_map; - - // Edge->Source map for a Target for in_*, degree - template<typename RepresentationTag, typename Target, typename GraphData> - struct produce_in_map; - - // Edge->pair<Source,Target> map for source, target - template<typename RepresentationTag, typename GraphData> - struct produce_edge_st_map; - - // Vertex set for VertexListGraph - template<typename RepresentationTag, typename GraphData> - struct produce_vertex_set; - - // Edge set for EdgeListGraph - template<typename RepresentationTag, typename GraphData> - struct produce_edge_set; - -} // namespaces -} -} -} - -#endif // BOOST_MSM_MPL_GRAPH_DETAIL_GRAPH_IMPLEMENTATION_INTERFACE_IPP_INCLUDED - diff --git a/contrib/restricted/boost/boost/msm/mpl_graph/detail/incidence_list_graph.ipp b/contrib/restricted/boost/boost/msm/mpl_graph/detail/incidence_list_graph.ipp deleted file mode 100644 index 30bfffc910e..00000000000 --- a/contrib/restricted/boost/boost/msm/mpl_graph/detail/incidence_list_graph.ipp +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2008-2010 Gordon Woodhull -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_MPL_GRAPH_DETAIL_INCIDENCE_LIST_GRAPH_IPP_INCLUDED - -#define BOOST_MSM_MPL_GRAPH_DETAIL_INCIDENCE_LIST_GRAPH_IPP_INCLUDED - -// these metafunctions provide the metadata structures needed by the public interface -// in mpl_graph.hpp - -#include <boost/mpl/map.hpp> -#include <boost/mpl/vector.hpp> -#include <boost/mpl/copy.hpp> -#include <boost/mpl/vector.hpp> -#include <boost/mpl/next.hpp> -#include <boost/mpl/front.hpp> -#include <boost/mpl/back.hpp> -#include <boost/mpl/deref.hpp> -#include <boost/mpl/if.hpp> -#include <boost/mpl/size.hpp> -#include <boost/mpl/void.hpp> -#include <boost/mpl/erase_key.hpp> -#include <boost/mpl/has_key.hpp> -#include <boost/mpl/inserter.hpp> -#include <boost/mpl/back_inserter.hpp> -#include <boost/mpl/set.hpp> -#include <boost/mpl/insert.hpp> -#include <boost/mpl/transform.hpp> -#include <boost/mpl/pair.hpp> -#include <boost/mpl/size.hpp> -#include <boost/mpl/fold.hpp> -#include <boost/mpl/transform.hpp> -#include <boost/mpl/at.hpp> -#include <boost/mpl/push_back.hpp> -#include <boost/mpl/filter_view.hpp> -#include <boost/mpl/transform_view.hpp> -#include <boost/mpl/equal.hpp> -#include <boost/type_traits.hpp> - - -namespace boost { -namespace msm { -namespace mpl_graph { -namespace detail { - -// tag to identify this graph implementation (not defined) -struct incidence_list_tag; - -// clarifiers -template<typename EST> struct fetch_edge : - mpl::front<EST> {}; -template<typename EST> struct fetch_source : - mpl::deref<typename mpl::next<typename mpl::begin<EST>::type>::type> {}; -template<typename EST> struct fetch_target : - mpl::back<EST> {}; - -// Edge->Target map for an Source for out_*, adjacent_vertices -template<typename Source, typename ESTSequence> -struct produce_out_map<incidence_list_tag, Source, ESTSequence> : - mpl::fold<typename mpl::filter_view<ESTSequence, boost::is_same<fetch_source<mpl::_1>,Source> >::type, - mpl::map<>, - mpl::insert<mpl::_1,mpl::pair<fetch_edge<mpl::_2>,fetch_target<mpl::_2> > > > -{}; - -// Edge->Source map for a Target for in_*, degree -template<typename Target, typename ESTSequence> -struct produce_in_map<incidence_list_tag, Target, ESTSequence> : - mpl::fold<typename mpl::filter_view<ESTSequence, - boost::is_same<fetch_target<mpl::_1>,Target> >::type, - mpl::map<>, - mpl::insert<mpl::_1,mpl::pair<fetch_edge<mpl::_2>,fetch_source<mpl::_2> > > > - -{}; -// Edge->pair<Source,Target> map for source, target -template<typename ESTSequence> -struct produce_edge_st_map<incidence_list_tag, ESTSequence> : - mpl::fold<ESTSequence, - mpl::map<>, - mpl::insert<mpl::_1,mpl::pair<fetch_edge<mpl::_2>, - mpl::pair<fetch_source<mpl::_2>, - fetch_target<mpl::_2> > > > > -{}; -// Vertex set for VertexListGraph -template<typename ESTSequence> -struct produce_vertex_set<incidence_list_tag, ESTSequence> : - mpl::fold<ESTSequence, - typename mpl::fold<ESTSequence, - mpl::set<>, - mpl::insert<mpl::_1,fetch_target<mpl::_2> > - >::type, - mpl::insert<mpl::_1, fetch_source<mpl::_2> > > -{}; -// Edge set for EdgeListGraph -template<typename ESTSequence> -struct produce_edge_set<incidence_list_tag, ESTSequence> : - mpl::fold<ESTSequence, - mpl::set<>, - mpl::insert<mpl::_1,fetch_edge<mpl::_2> > > -{}; -} -} -} -} - -#endif // BOOST_MSM_MPL_GRAPH_DETAIL_INCIDENCE_LIST_GRAPH_IPP_INCLUDED diff --git a/contrib/restricted/boost/boost/msm/mpl_graph/incidence_list_graph.hpp b/contrib/restricted/boost/boost/msm/mpl_graph/incidence_list_graph.hpp deleted file mode 100644 index 2e3c250e756..00000000000 --- a/contrib/restricted/boost/boost/msm/mpl_graph/incidence_list_graph.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2008-2010 Gordon Woodhull -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_MPL_GRAPH_INCIDENCE_LIST_GRAPH_HPP_INCLUDED -#define BOOST_MSM_MPL_GRAPH_INCIDENCE_LIST_GRAPH_HPP_INCLUDED - -// graph implementation based on a an mpl sequence of sequences <Edge,Source,Target> - -// incidence_list_graph labels such a sequence as manipulable by the metafunctions -// in the corresponding implementation header detail/incidence_list_graph.ipp -// to produce the metadata structures needed by mpl_graph.hpp - -// the public interface -#include <boost/msm/mpl_graph/mpl_graph.hpp> - -// the implementation -#include <boost/msm/mpl_graph/detail/incidence_list_graph.ipp> - -namespace boost { -namespace msm { -namespace mpl_graph { - -template<typename EdgeSequence> -struct incidence_list_graph { - typedef detail::incidence_list_tag representation; - typedef EdgeSequence data; -}; - -} -} -} - -#endif // BOOST_MSM_MPL_GRAPH_INCIDENCE_LIST_GRAPH_HPP_INCLUDED diff --git a/contrib/restricted/boost/boost/msm/mpl_graph/mpl_graph.hpp b/contrib/restricted/boost/boost/msm/mpl_graph/mpl_graph.hpp deleted file mode 100644 index ec2db14c746..00000000000 --- a/contrib/restricted/boost/boost/msm/mpl_graph/mpl_graph.hpp +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright 2008-2010 Gordon Woodhull -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// mpl_graph - defines a metadata implementation of the BGL immutable graph concepts - -// (c) 2008 Gordon Woodhull -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSEmpl::_1_0.txt or copy at -// http://www.boost.org/LICENSEmpl::_1_0.txt) - -#ifndef BOOST_MSM_MPL_GRAPH_MPL_GRAPH_HPP_INCLUDED -#define BOOST_MSM_MPL_GRAPH_MPL_GRAPH_HPP_INCLUDED - -#include <boost/msm/mpl_graph/detail/graph_implementation_interface.ipp> - -#include <boost/mpl/vector.hpp> -#include <boost/mpl/pair.hpp> -#include <boost/mpl/fold.hpp> -#include <boost/mpl/push_back.hpp> -#include <boost/mpl/at.hpp> -#include <boost/mpl/size.hpp> -#include <boost/mpl/plus.hpp> -#include <boost/mpl/transform.hpp> -#include <boost/mpl/back_inserter.hpp> - -namespace boost { -namespace msm { -namespace mpl_graph { - -// Boost Graph concepts, MPL style - -// The metafunctions of the public interface rely -// metafunctions in the graph implementation to transform the input -// into the maps which are required to deliver results. Since the -// maps are produced lazily and are memoized, all of the graph -// concepts can be supported with no cost until they are actually -// used. - -// Each of these dispatch to the correct producer metafunctions based -// on the representation inner type tag - - - -// IncidenceGraph -template<typename Edge, typename Graph> -struct source : - mpl::first<typename mpl::at<typename detail::produce_edge_st_map<typename Graph::representation, typename Graph::data>::type,Edge>::type> -{}; -template<typename Edge, typename Graph> -struct target : - mpl::second<typename mpl::at<typename detail::produce_edge_st_map<typename Graph::representation, typename Graph::data>::type,Edge>::type> -{}; -template<typename Vertex, typename Graph> -struct out_edges : - mpl::fold<typename detail::produce_out_map<typename Graph::representation, Vertex, typename Graph::data>::type, - mpl::vector<>, - mpl::push_back<mpl::_1, mpl::first<mpl::_2> > > -{}; -template<typename Vertex, typename Graph> -struct out_degree : - mpl::size<typename out_edges<Vertex, Graph>::type> -{}; - -// BidirectionalGraph -template<typename Vertex, typename Graph> -struct in_edges : - mpl::fold<typename detail::produce_in_map<typename Graph::representation, Vertex, typename Graph::data>::type, - mpl::vector<>, - mpl::push_back<mpl::_1, mpl::first<mpl::_2> > > -{}; -template<typename Vertex, typename Graph> -struct in_degree : - mpl::size<typename in_edges<Vertex, Graph>::type> -{}; -template<typename Vertex, typename Graph> -struct degree : - mpl::plus<typename out_degree<Vertex, Graph>::type,typename in_degree<Vertex, Graph>::type> -{}; - -// AdjacencyGraph -template<typename Vertex, typename Graph> -struct adjacent_vertices : - mpl::transform<typename detail::produce_out_map<typename Graph::representation, Vertex, typename Graph::data>::type, - mpl::second<mpl::_1>, - mpl::back_inserter<mpl::vector<> > > -{}; - -// VertexListGraph -template<typename Graph> -struct vertices : - detail::produce_vertex_set<typename Graph::representation, typename Graph::data> -{}; -template<typename Graph> -struct num_vertices : - mpl::size<typename vertices<Graph>::type> -{}; - -// EdgeListGraph -template<typename Graph> -struct edges : - detail::produce_edge_set<typename Graph::representation, typename Graph::data> -{}; -template<typename Graph> -struct num_edges : - mpl::size<typename edges<Graph>::type> -{}; -// source and target are defined in IncidenceGraph - -} // mpl_graph -} // msm -} // boost - -#endif // BOOST_MSM_MPL_GRAPH_MPL_GRAPH_HPP_INCLUDED diff --git a/contrib/restricted/boost/boost/msm/mpl_graph/mpl_utils.hpp b/contrib/restricted/boost/boost/msm/mpl_graph/mpl_utils.hpp deleted file mode 100644 index 97687b21f0d..00000000000 --- a/contrib/restricted/boost/boost/msm/mpl_graph/mpl_utils.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2008-2010 Gordon Woodhull -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_MPL_GRAPH_MPL_UTILS_HPP_INCLUDED -#define BOOST_MSM_MPL_GRAPH_MPL_UTILS_HPP_INCLUDED - -#include <boost/mpl/fold.hpp> -#include <boost/mpl/map.hpp> -#include <boost/mpl/set.hpp> -#include <boost/mpl/insert.hpp> -#include <boost/mpl/if.hpp> -#include <boost/mpl/has_key.hpp> -#include <boost/mpl/at.hpp> -#include <boost/mpl/and.hpp> - -namespace boost { -namespace msm { -namespace mpl_graph { -namespace mpl_utils { - -// This is a grab bag of little metafunctions I expect already -// exist under some name I haven't looked for - -// I figure there are probably better ways to do all of these things, -// but for now I'll just write some utilities to isolate my ignorance - -template<typename Seq> -struct as_map : - mpl::fold<Seq, - mpl::map<>, - mpl::insert<mpl::_1, mpl::_2> > -{}; -template<typename Seq> -struct as_set : - mpl::fold<Seq, - mpl::set<>, - mpl::insert<mpl::_1, mpl::_2> > -{}; - -template<typename AssocSeq, typename Key, typename Default> -struct at_or_default : - mpl::if_<typename mpl::has_key<AssocSeq, Key>::type, - typename mpl::at<AssocSeq, Key>::type, - Default> -{}; - -template<typename Seq1, typename Seq2> -struct set_equal : - mpl::fold<Seq2, - mpl::true_, - mpl::and_<mpl::_1, - mpl::has_key<typename as_set<Seq1>::type, - mpl::_2 > > > -{}; - -} -} -} -} - -#endif // BOOST_MSM_MPL_GRAPH_MPL_UTILS_HPP_INCLUDED diff --git a/contrib/restricted/boost/boost/msm/mpl_graph/search_colors.hpp b/contrib/restricted/boost/boost/msm/mpl_graph/search_colors.hpp deleted file mode 100644 index 3b1dfe6c950..00000000000 --- a/contrib/restricted/boost/boost/msm/mpl_graph/search_colors.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2008-2010 Gordon Woodhull -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_MPL_GRAPH_SEARCH_COLORS_HPP_INCLUDED -#define BOOST_MSM_MPL_GRAPH_SEARCH_COLORS_HPP_INCLUDED - -namespace boost { -namespace msm { -namespace mpl_graph { - -namespace search_colors { - struct White {}; - struct Gray {}; - struct Black {}; -} - -struct create_search_color_map : mpl::map<> {}; - -struct search_color_map_ops { - template<typename Node, typename Color, typename State> - struct set_color : - mpl::insert<State, mpl::pair<Node, Color> > - {}; - template<typename Node, typename State> - struct get_color : - mpl::if_<mpl::has_key<State, Node>, - mpl::at<State, Node>, - search_colors::White> - {}; -}; - - -} // namespace mpl_graph -} // namespace msm -} // namespace boost - - -#endif // BOOST_MSM_MPL_GRAPH_SEARCH_COLORS_HPP_INCLUDED diff --git a/contrib/restricted/boost/boost/msm/msm_grammar.hpp b/contrib/restricted/boost/boost/msm/msm_grammar.hpp deleted file mode 100644 index 8f95e986840..00000000000 --- a/contrib/restricted/boost/boost/msm/msm_grammar.hpp +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_GRAMMAR_H -#define BOOST_MSM_GRAMMAR_H - -#include <boost/proto/core.hpp> -#include <boost/msm/common.hpp> - - -namespace boost { namespace msm -{ -// base grammar for all of msm's proto-based grammars -struct basic_grammar : proto::_ -{}; - -// Forward-declare an expression wrapper -template<typename Expr> -struct msm_terminal; - -struct msm_domain - : proto::domain< proto::generator<msm_terminal>, basic_grammar > -{}; - -template<typename Expr> -struct msm_terminal - : proto::extends<Expr, msm_terminal<Expr>, msm_domain> -{ - typedef - proto::extends<Expr, msm_terminal<Expr>, msm_domain> - base_type; - // Needs a constructor - msm_terminal(Expr const &e = Expr()) - : base_type(e) - {} -}; - -// grammar forbidding address of for terminals -struct terminal_grammar : proto::not_<proto::address_of<proto::_> > -{}; - -// Forward-declare an expression wrapper -template<typename Expr> -struct euml_terminal; - -struct sm_domain - : proto::domain< proto::generator<euml_terminal>, terminal_grammar, boost::msm::msm_domain > -{}; - -struct state_grammar : - proto::and_< - proto::not_<proto::address_of<proto::_> >, - proto::not_<proto::shift_right<proto::_,proto::_> >, - proto::not_<proto::shift_left<proto::_,proto::_> >, - proto::not_<proto::bitwise_and<proto::_,proto::_> > - > -{}; -struct state_domain - : proto::domain< proto::generator<euml_terminal>, boost::msm::state_grammar,boost::msm::sm_domain > -{}; - -template<typename Expr> -struct euml_terminal - : proto::extends<Expr, euml_terminal<Expr>, boost::msm::sm_domain> -{ - typedef - proto::extends<Expr, euml_terminal<Expr>, boost::msm::sm_domain> - base_type; - // Needs a constructor - euml_terminal(Expr const &e = Expr()) - : base_type(e) - {} - // Unhide Proto's overloaded assignment operator - using base_type::operator=; -}; - -} } // boost::msm -#endif //BOOST_MSM_GRAMMAR_H - diff --git a/contrib/restricted/boost/boost/msm/proto_config.hpp b/contrib/restricted/boost/boost/msm/proto_config.hpp deleted file mode 100644 index 888e9ecdf40..00000000000 --- a/contrib/restricted/boost/boost/msm/proto_config.hpp +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_PROTO_CONFIG_H -#define BOOST_MSM_PROTO_CONFIG_H - -#include <boost/proto/proto_fwd.hpp> - -#endif //BOOST_MSM_PROTO_CONFIG_H diff --git a/contrib/restricted/boost/boost/msm/row_tags.hpp b/contrib/restricted/boost/boost/msm/row_tags.hpp deleted file mode 100644 index f674be1ede0..00000000000 --- a/contrib/restricted/boost/boost/msm/row_tags.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2008 Christophe Henry -// henry UNDERSCORE christophe AT hotmail DOT com -// This is an extended version of the state machine available in the boost::mpl library -// Distributed under the same license as the original. -// Copyright for the original version: -// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed -// under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_MSM_ROW_TAGS_H -#define BOOST_MSM_ROW_TAGS_H - - - -namespace boost { namespace msm -{ -//tags -struct a_row_tag {}; -struct g_row_tag {}; -struct _row_tag {}; -struct row_tag {}; -// tags for internal transitions -struct a_irow_tag {}; -struct g_irow_tag {}; -struct _irow_tag {}; -struct irow_tag {}; -// tags for transitions internal to state machines (not using any substate) -struct sm_a_i_row_tag {}; -struct sm_g_i_row_tag {}; -struct sm__i_row_tag {}; -struct sm_i_row_tag {}; - -// flags used internally to handle terminate / interrupt states -struct TerminateFlag -{ - typedef int non_forwarding_flag; - typedef int event_blocking_flag; -}; -struct InterruptedFlag -{ - typedef int non_forwarding_flag; - typedef int event_blocking_flag; -}; -template <class EndEvent> -struct EndInterruptFlag -{ - typedef int non_forwarding_flag; -}; - -} } // boost::msm -#endif //BOOST_MSM_ROW_TAGS_H - diff --git a/contrib/restricted/boost/boost/sort/block_indirect_sort/blk_detail/backbone.hpp b/contrib/restricted/boost/boost/sort/block_indirect_sort/blk_detail/backbone.hpp deleted file mode 100644 index 1c2fdfec88a..00000000000 --- a/contrib/restricted/boost/boost/sort/block_indirect_sort/blk_detail/backbone.hpp +++ /dev/null @@ -1,219 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file backbone.hpp -/// @brief This file constains the class backbone, which is part of the -/// block_indirect_sort algorithm -/// -/// @author Copyright (c) 2016 Francisco Jose Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_PARALLEL_DETAIL_BACKBONE_HPP -#define __BOOST_SORT_PARALLEL_DETAIL_BACKBONE_HPP - -#include <atomic> -#include <boost/sort/pdqsort/pdqsort.hpp> -#include <boost/sort/common/util/atomic.hpp> -#include <boost/sort/common/util/algorithm.hpp> -#include <boost/sort/common/stack_cnc.hpp> -#include <future> -#include <iostream> -#include <iterator> - -#include <boost/sort/block_indirect_sort/blk_detail/block.hpp> - -namespace boost -{ -namespace sort -{ -namespace blk_detail -{ - -//--------------------------------------------------------------------------- -// USING SENTENCES -//--------------------------------------------------------------------------- -namespace bsc = boost::sort::common; -namespace bscu = bsc::util; -using bsc::stack_cnc; -using bsc::range; - -///--------------------------------------------------------------------------- -/// @struct backbone -/// @brief This contains all the information shared betwen the classes of the -/// block indirect sort algorithm - -//---------------------------------------------------------------------------- -template < uint32_t Block_size, class Iter_t, class Compare > -struct backbone -{ - //------------------------------------------------------------------------- - // D E F I N I T I O N S - //------------------------------------------------------------------------- - typedef typename std::iterator_traits< Iter_t >::value_type value_t; - typedef std::atomic< uint32_t > atomic_t; - typedef range< size_t > range_pos; - typedef range< Iter_t > range_it; - typedef range< value_t * > range_buf; - typedef std::function< void(void) > function_t; - typedef block< Block_size, Iter_t > block_t; - - //------------------------------------------------------------------------ - // V A R I A B L E S - //------------------------------------------------------------------------ - // range with all the element to sort - range< Iter_t > global_range; - - // index vector of block_pos elements - std::vector< block_pos > index; - - // Number of elements to sort - size_t nelem; - - // Number of blocks to sort - size_t nblock; - - // Number of elements in the last block (tail) - size_t ntail; - - // object for to compare two elements - Compare cmp; - - // range of elements of the last block (tail) - range_it range_tail; - - // thread local varible. It is a pointer to the buffer - static thread_local value_t *buf; - - // concurrent stack where store the function_t elements - stack_cnc< function_t > works; - - // global indicator of error - bool error; - // - //------------------------------------------------------------------------ - // F U N C T I O N S - //------------------------------------------------------------------------ - backbone (Iter_t first, Iter_t last, Compare comp); - - //------------------------------------------------------------------------ - // function : get_block - /// @brief obtain the block in the position pos - /// @param pos : position of the range - /// @return block required - //------------------------------------------------------------------------ - block_t get_block (size_t pos) const - { - return block_t (global_range.first + (pos * Block_size)); - }; - //------------------------------------------------------------------------- - // function : get_range - /// @brief obtain the range in the position pos - /// @param pos : position of the range - /// @return range required - //------------------------------------------------------------------------- - range_it get_range (size_t pos) const - { - Iter_t it1 = global_range.first + (pos * Block_size); - Iter_t it2 = - (pos == (nblock - 1)) ? global_range.last : it1 + Block_size; - return range_it (it1, it2); - }; - //------------------------------------------------------------------------- - // function : get_range_buf - /// @brief obtain the auxiliary buffer of the thread - //------------------------------------------------------------------------- - range_buf get_range_buf ( ) const - { - return range_buf (buf, buf + Block_size); - }; - - //------------------------------------------------------------------------- - // function : exec - /// @brief Initialize the thread local buffer with the ptr_buf pointer, - /// and begin with the execution of the functions stored in works - // - /// @param ptr_buf : Pointer to the memory assigned to the thread_local - /// buffer - /// @param counter : atomic counter for to invoke to the exec function - /// with only 1 parameter - //------------------------------------------------------------------------- - void exec (value_t *ptr_buf, atomic_t &counter) - { - buf = ptr_buf; - exec (counter); - }; - - void exec (atomic_t &counter); - -//--------------------------------------------------------------------------- -}; // end struct backbone -//--------------------------------------------------------------------------- -// -//############################################################################ -// ## -// ## -// N O N I N L I N E F U N C T I O N S ## -// ## -// ## -//############################################################################ -// -// initialization of the thread_local pointer to the auxiliary buffer -template < uint32_t Block_size, class Iter_t, class Compare > -thread_local typename std::iterator_traits< Iter_t > -::value_type *backbone< Block_size, Iter_t, Compare >::buf = nullptr; - -//------------------------------------------------------------------------ -// function : backbone -/// @brief constructor of the class -// -/// @param first : iterator to the first element of the range to sort -/// @param last : iterator after the last element to the range to sort -/// @param comp : object for to compare two elements pointed by Iter_t -/// iterators -//------------------------------------------------------------------------ -template < uint32_t Block_size, class Iter_t, class Compare > -backbone< Block_size, Iter_t, Compare > -::backbone (Iter_t first, Iter_t last, Compare comp) -: global_range (first, last), cmp (comp), error (false) -{ - assert ((last - first) >= 0); - if (first == last) return; // nothing to do - - nelem = size_t (last - first); - nblock = (nelem + Block_size - 1) / Block_size; - ntail = (nelem % Block_size); - index.reserve (nblock + 1); - - for (size_t i = 0; i < nblock; ++i) index.emplace_back (block_pos (i)); - - range_tail.first = - (ntail == 0) ? last : (first + ((nblock - 1) * Block_size)); - range_tail.last = last; -}; -// -//------------------------------------------------------------------------- -// function : exec -/// @brief execute the function_t stored in works, until counter is zero -// -/// @param counter : atomic counter. When 0 exits the function -//------------------------------------------------------------------------- -template < uint32_t Block_size, class Iter_t, class Compare > -void backbone< Block_size, Iter_t, Compare >::exec (atomic_t &counter) -{ - function_t func_exec; - while (bscu::atomic_read (counter) != 0) - { - if (works.pop_move_back (func_exec)) func_exec ( ); - else std::this_thread::yield ( ); - }; -}; -// -//**************************************************************************** -}; // End namespace blk_detail -}; // End namespace sort -}; // End namespace boost -//**************************************************************************** -#endif diff --git a/contrib/restricted/boost/boost/sort/block_indirect_sort/blk_detail/block.hpp b/contrib/restricted/boost/boost/sort/block_indirect_sort/blk_detail/block.hpp deleted file mode 100644 index 9c14b6103fd..00000000000 --- a/contrib/restricted/boost/boost/sort/block_indirect_sort/blk_detail/block.hpp +++ /dev/null @@ -1,180 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file block.hpp -/// @brief This file contains the internal data structures used in the -/// block_indirect_sort algorithm -/// -/// @author Copyright (c) 2016 Francisco Jose Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_PARALLEL_DETAIL_BLOCK_HPP -#define __BOOST_SORT_PARALLEL_DETAIL_BLOCK_HPP - -#include <boost/sort/common/range.hpp> - -namespace boost -{ -namespace sort -{ -namespace blk_detail -{ -//--------------------------------------------------------------------------- -// USING SENTENCES -//--------------------------------------------------------------------------- -using namespace boost::sort::common; -// -//--------------------------------------------------------------------------- -/// @struct block_pos -/// @brief represent a pair of values, a position represented as an unsigned -/// variable ( position ), and a bool variable ( side ). They are packed -/// in a size_t variable. The Least Significant Bit is the bool variable, -/// and the others bits are the position -//---------------------------------------------------------------------------- -class block_pos -{ - //------------------------------------------------------------------------ - // VARIABLES - //----------------------------------------------------------------------- - size_t num; // number which store a position and a bool side - - public: - //----------------------------- FUNCTIONS ------------------------------ - block_pos (void) : num (0){}; - // - //------------------------------------------------------------------------- - // function : block_pos - /// @brief constructor from a position and a side - /// @param position : position to sotre - /// @param side : side to store - //------------------------------------------------------------------------- - block_pos (size_t position, bool side = false) - { - num = (position << 1) + ((side) ? 1 : 0); - }; - // - //------------------------------------------------------------------------- - // function : pos - /// @brief obtain the position stored inside the block_pos - /// @return position - //------------------------------------------------------------------------- - size_t pos (void) const { return (num >> 1); }; - // - //------------------------------------------------------------------------- - // function : pos - /// @brief store a position inside the block_pos - /// @param position : value to store - //------------------------------------------------------------------------- - void set_pos (size_t position) { num = (position << 1) + (num & 1); }; - // - //------------------------------------------------------------------------- - // function : side - /// @brief obtain the side stored inside the block_pos - /// @return bool value - //------------------------------------------------------------------------- - bool side (void) const { return ((num & 1) != 0); }; - // - //------------------------------------------------------------------------- - // function : side - /// @brief store a bool value the block_pos - /// @param sd : bool value to store - //------------------------------------------------------------------------- - void set_side (bool sd) { num = (num & ~1) + ((sd) ? 1 : 0); }; -}; // end struct block_pos - -// -//--------------------------------------------------------------------------- -/// @struct block -/// @brief represent a group of Block_size contiguous elements, beginning -/// with the pointed by first -//---------------------------------------------------------------------------- -template < uint32_t Block_size, class Iter_t > -struct block -{ - //---------------------------------------------------------------------- - // VARIABLES - //---------------------------------------------------------------------- - Iter_t first; // iterator to the first element of the block - - //------------------------------------------------------------------------- - // function : block - /// @brief constructor from an iterator to the first element of the block - /// @param it : iterator to the first element of the block - //------------------------------------------------------------------------- - block (Iter_t it) : first (it){}; - - //------------------------------------------------------------------------- - // function : get_range - /// @brief convert a block in a range - /// @return range - //------------------------------------------------------------------------- - range< Iter_t > get_range (void) - { - return range_it (first, first + Block_size); - }; - -}; // end struct block - -// -//------------------------------------------------------------------------- -// function : compare_block -/// @brief compare two blocks using the content of the pointed by first -/// @param block1 : first block to compare -/// @param block2 : second block to compare -/// @param cmp : comparison operator -//------------------------------------------------------------------------- -template < uint32_t Block_size, class Iter_t, class Compare > -bool compare_block (block< Block_size, Iter_t > block1, - block< Block_size, Iter_t > block2, - Compare cmp = Compare ( )) -{ - return cmp (*block1.first, *block2.first); -}; -// -///--------------------------------------------------------------------------- -/// @struct compare_block_pos -/// @brief This is a object for to compare two block_pos objects -//---------------------------------------------------------------------------- -template < uint32_t Block_size, class Iter_t, class Compare > -struct compare_block_pos -{ - //----------------------------------------------------------------------- - // VARIABLES - //----------------------------------------------------------------------- - Iter_t global_first; // iterator to the first element to sort - Compare comp; // comparison object for to compare two elements - - //------------------------------------------------------------------------- - // function : compare_block_pos - /// @brief constructor - /// @param g_first : itertor to the first element to sort - /// @param cmp : comparison operator - //------------------------------------------------------------------------- - compare_block_pos (Iter_t g_first, Compare cmp) - : global_first (g_first), comp (cmp){}; - // - //------------------------------------------------------------------------- - // function : operator () - /// @brief compare two blocks using the content of the pointed by - /// global_first - /// @param block_pos1 : first block to compare - /// @param block_pos2 : second block to compare - //------------------------------------------------------------------------- - bool operator( ) (block_pos block_pos1, block_pos block_pos2) const - { - return comp (*(global_first + (block_pos1.pos ( ) * Block_size)), - *(global_first + (block_pos2.pos ( ) * Block_size))); - }; - -}; // end struct compare_block_pos - -//**************************************************************************** -}; // End namespace blk_detail -}; // End namespace sort -}; // End namespace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/block_indirect_sort/blk_detail/constants.hpp b/contrib/restricted/boost/boost/sort/block_indirect_sort/blk_detail/constants.hpp deleted file mode 100644 index c4072430255..00000000000 --- a/contrib/restricted/boost/boost/sort/block_indirect_sort/blk_detail/constants.hpp +++ /dev/null @@ -1,26 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file constants.hpp -/// @brief This file contains the constants values used in the algorithms -/// -/// @author Copyright (c) 2016 Francisco José Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_PARALLEL_DETAIL_CONSTANTS_HPP -#define __BOOST_SORT_PARALLEL_DETAIL_CONSTANTS_HPP - -// This value is the block size in the block_indirect_sort algorithm -#define BOOST_BLOCK_SIZE 1024 - -// This value represent the group size in the block_indirect_sort algorithm -#define BOOST_GROUP_SIZE 64 - -// This value is the minimal number of threads for to use the -// block_indirect_sort algorithm -#define BOOST_NTHREAD_BORDER 6 - -#endif diff --git a/contrib/restricted/boost/boost/sort/block_indirect_sort/blk_detail/merge_blocks.hpp b/contrib/restricted/boost/boost/sort/block_indirect_sort/blk_detail/merge_blocks.hpp deleted file mode 100644 index a4185b53afe..00000000000 --- a/contrib/restricted/boost/boost/sort/block_indirect_sort/blk_detail/merge_blocks.hpp +++ /dev/null @@ -1,426 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file merge_blocks.hpp -/// @brief contains the class merge_blocks, which is part of the -/// block_indirect_sort algorithm -/// -/// @author Copyright (c) 2016 Francisco Jose Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_PARALLEL_DETAIL_MERGE_BLOCKS_HPP -#define __BOOST_SORT_PARALLEL_DETAIL_MERGE_BLOCKS_HPP - -#include <atomic> -#include <boost/sort/block_indirect_sort/blk_detail/backbone.hpp> -#include <boost/sort/common/range.hpp> -#include <future> -#include <iostream> -#include <iterator> - -namespace boost -{ -namespace sort -{ -namespace blk_detail -{ -//---------------------------------------------------------------------------- -// USING SENTENCES -//---------------------------------------------------------------------------- -namespace bsc = boost::sort::common; -namespace bscu = bsc::util; -using bsc::range; -using bsc::is_mergeable; -using bsc::merge_uncontiguous; -// -///--------------------------------------------------------------------------- -/// @struct merge_blocks -/// @brief This class merge the blocks. The blocks to merge are defined by two -/// ranges of positions in the index of the backbone -//---------------------------------------------------------------------------- -template<uint32_t Block_size, uint32_t Group_size, class Iter_t, class Compare> -struct merge_blocks -{ - //----------------------------------------------------------------------- - // D E F I N I T I O N S - //----------------------------------------------------------------------- - typedef typename std::iterator_traits<Iter_t>::value_type value_t; - typedef std::atomic<uint32_t> atomic_t; - typedef range<size_t> range_pos; - typedef range<Iter_t> range_it; - typedef range<value_t *> range_buf; - typedef std::function<void(void)> function_t; - typedef backbone<Block_size, Iter_t, Compare> backbone_t; - typedef compare_block_pos<Block_size, Iter_t, Compare> compare_block_pos_t; - - //------------------------------------------------------------------------ - // V A R I A B L E S - //------------------------------------------------------------------------ - // Object with the elements to sort and all internal data structures of the - // algorithm - backbone_t &bk; - // - //------------------------------------------------------------------------ - // F U N C T I O N S - //------------------------------------------------------------------------ - merge_blocks(backbone_t &bkb, size_t pos_index1, size_t pos_index2, - size_t pos_index3); - - void tail_process(std::vector<block_pos> &vblkpos1, - std::vector<block_pos> &vblkpos2); - - void cut_range(range_pos rng); - - void merge_range_pos(range_pos rng); - - void extract_ranges(range_pos range_input); - // - //------------------------------------------------------------------------ - // function : function_merge_range_pos - /// @brief create a function_t with a call to merge_range_pos, and insert - /// in the stack of the backbone - // - /// @param rng_input : range of positions of blocks in the index to merge - /// @param son_counter : atomic variable which is decremented when finish - /// the function. This variable is used for to know - /// when are finished all the function_t created - /// inside an object - /// @param error : global indicator of error. - /// - //------------------------------------------------------------------------ - void function_merge_range_pos(const range_pos &rng_input, atomic_t &counter, - bool &error) - { - bscu::atomic_add(counter, 1); - function_t f1 = [this, rng_input, &counter, &error]( ) -> void - { - if (not error) - { - try - { - this->merge_range_pos (rng_input); - } - catch (std::bad_alloc &ba) - { - error = true; - }; - } - bscu::atomic_sub (counter, 1); - }; - bk.works.emplace_back(f1); - } - ; - // - //------------------------------------------------------------------------ - // function : function_cut_range - /// @brief create a function_t with a call to cut_range, and inser in - /// the stack of the backbone - // - /// @param rng_input : range of positions in the index to cut - /// @param counter : atomic variable which is decremented when finish - /// the function. This variable is used for to know - /// when are finished all the function_t created - /// inside an object - /// @param error : global indicator of error. - //------------------------------------------------------------------------ - void function_cut_range(const range_pos &rng_input, atomic_t &counter, - bool &error) - { - bscu::atomic_add(counter, 1); - function_t f1 = [this, rng_input, &counter, &error]( ) -> void - { - if (not error) - { - try - { - this->cut_range (rng_input); - } - catch (std::bad_alloc &) - { - error = true; - }; - } - bscu::atomic_sub (counter, 1); - }; - bk.works.emplace_back(f1); - } - - -//---------------------------------------------------------------------------- -}; -// end struct merge_blocks -//---------------------------------------------------------------------------- -// -//############################################################################ -// ## -// ## -// N O N I N L I N E F U N C T I O N S ## -// ## -// ## -//############################################################################ -// -//------------------------------------------------------------------------- -// function : merge_blocks -/// @brief make the indirect merge of the two range_pos defined by their index -/// position [pos_index1, pos_index2 ) and [ pos_index2, pos_index3 ) -// -/// @param bkb : backbone with all the data to sort , and the internal data -/// structures of the algorithm -/// @param pos_index1 : first position of the first range in the index -/// @param pos_index2 : last position of the first range and first position -/// of the second range in the index -/// @param pos_index3 : last position of the second range in the index -//------------------------------------------------------------------------- -template<uint32_t Block_size, uint32_t Group_size, class Iter_t, class Compare> -merge_blocks<Block_size, Group_size, Iter_t, Compare> -::merge_blocks( backbone_t &bkb, size_t pos_index1, size_t pos_index2, - size_t pos_index3) : bk(bkb) -{ - size_t nblock1 = pos_index2 - pos_index1; - size_t nblock2 = pos_index3 - pos_index2; - if (nblock1 == 0 or nblock2 == 0) return; - - //----------------------------------------------------------------------- - // Merging of the two intervals - //----------------------------------------------------------------------- - std::vector<block_pos> vpos1, vpos2; - vpos1.reserve(nblock1 + 1); - vpos2.reserve(nblock2 + 1); - - for (size_t i = pos_index1; i < pos_index2; ++i) - { - vpos1.emplace_back(bk.index[i].pos(), true); - }; - - for (size_t i = pos_index2; i < pos_index3; ++i) - { - vpos2.emplace_back(bk.index[i].pos(), false); - }; - //------------------------------------------------------------------- - // tail process - //------------------------------------------------------------------- - if (vpos2.back().pos() == (bk.nblock - 1) - and bk.range_tail.first != bk.range_tail.last) - { - tail_process(vpos1, vpos2); - nblock1 = vpos1.size(); - nblock2 = vpos2.size(); - }; - - compare_block_pos_t cmp_blk(bk.global_range.first, bk.cmp); - if (bk.error) return; - bscu::merge(vpos1.begin(), vpos1.end(), vpos2.begin(), vpos2.end(), - bk.index.begin() + pos_index1, cmp_blk); - if (bk.error) return; - // Extracting the ranges for to merge the elements - extract_ranges(range_pos(pos_index1, pos_index1 + nblock1 + nblock2)); -} - - -// -//------------------------------------------------------------------------- -// function : tail_process -/// @brief make the process when the second vector of block_pos to merge is -/// the last, and have an incomplete block ( tail) -// -/// @param vblkpos1 : first vector of block_pos elements to merge -/// @param vblkpos2 : second vector of block_pos elements to merge -//------------------------------------------------------------------------- -template<uint32_t Block_size, uint32_t Group_size, class Iter_t, class Compare> -void merge_blocks<Block_size, Group_size, Iter_t, Compare> -::tail_process( std::vector<block_pos> &vblkpos1, - std::vector<block_pos> &vblkpos2 ) -{ - if (vblkpos1.size() == 0 or vblkpos2.size() == 0) return; - - vblkpos2.pop_back(); - - size_t posback1 = vblkpos1.back().pos(); - range_it range_back1 = bk.get_range(posback1); - - if (bsc::is_mergeable(range_back1, bk.range_tail, bk.cmp)) - { - bsc::merge_uncontiguous(range_back1, bk.range_tail, bk.get_range_buf(), - bk.cmp); - if (vblkpos1.size() > 1) - { - size_t pos_aux = vblkpos1[vblkpos1.size() - 2].pos(); - range_it range_aux = bk.get_range(pos_aux); - - if (bsc::is_mergeable(range_aux, range_back1, bk.cmp)) - { - vblkpos2.emplace_back(posback1, false); - vblkpos1.pop_back(); - }; - }; - }; -} - -// -//------------------------------------------------------------------------- -// function : cut_range -/// @brief when the rng_input is greather than Group_size, this function divide -/// it in several parts creating function_t elements, which are inserted -/// in the concurrent stack of the backbone -// -/// @param rng_input : range to divide -//------------------------------------------------------------------------- -template<uint32_t Block_size, uint32_t Group_size, class Iter_t, class Compare> -void merge_blocks<Block_size, Group_size, Iter_t, Compare> -::cut_range(range_pos rng_input) -{ - if (rng_input.size() < Group_size) - { - merge_range_pos(rng_input); - return; - }; - - atomic_t counter(0); - size_t npart = (rng_input.size() + Group_size - 1) / Group_size; - size_t size_part = rng_input.size() / npart; - - size_t pos_ini = rng_input.first; - size_t pos_last = rng_input.last; - - while (pos_ini < pos_last) - { - size_t pos = pos_ini + size_part; - while (pos < pos_last - and bk.index[pos - 1].side() == bk.index[pos].side()) - { - ++pos; - }; - if (pos < pos_last) - { - merge_uncontiguous(bk.get_range(bk.index[pos - 1].pos()), - bk.get_range(bk.index[pos].pos()), - bk.get_range_buf(), bk.cmp); - } - else pos = pos_last; - if ((pos - pos_ini) > 1) - { - range_pos rng_aux(pos_ini, pos); - function_merge_range_pos(rng_aux, counter, bk.error); - }; - pos_ini = pos; - }; - bk.exec(counter); // wait until finish all the ranges -} - - -// -//------------------------------------------------------------------------- -// function : merge_range_pos -/// @brief make the indirect merge of the blocks inside the rng_input -// -/// @param rng_input : range of positions of the blocks to merge -//------------------------------------------------------------------------- -template<uint32_t Block_size, uint32_t Group_size, class Iter_t, class Compare> -void merge_blocks<Block_size, Group_size, Iter_t, Compare> -::merge_range_pos(range_pos rng_input) -{ - if (rng_input.size() < 2) return; - range_buf rbuf = bk.get_range_buf(); - - range_it rng_prev = bk.get_range(bk.index[rng_input.first].pos()); - move_forward(rbuf, rng_prev); - range_it rng_posx(rng_prev); - - for (size_t posx = rng_input.first + 1; posx != rng_input.last; ++posx) - { - rng_posx = bk.get_range(bk.index[posx].pos()); - bsc::merge_flow(rng_prev, rbuf, rng_posx, bk.cmp); - rng_prev = rng_posx; - - }; - move_forward(rng_posx, rbuf); -} -// -//------------------------------------------------------------------------- -// function : extract_ranges -/// @brief from a big range of positions of blocks in the index. Examine which -/// are mergeable, and generate a couple of ranges for to be merged. -/// With the ranges obtained generate function_t elements and are -/// inserted in the concurrent stack. -/// When the range obtained is smaller than Group_size, generate a -/// function_t calling to merge_range_pos, when is greater, generate a -/// function_t calling to cut_range -// -/// @param rpos range_input : range of the position in the index, where must -/// extract the ranges to merge -//------------------------------------------------------------------------- -template<uint32_t Block_size, uint32_t Group_size, class Iter_t, class Compare> -void merge_blocks<Block_size, Group_size, Iter_t, Compare> -::extract_ranges(range_pos range_input) -{ - if (range_input.size() < 2) return; - atomic_t counter(0); - - // The names with x are positions of the index - size_t posx_ini = range_input.first; - block_pos bp_posx_ini = bk.index[posx_ini]; - - range_it rng_max = bk.get_range(bp_posx_ini.pos()); - bool side_max = bp_posx_ini.side(); - - block_pos bp_posx; - range_it rng_posx = rng_max; - bool side_posx = side_max; - - for (size_t posx = posx_ini + 1; posx <= range_input.last; ++posx) - { - bool final = (posx == range_input.last); - bool mergeable = false; - - if (not final) - { - bp_posx = bk.index[posx]; - rng_posx = bk.get_range(bp_posx.pos()); - side_posx = bp_posx.side(); - mergeable = (side_max != side_posx - and is_mergeable(rng_max, rng_posx, bk.cmp)); - }; - if (bk.error) return; - if (final or not mergeable) - { - range_pos rp_final(posx_ini, posx); - if (rp_final.size() > 1) - { - if (rp_final.size() > Group_size) - { - function_cut_range(rp_final, counter, bk.error); - } - else - { - function_merge_range_pos(rp_final, counter, bk.error); - }; - }; - posx_ini = posx; - if (not final) - { - rng_max = rng_posx; - side_max = side_posx; - }; - } - else - { - if (bk.cmp(*(rng_max.back()), *(rng_posx.back()))) - { - rng_max = rng_posx; - side_max = side_posx; - }; - }; - }; - bk.exec(counter); -} -// -//**************************************************************************** -}; // End namespace blk_detail -}; // End namespace sort -}; // End namespace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/block_indirect_sort/blk_detail/move_blocks.hpp b/contrib/restricted/boost/boost/sort/block_indirect_sort/blk_detail/move_blocks.hpp deleted file mode 100644 index 6b556bcf472..00000000000 --- a/contrib/restricted/boost/boost/sort/block_indirect_sort/blk_detail/move_blocks.hpp +++ /dev/null @@ -1,284 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file move_blocks.hpp -/// @brief contains the class move_blocks, which is part of the -/// block_indirect_sort algorithm -/// -/// @author Copyright (c) 2016 Francisco Jose Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_PARALLEL_DETAIL_MOVE_BLOCKS_HPP -#define __BOOST_SORT_PARALLEL_DETAIL_MOVE_BLOCKS_HPP - -#include <atomic> -#include <boost/sort/block_indirect_sort/blk_detail/backbone.hpp> -#include <future> -#include <iostream> -#include <iterator> - -namespace boost -{ -namespace sort -{ -namespace blk_detail -{ -//---------------------------------------------------------------------------- -// USING SENTENCES -//---------------------------------------------------------------------------- -namespace bsc = boost::sort::common; -// -///--------------------------------------------------------------------------- -/// @struct move_blocks -/// @brief This class move the blocks, trnasforming a logical sort by an index, -/// in physical sort -//---------------------------------------------------------------------------- -template<uint32_t Block_size, uint32_t Group_size, class Iter_t, class Compare> -struct move_blocks -{ - //------------------------------------------------------------------------- - // D E F I N I T I O N S - //------------------------------------------------------------------------- - typedef move_blocks<Block_size, Group_size, Iter_t, Compare> this_type; - typedef typename std::iterator_traits<Iter_t>::value_type value_t; - typedef std::atomic<uint32_t> atomic_t; - typedef bsc::range<size_t> range_pos; - typedef bsc::range<Iter_t> range_it; - typedef bsc::range<value_t *> range_buf; - typedef std::function<void(void)> function_t; - typedef backbone<Block_size, Iter_t, Compare> backbone_t; - - //------------------------------------------------------------------------ - // V A R I A B L E S - //------------------------------------------------------------------------ - // Object with the elements to sort and all internal data structures of the - // algorithm - backbone_t &bk; - - //------------------------------------------------------------------------ - // F U N C T I O N S - //------------------------------------------------------------------------ - move_blocks(backbone_t &bkb); - - void move_sequence(const std::vector<size_t> &init_sequence); - - void move_long_sequence(const std::vector<size_t> &init_sequence); - // - //------------------------------------------------------------------------ - // function : function_move_sequence - /// @brief create a function_t with a call to move_sequence, and insert - /// in the stack of the backbone - /// - /// @param sequence :sequence of positions for to move the blocks - /// @param counter : atomic variable which is decremented when finish - /// the function. This variable is used for to know - /// when are finished all the function_t created - /// inside an object - /// @param error : global indicator of error. - //------------------------------------------------------------------------ - void function_move_sequence(std::vector<size_t> &sequence, - atomic_t &counter, bool &error) - { - bscu::atomic_add(counter, 1); - function_t f1 = [this, sequence, &counter, &error]( ) -> void - { - if (not error) - { - try - { - this->move_sequence (sequence); - } - catch (std::bad_alloc &) - { - error = true; - }; - } - bscu::atomic_sub (counter, 1); - }; - bk.works.emplace_back(f1); - } - - // - //------------------------------------------------------------------------ - // function : function_move_long_sequence - /// @brief create a function_t with a call to move_long_sequence, and - /// insert in the stack of the backbone - // - /// @param sequence :sequence of positions for to move the blocks - /// @param counter : atomic variable which is decremented when finish - /// the function. This variable is used for to know - /// when are finished all the function_t created - /// inside an object - /// @param error : global indicator of error. - //------------------------------------------------------------------------ - void function_move_long_sequence(std::vector<size_t> &sequence, - atomic_t &counter, bool &error) - { - bscu::atomic_add(counter, 1); - function_t f1 = [this, sequence, &counter, &error]( ) -> void - { - if (not error) - { - try - { - this->move_long_sequence (sequence); - } - catch (std::bad_alloc &) - { - error = true; - }; - } - bscu::atomic_sub (counter, 1); - }; - bk.works.emplace_back(f1); - } - ; -//--------------------------------------------------------------------------- -}; // end of struct move_blocks -//--------------------------------------------------------------------------- -// -//############################################################################ -// ## -// ## -// N O N I N L I N E F U N C T I O N S ## -// ## -// ## -//############################################################################ -// -//------------------------------------------------------------------------- -// function : move_blocks -/// @brief constructor of the class for to move the blocks to their true -/// position obtained from the index -// -/// @param bkb : backbone with the index and the blocks -//------------------------------------------------------------------------- -template<uint32_t Block_size, uint32_t Group_size, class Iter_t, class Compare> -move_blocks<Block_size, Group_size, Iter_t, Compare> -::move_blocks(backbone_t &bkb) : bk(bkb) -{ - std::vector<std::vector<size_t> > vsequence; - vsequence.reserve(bk.index.size() >> 1); - std::vector<size_t> sequence; - atomic_t counter(0); - - size_t pos_index_ini = 0, pos_index_src = 0, pos_index_dest = 0; - while (pos_index_ini < bk.index.size()) - { - while (pos_index_ini < bk.index.size() - and bk.index[pos_index_ini].pos() == pos_index_ini) - { - ++pos_index_ini; - }; - - if (pos_index_ini == bk.index.size()) break; - - sequence.clear(); - pos_index_src = pos_index_dest = pos_index_ini; - sequence.push_back(pos_index_ini); - - while (bk.index[pos_index_dest].pos() != pos_index_ini) - { - pos_index_src = bk.index[pos_index_dest].pos(); - sequence.push_back(pos_index_src); - - bk.index[pos_index_dest].set_pos(pos_index_dest); - pos_index_dest = pos_index_src; - }; - - bk.index[pos_index_dest].set_pos(pos_index_dest); - vsequence.push_back(sequence); - - if (sequence.size() < Group_size) - { - function_move_sequence(vsequence.back(), counter, bk.error); - } - else - { - function_move_long_sequence(vsequence.back(), counter, bk.error); - }; - }; - bk.exec(counter); -} -; -// -//------------------------------------------------------------------------- -// function : move_sequence -/// @brief move the blocks, following the positions of the init_sequence -// -/// @param init_sequence : vector with the positions from and where move the -/// blocks -//------------------------------------------------------------------------- -template<uint32_t Block_size, uint32_t Group_size, class Iter_t, class Compare> -void move_blocks<Block_size, Group_size, Iter_t, Compare> -::move_sequence(const std::vector<size_t> &init_sequence) -{ - range_buf rbuf = bk.get_range_buf(); - size_t pos_range2 = init_sequence[0]; - - range_it range2 = bk.get_range(pos_range2); - move_forward(rbuf, range2); - - for (size_t i = 1; i < init_sequence.size(); ++i) - { - pos_range2 = init_sequence[i]; - range_it range1(range2); - range2 = bk.get_range(pos_range2); - move_forward(range1, range2); - }; - move_forward(range2, rbuf); -}; -// -//------------------------------------------------------------------------- -// function : move_long_sequence -/// @brief move the blocks, following the positions of the init_sequence. -/// if the sequence is greater than Group_size, it is divided in small -/// sequences, creating function_t elements, for to be inserted in the -/// concurrent stack -// -/// @param init_sequence : vector with the positions from and where move the -/// blocks -//------------------------------------------------------------------------- -template<uint32_t Block_size, uint32_t Group_size, class Iter_t, class Compare> -void move_blocks<Block_size, Group_size, Iter_t, Compare> -::move_long_sequence(const std::vector<size_t> &init_sequence) -{ - if (init_sequence.size() < Group_size) return move_sequence(init_sequence); - - size_t npart = (init_sequence.size() + Group_size - 1) / Group_size; - size_t size_part = init_sequence.size() / npart; - atomic_t son_counter(0); - - std::vector<size_t> sequence; - sequence.reserve(size_part); - - std::vector<size_t> index_seq; - index_seq.reserve(npart); - - auto it_pos = init_sequence.begin(); - for (size_t i = 0; i < (npart - 1); ++i, it_pos += size_part) - { - sequence.assign(it_pos, it_pos + size_part); - index_seq.emplace_back(*(it_pos + size_part - 1)); - function_move_sequence(sequence, son_counter, bk.error); - }; - - sequence.assign(it_pos, init_sequence.end()); - index_seq.emplace_back(init_sequence.back()); - function_move_sequence(sequence, son_counter, bk.error); - - bk.exec(son_counter); - if (bk.error) return; - move_long_sequence(index_seq); -} - -// -//**************************************************************************** -}; // End namespace blk_detail -}; // End namespace sort -}; // End namespace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/block_indirect_sort/blk_detail/parallel_sort.hpp b/contrib/restricted/boost/boost/sort/block_indirect_sort/blk_detail/parallel_sort.hpp deleted file mode 100644 index 98c0e48a5c3..00000000000 --- a/contrib/restricted/boost/boost/sort/block_indirect_sort/blk_detail/parallel_sort.hpp +++ /dev/null @@ -1,236 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file parallel_sort.hpp -/// @brief Contains the parallel_sort class, which is part of the -/// block_indirect_sort algorithm -/// -/// @author Copyright (c) 2016 Francisco Jose Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_PARALLEL_DETAIL_PARALLEL_SORT_HPP -#define __BOOST_SORT_PARALLEL_DETAIL_PARALLEL_SORT_HPP - -#include <boost/sort/block_indirect_sort/blk_detail/backbone.hpp> -#include <boost/sort/pdqsort/pdqsort.hpp> -#include <boost/sort/common/pivot.hpp> - -namespace boost -{ -namespace sort -{ -namespace blk_detail -{ - -//---------------------------------------------------------------------------- -// USING SENTENCES -//---------------------------------------------------------------------------- -namespace bsc = boost::sort::common; -namespace bscu = bsc::util; -using bscu::nbits64; -using bsc::pivot9; -using boost::sort::pdqsort; -// -///--------------------------------------------------------------------------- -/// @struct parallel_sort -/// @brief This class do a parallel sort, using the quicksort filtering, -/// splitting the data until the number of elements is smaller than a -/// predefined value (max_per_thread) -//---------------------------------------------------------------------------- -template<uint32_t Block_size, class Iter_t, class Compare> -struct parallel_sort -{ - //------------------------------------------------------------------------- - // D E F I N I T I O N S - //------------------------------------------------------------------------- - typedef typename std::iterator_traits<Iter_t>::value_type value_t; - typedef std::atomic<uint32_t> atomic_t; - typedef std::function<void(void)> function_t; - typedef backbone<Block_size, Iter_t, Compare> backbone_t; - - //------------------------------------------------------------------------ - // V A R I A B L E S - //------------------------------------------------------------------------ - // reference to a object with all the data to sort - backbone_t &bk; - - // maximun number of element to sort woth 1 thread - size_t max_per_thread; - - // atomic counter for to detect the end of the works created inside - // the object - atomic_t counter; - - //------------------------------------------------------------------------ - // F U N C T I O N S - //------------------------------------------------------------------------ - parallel_sort(backbone_t &bkbn, Iter_t first, Iter_t last); - - void divide_sort(Iter_t first, Iter_t last, uint32_t level); - // - //------------------------------------------------------------------------ - // function : function_divide_sort - /// @brief create a function_t with a call to divide_sort, and inser in - /// the stack of the backbone - // - /// @param first : iterator to the first element of the range to divide - /// @param last : iterator to the next element after the last element of - /// the range to divide - /// @param level : level of depth in the division.When zero call to - /// pdqsort - /// @param counter : atomic variable which is decremented when finish - /// the function. This variable is used for to know - /// when are finished all the function_t created - /// inside an object - /// @param error : global indicator of error. - //------------------------------------------------------------------------ - void function_divide_sort(Iter_t first, Iter_t last, uint32_t level, - atomic_t &counter, bool &error) - { - bscu::atomic_add(counter, 1); - function_t f1 = [this, first, last, level, &counter, &error]( ) - { - if (not error) - { - try - { - this->divide_sort (first, last, level); - } - catch (std::bad_alloc &) - { - error = true; - }; - }; - bscu::atomic_sub (counter, 1); - }; - bk.works.emplace_back(f1); - }; - -//-------------------------------------------------------------------------- -};// end struct parallel_sort -//-------------------------------------------------------------------------- -// -//############################################################################ -// ## -// ## -// N O N I N L I N E F U N C T I O N S ## -// ## -// ## -//############################################################################ -// -//------------------------------------------------------------------------ -// function : parallel_sort -/// @brief constructor of the class -/// @param [in] bkbn : backbone struct with all the information to sort -/// @param [in] first : iterator to the first element to sort -/// @param [in] last : iterator to the next element after the last -//------------------------------------------------------------------------ -template<uint32_t Block_size, class Iter_t, class Compare> -parallel_sort<Block_size, Iter_t, Compare> -::parallel_sort(backbone_t &bkbn, Iter_t first, Iter_t last) - : bk(bkbn), counter(0) -{ - assert((last - first) >= 0); - size_t nelem = size_t(last - first); - - //------------------- check if sort -------------------------------------- - bool sorted = true; - for (Iter_t it1 = first, it2 = first + 1; - it2 != last and (sorted = not bk.cmp(*it2, *it1)); it1 = it2++); - if (sorted) return; - - //------------------- check if reverse sort --------------------------- - sorted = true; - for (Iter_t it1 = first, it2 = first + 1; - it2 != last and (sorted = not bk.cmp(*it1, *it2)); it1 = it2++); - - if (sorted) - { - size_t nelem2 = nelem >> 1; - Iter_t it1 = first, it2 = last - 1; - for (size_t i = 0; i < nelem2; ++i) - std::swap(*(it1++), *(it2--)); - return; - }; - - //-------------------max_per_thread --------------------------- - uint32_t nbits_size = (nbits64(sizeof(value_t))) >> 1; - if (nbits_size > 5) nbits_size = 5; - max_per_thread = 1 << (18 - nbits_size); - - uint32_t level = ((nbits64(nelem / max_per_thread)) * 3) / 2; - - //---------------- check if only single thread ----------------------- - if (nelem < (max_per_thread)) - { - pdqsort(first, last, bk.cmp); - return; - }; - if (not bk.error) divide_sort(first, last, level); - - // wait until all the parts are finished - bk.exec(counter); -}; - -//------------------------------------------------------------------------ -// function : divide_sort -/// @brief this function divide the data in two part, for to be sorted in -/// a parallel mode -/// @param first : iterator to the first element to sort -/// @param last : iterator to the next element after the last -/// @param level : level of depth before call to pdqsort -//------------------------------------------------------------------------ -template<uint32_t Block_size, class Iter_t, class Compare> -void parallel_sort<Block_size, Iter_t, Compare> -::divide_sort(Iter_t first, Iter_t last, uint32_t level) -{ - //------------------- check if sort ----------------------------------- - bool sorted = true; - for (Iter_t it1 = first, it2 = first + 1; - it2 != last and (sorted = not bk.cmp(*it2, *it1)); it1 = it2++); - if (sorted) return; - - //---------------- check if finish the subdivision ------------------- - size_t nelem = last - first; - if (level == 0 or nelem < (max_per_thread)) - { - return pdqsort(first, last, bk.cmp); - }; - - //-------------------- pivoting ---------------------------------- - pivot9(first, last, bk.cmp); - const value_t &val = const_cast<value_t &>(*first); - Iter_t c_first = first + 1, c_last = last - 1; - - while (bk.cmp(*c_first, val)) ++c_first; - while (bk.cmp(val, *c_last)) --c_last; - - while (not (c_first > c_last)) - { - std::swap(*(c_first++), *(c_last--)); - while (bk.cmp(*c_first, val)) - ++c_first; - while (bk.cmp(val, *c_last)) - --c_last; - }; - - std::swap(*first, *c_last); - - // insert the work of the second half in the stack of works - function_divide_sort(c_first, last, level - 1, counter, bk.error); - if (bk.error) return; - - // The first half is done by the same thread - function_divide_sort(first, c_last, level - 1, counter, bk.error); -}; -// -//**************************************************************************** -};// End namespace blk_detail -};// End namespace sort -};// End namespace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/block_indirect_sort/block_indirect_sort.hpp b/contrib/restricted/boost/boost/sort/block_indirect_sort/block_indirect_sort.hpp deleted file mode 100644 index 62abde29a50..00000000000 --- a/contrib/restricted/boost/boost/sort/block_indirect_sort/block_indirect_sort.hpp +++ /dev/null @@ -1,501 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file block_indirect_sort.hpp -/// @brief block indirect sort algorithm -/// -/// @author Copyright (c) 2016 Francisco Jose Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_PARALLEL_DETAIL_BLOCK_INDIRECT_SORT_HPP -#define __BOOST_SORT_PARALLEL_DETAIL_BLOCK_INDIRECT_SORT_HPP - -#include <atomic> -#include <boost/sort/block_indirect_sort/blk_detail/merge_blocks.hpp> -#include <boost/sort/block_indirect_sort/blk_detail/move_blocks.hpp> -#include <boost/sort/block_indirect_sort/blk_detail/parallel_sort.hpp> -#include <boost/sort/pdqsort/pdqsort.hpp> -#include <boost/sort/common/util/traits.hpp> -#include <boost/sort/common/util/algorithm.hpp> -#include <future> -#include <iterator> - -// This value is the minimal number of threads for to use the -// block_indirect_sort algorithm -#define BOOST_NTHREAD_BORDER 6 - -namespace boost -{ -namespace sort -{ -namespace blk_detail -{ -//--------------------------------------------------------------------------- -// USING SENTENCES -//--------------------------------------------------------------------------- -namespace bs = boost::sort; -namespace bsc = bs::common; -namespace bscu = bsc::util; -using bscu::compare_iter; -using bscu::value_iter; -using bsc::range; -using bsc::destroy; -using bsc::initialize; -using bscu::nbits64; -using bs::pdqsort; -using bscu::enable_if_string; -using bscu::enable_if_not_string; -using bscu::tmsb; -// -///--------------------------------------------------------------------------- -/// @struct block_indirect_sort -/// @brief This class is the entry point of the block indirect sort. The code -/// of this algorithm is divided in several classes: -/// bis/block.hpp : basic structures used in the algorithm -/// bis/backbone.hpp : data used by all the classes -/// bis/merge_blocks.hpp : merge the internal blocks -/// bis/move_blocks.hpp : move the blocks, and obtain all the elements -/// phisicaly sorted -/// bis/parallel_sort.hpp : make the parallel sort of each part in the -/// initial division of the data -/// -//---------------------------------------------------------------------------- -template<uint32_t Block_size, uint32_t Group_size, class Iter_t, - class Compare = compare_iter<Iter_t> > -struct block_indirect_sort -{ - //------------------------------------------------------------------------ - // D E F I N I T I O N S - //------------------------------------------------------------------------ - typedef typename std::iterator_traits<Iter_t>::value_type value_t; - typedef std::atomic<uint32_t> atomic_t; - typedef range<size_t> range_pos; - typedef range<Iter_t> range_it; - typedef range<value_t *> range_buf; - typedef std::function<void(void)> function_t; - - // classes used in the internal operations of the algorithm - typedef block_pos block_pos_t; - typedef block<Block_size, Iter_t> block_t; - typedef backbone<Block_size, Iter_t, Compare> backbone_t; - typedef parallel_sort<Block_size, Iter_t, Compare> parallel_sort_t; - - typedef merge_blocks<Block_size, Group_size, Iter_t, Compare> merge_blocks_t; - typedef move_blocks<Block_size, Group_size, Iter_t, Compare> move_blocks_t; - typedef compare_block_pos<Block_size, Iter_t, Compare> compare_block_pos_t; - // - //------------------------------------------------------------------------ - // V A R I A B L E S A N D C O N S T A N T S - //------------------------------------------------------------------------ - // contains the data and the internal data structures of the algorithm for - // to be shared between the classes which are part of the algorithm - backbone_t bk; - // atomic counter for to detect the end of the works created inside - // the object - atomic_t counter; - // pointer to the uninitialized memory used for the thread buffers - value_t *ptr; - // indicate if the memory pointed by ptr is initialized - bool construct; - // range from extract the buffers for the threads - range_buf rglobal_buf; - // number of threads to use - uint32_t nthread; - // - //------------------------------------------------------------------------ - // F U N C T I O N S - //------------------------------------------------------------------------ - - block_indirect_sort(Iter_t first, Iter_t last, Compare cmp, uint32_t nthr); - - block_indirect_sort(Iter_t first, Iter_t last) : - block_indirect_sort(first, last, Compare(), - std::thread::hardware_concurrency()) { } - - - block_indirect_sort(Iter_t first, Iter_t last, Compare cmp) : - block_indirect_sort(first, last, cmp, - std::thread::hardware_concurrency()) { } - - - block_indirect_sort(Iter_t first, Iter_t last, uint32_t nthread) : - block_indirect_sort(first, last, Compare(), nthread){} - - - // - //------------------------------------------------------------------------ - // function :destroy_all - /// @brief destructor all the data structures of the class (if the memory - /// is constructed, is destroyed) and return the uninitialized - /// memory - //------------------------------------------------------------------------ - void destroy_all(void) - { - if (ptr != nullptr) - { - if (construct) - { - destroy(rglobal_buf); - construct = false; - }; - std::return_temporary_buffer(ptr); - ptr = nullptr; - }; - } - // - //------------------------------------------------------------------------ - // function :~block_indirect_sort - /// @brief destructor of the class (if the memory is constructed, is - /// destroyed) and return the uninitialized memory - //------------------------------------------------------------------------ - ~block_indirect_sort(void) - { - destroy_all(); - } - - void split_range(size_t pos_index1, size_t pos_index2, - uint32_t level_thread); - - void start_function(void); - -//------------------------------------------------------------------------- -}; // End class block_indirect_sort -//---------------------------------------------------------------------------- -// -//############################################################################ -// ## -// ## -// N O N I N L I N E F U N C T I O N S ## -// ## -// ## -//############################################################################ -// -//------------------------------------------------------------------------- -// function : block_indirect_sort -/// @brief begin with the execution of the functions stored in works -/// @param first : iterator to the first element of the range to sort -/// @param last : iterator after the last element to the range to sort -/// @param comp : object for to compare two elements pointed by Iter_t -/// iterators -/// @param nthr : Number of threads to use in the process.When this value -/// is lower than 2, the sorting is done with 1 thread -//------------------------------------------------------------------------- -template<uint32_t Block_size, uint32_t Group_size, class Iter_t, class Compare> -block_indirect_sort<Block_size, Group_size, Iter_t, Compare> -::block_indirect_sort(Iter_t first, Iter_t last, Compare cmp, uint32_t nthr) -: bk(first, last, cmp), counter(0), ptr(nullptr), construct(false), - nthread(nthr) -{ - try - { - assert((last - first) >= 0); - size_t nelem = size_t(last - first); - if (nelem == 0) return; - - //------------------- check if sort ----------------------------------- - bool sorted = true; - for (Iter_t it1 = first, it2 = first + 1; it2 != last and (sorted = - not bk.cmp(*it2, *it1)); it1 = it2++); - if (sorted) return; - - //------------------- check if reverse sort --------------------------- - sorted = true; - for (Iter_t it1 = first, it2 = first + 1; it2 != last and (sorted = - not bk.cmp(*it1, *it2)); it1 = it2++); - - if (sorted) - { - size_t nelem2 = nelem >> 1; - Iter_t it1 = first, it2 = last - 1; - for (size_t i = 0; i < nelem2; ++i) - { - std::swap(*(it1++), *(it2--)); - }; - return; - }; - - //---------------- check if only single thread ----------------------- - size_t nthreadmax = nelem / (Block_size * Group_size) + 1; - if (nthread > nthreadmax) nthread = (uint32_t) nthreadmax; - - uint32_t nbits_size = (nbits64(sizeof(value_t)) >> 1); - if (nbits_size > 5) nbits_size = 5; - size_t max_per_thread = 1 << (18 - nbits_size); - - if (nelem < (max_per_thread) or nthread < 2) - { - //intro_sort (first, last, bk.cmp); - pdqsort(first, last, bk.cmp); - return; - }; - - //----------- creation of the temporary buffer -------------------- - ptr = std::get_temporary_buffer<value_t>(Block_size * nthread).first; - if (ptr == nullptr) - { - bk.error = true; - throw std::bad_alloc(); - }; - - rglobal_buf = range_buf(ptr, ptr + (Block_size * nthread)); - initialize(rglobal_buf, *first); - construct = true; - - // creation of the buffers for the threads - std::vector<value_t *> vbuf(nthread); - for (uint32_t i = 0; i < nthread; ++i) - { - vbuf[i] = ptr + (i * Block_size); - }; - - // Insert the first work in the stack - bscu::atomic_write(counter, 1); - function_t f1 = [&]( ) - { - start_function ( ); - bscu::atomic_sub (counter, 1); - }; - bk.works.emplace_back(f1); - - //--------------------------------------------------------------------- - // PROCESS - //--------------------------------------------------------------------- - std::vector<std::future<void> > vfuture(nthread); - - // The function launched with the futures is "execute the functions of - // the stack until this->counter is zero - // vbuf[i] is the memory from the main thread for to configure the - // thread local buffer - for (uint32_t i = 0; i < nthread; ++i) - { - auto f1 = [=, &vbuf]( ) - { bk.exec (vbuf[i], this->counter);}; - vfuture[i] = std::async(std::launch::async, f1); - }; - for (uint32_t i = 0; i < nthread; ++i) - vfuture[i].get(); - if (bk.error) throw std::bad_alloc(); - } - catch (std::bad_alloc &) - { - destroy_all(); - throw; - } -}; -// -//----------------------------------------------------------------------------- -// function : split_rage -/// @brief this function splits a range of positions in the index, and -/// depending of the size, sort directly or make to a recursive call -/// to split_range -/// @param pos_index1 : first position in the index -/// @param pos_index2 : position after the last in the index -/// @param level_thread : depth of the call. When 0 sort the blocks -//----------------------------------------------------------------------------- -template<uint32_t Block_size, uint32_t Group_size, class Iter_t, class Compare> -void block_indirect_sort<Block_size, Group_size, Iter_t, Compare> -::split_range(size_t pos_index1, size_t pos_index2, uint32_t level_thread) -{ - size_t nblock = pos_index2 - pos_index1; - - //------------------------------------------------------------------------- - // In the blocks not sorted, the physical position is the logical position - //------------------------------------------------------------------------- - Iter_t first = bk.get_block(pos_index1).first; - Iter_t last = bk.get_range(pos_index2 - 1).last; - - if (nblock < Group_size) - { - pdqsort(first, last, bk.cmp); - return; - }; - - size_t pos_index_mid = pos_index1 + (nblock >> 1); - atomic_t son_counter(1); - - //------------------------------------------------------------------------- - // Insert in the stack the work for the second part, and the actual thread, - // execute the first part - //------------------------------------------------------------------------- - if (level_thread != 0) - { - auto f1 = [=, &son_counter]( ) - { - split_range (pos_index_mid, pos_index2, level_thread - 1); - bscu::atomic_sub (son_counter, 1); - }; - bk.works.emplace_back(f1); - if (bk.error) return; - split_range(pos_index1, pos_index_mid, level_thread - 1); - } - else - { - Iter_t mid = first + ((nblock >> 1) * Block_size); - auto f1 = [=, &son_counter]( ) - { - parallel_sort_t (bk, mid, last); - bscu::atomic_sub (son_counter, 1); - }; - bk.works.emplace_back(f1); - if (bk.error) return; - parallel_sort_t(bk, first, mid); - }; - bk.exec(son_counter); - if (bk.error) return; - merge_blocks_t(bk, pos_index1, pos_index_mid, pos_index2); -}; - -// -//----------------------------------------------------------------------------- -// function : start_function -/// @brief this function init the process. When the number of threads is lower -/// than a predefined value, sort the elements with a parallel pdqsort. -//----------------------------------------------------------------------------- -template<uint32_t Block_size, uint32_t Group_size, class Iter_t, class Compare> -void block_indirect_sort<Block_size, Group_size, Iter_t, Compare> -::start_function(void) -{ - if (nthread < BOOST_NTHREAD_BORDER) - { - parallel_sort_t(bk, bk.global_range.first, bk.global_range.last); - } - else - { - size_t level_thread = nbits64(nthread - 1) - 1; - split_range(0, bk.nblock, level_thread - 1); - if (bk.error) return; - move_blocks_t k(bk); - }; -}; - -///--------------------------------------------------------------------------- -// function block_indirect_sort_call -/// @brief This class is select the block size in the block_indirect_sort -/// algorithm depending of the type and size of the data to sort -/// -//---------------------------------------------------------------------------- -template <class Iter_t, class Compare, - enable_if_string<value_iter<Iter_t>> * = nullptr> -inline void block_indirect_sort_call(Iter_t first, Iter_t last, Compare cmp, - uint32_t nthr) -{ - block_indirect_sort<128, 128, Iter_t, Compare>(first, last, cmp, nthr); -}; - -template<size_t Size> -struct block_size -{ - static constexpr const uint32_t BitsSize = - (Size == 0) ? 0 : (Size > 256) ? 9 : tmsb[Size - 1]; - static constexpr const uint32_t sz[10] = - { 4096, 4096, 4096, 4096, 2048, 1024, 768, 512, 256, 128 }; - static constexpr const uint32_t data = sz[BitsSize]; -}; -// -///--------------------------------------------------------------------------- -/// @struct block_indirect_sort_call -/// @brief This class is select the block size in the block_indirect_sort -/// algorithm depending of the type and size of the data to sort -/// -//---------------------------------------------------------------------------- -template <class Iter_t, class Compare, - enable_if_not_string<value_iter<Iter_t>> * = nullptr> -inline void block_indirect_sort_call (Iter_t first, Iter_t last, Compare cmp, - uint32_t nthr) -{ - block_indirect_sort<block_size<sizeof (value_iter<Iter_t> )>::data, 64, - Iter_t, Compare> (first, last, cmp, nthr); -}; - -// -//**************************************************************************** -}; // End namespace blk_detail -//**************************************************************************** -// -namespace bscu = boost::sort::common::util; -// -//############################################################################ -// ## -// ## -// B L O C K _ I N D I R E C T _ S O R T ## -// ## -// ## -//############################################################################ -// -//----------------------------------------------------------------------------- -// function : block_indirect_sort -/// @brief parallel sample sort algorithm (stable sort) -/// -/// @param first : iterator to the first element of the range to sort -/// @param last : iterator after the last element to the range to sort -//----------------------------------------------------------------------------- -template<class Iter_t> -void block_indirect_sort(Iter_t first, Iter_t last) -{ - typedef bscu::compare_iter<Iter_t> Compare; - blk_detail::block_indirect_sort_call (first, last, Compare(), - std::thread::hardware_concurrency()); -} - -// -//----------------------------------------------------------------------------- -// function : block_indirect_sort -/// @brief parallel sample sort algorithm (stable sort) -/// -/// @param first : iterator to the first element of the range to sort -/// @param last : iterator after the last element to the range to sort -/// @param nthread : Number of threads to use in the process. When this value -/// is lower than 2, the sorting is done with 1 thread -//----------------------------------------------------------------------------- -template<class Iter_t> -void block_indirect_sort(Iter_t first, Iter_t last, uint32_t nthread) -{ - typedef bscu::compare_iter<Iter_t> Compare; - blk_detail::block_indirect_sort_call(first, last, Compare(), nthread); -} -// -//----------------------------------------------------------------------------- -// function : block_indirect_sort -/// @brief parallel sample sort algorithm (stable sort) -/// -/// @param first : iterator to the first element of the range to sort -/// @param last : iterator after the last element to the range to sort -/// @param comp : object for to compare two elements pointed by Iter_t -/// iterators -//----------------------------------------------------------------------------- -template <class Iter_t, class Compare, - bscu::enable_if_not_integral<Compare> * = nullptr> -void block_indirect_sort(Iter_t first, Iter_t last, Compare comp) -{ - blk_detail::block_indirect_sort_call (first, last, comp, - std::thread::hardware_concurrency()); -} - -// -//----------------------------------------------------------------------------- -// function : block_indirect_sort -/// @brief parallel sample sort algorithm (stable sort) -/// -/// @param first : iterator to the first element of the range to sort -/// @param last : iterator after the last element to the range to sort -/// @param comp : object for to compare two elements pointed by Iter_t -/// iterators -/// @param nthread : Number of threads to use in the process. When this value -/// is lower than 2, the sorting is done with 1 thread -//----------------------------------------------------------------------------- -template<class Iter_t, class Compare> -void block_indirect_sort (Iter_t first, Iter_t last, Compare comp, - uint32_t nthread) -{ - blk_detail::block_indirect_sort_call(first, last, comp, nthread); -} -// -//**************************************************************************** -}; // End namespace sort -}; // End namespace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/common/deque_cnc.hpp b/contrib/restricted/boost/boost/sort/common/deque_cnc.hpp deleted file mode 100644 index eb3b31ee6ad..00000000000 --- a/contrib/restricted/boost/boost/sort/common/deque_cnc.hpp +++ /dev/null @@ -1,366 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file deque_cnc.hpp -/// @brief This file contains the implementation of the several types of -/// recursive fastmutex for read and write -/// -/// @author Copyright (c) 2010 2015 Francisco José Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanyingfile LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __TOOLS_DEQUE_CNC_HPP -#define __TOOLS_DEQUE_CNC_HPP - -#include <sort/tools/spinlock.hpp> -#include <vector> -#include <deque> - -namespace sort -{ -namespace tools -{ - -//########################################################################### -// ## -// ################################################################ ## -// # # ## -// # C L A S S # ## -// # S T A C K _ C N C # ## -// # # ## -// ################################################################ ## -// ## -//########################################################################### -// -//--------------------------------------------------------------------------- -/// @class deque_cnc -/// @brief This class is a concurrent stack controled by a spin_lock -/// @remarks -//--------------------------------------------------------------------------- -template<typename T, typename Allocator = std::allocator<T> > -class deque_cnc -{ -public: - //----------------------------------------------------------------------- - // D E F I N I T I O N S - //----------------------------------------------------------------------- - typedef std::deque<T, Allocator> deque_t; - typedef typename deque_t::size_type size_type; - typedef typename deque_t::difference_type difference_type; - typedef typename deque_t::value_type value_type; - typedef typename deque_t::pointer pointer; - typedef typename deque_t::const_pointer const_pointer; - typedef typename deque_t::reference reference; - typedef typename deque_t::const_reference const_reference; - typedef typename deque_t::allocator_type allocator_type; - -protected: - //------------------------------------------------------------------------ - // VARIABLES - //------------------------------------------------------------------------ - deque_t dq; - mutable spinlock spl; - -public: - // - //----------------------------------------------------------------------- - // C O N S T R U C T O R S A N D D E S T R U C T O R - //----------------------------------------------------------------------- - // - //----------------------------------------------------------------------- - // function : deque_cnc - /// @brief constructor - //---------------------------------------------------------------------- - explicit inline deque_cnc(void): dq() { }; -// - //---------------------------------------------------------------------- - // function : deque_cnc - /// @brief constructor - /// @param [in] ALLC : Allocator - //---------------------------------------------------------------------- - explicit inline deque_cnc(const Allocator &ALLC): dq(ALLC){ }; - // - //---------------------------------------------------------------------- - // function : ~deque_cnc - /// @brief Destructor - //---------------------------------------------------------------------- - virtual ~deque_cnc(void){ dq.clear(); }; - // - //---------------------------------------------------------------------- - // function : clear - /// @brief Delete all the elements of the deque_cnc. - //---------------------------------------------------------------------- - void clear(void) - { - std::lock_guard < spinlock > S(spl); - dq.clear(); - }; - // - //------------------------------------------------------------------------ - // function : swap - /// @brief swap the data between the two deque_cnc - /// @param [in] A : deque_cnc to swap - /// @return none - //----------------------------------------------------------------------- - void swap(deque_cnc & A) noexcept - { - if (this == &A) return; - std::lock_guard < spinlock > S(spl); - dq.swap(A.dq); - }; - // - //----------------------------------------------------------------------- - // S I Z E , M A X _ S I Z E , R E S I Z E - // C A P A C I T Y , E M P T Y , R E S E R V E - //----------------------------------------------------------------------- - // - //------------------------------------------------------------------------ - // function : size - /// @brief return the number of elements in the deque_cnc - /// @return number of elements in the deque_cnc - //------------------------------------------------------------------------ - size_type size(void) const noexcept - { - std::lock_guard < spinlock > S(spl); - return dq.size(); - }; - // - //------------------------------------------------------------------------ - // function :max_size - /// @brief return the maximun size of the container - /// @return maximun size of the container - //------------------------------------------------------------------------ - size_type max_size(void) const noexcept - { - std::lock_guard < spinlock > S(spl); - return (dq.max_size()); - }; - // - //------------------------------------------------------------------------- - // function : shrink_to_fit - /// @brief resize the current vector size and change to size.\n - /// If sz is smaller than the current size, delete elements to end\n - /// If sz is greater than the current size, insert elements to the - /// end with the value c - /// @param [in] sz : new size of the deque_cnc after the resize - /// @param [in] c : Value to insert if sz is greather than the current size - /// @return none - //------------------------------------------------------------------------ - void shrink_to_fit() - { - std::lock_guard < spinlock > S(spl); - dq.shrink_to_fit(); - }; - // - //------------------------------------------------------------------------ - // function : empty - /// @brief indicate if the map is empty - /// @return true if the map is empty, false in any other case - //------------------------------------------------------------------------ - bool empty(void) const noexcept - { - std::lock_guard < spinlock > S(spl); - return (dq.empty()); - }; - //--------------------------------------------------------------------------- - // function : push_back - /// @brief Insert one element in the back of the container - /// @param [in] D : value to insert. Can ve a value, a reference or an - /// rvalue - //--------------------------------------------------------------------------- - void push_back(const value_type & D) - { - std::lock_guard < spinlock > S(spl); - dq.push_back(D); - }; - - //------------------------------------------------------------------------ - // function : emplace_back - /// @brief Insert one element in the back of the container - /// @param [in] args :group of arguments for to build the object to insert - //------------------------------------------------------------------------- - template<class ... Args> - void emplace_back(Args && ... args) - { - std::lock_guard < spinlock > S(spl); - dq.emplace_back(std::forward <Args>(args) ...); - }; - //------------------------------------------------------------------------ - // function : push_back - /// @brief Insert one element in the back of the container - /// @param [in] D : deque to insert in the actual deque, inserting a copy - /// of the elements - /// @return reference to the deque after the insertion - //------------------------------------------------------------------------ - template<class Allocator2> - deque_cnc & push_back(const std::deque<value_type, Allocator2> & D) - { - std::lock_guard < spinlock > S(spl); - for (size_type i = 0; i < D.size(); ++i) - dq.push_back(D[i]); - return *this; - }; - //------------------------------------------------------------------------ - // function : push_back - /// @brief Insert one element in the back of the container - /// @param [in] D : deque to insert in the actual deque, inserting a move - /// of the elements - /// @return reference to the deque after the insertion - //------------------------------------------------------------------------ - deque_cnc & push_back(std::deque<value_type, Allocator> && D) - { - std::lock_guard < spinlock > S(spl); - for (size_type i = 0; i < D.size(); ++i) - dq.emplace_back(std::move(D[i])); - return *this; - }; - // - //------------------------------------------------------------------------ - // function :pop_back - /// @brief erase the last element of the container - //----------------------------------------------------------------------- - void pop_back(void) - { - std::lock_guard < spinlock > S(spl); - dq.pop_back(); - }; - // - //------------------------------------------------------------------------ - // function :pop_copy_back - /// @brief erase the last element and return a copy over P - /// @param [out] P : reference to a variable where copy the element - /// @return code of the operation - /// true - Element erased - /// false - Empty tree - //------------------------------------------------------------------------ - bool pop_copy_back(value_type & P) - { //-------------------------- begin ----------------------------- - std::lock_guard < spinlock > S(spl); - if (dq.size() == 0) return false; - P = dq.back(); - dq.pop_back(); - return true; - }; - // - //------------------------------------------------------------------------ - // function :pop_move_back - /// @brief erase the last element and move over P - /// @param [out] P : reference to a variable where move the element - /// @return code of the operation - /// true - Element erased - /// false - Empty tree - //------------------------------------------------------------------------ - bool pop_move_back(value_type & P) - { //-------------------------- begin ----------------------------- - std::lock_guard < spinlock > S(spl); - if (dq.size() == 0) return false; - P = std::move(dq.back()); - dq.pop_back(); - return true; - }; - - //------------------------------------------------------------------------ - // function : push_front - /// @brief Insert one copy of the element in the front of the container - /// @param [in] D : value to insert - //------------------------------------------------------------------------ - void push_front(const value_type & D) - { - std::lock_guard < spinlock > S(spl); - dq.push_front(D); - }; - - //------------------------------------------------------------------------ - // function : emplace_front - /// @brief Insert one element in the front of the container - /// @param [in] args :group of arguments for to build the object to insert - //------------------------------------------------------------------------- - template<class ... Args> - void emplace_front(Args && ... args) - { - std::lock_guard < spinlock > S(spl); - dq.emplace_front(std::forward <Args>(args) ...); - }; - //------------------------------------------------------------------------ - // function : push_front - /// @brief Insert a copy of the elements of the deque V1 in the front - /// of the container - /// @param [in] V1 : deque with the elements to insert - /// @return reference to the deque after the insertion - //------------------------------------------------------------------------ - template<class Allocator2> - deque_cnc & push_front(const std::deque<value_type, Allocator2> & V1) - { - std::lock_guard < spinlock > S(spl); - for (size_type i = 0; i < V1.size(); ++i) - dq.push_front(V1[i]); - return *this; - }; - //----------------------------------------------------------------------- - // function : push_front - /// @brief Insert a move of the elements of the deque V1 in the front - /// of the container - /// @param [in] V1 : deque with the elements to insert - /// @return reference to the deque after the insertion - //----------------------------------------------------------------------- - deque_cnc & push_front(std::deque<value_type, Allocator> && V1) - { - std::lock_guard < spinlock > S(spl); - for (size_type i = 0; i < V1.size(); ++i) - dq.emplace_front(std::move(V1[i])); - return *this; - }; - // - //----------------------------------------------------------------------- - // function :pop_front - /// @brief erase the first element of the container - //----------------------------------------------------------------------- - void pop_front(void) - { - std::lock_guard < spinlock > S(spl); - dq.pop_front(); - }; - // - //----------------------------------------------------------------------- - // function :pop_copy_front - /// @brief erase the first element of the tree and return a copy over P - /// @param [out] P : reference to a variable where copy the element - /// @return code of the operation - /// true- Element erased - /// false - Empty tree - //----------------------------------------------------------------------- - bool pop_copy_front(value_type & P) - { //-------------------------- begin ----------------------------- - std::lock_guard < spinlock > S(spl); - if (dq.size() == 0) return false; - P = dq.front(); - dq.pop_front(); - return true; - }; - // - //------------------------------------------------------------------------ - // function :pop_move_front - /// @brief erase the first element of the tree and return a move over P - /// @param [out] P : reference to a variable where move the element - /// @return code of the operation - /// true- Element erased - /// false - Empty tree - //------------------------------------------------------------------------ - bool pop_move_front(value_type & P) - { //-------------------------- begin ----------------------------- - std::lock_guard < spinlock > S(spl); - if (dq.size() == 0) return false; - P = std::move(dq.front()); - dq.pop_front(); - return true; - }; -}; -// end class deque_cnc - -//*************************************************************************** -};// end namespace tools -};// end namespace sort -//*************************************************************************** -#endif diff --git a/contrib/restricted/boost/boost/sort/common/file_vector.hpp b/contrib/restricted/boost/boost/sort/common/file_vector.hpp deleted file mode 100644 index 1dc62fc02fa..00000000000 --- a/contrib/restricted/boost/boost/sort/common/file_vector.hpp +++ /dev/null @@ -1,272 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file file_vector.hpp -/// @brief This file contains functions for to work with random data and files -/// Have functions for to create a vector with random data, and -/// functions for lo load a vector of numbers or strings from the file -/// -/// @author Copyright (c) 2015 Francisco José Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanyingfile LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_COMMON_FILE_VECTOR_HPP -#define __BOOST_SORT_COMMON_FILE_VECTOR_HPP - -#include <ios> -#include <cstdio> -#include <cstdlib> -#include <ciso646> -#include <vector> -#include <string> -#include <fstream> -#include <sstream> -#include <iostream> -#include <random> -#include <cstdint> - -namespace boost -{ -namespace sort -{ -namespace common -{ -// -//----------------------------------------------------------------------------- -// function : generate_file -/// @brief Generate a binary file filed with random numbers of 64 bits -/// @param [in] filename : name of the file -/// @param [in] NElem : number of 64 bits numbers to insert in the file -/// @exception -/// @return -/// @remarks -//----------------------------------------------------------------------------- -static int generate_file(const std::string & filename, size_t NElem) -{ //------------------------------- begin ---------------------------------- - std::ofstream ofile; - ofile.open(filename, std::ios_base::out | std::ios_base::binary | - std::ios_base::trunc); - if (ofile.bad()) - { - throw std::ios_base::failure("could not open file \n"); - }; - std::mt19937_64 my_rand(0); - - for (size_t i = 0; i < NElem; ++i) - { - uint64_t Aux = my_rand(); - ofile.write((char *) &Aux, 8); - } - ofile.close(); - return 0; -}; -// -//----------------------------------------------------------------------------- -// function : fill_vector_uint64 -/// @brief : fill a vector of uint64_t elements from a file -/// @param [in] filename : name of the file -/// @param [in] V : vector to fill -/// @param [in] NElem : number of elements for to read from the file -/// @exception -/// @return -/// @remarks -//----------------------------------------------------------------------------- -static int fill_vector_uint64(const std::string & filename, - std::vector<uint64_t> & V, size_t NElem) -{ //----------------------- begin ------------------------------------------ - std::ifstream input(filename, std::ios_base::in | std::ios_base::binary); - if (input.fail()) - { - throw std::ios_base::failure("could not open file \n"); - }; - //------------------------------------------------------------------------ - // Calculate the lenght of the file and the number of elements inside - //------------------------------------------------------------------------ - input.seekg(0, std::ios_base::end); - size_t length = input.tellg(); - size_t uCount = length / 8; - if (uCount < NElem) - { - throw std::ios_base::failure("incorrect lenght of the file\n"); - }; - V.clear(); - V.reserve(NElem); - - uint64_t Aux = 0; - input.seekg(0, std::ios_base::beg); - for (size_t i = 0; i < NElem; ++i) - { - input.read(reinterpret_cast<char *>(&Aux), 8); - V.push_back(Aux); - }; - input.close(); - return 0; -}; - -// -//----------------------------------------------------------------------------- -// function :write_file_uint64 -/// @brief Write a file with the contnt of a vector of Uint64_t elements -/// @param [in] V : vector from read the numbersl -/// @param [in] filename : name of the file -/// @exception -/// @return -/// @remarks -//----------------------------------------------------------------------------- -static int write_file_uint64 (const std::vector<uint64_t> & V, - const std::string & filename) -{ //--------------------------------- begin -------------------------------- - std::ofstream ofile; - ofile.open(filename, - std::ios_base::out | std::ios_base::binary - | std::ios_base::trunc); - if (ofile.bad()) - { - throw std::ios_base::failure("could not open file \n"); - }; - for (size_t i = 0; i < V.size(); ++i) - { - ofile.write((char *) &(V[i]), 8); - } - ofile.close(); - return 0; -}; -// -//----------------------------------------------------------------------------- -// function : fill_vector_string -/// @brief fill a vector of strings from a file -/// @param [in] filename : name of the file from read the strings -/// @param [in] V : vector where store the strings -/// @param [in] NElem : Number of strings for to read from the file -/// @exception -/// @return -/// @remarks -//----------------------------------------------------------------------------- -static int fill_vector_string (const std::string & filename, - std::vector<std::string> & V, size_t NElem) -{ //----------------------- begin ------------------------------------------ - std::ifstream input(filename, std::ios_base::in | std::ios_base::binary); - if (input.fail()) - { - throw std::ios_base::failure("could not open file \n"); - }; - //------------------------------------------------------------------------ - // Calculate the lenght of the file and the number of elements inside - //------------------------------------------------------------------------ - input.seekg(0, std::ios_base::end); - V.clear(); - V.reserve(NElem); - - std::string inval; - input.seekg(0, std::ios_base::beg); - - for (size_t i = 0; i < NElem; ++i) - { - if (!input.eof()) - { - input >> inval; - V.push_back(inval); - inval.clear(); - } - else - { - throw std::ios_base::failure("Insuficient lenght of the file\n"); - }; - }; - input.close(); - return 0; -}; - -// -//----------------------------------------------------------------------------- -// function :write_file_string -/// @brief : write a file with the strings of a vector -/// @param [in] V : vector from read the sttrings -/// @param [in] filename : file where store the strings -/// @exception -/// @return -/// @remarks -//----------------------------------------------------------------------------- -static int write_file_string (const std::vector<std::string> & V, - const std::string & filename) -{ //--------------------------------- begin -------------------------------- - std::ofstream ofile; - ofile.open(filename, - std::ios_base::out | std::ios_base::binary - | std::ios_base::trunc); - if (ofile.bad()) - { - throw std::ios_base::failure("could not open file \n"); - }; - for (size_t i = 0; i < V.size(); ++i) - { - ofile.write((char *) &(V[i][0]), V[i].size()); - ofile.put(0x0); - } - ofile.close(); - return 0; -}; -//--------------------------------------------------------------------------- -/// @struct uint64_file_generator -/// @brief This struct is a number generator from a file, with several options -/// for to limit the numbers between 0 and Max_Val -/// @remarks -//--------------------------------------------------------------------------- -struct uint64_file_generator -{ //---------------------------------------------------------------------- - // VARIABLES - //---------------------------------------------------------------------- - std::ifstream input; - size_t NMax, Pos; - size_t Max_Val; - std::string s; - - //---------------------------------------------------------------------- - // FUNCTIONS - //---------------------------------------------------------------------- - uint64_file_generator(const std::string & filename) - { //---------------------------- begin --------------------------------- - s = filename; - input.open(filename, std::ios_base::in | std::ios_base::binary); - if (input.fail() or input.bad()) - { - throw std::ios_base::failure("could not open file \n"); - }; - //-------------------------------------------------------------------- - // Calculate the lenght of the file and the number of elements inside - //-------------------------------------------------------------------- - input.seekg(0, std::ios_base::end); - size_t length = input.tellg(); - NMax = length / 8; - Pos = 0; - Max_Val = ~((size_t) 0); - input.seekg(0); - }; - - void set_max_val(size_t MV){ Max_Val = MV; }; - - size_t size() const { return NMax; }; - - uint64_t get(void) - { - uint64_t Aux; - input.read(reinterpret_cast<char *>(&Aux), 8); - return (Aux % Max_Val); - }; - - uint64_t operator ( )(){ return get(); }; - - void reset(void) { input.seekg(0, std::ios_base::beg); }; - - ~uint64_file_generator() { if (input.is_open()) input.close(); }; -}; -// -//**************************************************************************** -};// end namespace benchmark -};// end namespace sort -};// end namespace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/common/indirect.hpp b/contrib/restricted/boost/boost/sort/common/indirect.hpp deleted file mode 100644 index a55ef820239..00000000000 --- a/contrib/restricted/boost/boost/sort/common/indirect.hpp +++ /dev/null @@ -1,153 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file indirect.hpp -/// @brief Indirect algorithm -/// -/// @author Copyright (c) 2016 Francisco Jose Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_PARALLEL_COMMON_INDIRECT_HPP -#define __BOOST_SORT_PARALLEL_COMMON_INDIRECT_HPP - -//#include <boost/sort/common/atomic.hpp> -#include <boost/sort/common/util/traits.hpp> -#include <functional> -#include <iterator> -#include <type_traits> -#include <vector> - -namespace boost -{ -namespace sort -{ -namespace common -{ - -// -//--------------------------------------------------------------------------- -/// @struct less_ptr_no_null -/// -/// @remarks this is the comparison object for pointers. Compare the objects -/// pointed by the iterators -//--------------------------------------------------------------------------- -template<class Iter_t, class Compare = util::compare_iter<Iter_t> > -struct less_ptr_no_null -{ - //----------------------------- Variables ----------------------- - Compare comp; // comparison object of the elements pointed by Iter_t - - //------------------------------------------------------------------------ - // function : less_ptr_no_null - /// @brief constructor from a Compare object - /// @param C1 : comparison object - //----------------------------------------------------------------------- - less_ptr_no_null(Compare C1 = Compare()): comp(C1) { }; - - //------------------------------------------------------------------------ - // function : operator ( ) - /// @brief Make the comparison of the objects pointed by T1 and T2, using - // the internal comp - // - /// @param T1 : first iterator - /// @param T2 : second iterator - /// @return bool result of the comparison - //----------------------------------------------------------------------- - bool operator( )(Iter_t T1, Iter_t T2) const - { - return comp(*T1, *T2); - }; -}; -// -//----------------------------------------------------------------------------- -// function : create_index -/// @brief From a vector of objects, create a vector of iterators to -/// the objects -/// -/// @param first : iterator to the first element of the range -/// @param last : iterator to the element after the last of the range -/// @param index : vector where store the iterators -//----------------------------------------------------------------------------- -template<class Iter_t> -static void create_index(Iter_t first, Iter_t last, std::vector<Iter_t> &index) -{ - auto nelem = last - first; - assert(nelem >= 0); - index.clear(); - index.reserve(nelem); - for (; first != last; ++first) index.push_back(first); -}; -// -//----------------------------------------------------------------------------- -// function : sort_index -/// @brief This function transform a logical sort of the elements in the index -/// in a physical sort -// -/// @param global_first : iterator to the first element of the data -/// @param [in] index : vector of the iterators -//----------------------------------------------------------------------------- -template<class Iter_t> -static void sort_index(Iter_t global_first, std::vector<Iter_t> &index) -{ - typedef util::value_iter<Iter_t> value_t; - - size_t pos_dest = 0; - size_t pos_src = 0; - size_t pos_in_vector = 0; - size_t nelem = index.size(); - Iter_t it_dest, it_src; - - while (pos_in_vector < nelem) - { - while (pos_in_vector < nelem and - (size_t(index[pos_in_vector] - global_first)) == pos_in_vector) - { - ++pos_in_vector; - }; - - if (pos_in_vector == nelem) return; - pos_dest = pos_src = pos_in_vector; - it_dest = global_first + pos_dest; - value_t Aux = std::move(*it_dest); - - while ((pos_src = (size_t(index[pos_dest] - global_first))) - != pos_in_vector) - { - index[pos_dest] = it_dest; - it_src = global_first + pos_src; - *it_dest = std::move(*it_src); - it_dest = it_src; - pos_dest = pos_src; - }; - - *it_dest = std::move(Aux); - index[pos_dest] = it_dest; - ++pos_in_vector; - }; -}; - -template<class func, class Iter_t, class Compare = compare_iter<Iter_t> > -static void indirect_sort(func method, Iter_t first, Iter_t last, Compare comp) -{ - auto nelem = (last - first); - assert(nelem >= 0); - if (nelem < 2) return; - std::vector<Iter_t> index; - index.reserve((size_t) nelem); - create_index(first, last, index); - less_ptr_no_null<Iter_t, Compare> index_comp(comp); - method(index.begin(), index.end(), index_comp); - sort_index(first, index); -}; - -// -//**************************************************************************** -};// End namespace common -};// End namespace sort -};// End namespace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/common/int_array.hpp b/contrib/restricted/boost/boost/sort/common/int_array.hpp deleted file mode 100644 index 22c3b0c5a41..00000000000 --- a/contrib/restricted/boost/boost/sort/common/int_array.hpp +++ /dev/null @@ -1,75 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file int_array.hpp -/// @brief This file contains the struct int_array , which is an array of -/// uint64_t elements, being the template parameter NN the number of -/// elements in the array -/// -/// @author Copyright (c) 2010 2015 Francisco José Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanyingfile LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_COMMON_INT_ARRAY_HPP -#define __BOOST_SORT_COMMON_INT_ARRAY_HPP - -#include <cstdint> -#include <iostream> - -namespace boost -{ -namespace sort -{ -namespace common -{ - -template<uint32_t NN> -struct int_array -{ - uint64_t M[NN]; - - template<class generator> - static int_array<NN> generate(generator & gen) - { - int_array<NN> result; - for (uint32_t i = 0; i < NN; ++i) - { - result.M[i] = gen(); - }; - return result; - }; - - uint64_t counter(void) const - { - uint64_t Acc = M[0]; - for (uint32_t i = 1; i < NN; Acc += M[i++]) - ; - return Acc; - }; -}; - -template<class IA> -struct H_comp -{ - bool operator ( )(const IA & A1, const IA & A2) const - { - return (A1.counter() < A2.counter()); - }; -}; - -template<class IA> -struct L_comp -{ - bool operator ( )(const IA & A1, const IA & A2) const - { - return (A1.M[0] < A2.M[0]); - }; -}; -//*************************************************************************** -};// End namespace benchmark -};// End namespace sort -};// End namespace boost -//*************************************************************************** -#endif // end of int_array.hpp diff --git a/contrib/restricted/boost/boost/sort/common/merge_block.hpp b/contrib/restricted/boost/boost/sort/common/merge_block.hpp deleted file mode 100644 index 9a7b118270f..00000000000 --- a/contrib/restricted/boost/boost/sort/common/merge_block.hpp +++ /dev/null @@ -1,418 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file merge_block.hpp -/// @brief This file constains the class merge_block, which is part of the -/// block_indirect_sort algorithm -/// -/// @author Copyright (c) 2016 Francisco Jose Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_COMMON_MERGE_BLOCK_HPP -#define __BOOST_SORT_COMMON_MERGE_BLOCK_HPP - -#include <boost/sort/common/range.hpp> -#include <boost/sort/common/rearrange.hpp> -#include <boost/sort/common/util/merge.hpp> -#include <boost/sort/common/util/traits.hpp> - -namespace boost -{ -namespace sort -{ -namespace common -{ -///--------------------------------------------------------------------------- -/// @struct merge_block -/// @brief This contains all the information shared betwen the classes of the -/// block indirect sort algorithm - -//---------------------------------------------------------------------------- -template<class Iter_t, class Compare, uint32_t Power2 = 10> -struct merge_block -{ - //------------------------------------------------------------------------- - // D E F I N I T I O N S - //------------------------------------------------------------------------- - typedef util::value_iter<Iter_t> value_t; - typedef range<size_t> range_pos; - typedef range<Iter_t> range_it; - typedef range<value_t *> range_buf; - typedef typename std::vector<size_t>::iterator it_index; - typedef util::circular_buffer<value_t, Power2 + 1> circular_t; - - //------------------------------------------------------------------------ - // CONSTANTS - //------------------------------------------------------------------------ - const size_t BLOCK_SIZE = (size_t) 1 << Power2; - const size_t LOG_BLOCK = Power2; - - //------------------------------------------------------------------------ - // V A R I A B L E S - //------------------------------------------------------------------------ - // range with all the element to sort - range<Iter_t> global_range; - - // index vector of block_pos elements - std::vector<size_t> index; - - // Number of elements to sort - size_t nelem; - - // Number of blocks to sort - size_t nblock; - - // Number of elements in the last block (tail) - size_t ntail; - - // object for to compare two elements - Compare cmp; - - // range of elements of the last block (tail) - range_it range_tail; - - // circular buffer - circular_t * ptr_circ; - - // indicate if the circulr buffer is owned by the data structure - // or is received as parameter - bool owned; - - // - //------------------------------------------------------------------------ - // F U N C T I O N S - //------------------------------------------------------------------------ - // - //------------------------------------------------------------------------ - // function : merge_block - /// @brief constructor of the class - // - /// @param first : iterator to the first element of the range to sort - /// @param last : iterator after the last element to the range to sort - /// @param comp : object for to compare two elements pointed by Iter_t - /// iterators - //------------------------------------------------------------------------ - merge_block (Iter_t first, Iter_t last, Compare comp, - circular_t *pcirc_buffer) - : global_range(first, last), cmp(comp), ptr_circ(pcirc_buffer), - owned(pcirc_buffer == nullptr) - { - assert((last - first) >= 0); - if (first == last) return; // nothing to do - - nelem = size_t(last - first); - nblock = (nelem + BLOCK_SIZE - 1) / BLOCK_SIZE; - ntail = (nelem % BLOCK_SIZE); - index.reserve(nblock + 1); - - for (size_t i = 0; i < nblock; ++i) - index.emplace_back(i); - - range_tail.first = first + ((nblock - 1) << LOG_BLOCK); - range_tail.last = last; - if (owned) - { - ptr_circ = new circular_t; - ptr_circ->initialize(*first); - }; - } - - merge_block(Iter_t first, Iter_t last, Compare comp) - : merge_block(first, last, comp, nullptr) { }; - - ~ merge_block() - { - if (ptr_circ != nullptr and owned) - { - delete ptr_circ; - ptr_circ = nullptr; - }; - }; - //------------------------------------------------------------------------- - // function : get_range - /// @brief obtain the range in the position pos - /// @param pos : position of the range - /// @return range required - //------------------------------------------------------------------------- - range_it get_range(size_t pos) const - { - Iter_t it1 = global_range.first + (pos << LOG_BLOCK); - Iter_t it2 = (pos == (nblock - 1)) ? - global_range.last : it1 + BLOCK_SIZE; - return range_it(it1, it2); - }; - //------------------------------------------------------------------------- - // function : get_group_range - /// @brief obtain the range of the contiguous blocks beginning in the - // position pos - /// @param pos : position of the first range - /// @param nrange : number of ranges of the group - /// @return range required - //------------------------------------------------------------------------- - range_it get_group_range(size_t pos, size_t nrange) const - { - Iter_t it1 = global_range.first + (pos << LOG_BLOCK); - - Iter_t it2 = ((pos + nrange) == nblock)?global_range.last: global_range.first + ((pos + nrange) << LOG_BLOCK); - //Iter_t it2 = global_range.first + ((pos + nrange) << LOG_BLOCK); - //if ((pos + nrange) == nblock) it2 = global_range.last; - - return range_it(it1, it2); - }; - //------------------------------------------------------------------------- - // function : is_tail - /// @brief indicate if a block is the tail - /// @param pos : position of the block - /// @return true : taiol false : not tail - //------------------------------------------------------------------------- - bool is_tail(size_t pos) const - { - return (pos == (nblock - 1) and ntail != 0); - }; - //------------------------------------------------------------------------- - // function : - /// @brief - /// @param - /// @return - //------------------------------------------------------------------------- - void merge_range_pos(it_index itx_first, it_index itx_mid, - it_index itx_last); - - //------------------------------------------------------------------------- - // function : move_range_pos_backward - /// @brief Move backward the elements of a range of blocks in a index - /// @param itx_first : iterator to the position of the first block - /// @param itx_last : itertor to the position of the last block - /// @param npos : number of positions to move. Must be less than BLOCK_SIZE - /// @return - //------------------------------------------------------------------------- - void move_range_pos_backward(it_index itx_first, it_index itx_last, - size_t npos); - - //------------------------------------------------------------------------- - // function : rearrange_with_index - /// @brief rearrange the blocks with the relative positions of the index - /// @param - /// @param - /// @param - /// @return - //------------------------------------------------------------------------- - void rearrange_with_index(void); - -//--------------------------------------------------------------------------- -};// end struct merge_block -//--------------------------------------------------------------------------- -// -//############################################################################ -// ## -// N O N I N L I N E F U N C T IO N S ## -// ## -//############################################################################ -// -//------------------------------------------------------------------------- -// function : -/// @brief -/// @param -/// @return -//------------------------------------------------------------------------- -template<class Iter_t, class Compare, uint32_t Power2> -void merge_block<Iter_t, Compare, Power2> -::merge_range_pos(it_index itx_first, it_index itx_mid,it_index itx_last) -{ - assert((itx_last - itx_mid) >= 0 and (itx_mid - itx_first) >= 0); - - size_t nelemA = (itx_mid - itx_first), nelemB = (itx_last - itx_mid); - if (nelemA == 0 or nelemB == 0) return; - - //------------------------------------------------------------------- - // Create two index with the position of the blocks to merge - //------------------------------------------------------------------- - std::vector<size_t> indexA, indexB; - indexA.reserve(nelemA + 1); - indexB.reserve(nelemB); - - indexA.insert(indexA.begin(), itx_first, itx_mid); - indexB.insert(indexB.begin(), itx_mid, itx_last); - - it_index itx_out = itx_first; - it_index itxA = indexA.begin(), itxB = indexB.begin(); - range_it rngA, rngB; - Iter_t itA = global_range.first, itB = global_range.first; - bool validA = false, validB = false; - - while (itxA != indexA.end() and itxB != indexB.end()) - { //---------------------------------------------------------------- - // Load valid ranges from the itxA and ItxB positions - //---------------------------------------------------------------- - if (not validA) - { - rngA = get_range(*itxA); - itA = rngA.first; - validA = true; - }; - if (not validB) - { - rngB = get_range(*itxB); - itB = rngB.first; - validB = true; - }; - //---------------------------------------------------------------- - // If don't have merge betweeen the blocks, pass directly the - // position of the block to itx_out - //---------------------------------------------------------------- - if (ptr_circ->size() == 0) - { - if (not cmp(*rngB.front(), *rngA.back())) - { - *(itx_out++) = *(itxA++); - validA = false; - continue; - }; - if (cmp(*rngB.back(), *rngA.front())) - { - if (not is_tail(*itxB)) - *(itx_out++) = *itxB; - else ptr_circ->push_move_back(rngB.first, rngB.size()); - ++itxB; - validB = false; - continue; - }; - }; - //---------------------------------------------------------------- - // Normal merge - //---------------------------------------------------------------- - bool side = util::merge_circular(itA, rngA.last, itB, rngB.last, - *ptr_circ, cmp, itA, itB); - if (side) - { // rngA is finished - ptr_circ->pop_move_front(rngA.first, rngA.size()); - *(itx_out++) = *(itxA++); - validA = false; - } - else - { // rngB is finished - if (not is_tail(*itxB)) - { - ptr_circ->pop_move_front(rngB.first, rngB.size()); - *(itx_out++) = *itxB; - }; - ++itxB; - validB = false; - }; - }; // end while - - if (itxA == indexA.end()) - { // the index A is finished - rngB = get_range(*itxB); - ptr_circ->pop_move_front(rngB.first, ptr_circ->size()); - while (itxB != indexB.end()) - *(itx_out++) = *(itxB++); - } - else - { // The list B is finished - rngA = get_range(*itxA); - if (ntail != 0 and indexB.back() == (nblock - 1)) // exist tail - { // add the tail block to indexA, and shift the element - indexA.push_back(indexB.back()); - size_t numA = size_t(itA - rngA.first); - ptr_circ->pop_move_back(rngA.first, numA); - move_range_pos_backward(itxA, indexA.end(), ntail); - }; - - ptr_circ->pop_move_front(rngA.first, ptr_circ->size()); - while (itxA != indexA.end()) - *(itx_out++) = *(itxA++); - }; -}; - -//------------------------------------------------------------------------- -// function : move_range_pos_backward -/// @brief Move backward the elements of a range of blocks in a index -/// @param itx_first : iterator to the position of the first block -/// @param itx_last : itertor to the position of the last block -/// @param npos : number of positions to move. Must be less than BLOCK_SIZE -/// @return -//------------------------------------------------------------------------- -template<class Iter_t, class Compare, uint32_t Power2> -void merge_block<Iter_t, Compare, Power2> -::move_range_pos_backward(it_index itx_first, it_index itx_last, size_t npos) -{ - assert((itx_last - itx_first) >= 0 and npos <= BLOCK_SIZE); - - //-------------------------------------------------------------------- - // Processing the last block. Must be ready fore to accept npos - // elements from the upper block - //-------------------------------------------------------------------- - range_it rng1 = get_range(*(itx_last - 1)); - assert(rng1.size() >= npos); - if (rng1.size() > npos) - { - size_t nmove = rng1.size() - npos; - util::move_backward(rng1.last, rng1.first, rng1.first + nmove); - }; - //-------------------------------------------------------------------- - // Movement of elements between blocks - //-------------------------------------------------------------------- - for (it_index itx = itx_last - 1; itx != itx_first;) - { - --itx; - range_it rng2 = rng1; - rng1 = get_range(*itx); - Iter_t it_mid1 = rng1.last - npos, it_mid2 = rng2.first + npos; - util::move_backward(it_mid2, it_mid1, rng1.last); - util::move_backward(rng1.last, rng1.first, it_mid1); - }; -}; -//------------------------------------------------------------------------- -// function : rearrange_with_index -/// @brief rearrange the blocks with the relative positions of the index -/// @param -/// @param -/// @param -/// @return -//------------------------------------------------------------------------- -template<class Iter_t, class Compare, uint32_t Power2> -void merge_block<Iter_t, Compare, Power2> -::rearrange_with_index(void) -{ //-------------------------------------------------------------------- - // Code - //-------------------------------------------------------------------- - size_t pos_dest, pos_src, pos_ini; - size_t nelem = index.size(); - - ptr_circ->clear(); - value_t * aux = ptr_circ->get_buffer(); - range_buf rng_buf(aux, aux + ptr_circ->NMAX); - - pos_ini = 0; - while (pos_ini < nelem) - { - while (pos_ini < nelem and index[pos_ini] == pos_ini) - ++pos_ini; - if (pos_ini == nelem) return; - pos_dest = pos_src = pos_ini; - rng_buf = move_forward(rng_buf, get_range(pos_ini)); - pos_src = index[pos_ini]; - - while (pos_src != pos_ini) - { - move_forward(get_range(pos_dest), get_range(pos_src)); - index[pos_dest] = pos_dest; - pos_dest = pos_src; - pos_src = index[pos_src]; - }; - move_forward(get_range(pos_dest), rng_buf); - index[pos_dest] = pos_dest; - ++pos_ini; - }; -}; - -//**************************************************************************** -};// End namespace common -};// End namespace sort -};// End namespace boost -//**************************************************************************** -#endif diff --git a/contrib/restricted/boost/boost/sort/common/merge_four.hpp b/contrib/restricted/boost/boost/sort/common/merge_four.hpp deleted file mode 100644 index edfb2ffc728..00000000000 --- a/contrib/restricted/boost/boost/sort/common/merge_four.hpp +++ /dev/null @@ -1,327 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file merge_four.hpp -/// @brief This file have the functions for to merge 4 buffers -/// -/// @author Copyright (c) 2016 Francisco José Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_PARALLEL_DETAIL_UTIL_MERGE_FOUR_HPP -#define __BOOST_SORT_PARALLEL_DETAIL_UTIL_MERGE_FOUR_HPP - -#include <boost/sort/common/util/traits.hpp> -#include <boost/sort/common/range.hpp> -#include <functional> -#include <iterator> -#include <memory> -#include <vector> - -namespace boost -{ -namespace sort -{ -namespace common -{ - -// -//############################################################################ -// ## -// F U S I O N O F ## -// ## -// F O U R E L E M E N T S R A N G E ## -// ## -//############################################################################ -// - -//----------------------------------------------------------------------------- -// function : less_range -/// @brief Compare the elements pointed by it1 and it2, and if they -/// are equals, compare their position, doing a stable comparison -/// -/// @param it1 : iterator to the first element -/// @param pos1 : position of the object pointed by it1 -/// @param it2 : iterator to the second element -/// @param pos2 : position of the element pointed by it2 -/// @param comp : comparison object -/// @return result of the comparison -//----------------------------------------------------------------------------- -template<class Iter_t, class Compare = typename util::compare_iter<Iter_t> > -inline bool less_range(Iter_t it1, uint32_t pos1, Iter_t it2, uint32_t pos2, - Compare comp = Compare()) -{ - return (comp(*it1, *it2)) ? true : - (pos2 < pos1) ? false : not (comp(*it2, *it1)); -}; - -//----------------------------------------------------------------------------- -// function : full_merge4 -/// @brief Merge four ranges -/// -/// @param dest: range where move the elements merged. Their size must be -/// greater or equal than the sum of the sizes of the ranges -/// in vrange_input -/// @param vrange_input : array of ranges to merge -/// @param nrange_input : number of ranges in vrange_input -/// @param comp : comparison object -/// @return range with all the elements moved with the size adjusted -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Compare> -range<Iter1_t> full_merge4(const range<Iter1_t> &rdest, - range<Iter2_t> vrange_input[4], - uint32_t nrange_input, Compare comp) -{ - typedef range<Iter1_t> range1_t; - typedef util::value_iter<Iter1_t> type1; - typedef util::value_iter<Iter2_t> type2; - static_assert (std::is_same< type1, type2 >::value, - "Incompatible iterators\n"); - - size_t ndest = 0; - uint32_t i = 0; - while (i < nrange_input) - { - if (vrange_input[i].size() != 0) - { - ndest += vrange_input[i++].size(); - } - else - { - for (uint32_t k = i + 1; k < nrange_input; ++k) - { - vrange_input[k - 1] = vrange_input[k]; - }; - --nrange_input; - }; - }; - - if (nrange_input == 0) return range1_t(rdest.first, rdest.first); - if (nrange_input == 1) return move_forward(rdest, vrange_input[0]); - if (nrange_input == 2) - { - return merge(rdest, vrange_input[0], vrange_input[1], comp); - }; - - //------------------------------------------------------------------------ - // Initial sort - //------------------------------------------------------------------------ - uint32_t pos[4] = - { 0, 1, 2, 3 }, npos = nrange_input; - - //----------------------------------------------------------------------- - // thanks to Steven Ross by their suggestion about the optimal - // sorting networks - //----------------------------------------------------------------------- - if (less_range(vrange_input[pos[1]].first, pos[1], - vrange_input[pos[0]].first, pos[0], comp)) - { - std::swap(pos[0], pos[1]); - }; - if (npos == 4 and less_range(vrange_input[pos[3]].first, pos[3], - vrange_input[pos[2]].first, pos[2], comp)) - { - std::swap(pos[3], pos[2]); - }; - if (less_range (vrange_input[pos[2]].first, pos[2], - vrange_input[pos[0]].first, pos[0], comp)) - { - std::swap(pos[0], pos[2]); - }; - if (npos == 4 - and less_range (vrange_input[pos[3]].first, pos[3], - vrange_input[pos[1]].first, pos[1], comp)) - { - std::swap(pos[1], pos[3]); - }; - if (less_range (vrange_input[pos[2]].first, pos[2], - vrange_input[pos[1]].first, pos[1], comp)) - { - std::swap(pos[1], pos[2]); - }; - - Iter1_t it_dest = rdest.first; - while (npos > 2) - { - *(it_dest++) = std::move(*(vrange_input[pos[0]].first++)); - if (vrange_input[pos[0]].size() == 0) - { - pos[0] = pos[1]; - pos[1] = pos[2]; - pos[2] = pos[3]; - --npos; - } - else - { - if (less_range(vrange_input[pos[1]].first, pos[1], - vrange_input[pos[0]].first, pos[0], comp)) - { - std::swap(pos[0], pos[1]); - if (less_range(vrange_input[pos[2]].first, pos[2], - vrange_input[pos[1]].first, pos[1], comp)) - { - std::swap(pos[1], pos[2]); - if (npos == 4 - and less_range(vrange_input[pos[3]].first, - pos[3], - vrange_input[pos[2]].first, - pos[2], comp)) - { - std::swap(pos[2], pos[3]); - }; - }; - }; - }; - }; - - range1_t raux1(rdest.first, it_dest), raux2(it_dest, rdest.last); - if (pos[0] < pos[1]) - { - return concat(raux1,merge(raux2, vrange_input[pos[0]], - vrange_input[pos[1]], comp)); - } - else - { - return concat(raux1, merge (raux2, vrange_input[pos[1]], - vrange_input[pos[0]], comp)); - }; -}; - -//----------------------------------------------------------------------------- -// function : uninit_full_merge4 -/// @brief Merge four ranges and put the result in uninitialized memory -/// -/// @param dest: range where create and move the elements merged. Their -/// size must be greater or equal than the sum of the sizes -/// of the ranges in the array R -/// @param vrange_input : array of ranges to merge -/// @param nrange_input : number of ranges in vrange_input -/// @param comp : comparison object -/// @return range with all the elements move with the size adjusted -//----------------------------------------------------------------------------- -template<class Value_t, class Iter_t, class Compare> -range<Value_t *> uninit_full_merge4(const range<Value_t *> &dest, - range<Iter_t> vrange_input[4], - uint32_t nrange_input, Compare comp) -{ - typedef util::value_iter<Iter_t> type1; - static_assert (std::is_same< type1, Value_t >::value, - "Incompatible iterators\n"); - - size_t ndest = 0; - uint32_t i = 0; - while (i < nrange_input) - { - if (vrange_input[i].size() != 0) - { - ndest += vrange_input[i++].size(); - } - else - { - for (uint32_t k = i + 1; k < nrange_input; ++k) - { - vrange_input[k - 1] = vrange_input[k]; - }; - --nrange_input; - }; - }; - if (nrange_input == 0) return range<Value_t *>(dest.first, dest.first); - if (nrange_input == 1) return move_construct(dest, vrange_input[0]); - if (nrange_input == 2) - { - return merge_construct(dest, vrange_input[0], vrange_input[1], comp); - }; - - //------------------------------------------------------------------------ - // Initial sort - //------------------------------------------------------------------------ - uint32_t pos[4] = { 0, 1, 2, 3 }, npos = nrange_input; - - //----------------------------------------------------------------------- - // thanks to Steven Ross by their suggestion about the optimal - // sorting networks - //----------------------------------------------------------------------- - if (less_range(vrange_input[pos[1]].first, pos[1], - vrange_input[pos[0]].first, pos[0], comp)) - { - std::swap(pos[0], pos[1]); - }; - if (npos == 4 and less_range(vrange_input[pos[3]].first, pos[3], - vrange_input[pos[2]].first, pos[2], comp)) - { - std::swap(pos[3], pos[2]); - }; - if (less_range(vrange_input[pos[2]].first, pos[2], - vrange_input[pos[0]].first, pos[0], comp)) - { - std::swap(pos[0], pos[2]); - }; - if (npos == 4 and less_range(vrange_input[pos[3]].first, pos[3], - vrange_input[pos[1]].first, pos[1], comp)) - { - std::swap(pos[1], pos[3]); - }; - if (less_range(vrange_input[pos[2]].first, pos[2], - vrange_input[pos[1]].first, pos[1], comp)) - { - std::swap(pos[1], pos[2]); - }; - - Value_t *it_dest = dest.first; - while (npos > 2) - { - util::construct_object(&(*(it_dest++)), - std::move(*(vrange_input[pos[0]].first++))); - if (vrange_input[pos[0]].size() == 0) - { - pos[0] = pos[1]; - pos[1] = pos[2]; - pos[2] = pos[3]; - --npos; - } - else - { - if (less_range (vrange_input[pos[1]].first, pos[1], - vrange_input[pos[0]].first, pos[0], comp)) - { - std::swap(pos[0], pos[1]); - if (less_range (vrange_input[pos[2]].first, pos[2], - vrange_input[pos[1]].first, pos[1], comp)) - { - std::swap(pos[1], pos[2]); - if (npos == 4 and less_range(vrange_input[pos[3]].first, - pos[3], - vrange_input[pos[2]].first, - pos[2], comp)) - { - std::swap(pos[2], pos[3]); - }; - }; - }; - }; - }; // end while (npos > 2) - - range<Value_t *> raux1(dest.first, it_dest), raux2(it_dest, dest.last); - if (pos[0] < pos[1]) - { - return concat(raux1, - merge_construct(raux2, vrange_input[pos[0]], - vrange_input[pos[1]], comp)); - } - else - { - return concat(raux1, - merge_construct(raux2, vrange_input[pos[1]], - vrange_input[pos[0]], comp)); - }; -}; - -//**************************************************************************** -};// End namespace common -};// End namespace sort -};// End namespace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/common/merge_vector.hpp b/contrib/restricted/boost/boost/sort/common/merge_vector.hpp deleted file mode 100644 index 84afea5a5e4..00000000000 --- a/contrib/restricted/boost/boost/sort/common/merge_vector.hpp +++ /dev/null @@ -1,196 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file merge_vector.hpp -/// @brief In this file have the functions for to do a stable merge of -// ranges, in a vector -/// -/// @author Copyright (c) 2016 Francisco Jose Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_PARALLEL_DETAIL_UTIL_MERGE_VECTOR_HPP -#define __BOOST_SORT_PARALLEL_DETAIL_UTIL_MERGE_VECTOR_HPP - -#include <boost/sort/common/merge_four.hpp> -#include <functional> -#include <iterator> -#include <memory> -#include <type_traits> -#include <vector> - -namespace boost -{ -namespace sort -{ -namespace common -{ - -//############################################################################ -// ## -// F U S I O N O F ## -// ## -// A V E C T O R O F R A N G E S ## -// ## -//############################################################################ - -// -//----------------------------------------------------------------------------- -// function : merge_level4 -/// @brief merge the ranges in the vector v_input with the full_merge4 function. -/// The v_output vector is used as auxiliary memory in the internal -/// process. The final results is in the dest range. -/// All the ranges of v_output are inside the range dest -/// @param dest : range where move the elements merged -/// @param v_input : vector of ranges to merge -/// @param v_output : vector of ranges obtained -/// @param comp : comparison object -/// @return range with all the elements moved -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Compare> -void merge_level4(range<Iter1_t> dest, std::vector<range<Iter2_t> > &v_input, - std::vector<range<Iter1_t> > &v_output, Compare comp) -{ - typedef range<Iter1_t> range1_t; - typedef util::value_iter<Iter1_t> type1; - typedef util::value_iter<Iter2_t> type2; - static_assert (std::is_same< type1, type2 >::value, - "Incompatible iterators\n"); - - v_output.clear(); - if (v_input.size() == 0) return; - if (v_input.size() == 1) - { - v_output.emplace_back(move_forward(dest, v_input[0])); - return; - }; - - uint32_t nrange = v_input.size(); - uint32_t pos_ini = 0; - while (pos_ini < v_input.size()) - { - uint32_t nmerge = (nrange + 3) >> 2; - uint32_t nelem = (nrange + nmerge - 1) / nmerge; - range1_t rz = full_merge4(dest, &v_input[pos_ini], nelem, comp); - v_output.emplace_back(rz); - dest.first = rz.last; - pos_ini += nelem; - nrange -= nelem; - }; - return; -}; -// -//----------------------------------------------------------------------------- -// function : uninit_merge_level4 -/// @brief merge the ranges moving the objects and constructing them in -/// uninitialized memory, in the vector v_input -/// using full_merge4. The v_output vector is used as auxiliary memory -/// in the internal process. The final results is in the dest range. -/// All the ranges of v_output are inside the range dest -/// -/// @param dest : range where move the elements merged -/// @param v_input : vector of ranges to merge -/// @param v_output : vector of ranges obtained -/// @param comp : comparison object -/// @return range with all the elements moved and constructed -//----------------------------------------------------------------------------- -template<class Value_t, class Iter_t, class Compare> -void uninit_merge_level4(range<Value_t *> dest, - std::vector<range<Iter_t> > &v_input, - std::vector<range<Value_t *> > &v_output, Compare comp) -{ - typedef range<Value_t *> range1_t; - typedef util::value_iter<Iter_t> type1; - static_assert (std::is_same< type1, Value_t >::value, - "Incompatible iterators\n"); - - v_output.clear(); - if (v_input.size() == 0) return; - if (v_input.size() == 1) - { - v_output.emplace_back(move_construct(dest, v_input[0])); - return; - }; - - uint32_t nrange = v_input.size(); - uint32_t pos_ini = 0; - while (pos_ini < v_input.size()) - { - uint32_t nmerge = (nrange + 3) >> 2; - uint32_t nelem = (nrange + nmerge - 1) / nmerge; - range1_t rz = uninit_full_merge4(dest, &v_input[pos_ini], nelem, comp); - v_output.emplace_back(rz); - dest.first = rz.last; - pos_ini += nelem; - nrange -= nelem; - }; - return; -}; -// -//----------------------------------------------------------------------------- -// function : merge_vector4 -/// @brief merge the ranges in the vector v_input using the merge_level4 -/// function. The v_output vector is used as auxiliary memory in the -/// internal process -/// The final results is in the range_output range. -/// All the ranges of v_output are inside the range range_output -/// All the ranges of v_input are inside the range range_input -/// @param range_input : range including all the ranges of v_input -/// @param ange_output : range including all the elements of v_output -/// @param v_input : vector of ranges to merge -/// @param v_output : vector of ranges obtained -/// @param comp : comparison object -/// @return range with all the elements moved -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Compare> -range<Iter2_t> merge_vector4(range<Iter1_t> range_input, - range<Iter2_t> range_output, - std::vector<range<Iter1_t> > &v_input, - std::vector<range<Iter2_t> > &v_output, - Compare comp) -{ - typedef range<Iter2_t> range2_t; - typedef util::value_iter<Iter1_t> type1; - typedef util::value_iter<Iter2_t> type2; - static_assert (std::is_same< type1, type2 >::value, - "Incompatible iterators\n"); - - v_output.clear(); - if (v_input.size() == 0) - { - return range2_t(range_output.first, range_output.first); - }; - if (v_input.size() == 1) - { - return move_forward(range_output, v_input[0]); - }; - bool sw = false; - uint32_t nrange = v_input.size(); - - while (nrange > 1) - { - if (sw) - { - merge_level4(range_input, v_output, v_input, comp); - sw = false; - nrange = v_input.size(); - } - else - { - merge_level4(range_output, v_input, v_output, comp); - sw = true; - nrange = v_output.size(); - }; - }; - return (sw) ? v_output[0] : move_forward(range_output, v_input[0]); -}; - -//**************************************************************************** -};// End namespace common -};// End namespace sort -};// End namespace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/common/pivot.hpp b/contrib/restricted/boost/boost/sort/common/pivot.hpp deleted file mode 100644 index 5182fbd2735..00000000000 --- a/contrib/restricted/boost/boost/sort/common/pivot.hpp +++ /dev/null @@ -1,122 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file pivot.hpp -/// @brief This file contains the description of several low level algorithms -/// -/// @author Copyright (c) 2010 2015 Francisco José Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_COMMON_PIVOT_HPP -#define __BOOST_SORT_COMMON_PIVOT_HPP - -#include <cstdint> - -namespace boost -{ -namespace sort -{ -namespace common -{ -// -//########################################################################## -// ## -// G L O B A L V A R I B L E S ## -// ## -//########################################################################## -// -//----------------------------------------------------------------------------- -// function : mid3 -/// @brief : return the iterator to the mid value of the three values passsed -/// as parameters -// -/// @param iter_1 : iterator to the first value -/// @param iter_2 : iterator to the second value -/// @param iter_3 : iterator to the third value -/// @param comp : object for to compare two values -/// @return iterator to mid value -//----------------------------------------------------------------------------- -template < typename Iter_t, typename Compare > -inline Iter_t mid3 (Iter_t iter_1, Iter_t iter_2, Iter_t iter_3, Compare comp) -{ - return comp (*iter_1, *iter_2) - ? (comp (*iter_2, *iter_3)? - iter_2 : (comp (*iter_1, *iter_3) ? iter_3 : iter_1)) - : (comp (*iter_3, *iter_2)? - iter_2 : (comp (*iter_3, *iter_1) ? iter_3 : iter_1)); -}; -// -//----------------------------------------------------------------------------- -// function : pivot3 -/// @brief : receive a range between first and last, calcule the mid iterator -/// with the first, the previous to the last, and the central -/// position. With this mid iterator swap with the first position -// -/// @param first : iterator to the first element -/// @param last : iterator to the last element -/// @param comp : object for to compare two elements -//----------------------------------------------------------------------------- -template < class Iter_t, class Compare > -inline void pivot3 (Iter_t first, Iter_t last, Compare comp) -{ - auto N2 = (last - first) >> 1; - Iter_t it_val = mid3 (first + 1, first + N2, last - 1, comp); - std::swap (*first, *it_val); -}; - -// -//----------------------------------------------------------------------------- -// function : mid9 -/// @brief : return the iterator to the mid value of the nine values passsed -/// as parameters -// -/// @param iter_1 : iterator to the first value -/// @param iter_2 : iterator to the second value -/// @param iter_3 : iterator to the third value -/// @param iter_4 : iterator to the fourth value -/// @param iter_5 : iterator to the fifth value -/// @param iter_6 : iterator to the sixth value -/// @param iter_7 : iterator to the seventh value -/// @param iter_8 : iterator to the eighth value -/// @param iter_9 : iterator to the ninth value -/// @return iterator to the mid value -//----------------------------------------------------------------------------- -template < class Iter_t, class Compare > -inline Iter_t mid9 (Iter_t iter_1, Iter_t iter_2, Iter_t iter_3, Iter_t iter_4, - Iter_t iter_5, Iter_t iter_6, Iter_t iter_7, Iter_t iter_8, - Iter_t iter_9, Compare comp) -{ - return mid3 (mid3 (iter_1, iter_2, iter_3, comp), - mid3 (iter_4, iter_5, iter_6, comp), - mid3 (iter_7, iter_8, iter_9, comp), comp); -}; -// -//----------------------------------------------------------------------------- -// function : pivot9 -/// @brief : receive a range between first and last, obtain 9 values between -/// the elements including the first and the previous to the last. -/// Obtain the iterator to the mid value and swap with the first -/// position -// -/// @param first : iterator to the first element -/// @param last : iterator to the last element -/// @param comp : object for to compare two elements -//----------------------------------------------------------------------------- -template < class Iter_t, class Compare > -inline void pivot9 (Iter_t first, Iter_t last, Compare comp) -{ - size_t cupo = (last - first) >> 3; - Iter_t itaux = mid9 (first + 1, first + cupo, first + 2 * cupo, - first + 3 * cupo, first + 4 * cupo, first + 5 * cupo, - first + 6 * cupo, first + 7 * cupo, last - 1, comp); - std::swap (*first, *itaux); -}; -//**************************************************************************** -}; // End namespace common -}; // End namespace sort -}; // End namespace boost -//**************************************************************************** -#endif diff --git a/contrib/restricted/boost/boost/sort/common/range.hpp b/contrib/restricted/boost/boost/sort/common/range.hpp deleted file mode 100644 index 072d98a938a..00000000000 --- a/contrib/restricted/boost/boost/sort/common/range.hpp +++ /dev/null @@ -1,399 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file range.hpp -/// @brief Define a range [first, last), and the associated operations -/// -/// @author Copyright (c) 2016 Francisco José Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanyingfile LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_PARALLEL_DETAIL_UTIL_RANGE_HPP -#define __BOOST_SORT_PARALLEL_DETAIL_UTIL_RANGE_HPP - -#include <boost/sort/common/util/algorithm.hpp> -#include <boost/sort/common/util/merge.hpp> -#include <boost/sort/common/util/traits.hpp> -#include <cassert> -#include <functional> -#include <memory> -#include <vector> - -namespace boost -{ -namespace sort -{ -namespace common -{ - -///--------------------------------------------------------------------------- -/// @struct range -/// @brief this represent a range between two iterators -/// @remarks -//---------------------------------------------------------------------------- -template <class Iter_t> -struct range -{ - Iter_t first, last; - // - //------------------------------------------------------------------------ - // function : range - /// @brief empty constructor - //------------------------------------------------------------------------ - range(void) { }; - // - //------------------------------------------------------------------------ - // function : range - /// @brief constructor with two parameters - /// @param frs : iterator to the first element - /// @param lst : iterator to the last element - //----------------------------------------------------------------------- - range(const Iter_t &frs, const Iter_t &lst): first(frs), last(lst) { }; - // - //----------------------------------------------------------------------- - // function : empty - /// @brief indicate if the range is empty - /// @return true : empty false : not empty - //----------------------------------------------------------------------- - bool empty(void) const { return (first == last); }; - // - //----------------------------------------------------------------------- - // function : not_empty - /// @brief indicate if the range is not empty - /// @return true : not empty false : empty - //----------------------------------------------------------------------- - bool not_empty(void) const {return (first != last); }; - // - //----------------------------------------------------------------------- - // function : valid - /// @brief Indicate if the range is well constructed, and valid - /// @return true : valid, false : not valid - //----------------------------------------------------------------------- - bool valid(void) const { return ((last - first) >= 0); }; - // - //----------------------------------------------------------------------- - // function : size - /// @brief return the size of the range - /// @return size - //----------------------------------------------------------------------- - size_t size(void) const { return (last - first); }; - // - //------------------------------------------------------------------------ - // function : front - /// @brief return an iterator to the first element of the range - /// @return iterator - //----------------------------------------------------------------------- - Iter_t front(void) const { return first; }; - // - //------------------------------------------------------------------------- - // function : back - /// @brief return an iterator to the last element of the range - /// @return iterator - //------------------------------------------------------------------------- - Iter_t back(void) const {return (last - 1); }; -}; - -// -//----------------------------------------------------------------------------- -// function : concat -/// @brief concatenate two contiguous ranges -/// @param it1 : first range -/// @param it2 : second range -/// @return range resulting of the concatenation -//----------------------------------------------------------------------------- -template<class Iter_t> -inline range<Iter_t> concat(const range<Iter_t> &it1, const range<Iter_t> &it2) -{ - return range<Iter_t>(it1.first, it2.last); -} -; -// -//----------------------------------------------------------------------------- -// function : move_forward -/// @brief Move initialized objets from the range src to dest -/// @param dest : range where move the objects -/// @param src : range from where move the objects -/// @return range with the objects moved and the size adjusted -//----------------------------------------------------------------------------- -template <class Iter1_t, class Iter2_t> -inline range<Iter2_t> move_forward(const range<Iter2_t> &dest, - const range<Iter1_t> &src) -{ - assert(dest.size() >= src.size()); - Iter2_t it_aux = util::move_forward(dest.first, src.first, src.last); - return range<Iter2_t>(dest.first, it_aux); -}; -// -//----------------------------------------------------------------------------- -// function : move_backward -/// @brief Move initialized objets from the range src to dest -/// @param dest : range where move the objects -/// @param src : range from where move the objects -/// @return range with the objects moved and the size adjusted -//----------------------------------------------------------------------------- -template <class Iter1_t, class Iter2_t> -inline range<Iter2_t> move_backward(const range<Iter2_t> &dest, - const range<Iter1_t> &src) -{ - assert(dest.size() >= src.size()); - Iter2_t it_aux = util::move_backward(dest.first + src.size(), src.first, - src.last); - return range<Iter2_t>(dest.first, dest.src.size()); -}; - -//----------------------------------------------------------------------------- -// function : uninit_move -/// @brief Move uninitialized objets from the range src creating them in dest -/// -/// @param dest : range where move and create the objects -/// @param src : range from where move the objects -/// @return range with the objects moved and the size adjusted -//----------------------------------------------------------------------------- -template<class Iter_t, class Value_t = util::value_iter<Iter_t> > -inline range<Value_t*> move_construct(const range<Value_t*> &dest, - const range<Iter_t> &src) -{ - Value_t *ptr_aux = util::move_construct(dest.first, src.first, src.last); - return range<Value_t*>(dest.first, ptr_aux); -}; -// -//----------------------------------------------------------------------------- -// function : destroy -/// @brief destroy a range of objects -/// @param rng : range to destroy -//----------------------------------------------------------------------------- -template<class Iter_t> -inline void destroy(range<Iter_t> rng) -{ - util::destroy(rng.first, rng.last); -}; -// -//----------------------------------------------------------------------------- -// function : initialize -/// @brief initialize a range of objects with the object val moving across them -/// @param rng : range of elements not initialized -/// @param val : object used for the initialization -/// @return range initialized -//----------------------------------------------------------------------------- -template<class Iter_t, class Value_t = util::value_iter<Iter_t> > -inline range<Iter_t> initialize(const range<Iter_t> &rng, Value_t &val) -{ - util::initialize(rng.first, rng.last, val); - return rng; -}; -// -//----------------------------------------------------------------------------- -// function : is_mergeable -/// @brief : indicate if two ranges have a possible merge -/// @param src1 : first range -/// @param src2 : second range -/// @param comp : object for to compare elements -/// @return true : they can be merged -/// false : they can't be merged -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Compare> -inline bool is_mergeable(const range<Iter1_t> &src1, const range<Iter2_t> &src2, - Compare comp) -{ - //------------------------------------------------------------------------ - // Metaprogramming - //------------------------------------------------------------------------ - typedef util::value_iter<Iter1_t> type1; - typedef util::value_iter<Iter2_t> type2; - static_assert (std::is_same< type1, type2 >::value, - "Incompatible iterators\n"); - //------------------------------------------------------------------------ - // Code - //------------------------------------------------------------------------ - return comp(*(src2.front()), *(src1.back())); -}; -// -//----------------------------------------------------------------------------- -// function : is_mergeable_stable -/// @brief : indicate if two ranges have a possible merge -/// @param src1 : first range -/// @param src2 : second range -/// @param comp : object for to compare elements -/// @return true : they can be merged -/// false : they can't be merged -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Compare> -inline bool is_mergeable_stable(const range<Iter1_t> &src1, - const range<Iter2_t> &src2, Compare comp) -{ - //------------------------------------------------------------------------ - // Metaprogramming - //------------------------------------------------------------------------ - typedef util::value_iter<Iter1_t> type1; - typedef util::value_iter<Iter2_t> type2; - static_assert (std::is_same< type1, type2 >::value, - "Incompatible iterators\n"); - //------------------------------------------------------------------------ - // Code - //------------------------------------------------------------------------ - return not comp(*(src1.back()), *(src2.front())); -}; -// -//----------------------------------------------------------------------------- -// function : merge -/// @brief Merge two contiguous ranges src1 and src2, and put the result in -/// the range dest, returning the range merged -/// -/// @param dest : range where locate the lements merged. the size of dest -/// must be greater or equal than the sum of the sizes of -/// src1 and src2 -/// @param src1 : first range to merge -/// @param src2 : second range to merge -/// @param comp : comparison object -/// @return range with the elements merged and the size adjusted -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Iter3_t, class Compare> -inline range<Iter3_t> merge(const range<Iter3_t> &dest, - const range<Iter1_t> &src1, - const range<Iter2_t> &src2, Compare comp) -{ - Iter3_t it_aux = util::merge(src1.first, src1.last, src2.first, src2.last, - dest.first, comp); - return range<Iter3_t>(dest.first, it_aux); -}; - -//----------------------------------------------------------------------------- -// function : merge_construct -/// @brief Merge two contiguous uninitialized ranges src1 and src2, and create -/// and move the result in the uninitialized range dest, returning the -/// range merged -// -/// @param dest : range where locate the elements merged. the size of dest -/// must be greater or equal than the sum of the sizes of -/// src1 and src2. Initially is uninitialize memory -/// @param src1 : first range to merge -/// @param src2 : second range to merge -/// @param comp : comparison object -/// @return range with the elements merged and the size adjusted -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Value_t, class Compare> -inline range<Value_t *> merge_construct(const range<Value_t *> &dest, - const range<Iter1_t> &src1, - const range<Iter2_t> &src2, - Compare comp) -{ - Value_t * ptr_aux = util::merge_construct(src1.first, src1.last, src2.first, - src2.last, dest.first, comp); - return range<Value_t*>(dest.first, ptr_aux); -}; -// -//--------------------------------------------------------------------------- -// function : half_merge -/// @brief : Merge two initialized buffers. The first buffer is in a separate -/// memory -// -/// @param dest : range where finish the two buffers merged -/// @param src1 : first range to merge in a separate memory -/// @param src2 : second range to merge, in the final part of the -/// range where deposit the final results -/// @param comp : object for compare two elements of the type pointed -/// by the Iter1_t and Iter2_t -/// @return : range with the two buffers merged -//--------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Compare> -inline range<Iter2_t> merge_half(const range<Iter2_t> &dest, - const range<Iter1_t> &src1, - const range<Iter2_t> &src2, Compare comp) -{ - Iter2_t it_aux = util::merge_half(src1.first, src1.last, src2.first, - src2.last, dest.first, comp); - return range<Iter2_t>(dest.first, it_aux); -}; -// -//----------------------------------------------------------------------------- -// function : merge_uncontiguous -/// @brief : merge two non contiguous ranges src1, src2, using the range -/// aux as auxiliary memory. The results are in the original ranges -// -/// @param src1 : first range to merge -/// @param src2 : second range to merge -/// @param aux : auxiliary range used in the merge -/// @param comp : object for to compare elements -/// @return true : not changes done, false : changes in the buffers -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Iter3_t, class Compare> -inline bool merge_uncontiguous(const range<Iter1_t> &src1, - const range<Iter2_t> &src2, - const range<Iter3_t> &aux, Compare comp) -{ - return util::merge_uncontiguous(src1.first, src1.last, src2.first, - src2.last, aux.first, comp); -}; -// -//----------------------------------------------------------------------------- -// function : merge_contiguous -/// @brief : merge two contiguous ranges ( src1, src2) using buf as -/// auxiliary memory. The results are in the same ranges -/// @param src1 : first range to merge -/// @param src1 : second range to merge -/// @param buf : auxiliary memory used in the merge -/// @param comp : object for to compare elements -/// @return true : not changes done, false : changes in the buffers -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Compare> -inline range<Iter1_t> merge_contiguous(const range<Iter1_t> &src1, - const range<Iter1_t> &src2, - const range<Iter2_t> &buf, Compare comp) -{ - util::merge_contiguous(src1.first, src1.last, src2.last, buf.first, comp); - return concat(src1, src2); -}; -// -//----------------------------------------------------------------------------- -// function : merge_flow -/// @brief : merge two ranges, as part of a merge the ranges in a list. This -/// function reduce the number of movements compared with inplace_merge -/// when you need to merge a sequence of ranges. -/// This function merge the ranges rbuf and rng2, and the results -/// are in rng1 and rbuf -// -/// @param rng1 : range where locate the first elements of the merge -/// @param rbuf : range which provide the first elements, and where store -/// the last results of the merge -/// @param rng2 : range which provide the last elements to merge -/// @param comp : object for to compare elements -/// @return true : not changes done, false : changes in the buffers -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Compare> -static void merge_flow(range<Iter1_t> rng1, range<Iter2_t> rbuf, - range<Iter1_t> rng2, Compare cmp) -{ - //------------------------------------------------------------------------- - // Metaprogramming - //------------------------------------------------------------------------- - typedef util::value_iter<Iter1_t> type1; - typedef util::value_iter<Iter2_t> type2; - static_assert (std::is_same< type1, type2 >::value, - "Incompatible iterators\n"); - - //------------------------------------------------------------------------- - // Code - //------------------------------------------------------------------------- - range<Iter2_t> rbx(rbuf); - range<Iter1_t> rx1(rng1), rx2(rng2); - assert(rbx.size() == rx1.size() and rx1.size() == rx2.size()); - while (rx1.first != rx1.last) - { - *(rx1.first++) = (cmp(*rbx.first, *rx2.first)) ? - std::move(*(rbx.first++)): - std::move(*(rx2.first++)); - }; - if (rx2.first == rx2.last) return; - if (rbx.first == rbx.last) move_forward(rbuf, rng2); - else merge_half(rbuf, rx2, rbx, cmp); -}; - -//**************************************************************************** -};// End namespace common -};// End namespace sort -};// End namespace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/common/rearrange.hpp b/contrib/restricted/boost/boost/sort/common/rearrange.hpp deleted file mode 100644 index 5c65c4f2b74..00000000000 --- a/contrib/restricted/boost/boost/sort/common/rearrange.hpp +++ /dev/null @@ -1,168 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file rearrange.hpp -/// @brief Indirect algorithm -/// -/// @author Copyright (c) 2016 Francisco Jose Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_COMMON_REARRANGE_HPP -#define __BOOST_SORT_COMMON_REARRANGE_HPP - -//#include <boost/sort/common/atomic.hpp> -#include <boost/sort/common/util/traits.hpp> -#include <functional> -#include <iterator> -#include <type_traits> -#include <vector> -#include <cassert> - -namespace boost -{ -namespace sort -{ -namespace common -{ - -template<class Iter_data> -struct filter_iterator -{ - //----------------------------------------------------------------------- - // Variables - //----------------------------------------------------------------------- - Iter_data origin; - - //----------------------------------------------------------------------- - // Functions - //----------------------------------------------------------------------- - filter_iterator(Iter_data global_first): origin(global_first) { }; - size_t operator ()(Iter_data itx) const - { - return size_t(itx - origin); - } -}; - -struct filter_pos -{ - size_t operator ()(size_t pos) const { return pos; }; -}; - -// -//----------------------------------------------------------------------------- -// function : rearrange -/// @brief This function transform a logical sort of the elements in the index -/// of iterators in a physical sort. -// -/// @param global_first : iterator to the first element of the data -/// @param [in] index : vector of the iterators -//----------------------------------------------------------------------------- -template<class Iter_data, class Iter_index, class Filter_pos> -void rearrange(Iter_data global_first, Iter_index itx_first, - Iter_index itx_last, Filter_pos pos) -{ - //----------------------------------------------------------------------- - // Metaprogramming - //----------------------------------------------------------------------- - typedef util::value_iter<Iter_data> value_data; - typedef util::value_iter<Iter_index> value_index; - - //------------------------------------------------------------------------- - // Code - //------------------------------------------------------------------------- - assert((itx_last - itx_first) >= 0); - size_t pos_dest, pos_src, pos_ini; - size_t nelem = size_t(itx_last - itx_first); - Iter_data data = global_first; - Iter_index index = itx_first; - - pos_ini = 0; - while (pos_ini < nelem) - { - while (pos_ini < nelem and pos(index[pos_ini]) == pos_ini) - ++pos_ini; - if (pos_ini == nelem) return; - pos_dest = pos_src = pos_ini; - value_data aux = std::move(data[pos_ini]); - value_index itx_src = std::move(index[pos_ini]); - - while ((pos_src = pos(itx_src)) != pos_ini) - { - data[pos_dest] = std::move(data[pos_src]); - std::swap(itx_src, index[pos_src]); - pos_dest = pos_src; - }; - - data[pos_dest] = std::move(aux); - index[pos_ini] = std::move(itx_src); - ++pos_ini; - }; -}; - -/* - // - //----------------------------------------------------------------------------- - // function : rearrange_pos - /// @brief This function transform a logical sort of the elements in the index - /// of iterators in a physical sort. - // - /// @param global_first : iterator to the first element of the data - /// @param [in] index : vector of the iterators - //----------------------------------------------------------------------------- - template < class Iter_t, class Number > - void rearrange_pos (Iter_t global_first, std::vector< Number> &index) - { - //------------------------------------------------------------------------- - // METAPROGRAMMING AND DEFINITIONS - //------------------------------------------------------------------------- - static_assert ( std::is_integral<Number>::value, "Incompatible Types"); - typedef iter_value< Iter_t > value_t; - - //------------------------------------------------------------------------- - // CODE - //------------------------------------------------------------------------- - size_t pos_dest = 0; - size_t pos_src = 0; - size_t pos_ini = 0; - size_t nelem = index.size ( ); - Iter_t it_dest (global_first), it_src(global_first); - - while (pos_ini < nelem) - { - while (pos_ini < nelem and - index[pos_ini] == pos_ini) - { - ++pos_ini; - }; - - if (pos_ini == nelem) return; - pos_dest = pos_src = pos_ini; - it_dest = global_first + pos_dest; - value_t Aux = std::move (*it_dest); - - while ((pos_src = index[pos_dest]) != pos_ini) - { - index[pos_dest] = it_dest - global_first; - it_src = global_first + pos_src; - *it_dest = std::move (*it_src); - it_dest = it_src; - pos_dest = pos_src; - }; - - *it_dest = std::move (Aux); - index[pos_dest] = it_dest - global_first; - ++pos_ini; - }; - }; - */ -// -//**************************************************************************** -};// End namespace common -};// End namespace sort -};// End namespace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/common/scheduler.hpp b/contrib/restricted/boost/boost/sort/common/scheduler.hpp deleted file mode 100644 index 33074a4534b..00000000000 --- a/contrib/restricted/boost/boost/sort/common/scheduler.hpp +++ /dev/null @@ -1,276 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file scheduler.hpp -/// @brief This file contains the implementation of the scheduler for -/// dispatch the works stored -/// -/// @author Copyright (c) 2010 2015 Francisco José Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanyingfile LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_COMMON_SCHEDULER_HPP -#define __BOOST_SORT_COMMON_SCHEDULER_HPP - -#include <boost/sort/common/spinlock.hpp> -#include <boost/sort/common/search.hpp> -#include <boost/sort/common/compare_traits.hpp> -#include <scoped_allocator> -#include <utility> -#include <vector> -#include <deque> -#include <iostream> -#include <unordered_map> - -namespace boost -{ -namespace sort -{ -namespace common -{ - -// -//########################################################################### -// ## -// ################################################################ ## -// # # ## -// # C L A S S S C H E D U L E R # ## -// # # ## -// ################################################################ ## -// ## -//########################################################################### - -// -//--------------------------------------------------------------------------- -/// @class scheduler -/// @brief This class is a concurrent stack controled by a spin_lock -/// @remarks -//--------------------------------------------------------------------------- -template<typename Func_t, typename Allocator = std::allocator<Func_t> > -struct scheduler -{ - //----------------------------------------------------------------------- - // D E F I N I T I O N S - //----------------------------------------------------------------------- - typedef std::scoped_allocator_adaptor <Allocator> scoped_alloc; - typedef std::deque <Func_t, scoped_alloc> deque_t; - typedef typename deque_t::iterator it_deque; - typedef std::thread::id key_t; - typedef std::hash <key_t> hash_t; - typedef std::equal_to <key_t> equal_t; - typedef std::unique_lock <spinlock_t> lock_t; - typedef std::unordered_map <key_t, deque_t, hash_t, - equal_t, scoped_alloc> map_t; - typedef typename map_t::iterator it_map; - - //----------------------------------------------------------------------- - // V A R I A B L E S - //----------------------------------------------------------------------- - map_t mp; - size_t nelem; - mutable spinlock_t spl; - - //------------------------------------------------------------------------ - // function : scheduler - /// @brief constructor - //------------------------------------------------------------------------ - scheduler(void) : mp(), nelem(0) { }; - // - //----------------------------------------------------------------------- - // function : scheduler - /// @brief Copy & move constructor - /// @param [in] VT : stack_cnc from where copy the data - //----------------------------------------------------------------------- - scheduler(scheduler && VT) = delete; - scheduler(const scheduler & VT) = delete; - // - //------------------------------------------------------------------------ - // function : ~scheduler - /// @brief Destructor - //------------------------------------------------------------------------ - virtual ~scheduler(void) {mp.clear();}; - // - //------------------------------------------------------------------------ - // function : operator = - /// @brief Asignation operator - /// @param [in] VT : stack_cnc from where copy the data - /// @return Reference to the stack_cnc after the copy - //------------------------------------------------------------------------ - scheduler & operator=(const scheduler &VT) = delete; - // - //------------------------------------------------------------------------ - // function : size - /// @brief Asignation operator - /// @param [in] VT : stack_cnc from where copy the data - /// @return Reference to the stack_cnc after the copy - //------------------------------------------------------------------------ - size_t size(void) const - { - lock_t s(spl); - return nelem; - }; - // - //------------------------------------------------------------------------ - // function : clear - /// @brief Delete all the elements of the stack_cnc. - //------------------------------------------------------------------------ - void clear_all(void) - { - lock_t s(spl); - mp.clear(); - nelem = 0; - }; - - // - //------------------------------------------------------------------------ - // function : insert - /// @brief Insert one element in the back of the container - /// @param [in] D : value to insert. Can ve a value, a reference or an - /// rvalue - /// @return iterator to the element inserted - /// @remarks This operation is O ( const ) - //------------------------------------------------------------------------ - void insert(Func_t & f) - { - lock_t s(spl); - key_t th_id = std::this_thread::get_id(); - it_map itmp = mp.find(th_id); - if (itmp == mp.end()) - { - auto aux = mp.emplace(th_id, deque_t()); - if (aux.second == false) throw std::bad_alloc(); - itmp = aux.first; - }; - itmp->second.emplace_back(std::move(f)); - nelem++; - }; - - // - //------------------------------------------------------------------------ - // function :emplace - /// @brief Insert one element in the back of the container - /// @param [in] args :group of arguments for to build the object to insert - /// @return iterator to the element inserted - /// @remarks This operation is O ( const ) - //------------------------------------------------------------------------ - template<class ... Args> - void emplace(Args && ... args) - { - lock_t s(spl); - key_t th_id = std::this_thread::get_id(); - it_map itmp = mp.find(th_id); - if (itmp == mp.end()) - { - auto aux = mp.emplace(th_id, deque_t()); - if (aux.second == false) throw std::bad_alloc(); - itmp = aux.first; - }; - itmp->second.emplace_back(std::forward <Args>(args) ...); - nelem++; - }; - // - //------------------------------------------------------------------------ - // function : insert - /// @brief Insert one element in the back of the container - /// @param [in] D : value to insert. Can ve a value, a reference or an rvalue - /// @return iterator to the element inserted - /// @remarks This operation is O ( const ) - //------------------------------------------------------------------------ - template<class it_func> - void insert_range(it_func first, it_func last) - { - //-------------------------------------------------------------------- - // Metaprogramming - //-------------------------------------------------------------------- - typedef value_iter<it_func> value2_t; - static_assert (std::is_same< Func_t, value2_t >::value, - "Incompatible iterators\n"); - - //-------------------------------------------------------------------- - // Code - //-------------------------------------------------------------------- - assert((last - first) > 0); - - lock_t s(spl); - key_t th_id = std::this_thread::get_id(); - it_map itmp = mp.find(th_id); - if (itmp == mp.end()) - { - auto aux = mp.emplace(th_id, deque_t()); - if (aux.second == true) throw std::bad_alloc(); - itmp = aux.first; - }; - while (first != last) - { - itmp->second.emplace_back(std::move(*(first++))); - nelem++; - }; - }; - // - //------------------------------------------------------------------------ - // function : extract - /// @brief erase the last element of the tree and return a copy - /// @param [out] V : reference to a variable where copy the element - /// @return code of the operation - /// 0- Element erased - /// 1 - Empty tree - /// @remarks This operation is O(1) - //------------------------------------------------------------------------ - bool extract(Func_t & f) - { - lock_t s(spl); - if (nelem == 0) return false; - key_t th_id = std::this_thread::get_id(); - it_map itmp = mp.find(th_id); - if (itmp != mp.end() and not itmp->second.empty()) - { - f = std::move(itmp->second.back()); - itmp->second.pop_back(); - --nelem; - return true; - }; - for (itmp = mp.begin(); itmp != mp.end(); ++itmp) - { - if (itmp->second.empty()) continue; - f = std::move(itmp->second.back()); - itmp->second.pop_back(); - --nelem; - return true; - } - return false; - }; -}; -// end class scheduler -//************************************************************************* -// P R I N T F U N C T I O N S -//************************************************************************ -template<class ... Args> -std::ostream & operator <<(std::ostream &out, const std::deque<Args ...> & dq) -{ - for (uint32_t i = 0; i < dq.size(); ++i) - out << dq[i] << " "; - out << std::endl; - return out; -} - -template<typename Func_t, typename Allocator = std::allocator<Func_t> > -std::ostream & operator <<(std::ostream &out, - const scheduler<Func_t, Allocator> &sch) -{ - std::unique_lock < spinlock_t > s(sch.spl); - out << "Nelem :" << sch.nelem << std::endl; - for (auto it = sch.mp.begin(); it != sch.mp.end(); ++it) - { - out << it->first << " :" << it->second << std::endl; - } - return out; -} - -//*************************************************************************** -};// end namespace common -};// end namespace sort -};// end namespace boost -//*************************************************************************** -#endif diff --git a/contrib/restricted/boost/boost/sort/common/sort_basic.hpp b/contrib/restricted/boost/boost/sort/common/sort_basic.hpp deleted file mode 100644 index 68a6f540487..00000000000 --- a/contrib/restricted/boost/boost/sort/common/sort_basic.hpp +++ /dev/null @@ -1,334 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file sort_basic.hpp -/// @brief Spin Sort algorithm -/// -/// @author Copyright (c) 2016 Francisco José Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_COMMON_SORT_BASIC_HPP -#define __BOOST_SORT_COMMON_SORT_BASIC_HPP - -//#include <boost/sort/spinsort/util/indirect.hpp> -#include <boost/sort/insert_sort/insert_sort.hpp> -#include <boost/sort/common/util/traits.hpp> -#include <boost/sort/common/range.hpp> -#include <cstdlib> -#include <functional> -#include <iterator> -#include <memory> -#include <type_traits> -#include <vector> -#include <cstddef> - -namespace boost -{ -namespace sort -{ -namespace common -{ - -//---------------------------------------------------------------------------- -// USING SENTENCES -//---------------------------------------------------------------------------- -using boost::sort::insert_sort; - -//----------------------------------------------------------------------------- -// function : is_stable_sorted_forward -/// @brief examine the elements in the range first, last if they are stable -/// sorted, and return an iterator to the first element not sorted -/// @param first : iterator to the first element in the range -/// @param last : ierator after the last element of the range -/// @param comp : object for to compare two elements -/// @return iterator to the first element not stable sorted. The number of -/// elements sorted is the iterator returned minus first -//----------------------------------------------------------------------------- -template<class Iter_t, class Compare = std::less<value_iter<Iter_t> > > -inline Iter_t is_stable_sorted_forward (Iter_t first, Iter_t last, - Compare comp = Compare()) -{ -#ifdef __BS_DEBUG - assert ( (last- first) >= 0); -#endif - if ((last - first) < 2) return first; - Iter_t it2 = first + 1; - for (Iter_t it1 = first; it2 != last and not comp(*it2, *it1); it1 = it2++); - return it2; -} -//----------------------------------------------------------------------------- -// function : is_reverse_stable_sorted_forward -/// @brief examine the elements in the range first, last if they are reverse -/// stable sorted, and return an iterator to the first element not -/// reverse stable sorted -/// @param first : iterator to the first element in the range -/// @param last : ierator after the last element of the range -/// @param comp : object for to compare two elements -/// @return iterator to the first element not reverse stable sorted. The number -/// of elements sorted is the iterator returned minus first -//----------------------------------------------------------------------------- -template<class Iter_t, class Compare = std::less<value_iter<Iter_t> > > -inline Iter_t is_reverse_stable_sorted_forward(Iter_t first, Iter_t last, - Compare comp = Compare()) -{ -#ifdef __BS_DEBUG - assert ( (last- first) >= 0); -#endif - if ((last - first) < 2) return first; - Iter_t it2 = first + 1; - for (Iter_t it1 = first; it2 != last and comp(*it2, *it1); it1 = it2++); - return it2; -}; -//----------------------------------------------------------------------------- -// function : number_stable_sorted_forward -/// @brief examine the elements in the range first, last if they are stable -/// sorted, and return the number of elements sorted -/// @param first : iterator to the first element in the range -/// @param last : ierator after the last element of the range -/// @param comp : object for to compare two elements -/// @param min_process : minimal number of elements to be consideer -/// @return number of element sorted. I f the number is lower than min_process -/// return 0 -//----------------------------------------------------------------------------- -template<class Iter_t, class Compare = std::less<value_iter<Iter_t> > > -size_t number_stable_sorted_forward (Iter_t first, Iter_t last, - size_t min_process, - Compare comp = Compare()) -{ -#ifdef __BS_DEBUG - assert ( (last- first) >= 0); -#endif - if ((last - first) < 2) return 0; - - // sorted elements - Iter_t it2 = first + 1; - for (Iter_t it1 = first; it2 != last and not comp(*it2, *it1); it1 = it2++); - size_t nsorted = size_t ( it2 - first); - if ( nsorted != 1) - return (nsorted >= min_process) ? nsorted: 0; - - // reverse sorted elements - it2 = first + 1; - for (Iter_t it1 = first; it2 != last and comp(*it2, *it1); it1 = it2++); - nsorted = size_t ( it2 - first); - - if ( nsorted < min_process) return 0 ; - util::reverse ( first , it2); - return nsorted; -}; - -//----------------------------------------------------------------------------- -// function : is_stable_sorted_backward -/// @brief examine the elements in the range first, last beginning at end, and -/// if they are stablesorted, and return an iterator to the last element -/// sorted -/// @param first : iterator to the first element in the range -/// @param last : ierator after the last element of the range -/// @param comp : object for to compare two elements -/// @return iterator to the last element stable sorted. The number of -/// elements sorted is the last minus the iterator returned -//----------------------------------------------------------------------------- -template<class Iter_t, class Compare = std::less<value_iter<Iter_t> > > -inline Iter_t is_stable_sorted_backward(Iter_t first, Iter_t last, - Compare comp = Compare()) -{ -#ifdef __BS_DEBUG - assert ( (last- first) >= 0); -#endif - if ((last - first) < 2) return first; - Iter_t itaux = last - 1; - while (itaux != first and not comp(*itaux, *(itaux - 1))) {--itaux; }; - return itaux; -} -//----------------------------------------------------------------------------- -// function : is_reverse_stable_sorted_backward -/// @brief examine the elements in the range first, last beginning at end, and -/// if they are stablesorted, and return an iterator to the last element -/// sorted -/// @param first : iterator to the first element in the range -/// @param last : ierator after the last element of the range -/// @param comp : object for to compare two elements -/// @return iterator to the last element stable sorted. The number of -/// elements sorted is the last minus the iterator returned -//----------------------------------------------------------------------------- -template<class Iter_t, class Compare = std::less<value_iter<Iter_t> > > -inline Iter_t is_reverse_stable_sorted_backward (Iter_t first, Iter_t last, - Compare comp = Compare()) -{ -#ifdef __BS_DEBUG - assert ( (last- first) >= 0); -#endif - if ((last - first) < 2) return first; - Iter_t itaux = last - 1; - for (; itaux != first and comp(*itaux, *(itaux - 1)); --itaux); - return itaux; -} - -//----------------------------------------------------------------------------- -// function : number_stable_sorted_backward -/// @brief examine the elements in the range first, last if they are stable -/// sorted, and return the number of elements sorted -/// @param first : iterator to the first element in the range -/// @param last : ierator after the last element of the range -/// @param comp : object for to compare two elements -/// @param min_process : minimal number of elements to be consideer -/// @return number of element sorted. I f the number is lower than min_process -/// return 0 -//----------------------------------------------------------------------------- -template<class Iter_t, class Compare = std::less<value_iter<Iter_t> > > -size_t number_stable_sorted_backward (Iter_t first, Iter_t last, - size_t min_process, - Compare comp = Compare()) -{ -#ifdef __BS_DEBUG - assert ( (last- first) >= 0); -#endif - if ((last - first) < 2) return 0; - Iter_t itaux = last - 1; - while (itaux != first and not comp(*itaux, *(itaux - 1))) {--itaux; }; - size_t nsorted = size_t ( last - itaux); - if ( nsorted != 1) - return ( nsorted >= min_process)?nsorted: 0 ; - - itaux = last - 1; - for (; itaux != first and comp(*itaux, *(itaux - 1)); --itaux); - nsorted = size_t ( last - itaux); - if ( nsorted < min_process) return 0 ; - util::reverse ( itaux, last ); - return nsorted; -} -//----------------------------------------------------------------------------- -// function : internal_sort -/// @brief this function divide r_input in two parts, sort it,and merge moving -/// the elements to range_buf -/// @param range_input : range with the elements to sort -/// @param range_buffer : range with the elements sorted -/// @param comp : object for to compare two elements -/// @param level : when is 1, sort with the insertionsort algorithm -/// if not make a recursive call splitting the ranges -// -//----------------------------------------------------------------------------- -template <class Iter1_t, class Iter2_t, class Compare> -inline void internal_sort (const range<Iter1_t> &rng1, - const range<Iter2_t> &rng2, - Compare comp, uint32_t level, bool even = true) -{ - //----------------------------------------------------------------------- - // metaprogram - //----------------------------------------------------------------------- - typedef value_iter<Iter1_t> value_t; - typedef value_iter<Iter2_t> value2_t; - static_assert (std::is_same< value_t, value2_t>::value, - "Incompatible iterators\n"); - - //----------------------------------------------------------------------- - // program - //----------------------------------------------------------------------- -#ifdef __BS_DEBUG - assert (rng1.size ( ) == rng2.size ( ) ); -#endif - size_t nelem = (rng1.size() + 1) >> 1; - - range<Iter1_t> rng1_left(rng1.first, rng1.first + nelem), - rng1_right(rng1.first + nelem, rng1.last); - - range<Iter2_t> rng2_left(rng2.first, rng2.first + nelem), - rng2_right(rng2.first + nelem, rng2.last); - - if (nelem <= 32 and (level & 1) == even) - { - insert_sort(rng1_left.first, rng1_left.last, comp); - insert_sort(rng1_right.first, rng1_right.last, comp); - } - else - { - internal_sort(rng2_left, rng1_left, comp, level + 1, even); - internal_sort(rng2_right, rng1_right, comp, level + 1, even); - }; - merge(rng2, rng1_left, rng1_right, comp); -}; -//----------------------------------------------------------------------------- -// function : range_sort_data -/// @brief this sort elements using the range_sort function and receiving a -/// buffer of initialized memory -/// @param rng_data : range with the elements to sort -/// @param rng_aux : range of at least the same memory than rng_data used as -/// auxiliary memory in the sorting -/// @param comp : object for to compare two elements -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Compare> -static void range_sort_data (const range<Iter1_t> & rng_data, - const range<Iter2_t> & rng_aux, Compare comp) -{ - //----------------------------------------------------------------------- - // metaprogram - //----------------------------------------------------------------------- - typedef value_iter<Iter1_t> value_t; - typedef value_iter<Iter2_t> value2_t; - static_assert (std::is_same< value_t, value2_t>::value, - "Incompatible iterators\n"); - - //------------------------------------------------------------------------ - // program - //------------------------------------------------------------------------ -#ifdef __BS_DEBUG - assert ( rng_data.size() == rng_aux.size()); -#endif - // minimal number of element before to jump to insertionsort - const uint32_t sort_min = 32; - if (rng_data.size() <= sort_min) - { - insert_sort(rng_data.first, rng_data.last, comp); - return; - }; - - internal_sort(rng_aux, rng_data, comp, 0, true); -}; -//----------------------------------------------------------------------------- -// function : range_sort_buffer -/// @brief this sort elements using the range_sort function and receiving a -/// buffer of initialized memory -/// @param rng_data : range with the elements to sort -/// @param rng_aux : range of at least the same memory than rng_data used as -/// auxiliary memory in the sorting -/// @param comp : object for to compare two elements -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Compare> -static void range_sort_buffer(const range<Iter1_t> & rng_data, - const range<Iter2_t> & rng_aux, Compare comp) -{ - //----------------------------------------------------------------------- - // metaprogram - //----------------------------------------------------------------------- - typedef value_iter<Iter1_t> value_t; - typedef value_iter<Iter2_t> value2_t; - static_assert (std::is_same< value_t, value2_t>::value, - "Incompatible iterators\n"); - - //------------------------------------------------------------------------ - // program - //------------------------------------------------------------------------ -#ifdef __BS_DEBUG - assert ( rng_data.size() == rng_aux.size()); -#endif - // minimal number of element before to jump to insertionsort - const uint32_t sort_min = 32; - if (rng_data.size() <= sort_min) - { - insert_sort(rng_data.first, rng_data.last, comp); - move_forward(rng_aux, rng_data); - return; - }; - - internal_sort(rng_data, rng_aux, comp, 0, false); -}; -//**************************************************************************** -};// End namespace common -};// End namespace sort -};// End namepspace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/common/spinlock.hpp b/contrib/restricted/boost/boost/sort/common/spinlock.hpp deleted file mode 100644 index 450ba6b53e3..00000000000 --- a/contrib/restricted/boost/boost/sort/common/spinlock.hpp +++ /dev/null @@ -1,88 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file spinlock_t.hpp -/// @brief -/// -/// @author Copyright (c) 2010 2015 Francisco José Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanyingfile LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_PARALLEL_DETAIL_UTIL_SPINLOCK_HPP -#define __BOOST_SORT_PARALLEL_DETAIL_UTIL_SPINLOCK_HPP - -#include <atomic> -#include <ctime> -#include <functional> -#include <memory> -#include <mutex> -#include <thread> - -namespace boost -{ -namespace sort -{ -namespace common -{ -// -//--------------------------------------------------------------------------- -/// @class spinlock_t -/// @brief This class implement, from atomic variables, a spinlock -/// @remarks This class meet the BasicLockable requirements ( lock, unlock ) -//--------------------------------------------------------------------------- -class spinlock_t -{ - private: - //------------------------------------------------------------------------ - // P R I V A T E V A R I A B L E S - //------------------------------------------------------------------------ - std::atomic_flag af; - - public: - // - //------------------------------------------------------------------------- - // function : spinlock_t - /// @brief class constructor - /// @param [in] - //------------------------------------------------------------------------- - explicit spinlock_t ( ) noexcept { af.clear ( ); }; - // - //------------------------------------------------------------------------- - // function : lock - /// @brief Lock the spinlock_t - //------------------------------------------------------------------------- - void lock ( ) noexcept - { - while (af.test_and_set (std::memory_order_acquire)) - { - std::this_thread::yield ( ); - }; - }; - // - //------------------------------------------------------------------------- - // function : try_lock - /// @brief Try to lock the spinlock_t, if not, return false - /// @return true : locked - /// false: not previous locked - //------------------------------------------------------------------------- - bool try_lock ( ) noexcept - { - return not af.test_and_set (std::memory_order_acquire); - }; - // - //------------------------------------------------------------------------- - // function : unlock - /// @brief unlock the spinlock_t - //------------------------------------------------------------------------- - void unlock ( ) noexcept { af.clear (std::memory_order_release); }; - -}; // E N D C L A S S S P I N L O C K -// -//*************************************************************************** -}; // end namespace common -}; // end namespace sort -}; // end namespace boost -//*************************************************************************** -#endif diff --git a/contrib/restricted/boost/boost/sort/common/stack_cnc.hpp b/contrib/restricted/boost/boost/sort/common/stack_cnc.hpp deleted file mode 100644 index d4d6e53b25e..00000000000 --- a/contrib/restricted/boost/boost/sort/common/stack_cnc.hpp +++ /dev/null @@ -1,142 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file stack_cnc.hpp -/// @brief This file contains the implementation concurrent stack -/// -/// @author Copyright (c) 2010 2015 Francisco José Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanyingfile LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_PARALLEL_DETAIL_UTIL_STACK_CNC_HPP -#define __BOOST_SORT_PARALLEL_DETAIL_UTIL_STACK_CNC_HPP - -#include <boost/sort/common/spinlock.hpp> -#include <vector> - -namespace boost -{ -namespace sort -{ -namespace common -{ - -// -//########################################################################### -// ## -// ################################################################ ## -// # # ## -// # C L A S S # ## -// # S T A C K _ C N C # ## -// # # ## -// ################################################################ ## -// ## -//########################################################################### -// -//--------------------------------------------------------------------------- -/// @class stack_cnc -/// @brief This class is a concurrent stack controled by a spin_lock -/// @remarks -//--------------------------------------------------------------------------- -template<typename T, typename Allocator = std::allocator<T> > -class stack_cnc -{ -public: - //------------------------------------------------------------------------ - // D E F I N I T I O N S - //------------------------------------------------------------------------ - typedef std::vector<T, Allocator> vector_t; - typedef typename vector_t::size_type size_type; - typedef typename vector_t::difference_type difference_type; - typedef typename vector_t::value_type value_type; - typedef typename vector_t::pointer pointer; - typedef typename vector_t::const_pointer const_pointer; - typedef typename vector_t::reference reference; - typedef typename vector_t::const_reference const_reference; - typedef typename vector_t::allocator_type allocator_type; - typedef Allocator alloc_t; - -protected: - //------------------------------------------------------------------------- - // INTERNAL VARIABLES - //------------------------------------------------------------------------- - vector_t v_t; - mutable spinlock_t spl; - -public: - // - //------------------------------------------------------------------------- - // function : stack_cnc - /// @brief constructor - //------------------------------------------------------------------------- - explicit stack_cnc(void): v_t() { }; - - // - //------------------------------------------------------------------------- - // function : stack_cnc - /// @brief Move constructor - //------------------------------------------------------------------------- - stack_cnc(stack_cnc &&) = delete; - // - //------------------------------------------------------------------------- - // function : ~stack_cnc - /// @brief Destructor - //------------------------------------------------------------------------- - virtual ~stack_cnc(void) { v_t.clear(); }; - - //------------------------------------------------------------------------- - // function : emplace_back - /// @brief Insert one element in the back of the container - /// @param args : group of arguments for to build the object to insert. Can - /// be values, references or rvalues - //------------------------------------------------------------------------- - template<class ... Args> - void emplace_back(Args &&... args) - { - std::lock_guard < spinlock_t > guard(spl); - v_t.emplace_back(std::forward< Args > (args)...); - }; - - // - //------------------------------------------------------------------------- - // function :pop_move_back - /// @brief if exist, move the last element to P, and delete it - /// @param P : reference to a variable where move the element - /// @return true - Element moved and deleted - /// false - Empty stack_cnc - //------------------------------------------------------------------------- - bool pop_move_back(value_type &P) - { - std::lock_guard < spinlock_t > S(spl); - if (v_t.size() == 0) return false; - P = std::move(v_t.back()); - v_t.pop_back(); - return true; - }; - //------------------------------------------------------------------------- - // function : push_back - /// @brief Insert one vector at the end of the container - /// @param v_other : vector to insert - /// @return reference to the stack_cnc after the insertion - //------------------------------------------------------------------------- - template<class Allocator2> - stack_cnc &push_back(const std::vector<value_type, Allocator2> &v_other) - { - std::lock_guard < spinlock_t > guard(spl); - for (size_type i = 0; i < v_other.size(); ++i) - { - v_t.push_back(v_other[i]); - } - return *this; - }; -}; -// end class stack_cnc - -//*************************************************************************** -};// end namespace common -};// end namespace sort -};// end namespace boost -//*************************************************************************** -#endif diff --git a/contrib/restricted/boost/boost/sort/common/time_measure.hpp b/contrib/restricted/boost/boost/sort/common/time_measure.hpp deleted file mode 100644 index ef00dd49306..00000000000 --- a/contrib/restricted/boost/boost/sort/common/time_measure.hpp +++ /dev/null @@ -1,62 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file time_measure.hpp -/// @brief This class is done in order to simplify the time measure in the -/// benchmaark programs -/// -/// @author Copyright (c) 2010 2015 Francisco José Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanyingfile LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_PARALLEL_TOOLS_TIME_MEASURE_HPP -#define __BOOST_SORT_PARALLEL_TOOLS_TIME_MEASURE_HPP - -#include <chrono> - -namespace boost -{ -namespace sort -{ -namespace common -{ - -namespace chrn = std::chrono; -// -//*************************************************************************** -// D E F I N I T I O N S -//*************************************************************************** -typedef chrn::steady_clock::time_point time_point; - -time_point now ( ); -double subtract_time ( const time_point & t1, const time_point & t2 ); -// -//--------------------------------------------------------------------------- -// function : now -/// @brief return the time system in a internal format ( steady_clock) -/// @return time in steady_clock format -//--------------------------------------------------------------------------- -time_point now ( ) { return chrn::steady_clock::now( ); }; -// -//--------------------------------------------------------------------------- -// function : subtract_time -/// @brief return the time in double format -/// @param [in] t1 : first time in time_point format -/// @param [in] t2 : second time in time_point format -/// @return time in seconds of the difference of t1 - t2 -//--------------------------------------------------------------------------- -double subtract_time ( const time_point & t1, const time_point & t2 ) -{ //------------------------ begin --------------------------------- - chrn::duration<double> time_span = - chrn::duration_cast < chrn::duration < double > > ( t1 - t2 ); - return time_span.count( ); -}; - -//*************************************************************************** -};// End namespace benchmark -};// End namespace sort -};// End namespace boost -//*************************************************************************** -#endif diff --git a/contrib/restricted/boost/boost/sort/common/util/algorithm.hpp b/contrib/restricted/boost/boost/sort/common/util/algorithm.hpp deleted file mode 100644 index db7607aaeb5..00000000000 --- a/contrib/restricted/boost/boost/sort/common/util/algorithm.hpp +++ /dev/null @@ -1,309 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file algorithm.hpp -/// @brief low level functions of create, destroy, move and merge functions -/// -/// @author Copyright (c) 2017 Francisco Jose Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_COMMON_UTIL_ALGORITHM_HPP -#define __BOOST_SORT_COMMON_UTIL_ALGORITHM_HPP - -#include <algorithm> -#include <functional> -#include <iterator> -#include <memory> -#include <type_traits> -#include <vector> -#include <boost/sort/common/util/traits.hpp> - -namespace boost -{ -namespace sort -{ -namespace common -{ -namespace util -{ -// -//########################################################################### -// -// I M P O R T A N T -// -// The functions of this file are for internal use only -// All the operations are done with move operations, because the copy -// operations are unnecesary -// -//########################################################################### -// -//---------------------------------------------------------------------------- -// -// F U N C T I O N S I N T H E F I L E -// -//---------------------------------------------------------------------------- -// -// static inline uint32_t nbits32 (uint32_t num) noexcept -// -// static inline uint32_t nbits64 (uint64_t num) -// -// template < class Value_t, class... Args > -// inline void construct_object (Value_t *ptr, Args &&... args) -// -// template < class Value_t > -// inline void destroy_object (Value_t *ptr) -// -// template < class Iter_t, class Value_t = value_iter<Iter_t> > -// void initialize (Iter_t first, Iter_t last, Value_t && val) -// -// template < class Iter1_t, class Iter2_t > -// Iter2_t move_forward (Iter2_t it_dest, Iter1_t first, Iter1_t last) -// -// template < class Iter1_t, class Iter2_t > -// Iter2_t move_backward (Iter2_t it_dest, Iter1_t first, Iter1_t last) -// -// template < class Iter_t, class Value_t = value_iter< Iter_t > > -// Value_t * move_construct (Value_t *ptr, Iter_t first, Iter_t last) -// -// template < class Iter_t > -// void destroy (Iter_t first, const Iter_t last) -// -// template < class Iter_t > -// void reverse (Iter_t first, const Iter_t last) -// -//---------------------------------------------------------------------------- -// -//-------------------------------------------------------------------------- -// -// G L O B A L V A R I B L E S -// -//-------------------------------------------------------------------------- -// -// this array represent the number of bits needed for to represent the -// first 256 numbers -static constexpr const uint32_t tmsb[256] = -{ 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }; -// -//--------------------------------------------------------------------------- -// -// F U N C T I O N S -// -//--------------------------------------------------------------------------- -// -//--------------------------------------------------------------------------- -// function : nbits32 -/// @brief Obtain the number of bits of a number equal or greater than num -/// @param num : Number to examine -/// @return Number of bits -//--------------------------------------------------------------------------- -static inline uint32_t nbits32 (uint32_t num) noexcept -{ - int Pos = (num & 0xffff0000U) ? 16 : 0; - if ((num >> Pos) & 0xff00U) Pos += 8; - return (tmsb[num >> Pos] + Pos); -} -// -//--------------------------------------------------------------------------- -// function : nbits64 -/// @brief Obtain the number of bits of a number equal or greater than num -/// @param num : Number to examine -/// @exception none -/// @return Number of bits -//--------------------------------------------------------------------------- -static inline uint32_t nbits64(uint64_t num)noexcept -{ - uint32_t Pos = (num & 0xffffffff00000000ULL) ? 32 : 0; - if ((num >> Pos) & 0xffff0000ULL) Pos += 16; - if ((num >> Pos) & 0xff00ULL) Pos += 8; - return (tmsb[num >> Pos] + Pos); -} -// -//----------------------------------------------------------------------------- -// function : construct_object -/// @brief create an object in the memory specified by ptr -/// -/// @param ptr : pointer to the memory where to create the object -/// @param args : arguments to the constructor -//----------------------------------------------------------------------------- -template <class Value_t, class ... Args> -inline void construct_object (Value_t *ptr, Args &&... args) -{ - (::new (static_cast<void *>(ptr)) Value_t(std::forward< Args > (args)...)); -}; -// -//----------------------------------------------------------------------------- -// function : destroy_object -/// @brief destroy an object in the memory specified by ptr -/// @param ptr : pointer to the object to destroy -//----------------------------------------------------------------------------- -template<class Value_t> -inline void destroy_object(Value_t *ptr) -{ - ptr->~Value_t(); -}; -// -//----------------------------------------------------------------------------- -// function : initialize -/// @brief initialize a range of objects with the object val moving across them -/// -/// @param first : itertor to the first element to initialize -/// @param last : iterator to the last element to initialize -/// @param val : object used for the initialization -//----------------------------------------------------------------------------- -template <class Iter_t, class Value_t = value_iter<Iter_t> > -inline void initialize (Iter_t first, Iter_t last, Value_t & val) -{ - //------------------------------------------------------------------------ - // Metaprogramming - //------------------------------------------------------------------------ - typedef value_iter<Iter_t> value_t; - static_assert (std::is_same< Value_t, value_t >::value, - "Incompatible iterators\n"); - - //------------------------------------------------------------------------ - // Code - //------------------------------------------------------------------------ - if (first == last) return; - construct_object(&(*first), std::move(val)); - - Iter_t it1 = first, it2 = first + 1; - while (it2 != last) - { - construct_object(&(*(it2++)), std::move(*(it1++))); - }; - val = std::move(*(last - 1)); -}; -// -//----------------------------------------------------------------------------- -// function : move_forward -/// @brief Move initialized objets -/// @param it_dest : iterator to the final place of the objects -/// @param first : iterator to the first element to move -/// @param last : iterator to the last element to move -/// @return Output iterator to the element past the last element -/// moved (it_dest + (last - first)) -//----------------------------------------------------------------------------- -template <class Iter1_t, class Iter2_t> -inline Iter2_t move_forward (Iter2_t it_dest, Iter1_t first, Iter1_t last) -{ - //------------------------------------------------------------------------ - // Metaprogramming - //------------------------------------------------------------------------ - typedef value_iter<Iter1_t> value1_t; - typedef value_iter<Iter2_t> value2_t; - static_assert (std::is_same< value1_t, value2_t >::value, - "Incompatible iterators\n"); - - //------------------------------------------------------------------------ - // Code - //------------------------------------------------------------------------ - while (first != last) - { *it_dest++ = std::move(*first++); - } - return it_dest; - -}; -// -//----------------------------------------------------------------------------- -// function : move_backard -/// @brief Move initialized objets in reverse order -/// @param it_dest : last iterator to the final place of the objects -/// @param first : iterator to the first element to move -/// @param last : iterator to the last element to move -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t> -inline Iter2_t move_backward(Iter2_t it_dest, Iter1_t first, Iter1_t last) -{ - //------------------------------------------------------------------------ - // Metaprogramming - //------------------------------------------------------------------------ - typedef value_iter<Iter1_t> value1_t; - typedef value_iter<Iter2_t> value2_t; - static_assert (std::is_same< value1_t, value2_t >::value, - "Incompatible iterators\n"); - - //------------------------------------------------------------------------ - // Code - //------------------------------------------------------------------------ - while (first != last) - { *(--it_dest) = std::move (*(--last)); - } - return it_dest; -}; - -// -//----------------------------------------------------------------------------- -// function : move_construct -/// @brief Move objets to uninitialized memory -/// -/// @param ptr : pointer to the memory where to create the objects -/// @param first : iterator to the first element to move -/// @param last : iterator to the last element to move -//----------------------------------------------------------------------------- -template<class Iter_t, class Value_t = value_iter<Iter_t> > -inline Value_t * move_construct(Value_t *ptr, Iter_t first, Iter_t last) -{ - //------------------------------------------------------------------------ - // Metaprogramming - //------------------------------------------------------------------------ - typedef typename iterator_traits<Iter_t>::value_type value2_t; - static_assert (std::is_same< Value_t, value2_t >::value, - "Incompatible iterators\n"); - - //------------------------------------------------------------------------ - // Code - //------------------------------------------------------------------------ - while (first != last) - { - ::new (static_cast<void *>(ptr++)) Value_t(std::move(*(first++))); - }; - return ptr; -}; -// -//----------------------------------------------------------------------------- -// function : destroy -/// @brief destroy the elements between first and last -/// @param first : iterator to the first element to destroy -/// @param last : iterator to the last element to destroy -//----------------------------------------------------------------------------- -template<class Iter_t> -inline void destroy(Iter_t first, const Iter_t last) -{ - while (first != last) - destroy_object(&(*(first++))); -}; -// -//----------------------------------------------------------------------------- -// function : reverse -/// @brief destroy the elements between first and last -/// @param first : iterator to the first element to destroy -/// @param last : iterator to the last element to destroy -//----------------------------------------------------------------------------- -template<class Iter_t> -inline void reverse(Iter_t first, Iter_t last) -{ - std::reverse ( first, last); -}; -// -//**************************************************************************** -};// End namespace util -};// End namespace common -};// End namespace sort -};// End namespace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/common/util/atomic.hpp b/contrib/restricted/boost/boost/sort/common/util/atomic.hpp deleted file mode 100644 index 15906fe52a9..00000000000 --- a/contrib/restricted/boost/boost/sort/common/util/atomic.hpp +++ /dev/null @@ -1,98 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file atomic.hpp -/// @brief Basic layer for to simplify the use of atomic functions -/// @author Copyright(c) 2016 Francisco José Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_PARALLEL_DETAIL_UTIL_ATOMIC_HPP -#define __BOOST_SORT_PARALLEL_DETAIL_UTIL_ATOMIC_HPP - -#include <atomic> -#include <cassert> -#include <type_traits> - -namespace boost -{ -namespace sort -{ -namespace common -{ -namespace util -{ -//----------------------------------------------------------------------------- -// function : atomic_read -/// @brief make the atomic read of an atomic variable, using a memory model -/// @param at_var : atomic variable to read -/// @return value obtained -//----------------------------------------------------------------------------- -template<typename T> -inline T atomic_read(std::atomic<T> &at_var) -{ - return std::atomic_load_explicit < T > (&at_var, std::memory_order_acquire); -}; -// -//----------------------------------------------------------------------------- -// function : atomic_add -/// @brief Add a number to an atomic variable, using a memory model -/// @param at_var : variable to add -/// @param num : value to add to at_var -/// @return result of the operation -//----------------------------------------------------------------------------- -template<typename T, typename T2> -inline T atomic_add(std::atomic<T> &at_var, T2 num) -{ - static_assert (std::is_integral< T2 >::value, "Bad parameter"); - return std::atomic_fetch_add_explicit <T> - (&at_var, (T) num, std::memory_order_acq_rel); -}; -// -//----------------------------------------------------------------------------- -// function : atomic_sub -/// @brief Atomic subtract of an atomic variable using memory model -/// @param at_var : Varibale to subtract -/// @param num : value to sub to at_var -/// @return result of the operation -//----------------------------------------------------------------------------- -template<typename T, typename T2> -inline T atomic_sub(std::atomic<T> &at_var, T2 num) -{ - static_assert (std::is_integral< T2 >::value, "Bad parameter"); - return std::atomic_fetch_sub_explicit <T> - (&at_var, (T) num, std::memory_order_acq_rel); -}; -// -//----------------------------------------------------------------------------- -// function : atomic_write -/// @brief Write a value in an atomic variable using memory model -/// @param at_var : varible to write -/// @param num : value to write in at_var -//----------------------------------------------------------------------------- -template<typename T, typename T2> -inline void atomic_write(std::atomic<T> &at_var, T2 num) -{ - static_assert (std::is_integral< T2 >::value, "Bad parameter"); - std::atomic_store_explicit <T> - (&at_var, (T) num, std::memory_order_release); -}; -template<typename T> -struct counter_guard -{ - typedef std::atomic<T> atomic_t; - atomic_t &count; - - counter_guard(atomic_t & counter): count(counter) { }; - ~counter_guard() {atomic_sub(count, 1); }; -}; -// -//**************************************************************************** -};// End namespace util -};// End namespace common -};// End namespace sort -};// End namespace boost -//**************************************************************************** -#endif diff --git a/contrib/restricted/boost/boost/sort/common/util/circular_buffer.hpp b/contrib/restricted/boost/boost/sort/common/util/circular_buffer.hpp deleted file mode 100644 index 2fc7e973e1a..00000000000 --- a/contrib/restricted/boost/boost/sort/common/util/circular_buffer.hpp +++ /dev/null @@ -1,572 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file circular_buffer.hpp -/// @brief This file contains the implementation of the circular buffer -/// -/// @author Copyright (c) 2010 2015 Francisco José Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanyingfile LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_COMMON_UTIL_CIRCULAR_BUFFER_HPP -#define __BOOST_SORT_COMMON_UTIL_CIRCULAR_BUFFER_HPP - -#include <memory> -#include <cassert> -#include <exception> -#include <boost/sort/common/util/algorithm.hpp> -#include <boost/sort/common/util/traits.hpp> - -namespace boost -{ -namespace sort -{ -namespace common -{ -namespace util -{ - -//--------------------------------------------------------------------------- -/// @class circular_buffer -/// @brief This class implement a circular buffer -/// @remarks -//--------------------------------------------------------------------------- -template <class Value_t, uint32_t Power2 = 11> -struct circular_buffer -{ - //------------------------------------------------------------------------ - // STATIC CHECK - //------------------------------------------------------------------------ - static_assert ( Power2 != 0, "Wrong Power2"); - - //------------------------------------------------------------------------ - // DEFINITIONS - //------------------------------------------------------------------------ - typedef Value_t value_t; - - //------------------------------------------------------------------------ - // VARIABLES - //------------------------------------------------------------------------ - const size_t NMAX = (size_t) 1 << Power2; - const size_t MASK = (NMAX - 1); - const size_t BLOCK_SIZE = NMAX >> 1; - const size_t LOG_BLOCK = Power2 - 1; - Value_t * ptr = nullptr; - - //------------------------------------------------------------------------ - // first and last are the position of the first and last elements - // always are in the range [0, NMAX - 1] - //------------------------------------------------------------------------ - size_t nelem, first_pos; - bool initialized; - - // - //------------------------------------------------------------------------ - // function : circular_buffer - /// @brief constructor of the class - //----------------------------------------------------------------------- - circular_buffer(void) - : ptr(nullptr), nelem(0), first_pos(0), initialized(false) - { - ptr = std::get_temporary_buffer < Value_t > (NMAX).first; - if (ptr == nullptr) throw std::bad_alloc(); - }; - // - //------------------------------------------------------------------------ - // function : ~circular_buffer - /// @brief destructor of the class - //----------------------------------------------------------------------- - ~circular_buffer() - { - if (initialized) - { for (size_t i = 0; i < NMAX; ++i) (ptr + i)->~Value_t(); - initialized = false; - }; - std::return_temporary_buffer(ptr); - } - ; - // - //------------------------------------------------------------------------ - // function : initialize - /// @brief : initialize the memory of the buffer from the uninitialize - // memory obtained from the temporary buffer - /// @param val : value used to initialize the memory - //----------------------------------------------------------------------- - void initialize(Value_t & val) - { - assert (initialized == false); - ::new (static_cast<void*>(ptr)) Value_t(std::move(val)); - for (size_t i = 1; i < NMAX; ++i) - ::new (static_cast<void*>(ptr + i)) Value_t(std::move(ptr[i - 1])); - val = std::move(ptr[NMAX - 1]); - initialized = true; - }; - // - //------------------------------------------------------------------------ - // function : destroy_all - /// @brief : destroy all the objects in the internal memory - //----------------------------------------------------------------------- - void destroy_all(void) { destroy(ptr, ptr + NMAX); }; - // - //------------------------------------------------------------------------ - // function : get_buffer - /// @brief return the internal memory of the circular buffer - /// @return pointer to the internal memory of the buffer - //----------------------------------------------------------------------- - Value_t * get_buffer(void) { return ptr; }; - // - //------------------------------------------------------------------------ - // function : empty - /// @brief return if the buffer is empty - /// @return true : empty - //----------------------------------------------------------------------- - bool empty(void) const {return (nelem == 0); }; - // - //------------------------------------------------------------------------ - // function : full - /// @brief return if the buffer is full - /// @return true : full - //----------------------------------------------------------------------- - bool full(void) const { return (nelem == NMAX); }; - // - //------------------------------------------------------------------------ - // function : size - /// @brief return the number of elements stored in the buffer - /// @return number of elements stored - //----------------------------------------------------------------------- - size_t size(void) const { return nelem;}; - // - //------------------------------------------------------------------------ - // function : capacity - /// @brief : return the maximun capacity of the buffer - /// @return number of elements - //----------------------------------------------------------------------- - size_t capacity(void) const { return NMAX;}; - // - //------------------------------------------------------------------------ - // function : free_size - /// @brief return the free positions in the buffer - /// @return number of elements - //----------------------------------------------------------------------- - size_t free_size(void) const { return (NMAX - nelem); }; - // - //------------------------------------------------------------------------ - // function : clear - /// @brief clear the buffer - //----------------------------------------------------------------------- - void clear(void) { nelem = first_pos = 0; }; - // - //------------------------------------------------------------------------ - // function : front - /// @brief return the first element of the buffer - /// @return reference to the first value - //----------------------------------------------------------------------- - Value_t & front(void) - { -#ifdef __BS_DEBUG - assert (nelem > 0); -#endif - return (ptr[first_pos]); - }; - // - //------------------------------------------------------------------------ - // function :front - /// @brief return the first element of the buffer - /// @return const reference to the first value - //----------------------------------------------------------------------- - const Value_t & front(void) const - { -#ifdef __BS_DEBUG - assert ( nelem > 0 ); -#endif - return (ptr[first_pos]); - }; - // - //------------------------------------------------------------------------ - // function : back - /// @brief reference to the last value of the buffer - /// @return reference to the last value - //----------------------------------------------------------------------- - Value_t & back(void) - { -#ifdef __BS_DEBUG - assert ( nelem > 0 ); -#endif - return (ptr[(first_pos + nelem - 1) & MASK]); - }; - // - //------------------------------------------------------------------------ - // function : back - /// @brief reference to the last value of the buffer - /// @return const reference to the last value - //----------------------------------------------------------------------- - const Value_t & back(void) const - { -#ifdef __BS_DEBUG - assert ( nelem > 0 ); -#endif - return (ptr[(first_pos + nelem - 1) & MASK]); - }; - // - //------------------------------------------------------------------------ - // function : operator [] - /// @brief positional access to the elements - /// @param pos rquested - /// @return reference to the element - //----------------------------------------------------------------------- - Value_t & operator[](uint32_t pos) - { -#ifdef __BS_DEBUG - assert ( nelem > 0 ); -#endif - return ptr[(first_pos + pos) & MASK]; - }; - // - //------------------------------------------------------------------------ - // function : operator [] - /// @brief positional access to the elements - /// @param pos rquested - /// @return const reference to the element - //----------------------------------------------------------------------- - const Value_t & operator[](uint32_t pos) const - { - -#ifdef __BS_DEBUG - assert ( nelem > 0 ); -#endif - return ptr[(first_pos + pos) & MASK]; - }; - // - //------------------------------------------------------------------------ - // function : push_front - /// @brief insert an element in the first position of the buffer - /// @param val : const value to insert - //----------------------------------------------------------------------- - void push_front(const Value_t & val) - { -#ifdef __BS_DEBUG - assert ( nelem != NMAX); -#endif - ++nelem; - first_pos = ((first_pos + MASK) & MASK); - ptr[first_pos] = val; - - }; - // - //------------------------------------------------------------------------ - // function : push_front - /// @brief insert an element in the first position of the buffer - /// @param val : rvalue to insert - //----------------------------------------------------------------------- - void push_front(Value_t && val) - { -#ifdef __BS_DEBUG - assert ( nelem != NMAX); -#endif - ++nelem; - first_pos = ((first_pos + MASK) & MASK); - ptr[first_pos] = val; - }; - // - //------------------------------------------------------------------------ - // function : push_back - /// @brief insert an element in the last position of the buffer - /// @param val : value to insert - //----------------------------------------------------------------------- - void push_back(const Value_t & val) - { -#ifdef __BS_DEBUG - assert ( nelem != NMAX); -#endif - ptr[(first_pos + (nelem++)) & MASK] = val; - }; - // - //------------------------------------------------------------------------ - // function : push_back - /// @brief insert an element in the last position of the buffer - /// @param val : value to insert - //----------------------------------------------------------------------- - void push_back(Value_t && val) - { -#ifdef __BS_DEBUG - assert ( nelem != NMAX); -#endif - ptr[(first_pos + (nelem++)) & MASK] = std::move(val); - }; - // - //------------------------------------------------------------------------ - // function : pop_front - /// @brief remove the first element of the buffer - //----------------------------------------------------------------------- - void pop_front(void) - { -#ifdef __BS_DEBUG - assert ( nelem > 0 ); -#endif - --nelem; - (++first_pos) &= MASK; - }; - // - //------------------------------------------------------------------------ - // function : pop_back - /// @brief remove the last element of the buffer - //----------------------------------------------------------------------- - void pop_back(void) - { -#ifdef __BS_DEBUG - assert ( nelem > 0 ); -#endif - --nelem; - }; - - template<class iter_t> - void pop_copy_front(iter_t it_dest, size_t num); - - template<class iter_t> - void pop_move_front(iter_t it_dest, size_t num); - - template<class iter_t> - void pop_copy_back(iter_t it_dest, size_t num); - - template<class iter_t> - void pop_move_back(iter_t it_dest, size_t num); - - template<class iter_t> - void push_copy_front(iter_t it_src, size_t num); - - template<class iter_t> - void push_move_front(iter_t it_src, size_t num); - - template<class iter_t> - void push_copy_back(iter_t it_src, size_t num); - - template<class iter_t> - void push_move_back(iter_t it_src, size_t num); - -//--------------------------------------------------------------------------- -};// End of class circular_buffer -//--------------------------------------------------------------------------- -// -// -//############################################################################ -// ## -// N O N I N L I N E F U N C T I O N S ## -// ## -//############################################################################ -// -//------------------------------------------------------------------------ -// function : pop_copy_front -/// @brief copy and delete num elements from the front of the buffer -/// @param it_dest : iterator to the first position where copy the elements -/// @param num : number of elements to copy -//----------------------------------------------------------------------- -template <class Value_t, uint32_t Power2> -template<class iter_t> -void circular_buffer<Value_t, Power2> -::pop_copy_front(iter_t it_dest, size_t num) -{ - static_assert ( std::is_same <value_iter<iter_t>, Value_t>::value, - "Incompatible iterator"); - if (num == 0) return; -#ifdef __BS_DEBUG - assert ( num <= nelem); -#endif - nelem -= num; - size_t pos = first_pos; - first_pos = (first_pos + num) & MASK; - for (size_t i = 0; i < num; ++i) - { - *(it_dest++) = ptr[pos++ & MASK]; - }; - first_pos &= MASK; -}; -// -//------------------------------------------------------------------------ -// function : pop_move_front -/// @brief move num elements from the front of the buffer to the place -// pointed by it_dest -/// @param it_dest : iterator to the first position where move the elements -/// @param num : number of elements to move -//----------------------------------------------------------------------- -template <class Value_t, uint32_t Power2> -template<class iter_t> -void circular_buffer<Value_t, Power2> -:: pop_move_front(iter_t it_dest, size_t num) -{ - static_assert ( std::is_same <value_iter<iter_t>, Value_t>::value, - "Incompatible iterator"); - if (num == 0) return; -#ifdef __BS_DEBUG - assert ( num <= nelem); -#endif - nelem -= num; - size_t pos = first_pos; - first_pos = (first_pos + num) & MASK; - for (size_t i = 0; i < num; ++i) - { - *(it_dest++) = std::move(ptr[pos++ & MASK]); - }; - first_pos &= MASK; -}; -// -//------------------------------------------------------------------------ -// function : pop_copy_back -/// @brief copy and delete num elements from the back of the buffer -/// @param p1 : iterator where begin to copy the elements -/// @param num : number of elements to copy -//----------------------------------------------------------------------- -template <class Value_t, uint32_t Power2> -template<class iter_t> -void circular_buffer<Value_t, Power2> -::pop_copy_back(iter_t it_dest, size_t num) -{ - static_assert ( std::is_same <value_iter<iter_t>, Value_t>::value, - "Incompatible iterator"); - if (num == 0) return; -#ifdef __BS_DEBUG - assert ( num <= nelem); -#endif - nelem -= num; - size_t pos = (first_pos + nelem) & MASK; - for (size_t i = 0; i < num; ++i) - { - *(it_dest++) = ptr[pos++ & MASK]; - }; -}; -// -//------------------------------------------------------------------------ -// function : pop_move_back -/// @brief move and delete num elements from the back of the buffer -/// @param p1 : iterator where begin to move the elements -/// @param num : number of elements to move -//----------------------------------------------------------------------- -template <class Value_t, uint32_t Power2> -template<class iter_t> -void circular_buffer<Value_t, Power2> -::pop_move_back(iter_t it_dest, size_t num) -{ - static_assert ( std::is_same <value_iter<iter_t>, Value_t>::value, - "Incompatible iterator"); - if (num == 0) return; -#ifdef __BS_DEBUG - assert ( num <= nelem); -#endif - nelem -= num; - size_t pos = (first_pos + nelem) & MASK; - for (size_t i = 0; i < num; ++i) - { - *(it_dest++) = std::move(ptr[pos++ & MASK]); - }; -}; -// -//------------------------------------------------------------------------ -// function : push_copy_front -/// @brief copy num elements in the front of the buffer -/// @param it_src : iterator from where begin to copy the elements -/// @param mun : number of element to copy -//----------------------------------------------------------------------- -template <class Value_t, uint32_t Power2> -template<class iter_t> -void circular_buffer<Value_t, Power2> -::push_copy_front(iter_t it_src, size_t num) -{ - static_assert ( std::is_same <value_iter<iter_t>, Value_t>::value, - "Incompatible iterator"); - if (num == 0) return; -#ifdef __BS_DEBUG - assert ( free_size() >= num); -#endif - nelem += num; - - first_pos = (first_pos + NMAX - num) & MASK; - size_t pos = first_pos; - for (size_t i = 0; i < num; ++i) - { - ptr[(pos++) & MASK] = *(it_src++); - }; -}; -// -//------------------------------------------------------------------------ -// function : push_move_front -/// @brief move num elements in the front of the buffer -/// @param p1 : iterator from where begin to move the elements -/// @param mun : number of element to move -//----------------------------------------------------------------------- -template <class Value_t, uint32_t Power2> -template<class iter_t> -void circular_buffer<Value_t, Power2> -::push_move_front(iter_t it_src, size_t num) -{ - static_assert ( std::is_same <value_iter<iter_t>, Value_t>::value, - "Incompatible iterator"); - if (num == 0) return; -#ifdef __BS_DEBUG - assert ( free_size() >= num); -#endif - nelem += num; - size_t pos = first_pos; - for (size_t i = 0; i < num; ++i) - { - ptr[(pos++) & MASK] = std::move(*(it_src++)); - }; -}; -// -//------------------------------------------------------------------------ -// function : push_copy_back -/// @brief copy num elements in the back of the buffer -/// @param p1 : iterator from where begin to copy the elements -/// @param mun : number of element to copy -//----------------------------------------------------------------------- -template <class Value_t, uint32_t Power2> -template<class iter_t> -void circular_buffer<Value_t, Power2> -::push_copy_back(iter_t it_src, size_t num) -{ - static_assert ( std::is_same <value_iter<iter_t>, Value_t>::value, - "Incompatible iterator"); - if (num == 0) return; -#ifdef __BS_DEBUG - assert ( free_size() >= num); -#endif - size_t pos = first_pos + nelem; - nelem += num; - for (size_t i = 0; i < num; ++i) - { - ptr[(pos++) & MASK] = *(it_src++); - }; -}; -// -//------------------------------------------------------------------------ -// function : push_move_back -/// @brief move num elements in the back of the buffer -/// @param p1 : iterator from where begin to move the elements -/// @param mun : number of element to move -//----------------------------------------------------------------------- -template <class Value_t, uint32_t Power2> -template<class iter_t> -void circular_buffer<Value_t, Power2> -::push_move_back(iter_t it_src, size_t num) -{ - static_assert ( std::is_same <value_iter<iter_t>, Value_t>::value, - "Incompatible iterator"); - if (num == 0) return; -#ifdef __BS_DEBUG - assert ( free_size() >= num); -#endif - size_t pos = first_pos + nelem; - nelem += num; - for (size_t i = 0; i < num; ++i) - { - ptr[(pos++) & MASK] = std::move(*(it_src++)); - }; -}; - -//**************************************************************************** -};// End namespace util -};// End namespace common -};// End namespace sort -};// End namespace boost -//**************************************************************************** -#endif diff --git a/contrib/restricted/boost/boost/sort/common/util/insert.hpp b/contrib/restricted/boost/boost/sort/common/util/insert.hpp deleted file mode 100644 index 219fa8a3510..00000000000 --- a/contrib/restricted/boost/boost/sort/common/util/insert.hpp +++ /dev/null @@ -1,142 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file insert.hpp -/// @brief -/// -/// @author Copyright (c) 2016 Francisco José Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_COMMON_UTIL_INSERT_HPP -#define __BOOST_SORT_COMMON_UTIL_INSERT_HPP - -//#include <boost/sort/spinsort/util/indirect.hpp> -#include <boost/sort/common/util/insert.hpp> -#include <boost/sort/common/util/traits.hpp> -#include <boost/sort/common/util/algorithm.hpp> -#include <cstdlib> -#include <functional> -#include <iterator> -#include <memory> -#include <type_traits> -#include <vector> -#include <cstddef> - -namespace boost -{ -namespace sort -{ -namespace common -{ -namespace util -{ -namespace here = boost::sort::common::util; -// -//############################################################################ -// -// D E F I N I T I O N S O F F U N C T I O N S -// -// template < class Iter1_t, class Iter2_t, typename Compare> -// void insert_sorted (Iter1_t first, Iter1_t mid, Iter1_t last, -// Compare comp, Iter2_t it_aux) -// -//############################################################################ -// -//----------------------------------------------------------------------------- -// function : insert_sorted -/// @brief : Insertion sort of elements sorted -/// @param first: iterator to the first element of the range -/// @param mid : last pointer of the sorted data, and first pointer to the -/// elements to insert -/// @param last : iterator to the next element of the last in the range -/// @param comp : -/// @comments : the two ranges are sorted and in it_aux there is spave for -/// to store temporally the elements to insert -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, typename Compare> -static void insert_sorted(Iter1_t first, Iter1_t mid, Iter1_t last, - Compare comp, Iter2_t it_aux) -{ - //------------------------------------------------------------------------ - // metaprogram - //------------------------------------------------------------------------ - typedef value_iter<Iter1_t> value_t; - typedef value_iter<Iter2_t> value2_t; - static_assert (std::is_same< value_t, value2_t>::value, - "Incompatible iterators\n"); - - //-------------------------------------------------------------------- - // program - //-------------------------------------------------------------------- - if (mid == last) return; - if (first == mid) return; - - //------------------------------------------------------------------------ - // creation of the vector of elements to insert and their position in the - // sorted part - // the data are inserted in it_aux - //----------------------------------------------------------------------- - move_forward(it_aux, mid, last); - - // search of the iterators where insert the new elements - size_t ndata = last - mid; - Iter1_t mv_first = mid, mv_last = mid; - - for (size_t i = ndata; i > 0; --i) - { - mv_last = mv_first; - mv_first = std::upper_bound(first, mv_last, it_aux[i - 1], comp); - Iter1_t it1 = here::move_backward(mv_last + i, mv_first, mv_last); - *(it1 - 1) = std::move(it_aux[i - 1]); - }; -}; - -template<class Iter1_t, class Iter2_t, typename Compare> -static void insert_sorted_backward(Iter1_t first, Iter1_t mid, Iter1_t last, - Compare comp, Iter2_t it_aux) -{ - //------------------------------------------------------------------------ - // metaprogram - //------------------------------------------------------------------------ - typedef value_iter<Iter1_t> value_t; - typedef value_iter<Iter2_t> value2_t; - static_assert (std::is_same< value_t, value2_t>::value, - "Incompatible iterators\n"); - - //-------------------------------------------------------------------- - // program - //-------------------------------------------------------------------- - if (mid == last) return; - if (first == mid) return; - //------------------------------------------------------------------------ - // creation of the vector of elements to insert and their position in the - // sorted part - // the data are inserted in it_aux - //----------------------------------------------------------------------- - move_forward(it_aux, first, mid); - - // search of the iterators where insert the new elements - size_t ndata = mid - first; - Iter1_t mv_first = mid, mv_last = mid; - - for (size_t i = 0; i < ndata; ++i) - { - mv_first = mv_last; - mv_last = std::lower_bound(mv_first, last, it_aux[i], comp); - Iter1_t it1 = move_forward(mv_first - (ndata - i), mv_first, mv_last); - *(it1) = std::move(it_aux[i]); - }; - -}; -// -//**************************************************************************** -};// End namespace util -};// End namepspace common -};// End namespace sort -};// End namepspace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/common/util/merge.hpp b/contrib/restricted/boost/boost/sort/common/util/merge.hpp deleted file mode 100644 index 5fc90c0fd48..00000000000 --- a/contrib/restricted/boost/boost/sort/common/util/merge.hpp +++ /dev/null @@ -1,494 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file merge.hpp -/// @brief low level merge functions -/// -/// @author Copyright (c) 2016 Francisco Jose Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_COMMON_UTIL_MERGE_HPP -#define __BOOST_SORT_COMMON_UTIL_MERGE_HPP - -#include <algorithm> -#include <functional> -#include <iterator> -#include <memory> - -#include <boost/sort/common/util/algorithm.hpp> -#include <boost/sort/common/util/traits.hpp> -#include <boost/sort/common/util/circular_buffer.hpp> - -namespace boost -{ -namespace sort -{ -namespace common -{ -namespace util -{ -namespace here = boost::sort::common::util; -//---------------------------------------------------------------------------- -// -// F U N C T I O N S I N T H E F I L E -//---------------------------------------------------------------------------- -// -// template < class Iter1_t, class Iter2_t, class Compare > -// Iter2_t merge (Iter1_t buf1, const Iter1_t end_buf1, Iter1_t buf2, -// const Iter1_t end_buf2, Iter2_t buf_out, Compare comp) -// -// template < class Iter_t, class Value_t, class Compare > -// Value_t *merge_construct (Iter_t first1, const Iter_t last1, Iter_t first2, -// const Iter_t last2, Value_t *it_out, Compare comp) -// -// template < class Iter1_t, class Iter2_t, class Compare > -// Iter2_t merge_half (Iter1_t buf1, const Iter1_t end_buf1, Iter2_t buf2, -// const Iter2_t end_buf2, Iter2_t buf_out, Compare comp) -// -// template < class Iter1_t, class Iter2_t, class Compare > -// Iter2_t merge_half_backward (Iter1_t buf1, Iter1_t end_buf1, -// Iter2_t buf2, Iter2_t end_buf2, -// Iter1_t end_buf_out, Compare comp) -// -// template < class Iter1_t, class Iter2_t, class Iter3_t, class Compare > -// bool merge_uncontiguous (Iter1_t src1, const Iter1_t end_src1, -// Iter2_t src2, const Iter2_t end_src2, -// Iter3_t aux, Compare comp) -// -// template < class Iter1_t, class Iter2_t, class Compare > -// bool merge_contiguous (Iter1_t src1, Iter1_t src2, Iter1_t end_src2, -// Iter2_t buf, Compare comp) -// -// template < class Iter_t, class Circular ,class Compare > -// bool merge_circular (Iter_t buf1, Iter_t end_buf1, -// Iter_t buf2, Iter_t end_buf2, -// Circular &circ, Compare comp, Iter_t &it_aux) -// -//---------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -// function : merge -/// @brief Merge two contiguous buffers pointed by buf1 and buf2, and put -/// in the buffer pointed by buf_out -/// -/// @param buf1 : iterator to the first element in the first buffer -/// @param end_buf1 : final iterator of first buffer -/// @param buf2 : iterator to the first iterator to the second buffer -/// @param end_buf2 : final iterator of the second buffer -/// @param buf_out : buffer where move the elements merged -/// @param comp : comparison object -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Iter3_t, class Compare> -static Iter3_t merge(Iter1_t buf1, const Iter1_t end_buf1, Iter2_t buf2, - const Iter2_t end_buf2, Iter3_t buf_out, Compare comp) -{ - //------------------------------------------------------------------------- - // Metaprogramming - //------------------------------------------------------------------------- - typedef value_iter<Iter1_t> value1_t; - typedef value_iter<Iter2_t> value2_t; - typedef value_iter<Iter3_t> value3_t; - static_assert (std::is_same< value1_t, value2_t >::value, - "Incompatible iterators\n"); - static_assert (std::is_same< value3_t, value2_t >::value, - "Incompatible iterators\n"); - - //------------------------------------------------------------------------- - // Code - //------------------------------------------------------------------------- - const size_t MIN_CHECK = 1024; - - if (size_t((end_buf1 - buf1) + (end_buf2 - buf2)) >= MIN_CHECK) - { - if (buf1 == end_buf1) return move_forward(buf_out, buf2, end_buf2); - if (buf2 == end_buf2) return move_forward(buf_out, buf1, end_buf1); - - if (not comp(*buf2, *(end_buf1 - 1))) - { - Iter3_t mid = move_forward(buf_out, buf1, end_buf1); - return move_forward(mid, buf2, end_buf2); - }; - - if (comp(*(end_buf2 - 1), *buf1)) - { - Iter3_t mid = move_forward(buf_out, buf2, end_buf2); - return move_forward(mid, buf1, end_buf1); - }; - }; - while ((buf1 != end_buf1) and (buf2 != end_buf2)) - { - *(buf_out++) = (not comp(*buf2, *buf1)) ? - std::move(*(buf1++)) : std::move(*(buf2++)); - }; - - return (buf1 == end_buf1) ? - move_forward(buf_out, buf2, end_buf2) : - move_forward(buf_out, buf1, end_buf1); -} -; -// -//----------------------------------------------------------------------------- -// function : merge_construct -/// @brief Merge two contiguous buffers pointed by first1 and first2, and put -/// in the uninitialized buffer pointed by it_out -/// -/// @param first1 : iterator to the first element in the first buffer -/// @param last1 : last iterator of the first buffer -/// @param first2 : iterator to the first element to the second buffer -/// @param last2 : final iterator of the second buffer -/// @param it_out : uninitialized buffer where move the elements merged -/// @param comp : comparison object -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Value_t, class Compare> -static Value_t *merge_construct(Iter1_t first1, const Iter1_t last1, - Iter2_t first2, const Iter2_t last2, - Value_t *it_out, Compare comp) -{ - //------------------------------------------------------------------------- - // Metaprogramming - //------------------------------------------------------------------------- - typedef value_iter<Iter1_t> type1; - typedef value_iter<Iter2_t> type2; - static_assert (std::is_same< Value_t, type1 >::value, - "Incompatible iterators\n"); - static_assert (std::is_same< Value_t, type2 >::value, - "Incompatible iterators\n"); - - //------------------------------------------------------------------------- - // Code - //------------------------------------------------------------------------- - const size_t MIN_CHECK = 1024; - - if (size_t((last1 - first1) + (last2 - first2)) >= MIN_CHECK) - { - if (first1 == last1) return move_construct(it_out, first2, last2); - if (first2 == last2) return move_construct(it_out, first1, last1); - - if (not comp(*first2, *(last1 - 1))) - { - Value_t* mid = move_construct(it_out, first1, last1); - return move_construct(mid, first2, last2); - }; - - if (comp(*(last2 - 1), *first1)) - { - Value_t* mid = move_construct(it_out, first2, last2); - return move_construct(mid, first1, last1); - }; - }; - while (first1 != last1 and first2 != last2) - { - construct_object((it_out++), - (not comp(*first2, *first1)) ? - std::move(*(first1++)) : - std::move(*(first2++))); - }; - return (first1 == last1) ? - move_construct(it_out, first2, last2) : - move_construct(it_out, first1, last1); -}; -// -//--------------------------------------------------------------------------- -// function : merge_half -/// @brief : Merge two buffers. The first buffer is in a separate memory. -/// The second buffer have a empty space before buf2 of the same size -/// than the (end_buf1 - buf1) -/// -/// @param buf1 : iterator to the first element of the first buffer -/// @param end_buf1 : iterator to the last element of the first buffer -/// @param buf2 : iterator to the first element of the second buffer -/// @param end_buf2 : iterator to the last element of the second buffer -/// @param buf_out : iterator to the first element to the buffer where put -/// the result -/// @param comp : object for Compare two elements of the type pointed -/// by the Iter1_t and Iter2_t -//--------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Compare> -static Iter2_t merge_half(Iter1_t buf1, const Iter1_t end_buf1, Iter2_t buf2, - const Iter2_t end_buf2, Iter2_t buf_out, Compare comp) -{ - //------------------------------------------------------------------------- - // Metaprogramming - //------------------------------------------------------------------------- - typedef value_iter<Iter1_t> value1_t; - typedef value_iter<Iter2_t> value2_t; - static_assert (std::is_same< value1_t, value2_t >::value, - "Incompatible iterators\n"); - - //------------------------------------------------------------------------- - // Code - //------------------------------------------------------------------------- -#ifdef __BS_DEBUG - assert ( (buf2 - buf_out) == ( end_buf1 - buf1)); -#endif - const size_t MIN_CHECK = 1024; - - if (size_t((end_buf1 - buf1) + (end_buf2 - buf2)) >= MIN_CHECK) - { - if (buf1 == end_buf1) return end_buf2; - if (buf2 == end_buf2) return move_forward(buf_out, buf1, end_buf1); - - if (not comp(*buf2, *(end_buf1 - 1))) - { - move_forward(buf_out, buf1, end_buf1); - return end_buf2; - }; - - if (comp(*(end_buf2 - 1), *buf1)) - { - Iter2_t mid = move_forward(buf_out, buf2, end_buf2); - return move_forward(mid, buf1, end_buf1); - }; - }; - while ((buf1 != end_buf1) and (buf2 != end_buf2)) - { - *(buf_out++) = (not comp(*buf2, *buf1)) ? - std::move(*(buf1++)) : std::move(*(buf2++)); - }; - return (buf2 == end_buf2)? move_forward(buf_out, buf1, end_buf1) : end_buf2; -}; - -// -//--------------------------------------------------------------------------- -// function : merge_half_backward -/// @brief : Merge two buffers. The first buffer is in a separate memory. -/// The second buffer have a empty space before buf2 of the same size -/// than the (end_buf1 - buf1) -/// -/// @param buf1 : iterator to the first element of the first buffer -/// @param end_buf1 : iterator to the last element of the first buffer -/// @param buf2 : iterator to the first element of the second buffer -/// @param end_buf2 : iterator to the last element of the second buffer -/// @param buf_out : iterator to the first element to the buffer where put -/// the result -/// @param comp : object for Compare two elements of the type pointed -/// by the Iter1_t and Iter2_t -//--------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Compare> -static Iter2_t merge_half_backward(Iter1_t buf1, Iter1_t end_buf1, Iter2_t buf2, - Iter2_t end_buf2, Iter1_t end_buf_out, - Compare comp) -{ - //------------------------------------------------------------------------- - // Metaprogramming - //------------------------------------------------------------------------- - typedef value_iter<Iter1_t> value1_t; - typedef value_iter<Iter2_t> value2_t; - static_assert (std::is_same< value1_t, value2_t >::value, - "Incompatible iterators\n"); - - //------------------------------------------------------------------------- - // Code - //------------------------------------------------------------------------- -#ifdef __BS_DEBUG - assert ((end_buf_out - end_buf1) == (end_buf2 - buf2) ); -#endif - const size_t MIN_CHECK = 1024; - - if (size_t((end_buf1 - buf1) + (end_buf2 - buf2)) >= MIN_CHECK) - { - if (buf2 == end_buf2) return buf1; - if (buf1 == end_buf1) - return here::move_backward(end_buf_out, buf2, end_buf2); - - if (not comp(*buf2, *(end_buf1 - 1))) - { - here::move_backward(end_buf_out, buf2, end_buf2); - return buf1; - }; - - if (comp(*(end_buf2 - 1), *buf1)) - { - Iter1_t mid = here::move_backward(end_buf_out, buf1, end_buf1); - return here::move_backward(mid, buf2, end_buf2); - }; - }; - while ((buf1 != end_buf1) and (buf2 != end_buf2)) - { - *(--end_buf_out) = - (not comp(*(end_buf2 - 1), *(end_buf1 - 1))) ? - std::move(*(--end_buf2)): - std::move(*(--end_buf1)); - }; - return (buf1 == end_buf1) ? - here::move_backward(end_buf_out, buf2, end_buf2) : buf1; -}; - -// -//----------------------------------------------------------------------------- -// function : merge_uncontiguous -/// @brief : merge two uncontiguous buffers, placing the results in the buffers -/// Use an auxiliary buffer pointed by aux -/// -/// @param src1 : iterator to the first element of the first buffer -/// @param end_src1 : last iterator of the first buffer -/// @param src2 : iterator to the first element of the second buffer -/// @param end_src2 : last iterator of the second buffer -/// @param aux : iterator to the first element of the auxiliary buffer -/// @param comp : object for to Compare elements -/// @return true : not changes done, false : changes in the buffers -/// @remarks -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Iter3_t, class Compare> -static bool merge_uncontiguous(Iter1_t src1, const Iter1_t end_src1, - Iter2_t src2, const Iter2_t end_src2, - Iter3_t aux, Compare comp) -{ - //------------------------------------------------------------------------- - // Metaprogramming - //------------------------------------------------------------------------- - typedef value_iter<Iter1_t> type1; - typedef value_iter<Iter2_t> type2; - typedef value_iter<Iter3_t> type3; - static_assert (std::is_same< type1, type2 >::value, - "Incompatible iterators\n"); - static_assert (std::is_same< type3, type2 >::value, - "Incompatible iterators\n"); - - //------------------------------------------------------------------------- - // Code - //------------------------------------------------------------------------- - if (src1 == end_src1 or src2 == end_src2 - or not comp(*src2, *(end_src1 - 1))) return true; - - while (src1 != end_src1 and not comp(*src2, *src1)) - ++src1; - - Iter3_t const end_aux = aux + (end_src1 - src1); - Iter2_t src2_first = src2; - move_forward(aux, src1, end_src1); - - while ((src1 != end_src1) and (src2 != end_src2)) - { - *(src1++) = std::move((not comp(*src2, *aux)) ? *(aux++) : *(src2++)); - } - - if (src2 == end_src2) - { - while (src1 != end_src1) - *(src1++) = std::move(*(aux++)); - move_forward(src2_first, aux, end_aux); - } - else - { - merge_half(aux, end_aux, src2, end_src2, src2_first, comp); - }; - return false; -}; - -// -//----------------------------------------------------------------------------- -// function : merge_contiguous -/// @brief : merge two contiguous buffers,using an auxiliary buffer pointed -/// by buf. The results are in src1 and src2 -/// -/// @param src1: iterator to the first position of the first buffer -/// @param src2: final iterator of the first buffer and first iterator -/// of the second buffer -/// @param end_src2 : final iterator of the second buffer -/// @param buf : iterator to buffer used as auxiliary memory -/// @param comp : object for to Compare elements -/// @return true : not changes done, false : changes in the buffers -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Compare> -static bool merge_contiguous(Iter1_t src1, Iter1_t src2, Iter1_t end_src2, - Iter2_t buf, Compare comp) -{ - //------------------------------------------------------------------------- - // Metaprogramming - //------------------------------------------------------------------------- - typedef value_iter<Iter1_t> type1; - typedef value_iter<Iter2_t> type2; - static_assert (std::is_same< type1, type2 >::value, - "Incompatible iterators\n"); - - //------------------------------------------------------------------------- - // Code - //------------------------------------------------------------------------- - if (src1 == src2 or src2 == end_src2 or not comp(*src2, *(src2 - 1))) - return true; - - Iter1_t end_src1 = src2; - while (src1 != end_src1 and not comp(*src2, *src1)) - ++src1; - - if (src1 == end_src1) return false; - - size_t nx = end_src1 - src1; - move_forward(buf, src1, end_src1); - merge_half(buf, buf + nx, src2, end_src2, src1, comp); - return false; -}; -// -//----------------------------------------------------------------------------- -// function : merge_circular -/// @brief : merge two buffers,using a circular buffer -/// This function don't check the parameters -/// @param buf1: iterator to the first position of the first buffer -/// @param end_buf1: iterator after the last element of the first buffer -/// @param buf2: iterator to the first element of the secind buffer -/// @param end_buf2: iterator to the first element of the secind buffer -/// @param circ : circular buffer -/// @param comp : comparison object -/// @return true : finished buf1, false : finished buf2 -/// @comments : be carefully because the iterators buf1 and buf2 are modified -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Circular, class Compare> -static bool merge_circular(Iter1_t buf1, Iter1_t end_buf1, Iter2_t buf2, - Iter2_t end_buf2, Circular &circ, Compare comp, - Iter1_t &it1_out, Iter2_t &it2_out) -{ - //------------------------------------------------------------------------- - // Metaprogramming - //------------------------------------------------------------------------- - typedef value_iter<Iter1_t> type1; - typedef value_iter<Iter2_t> type2; - static_assert (std::is_same< type1, type2 >::value, - "Incompatible iterators\n"); - typedef typename Circular::value_t type3; - static_assert (std::is_same<type1, type3>::value, - "Incompatible iterators\n"); - - //------------------------------------------------------------------------- - // Code - //------------------------------------------------------------------------- -#ifdef __BS_DEBUG - assert ( circ.free_size() >= size_t ((end_buf1-buf1) + (end_buf2-buf2))); -#endif - - if (not comp(*buf2, *(end_buf1 - 1))) - { - circ.push_move_back(buf1, (end_buf1 - buf1)); - it1_out = end_buf1; - it2_out = buf2; - return true; - }; - if (comp(*(end_buf2 - 1), *buf1)) - { - circ.push_move_back(buf2, (end_buf2 - buf2)); - it1_out = buf1; - it2_out = end_buf2; - return false; - } - while (buf1 != end_buf1 and buf2 != end_buf2) - { - circ.push_back(comp(*buf2, *buf1) ? std::move(*(buf2++)) - : std::move(*(buf1++))); - }; - it2_out = buf2; - it1_out = buf1; - bool ret = (buf1 == end_buf1); - return ret; -}; -// -//**************************************************************************** -};// End namespace util -};// End namespace common -};// End namespace sort -};// End namespace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/common/util/search.hpp b/contrib/restricted/boost/boost/sort/common/util/search.hpp deleted file mode 100644 index fbe056e2f84..00000000000 --- a/contrib/restricted/boost/boost/sort/common/util/search.hpp +++ /dev/null @@ -1,529 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file search.hpp -/// @brief -/// @author Copyright (c) 2017 Francisco José Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See copy at http://www.boost.org/LICENSE_1_0.txt ) -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_COMMON_SEARCH_HPP -#define __BOOST_SORT_COMMON_SEARCH_HPP - -#include <boost/sort/common/util/traits.hpp> -#include <cassert> - -namespace boost -{ -namespace sort -{ -namespace common -{ -namespace util -{ - -template<class T> -struct filter_pass -{ - typedef T key; - const key & operator()(const T & val) const - { - return val; - }; -}; - -// -//########################################################################### -// ## -// ################################################################ ## -// # # ## -// # I N T E R N A L F U N C T I O N S # ## -// # # ## -// ################################################################ ## -// ## -// I M P O R T A N T ## -// ## -// These functions are not directly callable by the user, are for internal ## -// use only. ## -// These functions don't check the parameters ## -// ## -//########################################################################### -// -//----------------------------------------------------------------------------- -// function : internal_find_first -/// @brief find if a value exist in the range [first, last). -/// Always return as valid iterator in the range [first, last-1] -/// If exist return the iterator to the first occurrence. If don't exist -/// return the first greater than val. -/// If val is greater than the *(last-1), return (last-1) -/// If val is lower than (*first), return first -// -/// @param [in] first : iterator to the first element of the range -/// @param [in] last : iterator to the last element of the range -/// @param [in] val : value to find -/// @param [in] comp : object for to compare two value_t objects -/// @return iterator to the element found, -//----------------------------------------------------------------------------- -template <class Iter_t, class Filter = filter_pass<value_iter<Iter_t> >, - class Compare = std::less<typename Filter::key> > -inline Iter_t internal_find_first(Iter_t first, Iter_t last, - const typename Filter::key &val, - const Compare & comp = Compare(), - Filter flt = Filter()) -{ - Iter_t LI = first, LS = last - 1, it_out = first; - while (LI != LS) - { - it_out = LI + ((LS - LI) >> 1); - if (comp(flt(*it_out), val)) - LI = it_out + 1; - else LS = it_out; - }; - return LS; -}; -// -//----------------------------------------------------------------------------- -// function : internal_find_last -/// @brief find if a value exist in the range [first, last). -/// Always return as valid iterator in the range [first, last-1] -/// If exist return the iterator to the last occurrence. -/// If don't exist return the first lower than val. -/// If val is greater than *(last-1) return (last-1). -/// If is lower than the first, return first -// -/// @param [in] first : iterator to the first element of the range -/// @param [in] last : iterator to the last element of the range -/// @param [in] val : value to find -/// @param [in] comp : object for to compare two value_t objects -/// @return iterator to the element found, if not found return last - -//----------------------------------------------------------------------------- -template<class Iter_t, class Filter = filter_pass<value_iter<Iter_t> >, - class Compare = std::less<typename Filter::key> > -inline Iter_t internal_find_last(Iter_t first, Iter_t last, - const typename Filter::key &val, - const Compare & comp = Compare(), Filter flt = - Filter()) -{ - Iter_t LI = first, LS = last - 1, it_out = first; - while (LI != LS) - { - it_out = LI + ((LS - LI + 1) >> 1); - if (comp(val, flt(*it_out))) LS = it_out - 1; - else LI = it_out; - }; - return LS; -}; - -// -//########################################################################### -// ## -// ################################################################ ## -// # # ## -// # P U B L I C F U N C T I O N S # ## -// # # ## -// ################################################################ ## -// ## -//########################################################################### -// -//----------------------------------------------------------------------------- -// function : find_first -/// @brief find if a value exist in the range [first, last). If exist return the -/// iterator to the first occurrence. If don't exist return last -// -/// @param [in] first : iterator to the first element of the range -/// @param [in] last : iterator to the last element of the range -/// @param [in] val : value to find -/// @param [in] comp : object for to compare two value_t objects -/// @return iterator to the element found, and if not last -//----------------------------------------------------------------------------- -template<class Iter_t, class Filter = filter_pass<value_iter<Iter_t> >, - class Compare = std::less<typename Filter::key> > -inline Iter_t find_first(Iter_t first, Iter_t last, - const typename Filter::key &val, - const Compare & comp = Compare(), - Filter flt = Filter()) -{ - assert((last - first) >= 0); - if (first == last) return last; - Iter_t LS = internal_find_first(first, last, val, comp, flt); - return (comp(flt(*LS), val) or comp(val, flt(*LS))) ? last : LS; -}; -// -//----------------------------------------------------------------------------- -// function : find_last -/// @brief find if a value exist in the range [first, last). If exist return the -/// iterator to the last occurrence. If don't exist return last -// -/// @param [in] first : iterator to the first element of the range -/// @param [in] last : iterator to the last element of the range -/// @param [in] val : value to find -/// @param [in] comp : object for to compare two value_t objects -/// @return iterator to the element found, if not found return last - -//----------------------------------------------------------------------------- -template <class Iter_t, class Filter = filter_pass<value_iter<Iter_t> >, - class Compare = std::less<typename Filter::key> > -inline Iter_t find_last(Iter_t first, Iter_t last, - const typename Filter::key &val, - const Compare & comp = Compare(), - Filter flt = Filter()) -{ - assert((last - first) >= 0); - if (last == first) return last; - Iter_t LS = internal_find_last(first, last, val, comp, flt); - return (comp(flt(*LS), val) or comp(val, flt(*LS))) ? last : LS; -}; - -//---------------------------------------------------------------------------- -// function : lower_bound -/// @brief Returns an iterator pointing to the first element in the range -/// [first, last) that is not less than (i.e. greater or equal to) val. -/// @param [in] last : iterator to the last element of the range -/// @param [in] val : value to find -/// @param [in] comp : object for to compare two value_t objects -/// @return iterator to the element found -//----------------------------------------------------------------------------- -template<class Iter_t, class Filter = filter_pass<value_iter<Iter_t> >, - class Compare = std::less<typename Filter::key> > -inline Iter_t lower_bound(Iter_t first, Iter_t last, - const typename Filter::key &val, - const Compare & comp = Compare(), - Filter flt = Filter()) -{ - assert((last - first) >= 0); - if (last == first) return last; - Iter_t itaux = internal_find_first(first, last, val, comp, flt); - return (itaux == (last - 1) and comp(flt(*itaux), val)) ? last : itaux; -}; -//---------------------------------------------------------------------------- -// function :upper_bound -/// @brief return the first element greather than val.If don't exist -/// return last -// -/// @param [in] first : iterator to the first element of the range -/// @param [in] last : iterator to the last element of the range -/// @param [in] val : value to find -/// @param [in] comp : object for to compare two value_t objects -/// @return iterator to the element found -/// @remarks -//----------------------------------------------------------------------------- -template<class Iter_t, class Filter = filter_pass<value_iter<Iter_t> >, - class Compare = std::less<typename Filter::key> > -inline Iter_t upper_bound(Iter_t first, Iter_t last, - const typename Filter::key &val, - const Compare & comp = Compare(), - Filter flt = Filter()) -{ - assert((last - first) >= 0); - if (last == first) return last; - Iter_t itaux = internal_find_last(first, last, val, comp, flt); - return (itaux == first and comp(val, flt(*itaux))) ? itaux : itaux + 1; -} -; -//---------------------------------------------------------------------------- -// function :equal_range -/// @brief return a pair of lower_bound and upper_bound with the value val.If -/// don't exist return last in the two elements of the pair -// -/// @param [in] first : iterator to the first element of the range -/// @param [in] last : iterator to the last element of the range -/// @param [in] val : value to find -/// @param [in] comp : object for to compare two value_t objects -/// @return pair of iterators -//----------------------------------------------------------------------------- -template<class Iter_t, class Filter = filter_pass<value_iter<Iter_t> >, - class Compare = std::less<typename Filter::key> > -inline std::pair<Iter_t, Iter_t> equal_range(Iter_t first, Iter_t last, - const typename Filter::key &val, - const Compare & comp = Compare(), - Filter flt = Filter()) -{ - return std::make_pair(lower_bound(first, last, val, comp, flt), - upper_bound(first, last, val, comp, flt)); -}; -// -//----------------------------------------------------------------------------- -// function : insert_first -/// @brief find if a value exist in the range [first, last). If exist return the -/// iterator to the first occurrence. If don't exist return last -// -/// @param [in] first : iterator to the first element of the range -/// @param [in] last : iterator to the last element of the range -/// @param [in] val : value to find -/// @param [in] comp : object for to compare two value_t objects -/// @return iterator to the element found, and if not last -//----------------------------------------------------------------------------- -template<class Iter_t, class Filter = filter_pass<value_iter<Iter_t> >, - class Compare = std::less<typename Filter::key> > -inline Iter_t insert_first(Iter_t first, Iter_t last, - const typename Filter::key &val, - const Compare & comp = Compare(), Filter flt = - Filter()) -{ - return lower_bound(first, last, val, comp, flt); -}; -// -//----------------------------------------------------------------------------- -// function : insert_last -/// @brief find if a value exist in the range [first, last). If exist return the -/// iterator to the last occurrence. If don't exist return last -// -/// @param [in] first : iterator to the first element of the range -/// @param [in] last : iterator to the last element of the range -/// @param [in] val : value to find -/// @param [in] comp : object for to compare two value_t objects -/// @return iterator to the element found, if not found return last - -//----------------------------------------------------------------------------- -template<class Iter_t, class Filter = filter_pass<value_iter<Iter_t> >, - class Compare = std::less<typename Filter::key> > -inline Iter_t insert_last(Iter_t first, Iter_t last, - const typename Filter::key &val, - const Compare & comp = Compare(), Filter flt = - Filter()) -{ - return upper_bound(first, last, val, comp, flt); -}; - -/* - - // - //########################################################################### - // ## - // ################################################################ ## - // # # ## - // # I N T E R N A L F U N C T I O N S # ## - // # # ## - // ################################################################ ## - // ## - // I M P O R T A N T ## - // ## - // These functions are not directly callable by the user, are for internal ## - // use only. ## - // These functions don't check the parameters ## - // ## - //########################################################################### - // - //----------------------------------------------------------------------------- - // function : internal_find_first - /// @brief find if a value exist in the range [first, last). - /// Always return as valid iterator in the range [first, last-1] - /// If exist return the iterator to the first occurrence. If don't exist - /// return the first greater than val. - /// If val is greater than the *(last-1), return (last-1) - /// If val is lower than (*first), return first - // - /// @param [in] first : iterator to the first element of the range - /// @param [in] last : iterator to the last element of the range - /// @param [in] val : value to find - /// @param [in] comp : object for to compare two value_t objects - /// @return iterator to the element found, - //----------------------------------------------------------------------------- - template < class Iter_t, class Compare = compare_iter<Iter_t> > - inline Iter_t internal_find_first ( Iter_t first, Iter_t last, - const value_iter<Iter_t> &val, - const Compare & comp= Compare() ) - { - Iter_t LI = first , LS = last - 1, it_out = first; - while ( LI != LS) - { it_out = LI + ( (LS - LI) >> 1); - if ( comp ( *it_out, val)) LI = it_out + 1 ; else LS = it_out ; - }; - return LS ; - }; - // - //----------------------------------------------------------------------------- - // function : internal_find_last - /// @brief find if a value exist in the range [first, last). - /// Always return as valid iterator in the range [first, last-1] - /// If exist return the iterator to the last occurrence. - /// If don't exist return the first lower than val. - /// If val is greater than *(last-1) return (last-1). - /// If is lower than the first, return first - // - /// @param [in] first : iterator to the first element of the range - /// @param [in] last : iterator to the last element of the range - /// @param [in] val : value to find - /// @param [in] comp : object for to compare two value_t objects - /// @return iterator to the element found, if not found return last - - //----------------------------------------------------------------------------- - template < class Iter_t, class Compare = compare_iter<Iter_t> > - inline Iter_t internal_find_last ( Iter_t first, Iter_t last , - const value_iter<Iter_t> &val, - const Compare &comp= Compare() ) - { - Iter_t LI = first , LS = last - 1, it_out = first ; - while ( LI != LS) - { it_out = LI + ( (LS - LI + 1) >> 1); - if ( comp (val, *it_out)) LS = it_out - 1 ; else LI = it_out ; - }; - return LS ; - }; - - // - //########################################################################### - // ## - // ################################################################ ## - // # # ## - // # P U B L I C F U N C T I O N S # ## - // # # ## - // ################################################################ ## - // ## - //########################################################################### - // - //----------------------------------------------------------------------------- - // function : find_first - /// @brief find if a value exist in the range [first, last). If exist return the - /// iterator to the first occurrence. If don't exist return last - // - /// @param [in] first : iterator to the first element of the range - /// @param [in] last : iterator to the last element of the range - /// @param [in] val : value to find - /// @param [in] comp : object for to compare two value_t objects - /// @return iterator to the element found, and if not last - //----------------------------------------------------------------------------- - template < class Iter_t, class Compare = compare_iter<Iter_t> > - inline Iter_t find_first ( Iter_t first, Iter_t last, - const value_iter<Iter_t> &val, - Compare comp = Compare() ) - { - assert ( (last - first) >= 0 ); - if ( first == last) return last ; - Iter_t LS = internal_find_first ( first, last, val, comp); - return (comp (*LS, val) or comp (val, *LS))?last:LS; - }; - // - //----------------------------------------------------------------------------- - // function : find_last - /// @brief find if a value exist in the range [first, last). If exist return the - /// iterator to the last occurrence. If don't exist return last - // - /// @param [in] first : iterator to the first element of the range - /// @param [in] last : iterator to the last element of the range - /// @param [in] val : value to find - /// @param [in] comp : object for to compare two value_t objects - /// @return iterator to the element found, if not found return last - - //----------------------------------------------------------------------------- - template < class Iter_t, class Compare = compare_iter<Iter_t> > - inline Iter_t find_last ( Iter_t first, Iter_t last , - const value_iter<Iter_t> &val, - Compare comp = Compare()) - { - assert ( (last - first ) >= 0 ); - if ( last == first ) return last ; - Iter_t LS = internal_find_last (first, last, val, comp); - return (comp (*LS, val) or comp (val, *LS))?last:LS ; - }; - - //---------------------------------------------------------------------------- - // function : lower_bound - /// @brief Returns an iterator pointing to the first element in the range - /// [first, last) that is not less than (i.e. greater or equal to) val. - /// @param [in] last : iterator to the last element of the range - /// @param [in] val : value to find - /// @param [in] comp : object for to compare two value_t objects - /// @return iterator to the element found - //----------------------------------------------------------------------------- - template < class Iter_t, class Compare = compare_iter<Iter_t> > - inline Iter_t lower_bound ( Iter_t first, Iter_t last , - const value_iter<Iter_t> &val, - Compare &comp = Compare() ) - { - assert ( (last - first ) >= 0 ); - if ( last == first ) return last ; - Iter_t itaux = internal_find_first( first, last, val,comp); - return (itaux == (last - 1) and comp (*itaux, val))?last: itaux; - }; - //---------------------------------------------------------------------------- - // function :upper_bound - /// @brief return the first element greather than val.If don't exist - /// return last - // - /// @param [in] first : iterator to the first element of the range - /// @param [in] last : iterator to the last element of the range - /// @param [in] val : value to find - /// @param [in] comp : object for to compare two value_t objects - /// @return iterator to the element found - /// @remarks - //----------------------------------------------------------------------------- - template < class Iter_t, class Compare = compare_iter<Iter_t> > - inline Iter_t upper_bound ( Iter_t first, Iter_t last , - const value_iter<Iter_t> &val, - Compare &comp = Compare() ) - { - assert ( (last - first ) >= 0 ); - if ( last == first ) return last ; - Iter_t itaux = internal_find_last( first, last, val,comp); - return ( itaux == first and comp (val,*itaux))? itaux: itaux + 1; - }; - //---------------------------------------------------------------------------- - // function :equal_range - /// @brief return a pair of lower_bound and upper_bound with the value val.If - /// don't exist return last in the two elements of the pair - // - /// @param [in] first : iterator to the first element of the range - /// @param [in] last : iterator to the last element of the range - /// @param [in] val : value to find - /// @param [in] comp : object for to compare two value_t objects - /// @return pair of iterators - //----------------------------------------------------------------------------- - template < class Iter_t, class Compare = compare_iter<Iter_t> > - inline std::pair<Iter_t, Iter_t> equal_range ( Iter_t first, Iter_t last , - const value_iter<Iter_t> &val, - Compare &comp = Compare() ) - { - return std::make_pair(lower_bound(first, last, val,comp), - upper_bound(first, last, val,comp)); - }; - // - //----------------------------------------------------------------------------- - // function : insert_first - /// @brief find if a value exist in the range [first, last). If exist return the - /// iterator to the first occurrence. If don't exist return last - // - /// @param [in] first : iterator to the first element of the range - /// @param [in] last : iterator to the last element of the range - /// @param [in] val : value to find - /// @param [in] comp : object for to compare two value_t objects - /// @return iterator to the element found, and if not last - //----------------------------------------------------------------------------- - template < class Iter_t, class Compare = compare_iter<Iter_t> > - inline Iter_t insert_first ( Iter_t first, Iter_t last, - const value_iter<Iter_t> &val, - Compare comp = Compare() ) - { - return lower_bound (first, last, val, comp); - }; - // - //----------------------------------------------------------------------------- - // function : insert_last - /// @brief find if a value exist in the range [first, last). If exist return the - /// iterator to the last occurrence. If don't exist return last - // - /// @param [in] first : iterator to the first element of the range - /// @param [in] last : iterator to the last element of the range - /// @param [in] val : value to find - /// @param [in] comp : object for to compare two value_t objects - /// @return iterator to the element found, if not found return last - - //----------------------------------------------------------------------------- - template < class Iter_t, class Compare = compare_iter<Iter_t> > - inline Iter_t insert_last ( Iter_t first, Iter_t last , - const value_iter<Iter_t> &val, - Compare comp = Compare()) - { - return upper_bound (first, last, val, comp); - }; - - */ -// -//**************************************************************************** -};// End namespace util -};// End namespace common -};// End namespace sort -};// End namespace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/common/util/traits.hpp b/contrib/restricted/boost/boost/sort/common/util/traits.hpp deleted file mode 100644 index 68e5cf03599..00000000000 --- a/contrib/restricted/boost/boost/sort/common/util/traits.hpp +++ /dev/null @@ -1,123 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file traits.hpp -/// @brief this file contains the metaprogramming classes compare_iter and -/// enable_if_not_integral -/// @author Copyright(c) 2016 Francisco Jose Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_COMMON_UTIL_TRAITS_HPP -#define __BOOST_SORT_COMMON_UTIL_TRAITS_HPP - -#include <functional> -#include <iterator> -#include <type_traits> - -namespace boost -{ -namespace sort -{ -namespace common -{ -namespace util -{ -//---------------------------------------------------------------------------- -// USING SENTENCES -//---------------------------------------------------------------------------- -using std::iterator_traits; - -// -//--------------------------------------------------------------------------- -/// @class value_iter -/// @brief From the iterator, obtain the type pointed by it -/// @remarks The main utility of this, is simplify the default template -/// parameter of comparison -//--------------------------------------------------------------------------- -template<class iter_t> -using value_iter = typename iterator_traits< iter_t >::value_type; -// -//--------------------------------------------------------------------------- -/// @class compare_iter -/// @brief From the iterator, received as template parameter, obtain the type -/// of the object pointed by the iterator, and with this define the -/// std::less with this type obtained -/// @remarks The main utility of this, is simplify the default template -/// parameter of comparison -//--------------------------------------------------------------------------- -template<class iter_t> -using compare_iter = std::less< value_iter< iter_t > >; - -// -//--------------------------------------------------------------------------- -/// @class enable_if_not_integral -/// @brief This is a SFINAE class for to detect if the third parameter in the -/// invocation of the parallel sorting algorithms is an integer -/// representing the number of threads to use or is a comparison object -/// @remarks -//--------------------------------------------------------------------------- -template<class T> -using enable_if_not_integral = - typename std::enable_if< !std::is_integral< T >::value >::type; -// -//--------------------------------------------------------------------------- -/// @class enable_if_integral -/// @brief This is a SFINAE class for to detect if the third parameter in the -/// invocation of the parallel sorting algorithms is an integer -/// representing the number of threads to use or is a comparison object -/// @remarks -//--------------------------------------------------------------------------- -template<class T> -using enable_if_integral = - typename std::enable_if< std::is_integral< T >::value >::type; - -// -//--------------------------------------------------------------------------- -/// @class enable_if_string -/// @brief This is a SFINAE class for to detect if the parameter is a -/// std::string for to apply specialized parameters in the invocation -/// of the block_indirect_sort algorithm -/// @remarks -//--------------------------------------------------------------------------- -template<class T> -using enable_if_string = - typename std::enable_if< std::is_same< T, std::string >::value >::type; - -// -//--------------------------------------------------------------------------- -/// @class enable_if_not_string -/// @brief This is a SFINAE class for to detect if the parameter is a -/// std::string for to apply specialized parameters in the invocation -/// of the block_indirect_sort algorithm -/// @remarks -//--------------------------------------------------------------------------- -template<class T> -using enable_if_not_string = - typename std::enable_if<! std::is_same< T, std::string >::value >::type; - -// -//--------------------------------------------------------------------------- -/// @class constructor -/// @brief create a functor with the constructor of a class for to be invoked -/// from a bind or a lambda -/// @remarks -//--------------------------------------------------------------------------- -template<class T> -struct constructor -{ - template<class ... Args> - void operator()(Args && ... args) - { - T(std::forward<Args> (args) ...); - }; -}; -// -//**************************************************************************** -};// End namespace util -};// End namespace common -};// End namespace sort -};// End namespace boost -//**************************************************************************** -#endif diff --git a/contrib/restricted/boost/boost/sort/flat_stable_sort/flat_stable_sort.hpp b/contrib/restricted/boost/boost/sort/flat_stable_sort/flat_stable_sort.hpp deleted file mode 100644 index ee48e7b9a02..00000000000 --- a/contrib/restricted/boost/boost/sort/flat_stable_sort/flat_stable_sort.hpp +++ /dev/null @@ -1,312 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file flat_stable_sort.hpp -/// @brief Flat stable sort algorithm -/// -/// @author Copyright (c) 2017 Francisco José Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_FLAT_STABLE_SORT_HPP -#define __BOOST_SORT_FLAT_STABLE_SORT_HPP - -#include <boost/sort/insert_sort/insert_sort.hpp> -#include <boost/sort/common/util/insert.hpp> -#include <boost/sort/common/merge_block.hpp> -#include <boost/sort/common/sort_basic.hpp> -#include <boost/sort/common/range.hpp> -#include <boost/sort/common/util/traits.hpp> -#include <boost/sort/common/indirect.hpp> - -#include <cstdlib> -#include <functional> -#include <iterator> -#include <memory> -#include <type_traits> -#include <vector> - -namespace boost -{ -namespace sort -{ -namespace flat_internal -{ -namespace bsc = boost::sort::common; -namespace bscu = boost::sort::common::util; -//--------------------------------------------------------------------------- -/// @struct flat_stable_sort -/// @brief This class implement s stable sort algorithm with 1 thread, with -/// an auxiliary memory of N/2 elements -//---------------------------------------------------------------------------- -template <class Iter_t, typename Compare = bscu::compare_iter<Iter_t>, - uint32_t Power2 = 10> -class flat_stable_sort: public bsc::merge_block<Iter_t, Compare, Power2> -{ - //------------------------------------------------------------------------ - // DEFINITIONS AND CONSTANTS - //------------------------------------------------------------------------ - typedef bsc::merge_block<Iter_t, Compare, Power2> merge_block_t; - - //------------------------------------------------------------------------- - // D E F I N I T I O N S - //------------------------------------------------------------------------- - typedef typename merge_block_t::value_t value_t; - typedef typename merge_block_t::range_pos range_pos; - typedef typename merge_block_t::range_it range_it; - typedef typename merge_block_t::range_buf range_buf; - typedef typename merge_block_t::it_index it_index; - typedef typename merge_block_t::circular_t circular_t; - - //------------------------------------------------------------------------ - // CONSTANTS - //------------------------------------------------------------------------ - using merge_block_t::BLOCK_SIZE; - using merge_block_t::LOG_BLOCK; - - using merge_block_t::index; - using merge_block_t::cmp; - using merge_block_t::ptr_circ; - - using merge_block_t::get_range; - using merge_block_t::get_group_range; - using merge_block_t::merge_range_pos; - using merge_block_t::move_range_pos_backward; - using merge_block_t::rearrange_with_index; - -public: - //------------------------------------------------------------------------ - // PUBLIC FUNCTIONS - //------------------------------------------------------------------------- - flat_stable_sort(Iter_t first, Iter_t last, Compare comp, - circular_t *ptr_circ) - : merge_block_t(first, last, comp, ptr_circ) - { - divide(index.begin(), index.end()); - rearrange_with_index(); - }; - - flat_stable_sort(Iter_t first, Iter_t last, Compare comp = Compare()) - : flat_stable_sort(first, last, comp, nullptr) { }; - - void divide(it_index itx_first, it_index itx_last); - - void sort_small(it_index itx_first, it_index itx_last); - - bool is_sorted_forward(it_index itx_first, it_index itx_last); - - bool is_sorted_backward(it_index itx_first, it_index itx_last); -}; -//---------------------------------------------------------------------------- -// End of class flat_stable_sort -//---------------------------------------------------------------------------- -// -//------------------------------------------------------------------------ -// function : -/// @brief : -/// @param Pos : -/// @return -//------------------------------------------------------------------------ -template <class Iter_t, typename Compare, uint32_t Power2> -void flat_stable_sort <Iter_t, Compare, Power2> -::divide(it_index itx_first, it_index itx_last) -{ - size_t nblock = size_t(itx_last - itx_first); - if (nblock < 5) - { sort_small(itx_first, itx_last); - return; - }; - if ( nblock > 7) - { if (is_sorted_forward(itx_first, itx_last)) return; - if (is_sorted_backward(itx_first, itx_last)) return; - }; - size_t nblock1 = (nblock + 1) >> 1; - divide(itx_first, itx_first + nblock1); - divide(itx_first + nblock1, itx_last); - merge_range_pos(itx_first, itx_first + nblock1, itx_last); -}; -// -//------------------------------------------------------------------------ -// function : sort_small -/// @brief : -/// @param -/// @param -/// @param -//------------------------------------------------------------------------ -template <class Iter_t, typename Compare, uint32_t Power2> -void flat_stable_sort <Iter_t, Compare, Power2> -::sort_small(it_index itx_first, it_index itx_last) -{ - size_t nblock = size_t(itx_last - itx_first); - assert(nblock > 0 and nblock < 5); - value_t *paux = ptr_circ->get_buffer(); - range_it rng_data = get_group_range(*itx_first, nblock); - - if (nblock < 3) - { - range_buf rng_aux(paux, paux + rng_data.size()); - range_sort_data(rng_data, rng_aux, cmp); - return; - }; - - //-------------------------------------------------------------------- - // division of range_data in two ranges for be sorted and merged - //-------------------------------------------------------------------- - size_t nblock1 = (nblock + 1) >> 1; - range_it rng_data1 = get_group_range(*itx_first, nblock1); - range_it rng_data2(rng_data1.last, rng_data.last); - range_buf rng_aux1(paux, paux + rng_data1.size()); - range_buf rng_aux2(paux, paux + rng_data2.size()); - - range_sort_data(rng_data2, rng_aux2, cmp); - range_sort_buffer(rng_data1, rng_aux1, cmp); - merge_half(rng_data, rng_aux1, rng_data2, cmp); -}; -// -//------------------------------------------------------------------------ -// function : is_sorted_forward -/// @brief : return if the data are ordered, -/// @param itx_first : iterator to the first block in the index -/// @param itx_last : iterator to the last block in the index -/// @return : true : the data are ordered false : not ordered -//------------------------------------------------------------------------ -template <class Iter_t, typename Compare, uint32_t Power2> -bool flat_stable_sort <Iter_t, Compare, Power2> -::is_sorted_forward(it_index itx_first, it_index itx_last) -{ - size_t nblock = size_t(itx_last - itx_first); - range_it rng = get_group_range(*itx_first, nblock); - size_t nelem = rng.size(); - size_t min_process = std::max(BLOCK_SIZE, (nelem >> 3)); - - size_t nsorted1 = bsc::number_stable_sorted_forward (rng.first, rng.last, - min_process, cmp); - if (nsorted1 == nelem) return true; - if (nsorted1 == 0) return false; - - size_t nsorted2 = nelem - nsorted1; - Iter_t itaux = rng.first + nsorted1; - if (nsorted2 <= (BLOCK_SIZE << 1)) - { - flat_stable_sort(itaux, rng.last, cmp, ptr_circ); - bscu::insert_sorted(rng.first, itaux, rng.last, cmp, - ptr_circ->get_buffer()); - } - else - { // Adjust the size of the sorted data to a number of blocks - size_t mask = ~(BLOCK_SIZE - 1); - size_t nsorted1_adjust = nsorted1 & mask; - flat_stable_sort(rng.first + nsorted1_adjust, rng.last, cmp, - ptr_circ); - size_t nblock1 = nsorted1_adjust >> Power2; - merge_range_pos(itx_first, itx_first + nblock1, itx_last); - }; - return true; -}; -// -//------------------------------------------------------------------------ -// function : is_sorted_backward -/// @brief : return if the data are ordered, -/// @param itx_first : iterator to the first block in the index -/// @param itx_last : iterator to the last block in the index -/// @return : true : the data are ordered false : not ordered -//------------------------------------------------------------------------ -template <class Iter_t, typename Compare, uint32_t Power2> -bool flat_stable_sort <Iter_t, Compare, Power2> -::is_sorted_backward(it_index itx_first, it_index itx_last) -{ - size_t nblock = size_t(itx_last - itx_first); - range_it rng = get_group_range(*itx_first, nblock); - - size_t nelem = rng.size(); - size_t min_process = std::max(BLOCK_SIZE, (nelem >> 3)); - - size_t nsorted2 = bsc::number_stable_sorted_backward(rng.first, rng.last, - min_process, cmp); - if (nsorted2 == nelem) return true; - if (nsorted2 == 0 ) return false; - Iter_t itaux = rng.last - nsorted2; - size_t nsorted1 = nelem - nsorted2; - - if (nsorted1 <= (BLOCK_SIZE << 1)) - { - flat_stable_sort(rng.first, itaux, cmp, ptr_circ); - bscu::insert_sorted_backward(rng.first, itaux, rng.last, cmp, - ptr_circ->get_buffer()); - } - else - { // Adjust the size of nsorted2 for to be a number of blocks - size_t nblock1 = (nsorted1 + BLOCK_SIZE - 1) >> Power2; - size_t nsorted1_adjust = (nblock1 << Power2); - flat_stable_sort(rng.first, rng.first + nsorted1_adjust, cmp, - ptr_circ); - merge_range_pos(itx_first, itx_first + nblock1, itx_last); - }; - return true; -}; -//**************************************************************************** -};// End namespace flat_internal -//**************************************************************************** -// -namespace bscu = boost::sort::common::util; -namespace flat = boost::sort::flat_internal; -// -///--------------------------------------------------------------------------- -// function flat_stable_sort -/// @brief This class is select the block size in the block_indirect_sort -/// algorithm depending of the type and size of the data to sort -/// -//---------------------------------------------------------------------------- -template <class Iter_t, class Compare = bscu::compare_iter<Iter_t>, - bscu::enable_if_string<value_iter<Iter_t> > * = nullptr> -inline void flat_stable_sort (Iter_t first, Iter_t last, - Compare cmp = Compare()) -{ - flat::flat_stable_sort<Iter_t, Compare, 6> (first, last, cmp); -}; - -template<size_t Size> -struct block_size_fss -{ - static constexpr const uint32_t BitsSize = - (Size == 0) ? 0 : (Size > 128) ? 7 : bscu::tmsb[Size - 1]; - static constexpr const uint32_t sz[10] = - { 10, 10, 10, 9, 8, 7, 6, 6 }; - static constexpr const uint32_t data = sz[BitsSize]; -}; - -// -///--------------------------------------------------------------------------- -// function flat_stable_sort -/// @brief This class is select the block size in the flat_stable_sort -/// algorithm depending of the type and size of the data to sort -/// -//---------------------------------------------------------------------------- -template <class Iter_t, class Compare = bscu::compare_iter<Iter_t>, - bscu::enable_if_not_string<value_iter<Iter_t> >* = nullptr> -inline void flat_stable_sort (Iter_t first, Iter_t last, - Compare cmp = Compare()) -{ - flat::flat_stable_sort<Iter_t, Compare, - block_size_fss<sizeof(value_iter<Iter_t> )>::data> - (first, last, cmp); -}; - -template<class Iter_t, class Compare = compare_iter<Iter_t> > -inline void indirect_flat_stable_sort (Iter_t first, Iter_t last, - Compare comp = Compare()) -{ - typedef typename std::vector<Iter_t>::iterator itx_iter; - typedef common::less_ptr_no_null<Iter_t, Compare> itx_comp; - common::indirect_sort ( flat_stable_sort<itx_iter, itx_comp>, - first, last, comp); -}; - -//**************************************************************************** -};// End namespace sort -};// End namepspace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/heap_sort/heap_sort.hpp b/contrib/restricted/boost/boost/sort/heap_sort/heap_sort.hpp deleted file mode 100644 index 9e89d00b8cc..00000000000 --- a/contrib/restricted/boost/boost/sort/heap_sort/heap_sort.hpp +++ /dev/null @@ -1,215 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file heap_sort.hpp -/// @brief Insertion Sort algorithm -/// -/// @author Copyright (c) 2016 Francisco Jose Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_INTROSORT_DETAIL_HEAP_SORT_HPP -#define __BOOST_SORT_INTROSORT_DETAIL_HEAP_SORT_HPP - -#include <cassert> -#include <cstdint> -#include <iterator> -#include <stdexcept> -#include <utility> // for std::swap -#include <boost/sort/common/util/traits.hpp> - -namespace boost -{ -namespace sort -{ -namespace heap_detail -{ -namespace bscu = boost::sort::common::util; -// -//--------------------------------------------------------------------------- -// struct : heap_sort -/// @brief : Heap sort algorithm -/// @remarks This algorithm is O(NLogN) -//--------------------------------------------------------------------------- -template < class Iter_t, class Compare > -struct heap_sort -{ - typedef bscu::value_iter<Iter_t> value_t; - - // - //------------------------------------------------------------------------ - // function : sort3 - /// @brief Sort and signal the changes of three values - /// @param val_0 : first value to compare - /// @param val_1 : second value to compare - /// @param val_2 : third value to compare - /// @param [out] bool_0 : if true indicates val_0 had been changed - /// @param [out] bool_1 : if true indicates val_1 had been changed - /// @param [out] bool_2 : if true indicates val_2 had been changed - /// @return if true , some value had changed - /// @remarks - //------------------------------------------------------------------------ - bool sort3 (value_t &val_0, value_t &val_1, value_t &val_2, bool &bool_0, - bool &bool_1, bool &bool_2) - { - bool_0 = bool_1 = bool_2 = false; - int value = 0; - if (val_0 < val_1) value += 4; - if (val_1 < val_2) value += 2; - if (val_0 < val_2) value += 1; - - switch (value) - { - case 0: break; - - case 2: - std::swap (val_1, val_2); - bool_1 = bool_2 = true; - break; - - case 3: - if (not(val_0 > val_1)) { - std::swap (val_0, val_2); - bool_0 = bool_2 = true; - } - else - { - auto aux = std::move (val_2); - val_2 = std::move (val_1); - val_1 = std::move (val_0); - val_0 = std::move (aux); - bool_0 = bool_1 = bool_2 = true; - }; - break; - - case 4: - std::swap (val_0, val_1); - bool_0 = bool_1 = true; - break; - - case 5: - if (val_1 > val_2) { - auto aux = std::move (val_0); - val_0 = std::move (val_1); - val_1 = std::move (val_2); - val_2 = std::move (aux); - bool_0 = bool_1 = bool_2 = true; - } - else - { - std::swap (val_0, val_2); - bool_0 = bool_2 = true; - }; - break; - - case 7: - std::swap (val_0, val_2); - bool_0 = bool_2 = true; - break; - - default: abort ( ); - }; - return (bool_0 or bool_1 or bool_2); - }; - // - //----------------------------------------------------------------------- - // function : make_heap - /// @brief Make the heap for to extract the sorted elements - /// @param first : iterator to the first element of the range - /// @param nelem : number of lements of the range - /// @param comp : object for to compare two elements - /// @remarks This algorithm is O(NLogN) - //------------------------------------------------------------------------ - void make_heap (Iter_t first, size_t nelem, Compare comp) - { - size_t pos_father, pos_son; - Iter_t iter_father = first, iter_son = first; - bool sw = false; - - for (size_t i = 1; i < nelem; ++i) - { - pos_father = i; - iter_father = first + i; - sw = false; - do - { - iter_son = iter_father; - pos_son = pos_father; - pos_father = (pos_son - 1) >> 1; - iter_father = first + pos_father; - if ((sw = comp (*iter_father, *iter_son))) - std::swap (*iter_father, *iter_son); - } while (sw and pos_father != 0); - }; - }; - // - //------------------------------------------------------------------------ - // function : heap_sort - /// @brief : Heap sort algorithm - /// @param first: iterator to the first element of the range - /// @param last : iterator to the next element of the last in the range - /// @param comp : object for to do the comparison between the elements - /// @remarks This algorithm is O(NLogN) - //------------------------------------------------------------------------ - heap_sort (Iter_t first, Iter_t last, Compare comp) - { - assert ((last - first) >= 0); - size_t nelem = last - first; - if (nelem < 2) return; - - //-------------------------------------------------------------------- - // Creating the initial heap - //-------------------------------------------------------------------- - make_heap (first, nelem, comp); - - //-------------------------------------------------------------------- - // Sort the heap - //-------------------------------------------------------------------- - size_t pos_father, pos_son; - Iter_t iter_father = first, iter_son = first; - - bool sw = false; - for (size_t i = 1; i < nelem; ++i) - { - std::swap (*first, *(first + (nelem - i))); - pos_father = 0; - pos_son = 1; - iter_father = first; - sw = true; - while (sw and pos_son < (nelem - i)) - { - // if the father have two sons must select the bigger - iter_son = first + pos_son; - if ((pos_son + 1) < (nelem - i) and - comp (*iter_son, *(iter_son + 1))) - { - ++pos_son; - ++iter_son; - }; - if ((sw = comp (*iter_father, *iter_son))) - std::swap (*iter_father, *iter_son); - pos_father = pos_son; - iter_father = iter_son; - pos_son = (pos_father << 1) + 1; - }; - }; - }; -}; // End class heap_sort -}; // end namespace heap_sort - -namespace bscu = boost::sort::common::util; - -template < class Iter_t, typename Compare = bscu::compare_iter < Iter_t > > -void heap_sort (Iter_t first, Iter_t last, Compare comp = Compare()) -{ - heap_detail::heap_sort<Iter_t, Compare> ( first, last, comp); -} -// -//**************************************************************************** -}; // End namespace sort -}; // End namespace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/insert_sort/insert_sort.hpp b/contrib/restricted/boost/boost/sort/insert_sort/insert_sort.hpp deleted file mode 100644 index d40302ad101..00000000000 --- a/contrib/restricted/boost/boost/sort/insert_sort/insert_sort.hpp +++ /dev/null @@ -1,119 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file insert_sort.hpp -/// @brief Insertion Sort algorithm -/// -/// @author Copyright (c) 2016 Francisco Jose Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_INTROSORT_DETAIL_INSERT_SORT_HPP -#define __BOOST_SORT_INTROSORT_DETAIL_INSERT_SORT_HPP - -#include <functional> -#include <iterator> -#include <algorithm> -#include <utility> // std::swap -#include <boost/sort/common/util/traits.hpp> -#include <boost/sort/common/util/insert.hpp> - -namespace boost -{ -namespace sort -{ -using common::util::compare_iter; -using common::util::value_iter; -// -//----------------------------------------------------------------------------- -// function : insert_sort -/// @brief : Insertion sort algorithm -/// @param first: iterator to the first element of the range -/// @param last : iterator to the next element of the last in the range -/// @param comp : object for to do the comparison between the elements -/// @remarks This algorithm is O(N^2) -//----------------------------------------------------------------------------- -template < class Iter_t, typename Compare = compare_iter < Iter_t > > -static void insert_sort (Iter_t first, Iter_t last, - Compare comp = Compare()) -{ - //-------------------------------------------------------------------- - // DEFINITIONS - //-------------------------------------------------------------------- - typedef value_iter< Iter_t > value_t; - - if ((last - first) < 2) return; - - for (Iter_t it_examine = first + 1; it_examine != last; ++it_examine) - { - value_t Aux = std::move (*it_examine); - Iter_t it_insertion = it_examine; - - while (it_insertion != first and comp (Aux, *(it_insertion - 1))) - { - *it_insertion = std::move (*(it_insertion - 1)); - --it_insertion; - }; - *it_insertion = std::move (Aux); - }; -}; - -/* -// -//----------------------------------------------------------------------------- -// function : insert_partial_sort -/// @brief : Insertion sort of elements sorted -/// @param first: iterator to the first element of the range -/// @param mid : last pointer of the sorted data, and first pointer to the -/// elements to insert -/// @param last : iterator to the next element of the last in the range -/// @param comp : object for to do the comparison between the elements -/// @remarks This algorithm is O(N^2) -//----------------------------------------------------------------------------- -template < class Iter_t, typename Compare = compare_iter < Iter_t > > -void insert_partial_sort (Iter_t first, Iter_t mid, Iter_t last, - Compare comp = Compare()) -{ - //-------------------------------------------------------------------- - // DEFINITIONS - //-------------------------------------------------------------------- - typedef value_iter< Iter_t > value_t; - - if ( mid == last ) return ; - insert_sort ( mid, last, comp); - if (first == mid) return ; - - // creation of the vector of elements to insert and their position in the - // sorted part - std::vector<Iter_t> viter ; - std::vector<value_t> vdata ; - - for ( Iter_t alpha = mid ; alpha != last ; ++alpha) - vdata.push_back ( std::move ( *alpha)); - - Iter_t linf = first , lsup = mid ; - for ( uint32_t i= 0 ; i < vdata.size() ; ++i) - { Iter_t it1 = std::upper_bound ( linf, lsup , vdata[i], comp); - viter.push_back ( it1 ); - linf = it1 ; - }; - - // moving the elements - viter.push_back ( mid) ; - for ( uint32_t i = viter.size() -1 ; i!= 0 ; --i) - { Iter_t src = viter[i], limit = viter[i-1]; - Iter_t dest = src + ( i); - while ( src != limit) * (--dest) = std::move ( *(--src)); - *(viter[i-1] + (i -1)) = std::move (vdata[i-1]); - }; -} -*/ -// -//**************************************************************************** -}; // End namespace sort -}; // End namespace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/parallel_stable_sort/parallel_stable_sort.hpp b/contrib/restricted/boost/boost/sort/parallel_stable_sort/parallel_stable_sort.hpp deleted file mode 100644 index 9df7dffd2af..00000000000 --- a/contrib/restricted/boost/boost/sort/parallel_stable_sort/parallel_stable_sort.hpp +++ /dev/null @@ -1,270 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file parallel_stable_sort.hpp -/// @brief This file contains the class parallel_stable_sort -/// -/// @author Copyright (c) 2016 Francisco Jose Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_PARALLEL_DETAIL_PARALLEL_STABLE_SORT_HPP -#define __BOOST_SORT_PARALLEL_DETAIL_PARALLEL_STABLE_SORT_HPP - -#include <boost/sort/sample_sort/sample_sort.hpp> -#include <boost/sort/common/util/traits.hpp> -#include <functional> -#include <future> -#include <iterator> -#include <memory> -#include <type_traits> -#include <vector> - -namespace boost -{ -namespace sort -{ -namespace stable_detail -{ - -//--------------------------------------------------------------------------- -// USING SENTENCES -//--------------------------------------------------------------------------- -namespace bsc = boost::sort::common; -namespace bss = boost::sort::spin_detail; -using bsc::range; -using bsc::merge_half; -using boost::sort::sample_detail::sample_sort; -// -///--------------------------------------------------------------------------- -/// @struct parallel_stable_sort -/// @brief This a structure for to implement a parallel stable sort, exception -/// safe -//---------------------------------------------------------------------------- -template <class Iter_t, class Compare = compare_iter <Iter_t> > -struct parallel_stable_sort -{ - //------------------------------------------------------------------------- - // DEFINITIONS - //------------------------------------------------------------------------- - typedef value_iter<Iter_t> value_t; - - //------------------------------------------------------------------------- - // VARIABLES - //------------------------------------------------------------------------- - // Number of elements to sort - size_t nelem; - // Pointer to the auxiliary memory needed for the algorithm - value_t *ptr; - // Minimal number of elements for to be sorted in parallel mode - const size_t nelem_min = 1 << 16; - - //------------------------------------------------------------------------ - // F U N C T I O N S - //------------------------------------------------------------------------ - parallel_stable_sort (Iter_t first, Iter_t last) - : parallel_stable_sort (first, last, Compare(), - std::thread::hardware_concurrency()) { }; - - parallel_stable_sort (Iter_t first, Iter_t last, Compare cmp) - : parallel_stable_sort (first, last, cmp, - std::thread::hardware_concurrency()) { }; - - parallel_stable_sort (Iter_t first, Iter_t last, uint32_t num_thread) - : parallel_stable_sort (first, last, Compare(), num_thread) { }; - - parallel_stable_sort (Iter_t first, Iter_t last, Compare cmp, - uint32_t num_thread); - - // - //----------------------------------------------------------------------------- - // function : destroy_all - /// @brief The utility is to destroy the temporary buffer used in the - /// sorting process - //----------------------------------------------------------------------------- - void destroy_all() - { - if (ptr != nullptr) std::return_temporary_buffer(ptr); - }; - // - //----------------------------------------------------------------------------- - // function :~parallel_stable_sort - /// @brief destructor of the class. The utility is to destroy the temporary - /// buffer used in the sorting process - //----------------------------------------------------------------------------- - ~parallel_stable_sort() {destroy_all(); } ; -}; -// end struct parallel_stable_sort - -// -//############################################################################ -// ## -// ## -// N O N I N L I N E F U N C T I O N S ## -// ## -// ## -//############################################################################ -// -//----------------------------------------------------------------------------- -// function : parallel_stable_sort -/// @brief constructor of the class -/// -/// @param first : iterator to the first element of the range to sort -/// @param last : iterator after the last element to the range to sort -/// @param comp : object for to compare two elements pointed by Iter_t -/// iterators -/// @param nthread : Number of threads to use in the process. When this value -/// is lower than 2, the sorting is done with 1 thread -//----------------------------------------------------------------------------- -template <class Iter_t, class Compare> -parallel_stable_sort <Iter_t, Compare> -::parallel_stable_sort (Iter_t first, Iter_t last, Compare comp, - uint32_t nthread) : nelem(0), ptr(nullptr) -{ - range<Iter_t> range_initial(first, last); - assert(range_initial.valid()); - - nelem = range_initial.size(); - size_t nptr = (nelem + 1) >> 1; - - if (nelem < nelem_min or nthread < 2) - { - bss::spinsort<Iter_t, Compare> - (range_initial.first, range_initial.last, comp); - return; - }; - - //------------------- check if sort -------------------------------------- - bool sw = true; - for (Iter_t it1 = first, it2 = first + 1; - it2 != last and (sw = not comp(*it2, *it1)); it1 = it2++); - if (sw) return; - - //------------------- check if reverse sort --------------------------- - sw = true; - for (Iter_t it1 = first, it2 = first + 1; - it2 != last and (sw = comp(*it2, *it1)); it1 = it2++); - if (sw) - { - size_t nelem2 = nelem >> 1; - Iter_t it1 = first, it2 = last - 1; - for (size_t i = 0; i < nelem2; ++i) - std::swap(*(it1++), *(it2--)); - return; - }; - - ptr = std::get_temporary_buffer<value_t>(nptr).first; - if (ptr == nullptr) throw std::bad_alloc(); - - //--------------------------------------------------------------------- - // Parallel Process - //--------------------------------------------------------------------- - range<Iter_t> range_first(range_initial.first, range_initial.first + nptr); - - range<Iter_t> range_second(range_initial.first + nptr, range_initial.last); - - range<value_t *> range_buffer(ptr, ptr + nptr); - - try - { - sample_sort<Iter_t, Compare> - (range_initial.first, range_initial.first + nptr, - comp, nthread, range_buffer); - } catch (std::bad_alloc &) - { - destroy_all(); - throw std::bad_alloc(); - }; - - try - { - sample_sort<Iter_t, Compare> - (range_initial.first + nptr, - range_initial.last, comp, nthread, range_buffer); - } catch (std::bad_alloc &) - { - destroy_all(); - throw std::bad_alloc(); - }; - - range_buffer = move_forward(range_buffer, range_first); - range_initial = merge_half(range_initial, range_buffer, range_second, comp); -}; // end of constructor - -// -//**************************************************************************** -};// End namespace stable_detail -//**************************************************************************** -// - -//--------------------------------------------------------------------------- -// USING SENTENCES -//--------------------------------------------------------------------------- -namespace bsc = boost::sort::common; -namespace bscu = bsc::util; -namespace bss = boost::sort::spin_detail; -using bsc::range; -using bsc::merge_half; -// -//############################################################################ -// ## -// ## -// P A R A L L E L _ S T A B L E _ S O R T ## -// ## -// ## -//############################################################################ -// -//----------------------------------------------------------------------------- -// function : parallel_stable_sort -/// @brief : parallel stable sort algorithm. -/// -/// @param first : iterator to the first element of the range to sort -/// @param last : iterator after the last element to the range to sort -//----------------------------------------------------------------------------- -template<class Iter_t> -void parallel_stable_sort(Iter_t first, Iter_t last) -{ - typedef bscu::compare_iter<Iter_t> Compare; - stable_detail::parallel_stable_sort<Iter_t, Compare>(first, last); -}; -// -//----------------------------------------------------------------------------- -// function : parallel_stable_sort -/// @brief parallel stable sort. -/// -/// @param first : iterator to the first element of the range to sort -/// @param last : iterator after the last element to the range to sort -/// @param nthread : Number of threads to use in the process. When this value -/// is lower than 2, the sorting is done with 1 thread -//----------------------------------------------------------------------------- -template<class Iter_t> -void parallel_stable_sort(Iter_t first, Iter_t last, uint32_t nthread) -{ - typedef bscu::compare_iter<Iter_t> Compare; - stable_detail::parallel_stable_sort<Iter_t, Compare>(first, last, nthread); -}; -// -//----------------------------------------------------------------------------- -// function : parallel_stable_sort -/// @brief : parallel stable sort. -/// -/// @param first : iterator to the first element of the range to sort -/// @param last : iterator after the last element to the range to sort -/// @param comp : object for to compare two elements pointed by Iter_t -/// iterators -//----------------------------------------------------------------------------- -template <class Iter_t, class Compare, - bscu::enable_if_not_integral<Compare> * = nullptr> -void parallel_stable_sort(Iter_t first, Iter_t last, Compare comp) -{ - stable_detail::parallel_stable_sort<Iter_t, Compare>(first, last, comp); -}; -// -//**************************************************************************** -};// End namespace sort -};// End namespace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/pdqsort/pdqsort.hpp b/contrib/restricted/boost/boost/sort/pdqsort/pdqsort.hpp deleted file mode 100644 index dc81d870573..00000000000 --- a/contrib/restricted/boost/boost/sort/pdqsort/pdqsort.hpp +++ /dev/null @@ -1,632 +0,0 @@ -// Pattern-defeating quicksort - -// Copyright Orson Peters 2017. -// Distributed under the 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://www.boost.org/libs/sort/ for library home page. - - -#ifndef BOOST_SORT_PDQSORT_HPP -#define BOOST_SORT_PDQSORT_HPP - -#include <algorithm> -#include <cstddef> -#include <functional> -#include <iterator> -#include <utility> -#include <boost/type_traits.hpp> - -#if __cplusplus >= 201103L - #include <cstdint> - #define BOOST_PDQSORT_PREFER_MOVE(x) std::move(x) -#else - #define BOOST_PDQSORT_PREFER_MOVE(x) (x) -#endif - -namespace boost { -namespace sort { - -namespace pdqsort_detail { - enum { - // Partitions below this size are sorted using insertion sort. - insertion_sort_threshold = 24, - - // Partitions above this size use Tukey's ninther to select the pivot. - ninther_threshold = 128, - - // When we detect an already sorted partition, attempt an insertion sort that allows this - // amount of element moves before giving up. - partial_insertion_sort_limit = 8, - - // Must be multiple of 8 due to loop unrolling, and < 256 to fit in unsigned char. - block_size = 64, - - // Cacheline size, assumes power of two. - cacheline_size = 64 - }; - - template<class T> struct is_default_compare : boost::false_type { }; - template<class T> struct is_default_compare<std::less<T> > : boost::true_type { }; - template<class T> struct is_default_compare<std::greater<T> > : boost::true_type { }; - - // Returns floor(log2(n)), assumes n > 0. - template<class T> - inline int log2(T n) { - int log = 0; - while (n >>= 1) ++log; - return log; - } - - // Sorts [begin, end) using insertion sort with the given comparison function. - template<class Iter, class Compare> - inline void insertion_sort(Iter begin, Iter end, Compare comp) { - typedef typename std::iterator_traits<Iter>::value_type T; - if (begin == end) return; - - for (Iter cur = begin + 1; cur != end; ++cur) { - Iter sift = cur; - Iter sift_1 = cur - 1; - - // Compare first so we can avoid 2 moves for an element already positioned correctly. - if (comp(*sift, *sift_1)) { - T tmp = BOOST_PDQSORT_PREFER_MOVE(*sift); - - do { *sift-- = BOOST_PDQSORT_PREFER_MOVE(*sift_1); } - while (sift != begin && comp(tmp, *--sift_1)); - - *sift = BOOST_PDQSORT_PREFER_MOVE(tmp); - } - } - } - - // Sorts [begin, end) using insertion sort with the given comparison function. Assumes - // *(begin - 1) is an element smaller than or equal to any element in [begin, end). - template<class Iter, class Compare> - inline void unguarded_insertion_sort(Iter begin, Iter end, Compare comp) { - typedef typename std::iterator_traits<Iter>::value_type T; - if (begin == end) return; - - for (Iter cur = begin + 1; cur != end; ++cur) { - Iter sift = cur; - Iter sift_1 = cur - 1; - - // Compare first so we can avoid 2 moves for an element already positioned correctly. - if (comp(*sift, *sift_1)) { - T tmp = BOOST_PDQSORT_PREFER_MOVE(*sift); - - do { *sift-- = BOOST_PDQSORT_PREFER_MOVE(*sift_1); } - while (comp(tmp, *--sift_1)); - - *sift = BOOST_PDQSORT_PREFER_MOVE(tmp); - } - } - } - - // Attempts to use insertion sort on [begin, end). Will return false if more than - // partial_insertion_sort_limit elements were moved, and abort sorting. Otherwise it will - // successfully sort and return true. - template<class Iter, class Compare> - inline bool partial_insertion_sort(Iter begin, Iter end, Compare comp) { - typedef typename std::iterator_traits<Iter>::value_type T; - if (begin == end) return true; - - int limit = 0; - for (Iter cur = begin + 1; cur != end; ++cur) { - if (limit > partial_insertion_sort_limit) return false; - - Iter sift = cur; - Iter sift_1 = cur - 1; - - // Compare first so we can avoid 2 moves for an element already positioned correctly. - if (comp(*sift, *sift_1)) { - T tmp = BOOST_PDQSORT_PREFER_MOVE(*sift); - - do { *sift-- = BOOST_PDQSORT_PREFER_MOVE(*sift_1); } - while (sift != begin && comp(tmp, *--sift_1)); - - *sift = BOOST_PDQSORT_PREFER_MOVE(tmp); - limit += cur - sift; - } - } - - return true; - } - - template<class Iter, class Compare> - inline void sort2(Iter a, Iter b, Compare comp) { - if (comp(*b, *a)) std::iter_swap(a, b); - } - - // Sorts the elements *a, *b and *c using comparison function comp. - template<class Iter, class Compare> - inline void sort3(Iter a, Iter b, Iter c, Compare comp) { - sort2(a, b, comp); - sort2(b, c, comp); - sort2(a, b, comp); - } - - template<class T> - inline T* align_cacheline(T* p) { -#if defined(UINTPTR_MAX) && __cplusplus >= 201103L - std::uintptr_t ip = reinterpret_cast<std::uintptr_t>(p); -#else - std::size_t ip = reinterpret_cast<std::size_t>(p); -#endif - ip = (ip + cacheline_size - 1) & -cacheline_size; - return reinterpret_cast<T*>(ip); - } - - template<class Iter> - inline void swap_offsets(Iter first, Iter last, - unsigned char* offsets_l, unsigned char* offsets_r, - int num, bool use_swaps) { - typedef typename std::iterator_traits<Iter>::value_type T; - if (use_swaps) { - // This case is needed for the descending distribution, where we need - // to have proper swapping for pdqsort to remain O(n). - for (int i = 0; i < num; ++i) { - std::iter_swap(first + offsets_l[i], last - offsets_r[i]); - } - } else if (num > 0) { - Iter l = first + offsets_l[0]; Iter r = last - offsets_r[0]; - T tmp(BOOST_PDQSORT_PREFER_MOVE(*l)); *l = BOOST_PDQSORT_PREFER_MOVE(*r); - for (int i = 1; i < num; ++i) { - l = first + offsets_l[i]; *r = BOOST_PDQSORT_PREFER_MOVE(*l); - r = last - offsets_r[i]; *l = BOOST_PDQSORT_PREFER_MOVE(*r); - } - *r = BOOST_PDQSORT_PREFER_MOVE(tmp); - } - } - - // Partitions [begin, end) around pivot *begin using comparison function comp. Elements equal - // to the pivot are put in the right-hand partition. Returns the position of the pivot after - // partitioning and whether the passed sequence already was correctly partitioned. Assumes the - // pivot is a median of at least 3 elements and that [begin, end) is at least - // insertion_sort_threshold long. Uses branchless partitioning. - template<class Iter, class Compare> - inline std::pair<Iter, bool> partition_right_branchless(Iter begin, Iter end, Compare comp) { - typedef typename std::iterator_traits<Iter>::value_type T; - - // Move pivot into local for speed. - T pivot(BOOST_PDQSORT_PREFER_MOVE(*begin)); - Iter first = begin; - Iter last = end; - - // Find the first element greater than or equal than the pivot (the median of 3 guarantees - // this exists). - while (comp(*++first, pivot)); - - // Find the first element strictly smaller than the pivot. We have to guard this search if - // there was no element before *first. - if (first - 1 == begin) while (first < last && !comp(*--last, pivot)); - else while ( !comp(*--last, pivot)); - - // If the first pair of elements that should be swapped to partition are the same element, - // the passed in sequence already was correctly partitioned. - bool already_partitioned = first >= last; - if (!already_partitioned) { - std::iter_swap(first, last); - ++first; - } - - // The following branchless partitioning is derived from "BlockQuicksort: How Branch - // Mispredictions don't affect Quicksort" by Stefan Edelkamp and Armin Weiss. - unsigned char offsets_l_storage[block_size + cacheline_size]; - unsigned char offsets_r_storage[block_size + cacheline_size]; - unsigned char* offsets_l = align_cacheline(offsets_l_storage); - unsigned char* offsets_r = align_cacheline(offsets_r_storage); - int num_l, num_r, start_l, start_r; - num_l = num_r = start_l = start_r = 0; - - while (last - first > 2 * block_size) { - // Fill up offset blocks with elements that are on the wrong side. - if (num_l == 0) { - start_l = 0; - Iter it = first; - for (unsigned char i = 0; i < block_size;) { - offsets_l[num_l] = i++; num_l += !comp(*it, pivot); ++it; - offsets_l[num_l] = i++; num_l += !comp(*it, pivot); ++it; - offsets_l[num_l] = i++; num_l += !comp(*it, pivot); ++it; - offsets_l[num_l] = i++; num_l += !comp(*it, pivot); ++it; - offsets_l[num_l] = i++; num_l += !comp(*it, pivot); ++it; - offsets_l[num_l] = i++; num_l += !comp(*it, pivot); ++it; - offsets_l[num_l] = i++; num_l += !comp(*it, pivot); ++it; - offsets_l[num_l] = i++; num_l += !comp(*it, pivot); ++it; - } - } - if (num_r == 0) { - start_r = 0; - Iter it = last; - for (unsigned char i = 0; i < block_size;) { - offsets_r[num_r] = ++i; num_r += comp(*--it, pivot); - offsets_r[num_r] = ++i; num_r += comp(*--it, pivot); - offsets_r[num_r] = ++i; num_r += comp(*--it, pivot); - offsets_r[num_r] = ++i; num_r += comp(*--it, pivot); - offsets_r[num_r] = ++i; num_r += comp(*--it, pivot); - offsets_r[num_r] = ++i; num_r += comp(*--it, pivot); - offsets_r[num_r] = ++i; num_r += comp(*--it, pivot); - offsets_r[num_r] = ++i; num_r += comp(*--it, pivot); - } - } - - // Swap elements and update block sizes and first/last boundaries. - int num = (std::min)(num_l, num_r); - swap_offsets(first, last, offsets_l + start_l, offsets_r + start_r, - num, num_l == num_r); - num_l -= num; num_r -= num; - start_l += num; start_r += num; - if (num_l == 0) first += block_size; - if (num_r == 0) last -= block_size; - } - - int l_size = 0, r_size = 0; - int unknown_left = (last - first) - ((num_r || num_l) ? block_size : 0); - if (num_r) { - // Handle leftover block by assigning the unknown elements to the other block. - l_size = unknown_left; - r_size = block_size; - } else if (num_l) { - l_size = block_size; - r_size = unknown_left; - } else { - // No leftover block, split the unknown elements in two blocks. - l_size = unknown_left/2; - r_size = unknown_left - l_size; - } - - // Fill offset buffers if needed. - if (unknown_left && !num_l) { - start_l = 0; - Iter it = first; - for (unsigned char i = 0; i < l_size;) { - offsets_l[num_l] = i++; num_l += !comp(*it, pivot); ++it; - } - } - if (unknown_left && !num_r) { - start_r = 0; - Iter it = last; - for (unsigned char i = 0; i < r_size;) { - offsets_r[num_r] = ++i; num_r += comp(*--it, pivot); - } - } - - int num = (std::min)(num_l, num_r); - swap_offsets(first, last, offsets_l + start_l, offsets_r + start_r, num, num_l == num_r); - num_l -= num; num_r -= num; - start_l += num; start_r += num; - if (num_l == 0) first += l_size; - if (num_r == 0) last -= r_size; - - // We have now fully identified [first, last)'s proper position. Swap the last elements. - if (num_l) { - offsets_l += start_l; - while (num_l--) std::iter_swap(first + offsets_l[num_l], --last); - first = last; - } - if (num_r) { - offsets_r += start_r; - while (num_r--) std::iter_swap(last - offsets_r[num_r], first), ++first; - last = first; - } - - // Put the pivot in the right place. - Iter pivot_pos = first - 1; - *begin = BOOST_PDQSORT_PREFER_MOVE(*pivot_pos); - *pivot_pos = BOOST_PDQSORT_PREFER_MOVE(pivot); - - return std::make_pair(pivot_pos, already_partitioned); - } - - // Partitions [begin, end) around pivot *begin using comparison function comp. Elements equal - // to the pivot are put in the right-hand partition. Returns the position of the pivot after - // partitioning and whether the passed sequence already was correctly partitioned. Assumes the - // pivot is a median of at least 3 elements and that [begin, end) is at least - // insertion_sort_threshold long. - template<class Iter, class Compare> - inline std::pair<Iter, bool> partition_right(Iter begin, Iter end, Compare comp) { - typedef typename std::iterator_traits<Iter>::value_type T; - - // Move pivot into local for speed. - T pivot(BOOST_PDQSORT_PREFER_MOVE(*begin)); - - Iter first = begin; - Iter last = end; - - // Find the first element greater than or equal than the pivot (the median of 3 guarantees - // this exists). - while (comp(*++first, pivot)); - - // Find the first element strictly smaller than the pivot. We have to guard this search if - // there was no element before *first. - if (first - 1 == begin) while (first < last && !comp(*--last, pivot)); - else while ( !comp(*--last, pivot)); - - // If the first pair of elements that should be swapped to partition are the same element, - // the passed in sequence already was correctly partitioned. - bool already_partitioned = first >= last; - - // Keep swapping pairs of elements that are on the wrong side of the pivot. Previously - // swapped pairs guard the searches, which is why the first iteration is special-cased - // above. - while (first < last) { - std::iter_swap(first, last); - while (comp(*++first, pivot)); - while (!comp(*--last, pivot)); - } - - // Put the pivot in the right place. - Iter pivot_pos = first - 1; - *begin = BOOST_PDQSORT_PREFER_MOVE(*pivot_pos); - *pivot_pos = BOOST_PDQSORT_PREFER_MOVE(pivot); - - return std::make_pair(pivot_pos, already_partitioned); - } - - // Similar function to the one above, except elements equal to the pivot are put to the left of - // the pivot and it doesn't check or return if the passed sequence already was partitioned. - // Since this is rarely used (the many equal case), and in that case pdqsort already has O(n) - // performance, no block quicksort is applied here for simplicity. - template<class Iter, class Compare> - inline Iter partition_left(Iter begin, Iter end, Compare comp) { - typedef typename std::iterator_traits<Iter>::value_type T; - - T pivot(BOOST_PDQSORT_PREFER_MOVE(*begin)); - Iter first = begin; - Iter last = end; - - while (comp(pivot, *--last)); - - if (last + 1 == end) while (first < last && !comp(pivot, *++first)); - else while ( !comp(pivot, *++first)); - - while (first < last) { - std::iter_swap(first, last); - while (comp(pivot, *--last)); - while (!comp(pivot, *++first)); - } - - Iter pivot_pos = last; - *begin = BOOST_PDQSORT_PREFER_MOVE(*pivot_pos); - *pivot_pos = BOOST_PDQSORT_PREFER_MOVE(pivot); - - return pivot_pos; - } - - - template<class Iter, class Compare, bool Branchless> - inline void pdqsort_loop(Iter begin, Iter end, Compare comp, int bad_allowed, bool leftmost = true) { - typedef typename std::iterator_traits<Iter>::difference_type diff_t; - - // Use a while loop for tail recursion elimination. - while (true) { - diff_t size = end - begin; - - // Insertion sort is faster for small arrays. - if (size < insertion_sort_threshold) { - if (leftmost) insertion_sort(begin, end, comp); - else unguarded_insertion_sort(begin, end, comp); - return; - } - - // Choose pivot as median of 3 or pseudomedian of 9. - diff_t s2 = size / 2; - if (size > ninther_threshold) { - sort3(begin, begin + s2, end - 1, comp); - sort3(begin + 1, begin + (s2 - 1), end - 2, comp); - sort3(begin + 2, begin + (s2 + 1), end - 3, comp); - sort3(begin + (s2 - 1), begin + s2, begin + (s2 + 1), comp); - std::iter_swap(begin, begin + s2); - } else sort3(begin + s2, begin, end - 1, comp); - - // If *(begin - 1) is the end of the right partition of a previous partition operation - // there is no element in [begin, end) that is smaller than *(begin - 1). Then if our - // pivot compares equal to *(begin - 1) we change strategy, putting equal elements in - // the left partition, greater elements in the right partition. We do not have to - // recurse on the left partition, since it's sorted (all equal). - if (!leftmost && !comp(*(begin - 1), *begin)) { - begin = partition_left(begin, end, comp) + 1; - continue; - } - - // Partition and get results. - std::pair<Iter, bool> part_result = - Branchless ? partition_right_branchless(begin, end, comp) - : partition_right(begin, end, comp); - Iter pivot_pos = part_result.first; - bool already_partitioned = part_result.second; - - // Check for a highly unbalanced partition. - diff_t l_size = pivot_pos - begin; - diff_t r_size = end - (pivot_pos + 1); - bool highly_unbalanced = l_size < size / 8 || r_size < size / 8; - - // If we got a highly unbalanced partition we shuffle elements to break many patterns. - if (highly_unbalanced) { - // If we had too many bad partitions, switch to heapsort to guarantee O(n log n). - if (--bad_allowed == 0) { - std::make_heap(begin, end, comp); - std::sort_heap(begin, end, comp); - return; - } - - if (l_size >= insertion_sort_threshold) { - std::iter_swap(begin, begin + l_size / 4); - std::iter_swap(pivot_pos - 1, pivot_pos - l_size / 4); - - if (l_size > ninther_threshold) { - std::iter_swap(begin + 1, begin + (l_size / 4 + 1)); - std::iter_swap(begin + 2, begin + (l_size / 4 + 2)); - std::iter_swap(pivot_pos - 2, pivot_pos - (l_size / 4 + 1)); - std::iter_swap(pivot_pos - 3, pivot_pos - (l_size / 4 + 2)); - } - } - - if (r_size >= insertion_sort_threshold) { - std::iter_swap(pivot_pos + 1, pivot_pos + (1 + r_size / 4)); - std::iter_swap(end - 1, end - r_size / 4); - - if (r_size > ninther_threshold) { - std::iter_swap(pivot_pos + 2, pivot_pos + (2 + r_size / 4)); - std::iter_swap(pivot_pos + 3, pivot_pos + (3 + r_size / 4)); - std::iter_swap(end - 2, end - (1 + r_size / 4)); - std::iter_swap(end - 3, end - (2 + r_size / 4)); - } - } - } else { - // If we were decently balanced and we tried to sort an already partitioned - // sequence try to use insertion sort. - if (already_partitioned && partial_insertion_sort(begin, pivot_pos, comp) - && partial_insertion_sort(pivot_pos + 1, end, comp)) return; - } - - // Sort the left partition first using recursion and do tail recursion elimination for - // the right-hand partition. - pdqsort_loop<Iter, Compare, Branchless>(begin, pivot_pos, comp, bad_allowed, leftmost); - begin = pivot_pos + 1; - leftmost = false; - } - } -} - - -/*! \brief Generic sort algorithm using random access iterators and a user-defined comparison operator. - - \details @c pdqsort is a fast generic sorting algorithm that is similar in concept to introsort -but runs faster on certain patterns. @c pdqsort is in-place, unstable, deterministic, has a worst -case runtime of <em>O(N * lg(N))</em> and a best case of <em>O(N)</em>. Even without patterns, the -quicksort has been very efficiently implemented, and @c pdqsort runs 1-5% faster than GCC 6.2's -@c std::sort. If the type being sorted is @c std::is_arithmetic and Compare is @c std::less or -@c std::greater this function will automatically use @c pdqsort_branchless for far greater speedups. - - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - \param[in] comp A binary functor that returns whether the first element passed to it should go before the second in order. - \pre [@c first, @c last) is a valid range. - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/MoveAssignable">MoveAssignable</a> - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/MoveConstructible">MoveConstructible</a> - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable">LessThanComparable</a> - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \return @c void. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps - (or moves), functors, or any operations on iterators throw. - \warning Invalid arguments cause undefined behaviour. - \warning Throwing an exception may cause data loss. -*/ -template<class Iter, class Compare> -inline void pdqsort(Iter first, Iter last, Compare comp) { - if (first == last) return; - pdqsort_detail::pdqsort_loop<Iter, Compare, - pdqsort_detail::is_default_compare<typename boost::decay<Compare>::type>::value && - boost::is_arithmetic<typename std::iterator_traits<Iter>::value_type>::value>( - first, last, comp, pdqsort_detail::log2(last - first)); -} - - -/*! \brief Generic sort algorithm using random access iterators and a user-defined comparison operator. - - \details @c pdqsort_branchless is a fast generic sorting algorithm that is similar in concept to -introsort but runs faster on certain patterns. @c pdqsort_branchless is in-place, unstable, -deterministic, has a worst case runtime of <em>O(N * lg(N))</em> and a best case of <em>O(N)</em>. -Even without patterns, the quicksort has been very efficiently implemented with block based -partitioning, and @c pdqsort_branchless runs 80-90% faster than GCC 6.2's @c std::sort when sorting -small data such as integers. However, this speedup is gained by totally bypassing the branch -predictor, if your comparison operator or iterator contains branches you will most likely see little -gain or a small loss in performance. - - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - \param[in] comp A binary functor that returns whether the first element passed to it should go before the second in order. - \pre [@c first, @c last) is a valid range. - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/MoveAssignable">MoveAssignable</a> - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/MoveConstructible">MoveConstructible</a> - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable">LessThanComparable</a> - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \return @c void. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps - (or moves), functors, or any operations on iterators throw. - \warning Invalid arguments cause undefined behaviour. - \warning Throwing an exception may cause data loss. -*/ -template<class Iter, class Compare> -inline void pdqsort_branchless(Iter first, Iter last, Compare comp) { - if (first == last) return; - pdqsort_detail::pdqsort_loop<Iter, Compare, true>( - first, last, comp, pdqsort_detail::log2(last - first)); -} - - -/*! \brief Generic sort algorithm using random access iterators. - - \details @c pdqsort is a fast generic sorting algorithm that is similar in concept to introsort -but runs faster on certain patterns. @c pdqsort is in-place, unstable, deterministic, has a worst -case runtime of <em>O(N * lg(N))</em> and a best case of <em>O(N)</em>. Even without patterns, the -quicksort partitioning has been very efficiently implemented, and @c pdqsort runs 80-90% faster than -GCC 6.2's @c std::sort. If the type being sorted is @c std::is_arithmetic this function will -automatically use @c pdqsort_branchless. - - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - \pre [@c first, @c last) is a valid range. - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/MoveAssignable">MoveAssignable</a> - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/MoveConstructible">MoveConstructible</a> - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable">LessThanComparable</a> - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \return @c void. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps - (or moves), functors, or any operations on iterators throw. - \warning Invalid arguments cause undefined behaviour. - \warning Throwing an exception may cause data loss. -*/ -template<class Iter> -inline void pdqsort(Iter first, Iter last) { - typedef typename std::iterator_traits<Iter>::value_type T; - pdqsort(first, last, std::less<T>()); -} - - -/*! \brief Generic sort algorithm using random access iterators. - - \details @c pdqsort_branchless is a fast generic sorting algorithm that is similar in concept to -introsort but runs faster on certain patterns. @c pdqsort_branchless is in-place, unstable, -deterministic, has a worst case runtime of <em>O(N * lg(N))</em> and a best case of <em>O(N)</em>. -Even without patterns, the quicksort has been very efficiently implemented with block based -partitioning, and @c pdqsort_branchless runs 80-90% faster than GCC 6.2's @c std::sort when sorting -small data such as integers. However, this speedup is gained by totally bypassing the branch -predictor, if your comparison operator or iterator contains branches you will most likely see little -gain or a small loss in performance. - - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - \pre [@c first, @c last) is a valid range. - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/MoveAssignable">MoveAssignable</a> - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/MoveConstructible">MoveConstructible</a> - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable">LessThanComparable</a> - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \return @c void. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps - (or moves), functors, or any operations on iterators throw. - \warning Invalid arguments cause undefined behaviour. - \warning Throwing an exception may cause data loss. -*/ -template<class Iter> -inline void pdqsort_branchless(Iter first, Iter last) { - typedef typename std::iterator_traits<Iter>::value_type T; - pdqsort_branchless(first, last, std::less<T>()); -} - -} -} - -#undef BOOST_PDQSORT_PREFER_MOVE - -#endif diff --git a/contrib/restricted/boost/boost/sort/sample_sort/sample_sort.hpp b/contrib/restricted/boost/boost/sort/sample_sort/sample_sort.hpp deleted file mode 100644 index ded1781cfad..00000000000 --- a/contrib/restricted/boost/boost/sort/sample_sort/sample_sort.hpp +++ /dev/null @@ -1,560 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file sample_sort.hpp -/// @brief contains the class sample_sort -/// -/// @author Copyright (c) 2016 Francisco Jose Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_PARALLEL_DETAIL_SAMPLE_SORT_HPP -#define __BOOST_SORT_PARALLEL_DETAIL_SAMPLE_SORT_HPP - -#include <functional> -#include <future> -#include <iterator> -#include <memory> -#include <type_traits> -#include <vector> - -#include <algorithm> -#include <boost/sort/spinsort/spinsort.hpp> -#include <boost/sort/common/indirect.hpp> -#include <boost/sort/common/util/atomic.hpp> -#include <boost/sort/common/merge_four.hpp> -#include <boost/sort/common/merge_vector.hpp> -#include <boost/sort/common/range.hpp> - -namespace boost -{ -namespace sort -{ -namespace sample_detail -{ -//--------------------------------------------------------------------------- -// USING SENTENCES -//--------------------------------------------------------------------------- -namespace bsc = boost::sort::common; -namespace bss = boost::sort::spin_detail; -namespace bscu = boost::sort::common::util; -using bsc::range; -using bscu::atomic_add; -using bsc::merge_vector4; -using bsc::uninit_merge_level4; -using bsc::less_ptr_no_null; - -// -///--------------------------------------------------------------------------- -/// @struct sample_sort -/// @brief This a structure for to implement a sample sort, exception -/// safe -/// @tparam -/// @remarks -//---------------------------------------------------------------------------- -template<class Iter_t, class Compare> -struct sample_sort -{ - //------------------------------------------------------------------------ - // DEFINITIONS - //------------------------------------------------------------------------ - typedef value_iter<Iter_t> value_t; - typedef range<Iter_t> range_it; - typedef range<value_t *> range_buf; - typedef sample_sort<Iter_t, Compare> this_t; - - //------------------------------------------------------------------------ - // VARIABLES AND CONSTANTS - //------------------------------------------------------------------------ - // minimun numbers of elements for to be sortd in parallel mode - static const uint32_t thread_min = (1 << 16); - - // Number of threads to use in the algorithm - // Number of intervals for to do the internal division of the data - uint32_t nthread, ninterval; - - // Bool variables indicating if the auxiliary memory is constructed - // and indicating in the auxiliary memory had been obtained inside the - /// algorithm or had been received as a parameter - bool construct = false, owner = false; - - // Comparison object for to compare two elements - Compare comp; - - // Range with all the elements to sort - range_it global_range; - - // range with the auxiliary memory - range_buf global_buf; - - // vector of futures - std::vector<std::future<void>> vfuture; - - // vector of vectors which contains the ranges to merge obtained in the - // subdivision - std::vector<std::vector<range_it>> vv_range_it; - - // each vector of ranges of the vv_range_it, need their corresponding buffer - // for to do the merge - std::vector<std::vector<range_buf>> vv_range_buf; - - // Initial vector of ranges - std::vector<range_it> vrange_it_ini; - - // Initial vector of buffers - std::vector<range_buf> vrange_buf_ini; - - // atomic counter for to know when are finished the function_t created - // inside a function - std::atomic<uint32_t> njob; - - // Indicate if an error in the algorithm for to undo all - bool error; - - //------------------------------------------------------------------------ - // FUNCTIONS OF THE STRUCT - //------------------------------------------------------------------------ - void initial_configuration(void); - - sample_sort (Iter_t first, Iter_t last, Compare cmp, uint32_t num_thread, - value_t *paux, size_t naux); - - sample_sort(Iter_t first, Iter_t last) - : sample_sort (first, last, Compare(), std::thread::hardware_concurrency(), - nullptr, 0) { }; - - sample_sort(Iter_t first, Iter_t last, Compare cmp) - : sample_sort(first, last, cmp, std::thread::hardware_concurrency(), - nullptr, 0) { }; - - sample_sort(Iter_t first, Iter_t last, uint32_t num_thread) - : sample_sort(first, last, Compare(), num_thread, nullptr, 0) { }; - - sample_sort(Iter_t first, Iter_t last, Compare cmp, uint32_t num_thread) - : sample_sort(first, last, cmp, num_thread, nullptr, 0) { }; - - sample_sort(Iter_t first, Iter_t last, Compare cmp, uint32_t num_thread, - range_buf range_buf_initial) - : sample_sort(first, last, cmp, num_thread, - range_buf_initial.first, range_buf_initial.size()) { }; - - void destroy_all(void); - // - //----------------------------------------------------------------------------- - // function :~sample_sort - /// @brief destructor of the class. The utility is to destroy the temporary - /// buffer used in the sorting process - //----------------------------------------------------------------------------- - ~sample_sort(void) { destroy_all(); }; - // - //----------------------------------------------------------------------- - // function : execute first - /// @brief this a function to assign to each thread in the first merge - //----------------------------------------------------------------------- - void execute_first(void) - { - uint32_t job = 0; - while ((job = atomic_add(njob, 1)) < ninterval) - { - uninit_merge_level4(vrange_buf_ini[job], vv_range_it[job], - vv_range_buf[job], comp); - }; - }; - // - //----------------------------------------------------------------------- - // function : execute - /// @brief this is a function to assignt each thread the final merge - //----------------------------------------------------------------------- - void execute(void) - { - uint32_t job = 0; - while ((job = atomic_add(njob, 1)) < ninterval) - { - merge_vector4(vrange_buf_ini[job], vrange_it_ini[job], - vv_range_buf[job], vv_range_it[job], comp); - }; - }; - // - //----------------------------------------------------------------------- - // function : first merge - /// @brief Implement the merge of the initially sparse ranges - //----------------------------------------------------------------------- - void first_merge(void) - { //---------------------------------- begin -------------------------- - njob = 0; - - for (uint32_t i = 0; i < nthread; ++i) - { - vfuture[i] = std::async(std::launch::async, &this_t::execute_first, - this); - }; - for (uint32_t i = 0; i < nthread; ++i) - vfuture[i].get(); - }; - // - //----------------------------------------------------------------------- - // function : final merge - /// @brief Implement the final merge of the ranges - //----------------------------------------------------------------------- - void final_merge(void) - { //---------------------------------- begin -------------------------- - njob = 0; - - for (uint32_t i = 0; i < nthread; ++i) - { - vfuture[i] = std::async(std::launch::async, &this_t::execute, this); - }; - for (uint32_t i = 0; i < nthread; ++i) - vfuture[i].get(); - }; - //---------------------------------------------------------------------------- -}; -// End class sample_sort -//---------------------------------------------------------------------------- -// -//############################################################################ -// ## -// N O N I N L I N E F U N C T I O N S ## -// ## -// ## -//############################################################################ -// -//----------------------------------------------------------------------------- -// function : sample_sort -/// @brief constructor of the class -/// -/// @param first : iterator to the first element of the range to sort -/// @param last : iterator after the last element to the range to sort -/// @param cmp : object for to compare two elements pointed by Iter_t iterators -/// @param num_thread : Number of threads to use in the process. When this value -/// is lower than 2, the sorting is done with 1 thread -/// @param paux : pointer to the auxiliary memory. If nullptr, the memory is -/// created inside the class -/// @param naux : number of elements of the memory pointed by paux -//----------------------------------------------------------------------------- -template<class Iter_t, typename Compare> -sample_sort<Iter_t, Compare> -::sample_sort (Iter_t first, Iter_t last, Compare cmp, uint32_t num_thread, - value_t *paux, size_t naux) -: nthread(num_thread), owner(false), comp(cmp), global_range(first, last), - global_buf(nullptr, nullptr), error(false) -{ - assert((last - first) >= 0); - size_t nelem = size_t(last - first); - construct = false; - njob = 0; - vfuture.resize(nthread); - - // Adjust when have many threads and only a few elements - while (nelem > thread_min and (nthread * nthread) > (nelem >> 3)) - { - nthread /= 2; - }; - ninterval = (nthread << 3); - - if (nthread < 2 or nelem <= (thread_min)) - { - bss::spinsort<Iter_t, Compare>(first, last, comp); - return; - }; - - //------------------- check if sort -------------------------------------- - bool sw = true; - for (Iter_t it1 = first, it2 = first + 1; - it2 != last and (sw = not comp(*it2, *it1)); it1 = it2++); - if (sw) return; - - //------------------- check if reverse sort --------------------------- - sw = true; - for (Iter_t it1 = first, it2 = first + 1; - it2 != last and (sw = comp(*it2, *it1)); it1 = it2++); - if (sw) - { - size_t nelem2 = nelem >> 1; - Iter_t it1 = first, it2 = last - 1; - for (size_t i = 0; i < nelem2; ++i) - std::swap(*(it1++), *(it2--)); - return; - }; - - if (paux != nullptr) - { - assert(naux != 0); - global_buf.first = paux; - global_buf.last = paux + naux; - owner = false; - } - else - { - value_t *ptr = std::get_temporary_buffer<value_t>(nelem).first; - if (ptr == nullptr) throw std::bad_alloc(); - owner = true; - global_buf = range_buf(ptr, ptr + nelem); - }; - //------------------------------------------------------------------------ - // PROCESS - //------------------------------------------------------------------------ - try - { - initial_configuration(); - } catch (std::bad_alloc &) - { - error = true; - }; - if (not error) - { - first_merge(); - construct = true; - final_merge(); - }; - if (error) - { - destroy_all(); - throw std::bad_alloc(); - }; -} -; -// -//----------------------------------------------------------------------------- -// function : destroy_all -/// @brief destructor of the class. The utility is to destroy the temporary -/// buffer used in the sorting process -//----------------------------------------------------------------------------- -template<class Iter_t, typename Compare> -void sample_sort<Iter_t, Compare>::destroy_all(void) -{ - if (construct) - { - destroy(global_buf); - construct = false; - } - if (global_buf.first != nullptr and owner) - std::return_temporary_buffer(global_buf.first); -} -// -//----------------------------------------------------------------------------- -// function : initial_configuration -/// @brief Create the internal data structures, and obtain the inital set of -/// ranges to merge -//----------------------------------------------------------------------------- -template<class Iter_t, typename Compare> -void sample_sort<Iter_t, Compare>::initial_configuration(void) -{ - std::vector<range_it> vmem_thread; - std::vector<range_buf> vbuf_thread; - size_t nelem = global_range.size(); - - //------------------------------------------------------------------------ - size_t cupo = nelem / nthread; - Iter_t it_first = global_range.first; - value_t *buf_first = global_buf.first; - vmem_thread.reserve(nthread + 1); - vbuf_thread.reserve(nthread + 1); - - for (uint32_t i = 0; i < (nthread - 1); ++i, it_first += cupo, buf_first += - cupo) - { - vmem_thread.emplace_back(it_first, it_first + cupo); - vbuf_thread.emplace_back(buf_first, buf_first + cupo); - }; - - vmem_thread.emplace_back(it_first, global_range.last); - vbuf_thread.emplace_back(buf_first, global_buf.last); - - //------------------------------------------------------------------------ - // Sorting of the ranges - //------------------------------------------------------------------------ - std::vector<std::future<void>> vfuture(nthread); - - for (uint32_t i = 0; i < nthread; ++i) - { - auto func = [=]() - { - bss::spinsort<Iter_t, Compare> (vmem_thread[i].first, - vmem_thread[i].last, comp, - vbuf_thread[i]); - }; - vfuture[i] = std::async(std::launch::async, func); - }; - - for (uint32_t i = 0; i < nthread; ++i) - vfuture[i].get(); - - //------------------------------------------------------------------------ - // Obtain the vector of milestones - //------------------------------------------------------------------------ - std::vector<Iter_t> vsample; - vsample.reserve(nthread * (ninterval - 1)); - - for (uint32_t i = 0; i < nthread; ++i) - { - size_t distance = vmem_thread[i].size() / ninterval; - for (size_t j = 1, pos = distance; j < ninterval; ++j, pos += distance) - { - vsample.push_back(vmem_thread[i].first + pos); - }; - }; - typedef less_ptr_no_null<Iter_t, Compare> compare_ptr; - typedef typename std::vector<Iter_t>::iterator it_to_it; - - bss::spinsort<it_to_it, compare_ptr>(vsample.begin(), vsample.end(), - compare_ptr(comp)); - - //------------------------------------------------------------------------ - // Create the final milestone vector - //------------------------------------------------------------------------ - std::vector<Iter_t> vmilestone; - vmilestone.reserve(ninterval); - - for (uint32_t pos = nthread >> 1; pos < vsample.size(); pos += nthread) - { - vmilestone.push_back(vsample[pos]); - }; - - //------------------------------------------------------------------------ - // Creation of the first vector of ranges - //------------------------------------------------------------------------ - std::vector<std::vector<range<Iter_t>>>vv_range_first (nthread); - - for (uint32_t i = 0; i < nthread; ++i) - { - Iter_t itaux = vmem_thread[i].first; - - for (uint32_t k = 0; k < (ninterval - 1); ++k) - { - Iter_t it2 = std::upper_bound(itaux, vmem_thread[i].last, - *vmilestone[k], comp); - - vv_range_first[i].emplace_back(itaux, it2); - itaux = it2; - }; - vv_range_first[i].emplace_back(itaux, vmem_thread[i].last); - }; - - //------------------------------------------------------------------------ - // Copy in buffer and creation of the final matrix of ranges - //------------------------------------------------------------------------ - vv_range_it.resize(ninterval); - vv_range_buf.resize(ninterval); - vrange_it_ini.reserve(ninterval); - vrange_buf_ini.reserve(ninterval); - - for (uint32_t i = 0; i < ninterval; ++i) - { - vv_range_it[i].reserve(nthread); - vv_range_buf[i].reserve(nthread); - }; - - Iter_t it = global_range.first; - value_t *it_buf = global_buf.first; - - for (uint32_t k = 0; k < ninterval; ++k) - { - size_t nelem_interval = 0; - - for (uint32_t i = 0; i < nthread; ++i) - { - size_t nelem_range = vv_range_first[i][k].size(); - if (nelem_range != 0) - { - vv_range_it[k].push_back(vv_range_first[i][k]); - }; - nelem_interval += nelem_range; - }; - - vrange_it_ini.emplace_back(it, it + nelem_interval); - vrange_buf_ini.emplace_back(it_buf, it_buf + nelem_interval); - - it += nelem_interval; - it_buf += nelem_interval; - }; -} -; -// -//**************************************************************************** -} -; -// End namespace sample_detail -//**************************************************************************** -// -namespace bscu = boost::sort::common::util; -// -//############################################################################ -// ## -// ## -// S A M P L E _ S O R T ## -// ## -// ## -//############################################################################ -// -//----------------------------------------------------------------------------- -// function : sample_sort -/// @brief parallel sample sort algorithm (stable sort) -/// -/// @param first : iterator to the first element of the range to sort -/// @param last : iterator after the last element to the range to sort -//----------------------------------------------------------------------------- -template<class Iter_t> -void sample_sort(Iter_t first, Iter_t last) -{ - typedef compare_iter<Iter_t> Compare; - sample_detail::sample_sort<Iter_t, Compare>(first, last); -}; -// -//----------------------------------------------------------------------------- -// function : sample_sort -/// @brief parallel sample sort algorithm (stable sort) -/// -/// @param first : iterator to the first element of the range to sort -/// @param last : iterator after the last element to the range to sort -/// @param nthread : Number of threads to use in the process. When this value -/// is lower than 2, the sorting is done with 1 thread -//----------------------------------------------------------------------------- -template<class Iter_t> -void sample_sort(Iter_t first, Iter_t last, uint32_t nthread) -{ - typedef compare_iter<Iter_t> Compare; - sample_detail::sample_sort<Iter_t, Compare>(first, last, nthread); -}; -// -//----------------------------------------------------------------------------- -// function : sample_sort -/// @brief parallel sample sort algorithm (stable sort) -/// -/// @param first : iterator to the first element of the range to sort -/// @param last : iterator after the last element to the range to sort -/// @param comp : object for to compare two elements pointed by Iter_t -/// iterators -//----------------------------------------------------------------------------- -template<class Iter_t, class Compare, bscu::enable_if_not_integral<Compare> * = - nullptr> -void sample_sort(Iter_t first, Iter_t last, Compare comp) -{ - sample_detail::sample_sort<Iter_t, Compare>(first, last, comp); -}; -// -//----------------------------------------------------------------------------- -// function : sample_sort -/// @brief parallel sample sort algorithm (stable sort) -/// -/// @param first : iterator to the first element of the range to sort -/// @param last : iterator after the last element to the range to sort -/// @param comp : object for to compare two elements pointed by Iter_t -/// iterators -/// @param nthread : Number of threads to use in the process. When this value -/// is lower than 2, the sorting is done with 1 thread -//----------------------------------------------------------------------------- -template<class Iter_t, class Compare> -void sample_sort(Iter_t first, Iter_t last, Compare comp, uint32_t nthread) -{ - sample_detail::sample_sort<Iter_t, Compare>(first, last, comp, nthread); -}; -// -//**************************************************************************** -};// End namespace sort -};// End namespace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/sort.hpp b/contrib/restricted/boost/boost/sort/sort.hpp deleted file mode 100644 index 625f134b5c1..00000000000 --- a/contrib/restricted/boost/boost/sort/sort.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// The Boost Sort library cumulative header. - -// Copyright Steven J. Ross 2014 -// Distributed under the 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://www.boost.org/libs/sort/ for library home page. - -#ifndef BOOST_SORT_HPP -#define BOOST_SORT_HPP - -/* -Cumulative include for the Boost Sort library -*/ -#include <boost/sort/spreadsort/spreadsort.hpp> -#include <boost/sort/spinsort/spinsort.hpp> -#include <boost/sort/flat_stable_sort/flat_stable_sort.hpp> -#include <boost/sort/pdqsort/pdqsort.hpp> -#include <boost/sort/block_indirect_sort/block_indirect_sort.hpp> -#include <boost/sort/sample_sort/sample_sort.hpp> -#include <boost/sort/parallel_stable_sort/parallel_stable_sort.hpp> - -#endif diff --git a/contrib/restricted/boost/boost/sort/spinsort/spinsort.hpp b/contrib/restricted/boost/boost/sort/spinsort/spinsort.hpp deleted file mode 100644 index 0e9f2d55721..00000000000 --- a/contrib/restricted/boost/boost/sort/spinsort/spinsort.hpp +++ /dev/null @@ -1,564 +0,0 @@ -//---------------------------------------------------------------------------- -/// @file spinsort.hpp -/// @brief Spin Sort algorithm -/// -/// @author Copyright (c) 2016 Francisco José Tapia (fjtapia@gmail.com )\n -/// Distributed under the Boost Software License, Version 1.0.\n -/// ( See accompanying file LICENSE_1_0.txt or copy at -/// http://www.boost.org/LICENSE_1_0.txt ) -/// @version 0.1 -/// -/// @remarks -//----------------------------------------------------------------------------- -#ifndef __BOOST_SORT_PARALLEL_ALGORITHM_SPIN_SORT_HPP -#define __BOOST_SORT_PARALLEL_ALGORITHM_SPIN_SORT_HPP - -//#include <boost/sort/spinsort/util/indirect.hpp> -#include <boost/sort/insert_sort/insert_sort.hpp> -#include <boost/sort/common/util/traits.hpp> -#include <boost/sort/common/util/algorithm.hpp> -#include <boost/sort/common/range.hpp> -#include <boost/sort/common/indirect.hpp> -#include <cstdlib> -#include <functional> -#include <iterator> -#include <memory> -#include <type_traits> -#include <vector> -#include <cstddef> - -namespace boost -{ -namespace sort -{ -namespace spin_detail -{ - -//---------------------------------------------------------------------------- -// USING SENTENCES -//---------------------------------------------------------------------------- -namespace bsc = boost::sort::common; -using bsc::range; -using bsc::util::nbits64; -using bsc::util::compare_iter; -using bsc::util::value_iter; -using boost::sort::insert_sort; - -// -//############################################################################ -// ## -// D E F I N I T I O N S O F F U N C T I O N S ## -// ## -//############################################################################ -// -template <class Iter1_t, class Iter2_t, typename Compare> -static void insert_partial_sort (Iter1_t first, Iter1_t mid, - Iter1_t last, Compare comp, - const range<Iter2_t> &rng_aux); - -template<class Iter1_t, class Iter2_t, class Compare> -static bool check_stable_sort (const range<Iter1_t> &rng_data, - const range<Iter2_t> &rng_aux, Compare comp); - -template<class Iter1_t, class Iter2_t, class Compare> -static void range_sort (const range<Iter1_t> &range1, - const range<Iter2_t> &range2, Compare comp, - uint32_t level); - -template<class Iter1_t, class Iter2_t, class Compare> -static void sort_range_sort (const range<Iter1_t> &rng_data, - const range<Iter2_t> &rng_aux, Compare comp); - -// -//----------------------------------------------------------------------------- -// function : insert_partial_sort -/// @brief : Insertion sort of elements sorted -/// @param first: iterator to the first element of the range -/// @param mid : last pointer of the sorted data, and first pointer to the -/// elements to insert -/// @param last : iterator to the next element of the last in the range -/// @param comp : -/// @comments : the two ranges are sorted -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, typename Compare> -static void insert_partial_sort (Iter1_t first, Iter1_t mid, Iter1_t last, - Compare comp, const range<Iter2_t> &rng_aux) -{ - //------------------------------------------------------------------------ - // metaprogram - //------------------------------------------------------------------------ - typedef value_iter<Iter1_t> value_t; - typedef value_iter<Iter2_t> value2_t; - static_assert (std::is_same<value_t, value2_t>::value, - "Incompatible iterators\n"); - - //-------------------------------------------------------------------- - // program - //-------------------------------------------------------------------- - assert(size_t(last - mid) <= rng_aux.size()); - - if (mid == last) return; - //insertionsort ( mid, last, comp); - if (first == mid) return; - - //------------------------------------------------------------------------ - // creation of the vector of elements to insert and their position in the - // sorted part - // the data are inserted in rng_aux - //----------------------------------------------------------------------- - std::vector<Iter1_t> viter; - Iter2_t beta = rng_aux.first, data = rng_aux.first; - - for (Iter1_t alpha = mid; alpha != last; ++alpha) - *(beta++) = std::move(*alpha); - - size_t ndata = last - mid; - - Iter1_t linf = first, lsup = mid; - for (uint32_t i = 0; i < ndata; ++i) - { - Iter1_t it1 = std::upper_bound(linf, lsup, *(data + i), comp); - viter.push_back(it1); - linf = it1; - }; - - // moving the elements - viter.push_back(mid); - for (uint32_t i = viter.size() - 1; i != 0; --i) - { - Iter1_t src = viter[i], limit = viter[i - 1]; - Iter1_t dest = src + (i); - while (src != limit) *(--dest) = std::move(*(--src)); - *(viter[i - 1] + (i - 1)) = std::move(*(data + (i - 1))); - }; -} -; -//----------------------------------------------------------------------------- -// function : check_stable_sort -/// @brief check if the elements between first and last are osted or reverse -/// sorted. If the number of elements not sorted is small, insert in -/// the sorted part -/// @param range_input : range with the elements to sort -/// @param range_buffer : range with the elements sorted -/// @param comp : object for to compare two elements -/// @param level : when is 1, sort with the insertionsort algorithm -/// if not make a recursive call splitting the ranges -// -/// @comments : if the number of levels is odd, the data are in the first -/// parameter of range_sort, and the results appear in the second parameter -/// If the number of levels is even, the data are in the second -/// parameter of range_sort, and the results are in the same parameter -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Compare> -static bool check_stable_sort(const range<Iter1_t> &rng_data, - const range<Iter2_t> &rng_aux, Compare comp) -{ - //------------------------------------------------------------------------ - // metaprogramming - //------------------------------------------------------------------------ - typedef value_iter<Iter1_t> value_t; - typedef value_iter<Iter2_t> value2_t; - static_assert (std::is_same<value_t, value2_t>::value, - "Incompatible iterators\n"); - - //------------------------------------------------------------------------ - // program - //------------------------------------------------------------------------ - // the maximun number of elements not ordered, for to be inserted in the - // sorted part - //const ptrdiff_t min_insert_partial_sort = 32 ; - const size_t ndata = rng_data.size(); - if (ndata < 32) - { - insert_sort(rng_data.first, rng_data.last, comp); - return true; - }; - const size_t min_insert_partial_sort = - ((ndata >> 3) < 33) ? 32 : (ndata >> 3); - if (ndata < 2) return true; - - // check if sorted - bool sw = true; - Iter1_t it2 = rng_data.first + 1; - for (Iter1_t it1 = rng_data.first; - it2 != rng_data.last and (sw = not comp(*it2, *it1)); it1 = - it2++) - ; - if (sw) return true; - - // insert the elements between it1 and last - if (size_t(rng_data.last - it2) < min_insert_partial_sort) - { - sort_range_sort(range<Iter1_t>(it2, rng_data.last), rng_aux, comp); - insert_partial_sort(rng_data.first, it2, rng_data.last, comp, rng_aux); - return true; - }; - - // check if reverse sorted - if ((it2 != (rng_data.first + 1))) return false; - sw = true; - for (Iter1_t it1 = rng_data.first; - it2 != rng_data.last and (sw = comp(*it2, *it1)); it1 = - it2++) - ; - if (size_t(rng_data.last - it2) >= min_insert_partial_sort) return false; - - // reverse the elements between first and it1 - size_t nreverse = it2 - rng_data.first; - Iter1_t alpha(rng_data.first), beta(it2 - 1), mid( - rng_data.first + (nreverse >> 1)); - while (alpha != mid) - std::swap(*(alpha++), *(beta--)); - - // insert the elements between it1 and last - if (it2 != rng_data.last) - { - sort_range_sort(range<Iter1_t>(it2, rng_data.last), rng_aux, comp); - insert_partial_sort(rng_data.first, it2, rng_data.last, comp, rng_aux); - }; - return true; -} -; -//----------------------------------------------------------------------------- -// function : range_sort -/// @brief this function divide r_input in two parts, sort it,and merge moving -/// the elements to range_buf -/// @param range_input : range with the elements to sort -/// @param range_buffer : range with the elements sorted -/// @param comp : object for to compare two elements -/// @param level : when is 1, sort with the insertionsort algorithm -/// if not make a recursive call splitting the ranges -// -/// @comments : if the number of levels is odd, the data are in the first -/// parameter of range_sort, and the results appear in the second parameter -/// If the number of levels is even, the data are in the second -/// parameter of range_sort, and the results are in the same parameter -/// The two ranges must have the same size -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Compare> -static void range_sort(const range<Iter1_t> &range1, - const range<Iter2_t> &range2, Compare comp, - uint32_t level) -{ - //----------------------------------------------------------------------- - // metaprogram - //----------------------------------------------------------------------- - typedef value_iter<Iter1_t> value_t; - typedef value_iter<Iter2_t> value2_t; - static_assert (std::is_same<value_t, value2_t>::value, - "Incompatible iterators\n"); - - //----------------------------------------------------------------------- - // program - //----------------------------------------------------------------------- - typedef range<Iter1_t> range_it1; - typedef range<Iter2_t> range_it2; - assert(range1.size() == range2.size() and level != 0); - - //------------------- check if sort -------------------------------------- - if (range1.size() > 1024) - { - if ((level & 1) == 0) - { - if (check_stable_sort(range2, range1, comp)) return; - } - else - { - if (check_stable_sort(range1, range2, comp)) - { - move_forward(range2, range1); - return; - }; - }; - }; - - //------------------- normal process ----------------------------------- - size_t nelem1 = (range1.size() + 1) >> 1; - range_it1 range_input1(range1.first, range1.first + nelem1), - range_input2(range1.first + nelem1, range1.last); - - if (level < 2) - { - insert_sort(range_input1.first, range_input1.last, comp); - insert_sort(range_input2.first, range_input2.last, comp); - } - else - { - range_sort (range_it2(range2.first, range2.first + nelem1), - range_input1, comp, level - 1); - - range_sort (range_it2(range2.first + nelem1, range2.last), - range_input2, comp, level - 1); - }; - - merge(range2, range_input1, range_input2, comp); -} -; -//----------------------------------------------------------------------------- -// function : sort_range_sort -/// @brief this sort elements using the range_sort function and receiving a -/// buffer of initialized memory -/// @param rng_data : range with the elements to sort -/// @param rng_aux : range of at least the same memory than rng_data used as -/// auxiliary memory in the sorting -/// @param comp : object for to compare two elements -//----------------------------------------------------------------------------- -template<class Iter1_t, class Iter2_t, class Compare> -static void sort_range_sort(const range<Iter1_t> &rng_data, - const range<Iter2_t> &rng_aux, Compare comp) -{ - //----------------------------------------------------------------------- - // metaprogram - //----------------------------------------------------------------------- - typedef value_iter<Iter1_t> value_t; - typedef value_iter<Iter2_t> value2_t; - static_assert (std::is_same<value_t, value2_t>::value, - "Incompatible iterators\n"); - - //------------------------------------------------------------------------ - // program - //------------------------------------------------------------------------ - // minimal number of element before to jump to insertionsort - static const uint32_t sort_min = 32; - if (rng_data.size() <= sort_min) - { - insert_sort(rng_data.first, rng_data.last, comp); - return; - }; - -#ifdef __BS_DEBUG - assert (rng_aux.size () >= rng_data.size ()); -#endif - - range<Iter2_t> rng_buffer(rng_aux.first, rng_aux.first + rng_data.size()); - uint32_t nlevel = - nbits64(((rng_data.size() + sort_min - 1) / sort_min) - 1); - //assert (nlevel != 0); - - if ((nlevel & 1) == 0) - { - range_sort(rng_buffer, rng_data, comp, nlevel); - } - else - { - range_sort(rng_data, rng_buffer, comp, nlevel); - move_forward(rng_data, rng_buffer); - }; -} -; -// -//############################################################################ -// ## -// S T R U C T ## -// ## -// S P I N _ S O R T ## -// ## -//############################################################################ -//--------------------------------------------------------------------------- -/// @struct spin_sort -/// @brief This class implement s stable sort algorithm with 1 thread, with -/// an auxiliary memory of N/2 elements -//---------------------------------------------------------------------------- -template<class Iter_t, typename Compare = compare_iter<Iter_t>> -class spinsort -{ - //------------------------------------------------------------------------ - // DEFINITIONS AND CONSTANTS - //------------------------------------------------------------------------ - typedef value_iter<Iter_t> value_t; - typedef range<Iter_t> range_it; - typedef range<value_t *> range_buf; - // When the number of elements to sort is smaller than Sort_min, are sorted - // by the insertion sort algorithm - static const uint32_t Sort_min = 36; - - //------------------------------------------------------------------------ - // VARIABLES - //------------------------------------------------------------------------ - // Pointer to the auxiliary memory - value_t *ptr; - - // Number of elements in the auxiliary memory - size_t nptr; - - // construct indicate if the auxiliary memory in initialized, and owner - // indicate if the auxiliary memory had been created inside the object or - // had - // been received as a parameter - bool construct = false, owner = false; - - //------------------------------------------------------------------------ - // PRIVATE FUNCTIONS - //------------------------------------------------------------------------- - spinsort (Iter_t first, Iter_t last, Compare comp, value_t *paux, - size_t naux); - -public: - //------------------------------------------------------------------------ - // PUBLIC FUNCTIONS - //------------------------------------------------------------------------- - spinsort(Iter_t first, Iter_t last, Compare comp = Compare()) - : spinsort(first, last, comp, nullptr, 0) { }; - - spinsort(Iter_t first, Iter_t last, Compare comp, range_buf range_aux) - : spinsort(first, last, comp, range_aux.first, range_aux.size()) { }; - // - //----------------------------------------------------------------------- - // function :~spinsort - /// @brief destructor of the struct. Destroy the elements if construct is - /// true, - /// and return the memory if owner is true - //----------------------------------------------------------------------- - ~spinsort(void) - { - if (construct) - { - destroy(range<value_t *>(ptr, ptr + nptr)); - construct = false; - }; - if (owner and ptr != nullptr) std::return_temporary_buffer(ptr); - }; -}; -//---------------------------------------------------------------------------- -// End of class spinsort -//---------------------------------------------------------------------------- -// -//------------------------------------------------------------------------- -// function : spinsort -/// @brief constructor of the struct -// -/// @param first : iterator to the first element of the range to sort -/// @param last : iterator after the last element to the range to sort -/// @param comp : object for to compare two elements pointed by Iter_t -/// iterators -/// @param paux : pointer to the auxiliary memory provided. If nullptr, the -/// memory is created inside the class -/// @param naux : number of elements pointed by paux -//------------------------------------------------------------------------ -template <class Iter_t, typename Compare> -spinsort <Iter_t, Compare> -::spinsort (Iter_t first, Iter_t last, Compare comp, value_t *paux, size_t naux) -: ptr(paux), nptr(naux), construct(false), owner(false) -{ - range<Iter_t> range_input(first, last); - assert(range_input.valid()); - - size_t nelem = range_input.size(); - owner = construct = false; - - nptr = (nelem + 1) >> 1; - size_t nelem_1 = nptr; - size_t nelem_2 = nelem - nelem_1; - - if (nelem <= (Sort_min << 1)) - { - insert_sort(range_input.first, range_input.last, comp); - return; - }; - - //------------------- check if sort --------------------------------- - bool sw = true; - for (Iter_t it1 = first, it2 = first + 1; it2 != last - and (sw = not comp(*it2, *it1)); it1 = it2++) ; - if (sw) return; - - //------------------- check if reverse sort ------------------------- - sw = true; - for (Iter_t it1 = first, it2 = first + 1; - it2 != last and (sw = comp(*it2, *it1)); it1 = it2++); - if (sw) - { - size_t nelem2 = nelem >> 1; - Iter_t it1 = first, it2 = last - 1; - for (size_t i = 0; i < nelem2; ++i) - std::swap(*(it1++), *(it2--)); - return; - }; - - if (ptr == nullptr) - { - ptr = std::get_temporary_buffer<value_t>(nptr).first; - if (ptr == nullptr) throw std::bad_alloc(); - owner = true; - }; - range_buf range_aux(ptr, (ptr + nptr)); - - //--------------------------------------------------------------------- - // Process - //--------------------------------------------------------------------- - uint32_t nlevel = nbits64(((nelem + Sort_min - 1) / Sort_min) - 1) - 1; - assert(nlevel != 0); - - if ((nlevel & 1) == 1) - { - //---------------------------------------------------------------- - // if the number of levels is odd, the data are in the first - // parameter of range_sort, and the results appear in the second - // parameter - //---------------------------------------------------------------- - range_it range_1(first, first + nelem_2), range_2(first + nelem_2, - last); - range_aux = move_construct(range_aux, range_2); - construct = true; - - range_sort(range_aux, range_2, comp, nlevel); - range_buf rng_bx(range_aux.first, range_aux.first + nelem_2); - - range_sort(range_1, rng_bx, comp, nlevel); - merge_half(range_input, rng_bx, range_2, comp); - } - else - { - //---------------------------------------------------------------- - // If the number of levels is even, the data are in the second - // parameter of range_sort, and the results are in the same - // parameter - //---------------------------------------------------------------- - range_it range_1(first, first + nelem_1), range_2(first + nelem_1, - last); - range_aux = move_construct(range_aux, range_1); - construct = true; - - range_sort(range_1, range_aux, comp, nlevel); - - range_1.last = range_1.first + range_2.size(); - range_sort(range_1, range_2, comp, nlevel); - merge_half(range_input, range_aux, range_2, comp); - }; -}; - -//**************************************************************************** -};// End namepspace spin_detail -//**************************************************************************** -// -namespace bsc = boost::sort::common; -//----------------------------------------------------------------------------- -// function : spinsort -/// @brief this function implement a single thread stable sort -/// -/// @param first : iterator to the first element of the range to sort -/// @param last : iterator after the last element to the range to sort -/// @param comp : object for to compare two elements pointed by Iter_t -/// iterators -//----------------------------------------------------------------------------- -template <class Iter_t, class Compare = compare_iter<Iter_t>> -inline void spinsort (Iter_t first, Iter_t last, Compare comp = Compare()) -{ - spin_detail::spinsort <Iter_t, Compare> (first, last, comp); -}; - -template <class Iter_t, class Compare = compare_iter<Iter_t>> -inline void indirect_spinsort (Iter_t first, Iter_t last, - Compare comp = Compare()) -{ - typedef typename std::vector<Iter_t>::iterator itx_iter; - typedef common::less_ptr_no_null <Iter_t, Compare> itx_comp; - common::indirect_sort (spinsort<itx_iter, itx_comp>, first, last, comp); -}; - -//**************************************************************************** -};// End namespace sort -};// End namepspace boost -//**************************************************************************** -// -#endif diff --git a/contrib/restricted/boost/boost/sort/spreadsort/detail/constants.hpp b/contrib/restricted/boost/boost/sort/spreadsort/detail/constants.hpp deleted file mode 100644 index 9eebc43c697..00000000000 --- a/contrib/restricted/boost/boost/sort/spreadsort/detail/constants.hpp +++ /dev/null @@ -1,46 +0,0 @@ -//constant definitions for the Boost Sort library - -// Copyright Steven J. Ross 2001 - 2014 -// Distributed under the 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://www.boost.org/libs/sort for library home page. -#ifndef BOOST_SORT_SPREADSORT_DETAIL_CONSTANTS -#define BOOST_SORT_SPREADSORT_DETAIL_CONSTANTS -namespace boost { -namespace sort { -namespace spreadsort { -namespace detail { -//Tuning constants -//This should be tuned to your processor cache; -//if you go too large you get cache misses on bins -//The smaller this number, the less worst-case memory usage. -//If too small, too many recursions slow down spreadsort -enum { max_splits = 11, -//It's better to have a few cache misses and finish sorting -//than to run another iteration -max_finishing_splits = max_splits + 1, -//Sets the minimum number of items per bin. -int_log_mean_bin_size = 2, -//Used to force a comparison-based sorting for small bins, if it's faster. -//Minimum value 1 -int_log_min_split_count = 9, -//This is the minimum split count to use spreadsort when it will finish in one -//iteration. Make this larger the faster std::sort is relative to integer_sort. -int_log_finishing_count = 31, -//Sets the minimum number of items per bin for floating point. -float_log_mean_bin_size = 2, -//Used to force a comparison-based sorting for small bins, if it's faster. -//Minimum value 1 -float_log_min_split_count = 8, -//This is the minimum split count to use spreadsort when it will finish in one -//iteration. Make this larger the faster std::sort is relative to float_sort. -float_log_finishing_count = 4, -//There is a minimum size below which it is not worth using spreadsort -min_sort_size = 1000 }; -} -} -} -} -#endif diff --git a/contrib/restricted/boost/boost/sort/spreadsort/detail/float_sort.hpp b/contrib/restricted/boost/boost/sort/spreadsort/detail/float_sort.hpp deleted file mode 100644 index 93aaa2f69e5..00000000000 --- a/contrib/restricted/boost/boost/sort/spreadsort/detail/float_sort.hpp +++ /dev/null @@ -1,831 +0,0 @@ -// Details for templated Spreadsort-based float_sort. - -// Copyright Steven J. Ross 2001 - 2014. -// Distributed under the 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://www.boost.org/libs/sort for library home page. - -/* -Some improvements suggested by: -Phil Endecott and Frank Gennari -float_mem_cast fix provided by: -Scott McMurray -*/ - -#ifndef BOOST_SORT_SPREADSORT_DETAIL_FLOAT_SORT_HPP -#define BOOST_SORT_SPREADSORT_DETAIL_FLOAT_SORT_HPP -#include <algorithm> -#include <vector> -#include <limits> -#include <functional> -#include <boost/static_assert.hpp> -#include <boost/serialization/static_warning.hpp> -#include <boost/utility/enable_if.hpp> -#include <boost/sort/spreadsort/detail/constants.hpp> -#include <boost/sort/spreadsort/detail/integer_sort.hpp> -#include <boost/sort/spreadsort/detail/spreadsort_common.hpp> -#include <boost/cstdint.hpp> - -namespace boost { -namespace sort { -namespace spreadsort { - namespace detail { - //Casts a RandomAccessIter to the specified integer type - template<class Cast_type, class RandomAccessIter> - inline Cast_type - cast_float_iter(const RandomAccessIter & floatiter) - { - typedef typename std::iterator_traits<RandomAccessIter>::value_type - Data_type; - //Only cast IEEE floating-point numbers, and only to same-sized integers - BOOST_STATIC_ASSERT(sizeof(Cast_type) == sizeof(Data_type)); - BOOST_STATIC_ASSERT(std::numeric_limits<Data_type>::is_iec559); - BOOST_STATIC_ASSERT(std::numeric_limits<Cast_type>::is_integer); - Cast_type result; - std::memcpy(&result, &(*floatiter), sizeof(Data_type)); - return result; - } - - // Return true if the list is sorted. Otherwise, find the minimum and - // maximum. Values are Right_shifted 0 bits before comparison. - template <class RandomAccessIter, class Div_type, class Right_shift> - inline bool - is_sorted_or_find_extremes(RandomAccessIter current, RandomAccessIter last, - Div_type & max, Div_type & min, Right_shift rshift) - { - min = max = rshift(*current, 0); - RandomAccessIter prev = current; - bool sorted = true; - while (++current < last) { - Div_type value = rshift(*current, 0); - sorted &= *current >= *prev; - prev = current; - if (max < value) - max = value; - else if (value < min) - min = value; - } - return sorted; - } - - // Return true if the list is sorted. Otherwise, find the minimum and - // maximum. Uses comp to check if the data is already sorted. - template <class RandomAccessIter, class Div_type, class Right_shift, - class Compare> - inline bool - is_sorted_or_find_extremes(RandomAccessIter current, RandomAccessIter last, - Div_type & max, Div_type & min, - Right_shift rshift, Compare comp) - { - min = max = rshift(*current, 0); - RandomAccessIter prev = current; - bool sorted = true; - while (++current < last) { - Div_type value = rshift(*current, 0); - sorted &= !comp(*current, *prev); - prev = current; - if (max < value) - max = value; - else if (value < min) - min = value; - } - return sorted; - } - - //Specialized swap loops for floating-point casting - template <class RandomAccessIter, class Div_type> - inline void inner_float_swap_loop(RandomAccessIter * bins, - const RandomAccessIter & nextbinstart, unsigned ii - , const unsigned log_divisor, const Div_type div_min) - { - RandomAccessIter * local_bin = bins + ii; - for (RandomAccessIter current = *local_bin; current < nextbinstart; - ++current) { - for (RandomAccessIter * target_bin = - (bins + ((cast_float_iter<Div_type, RandomAccessIter>(current) >> - log_divisor) - div_min)); target_bin != local_bin; - target_bin = bins + ((cast_float_iter<Div_type, RandomAccessIter> - (current) >> log_divisor) - div_min)) { - typename std::iterator_traits<RandomAccessIter>::value_type tmp; - RandomAccessIter b = (*target_bin)++; - RandomAccessIter * b_bin = bins + ((cast_float_iter<Div_type, - RandomAccessIter>(b) >> log_divisor) - div_min); - //Three-way swap; if the item to be swapped doesn't belong in the - //current bin, swap it to where it belongs - if (b_bin != local_bin) { - RandomAccessIter c = (*b_bin)++; - tmp = *c; - *c = *b; - } - else - tmp = *b; - *b = *current; - *current = tmp; - } - } - *local_bin = nextbinstart; - } - - template <class RandomAccessIter, class Div_type> - inline void float_swap_loop(RandomAccessIter * bins, - RandomAccessIter & nextbinstart, unsigned ii, - const size_t *bin_sizes, - const unsigned log_divisor, const Div_type div_min) - { - nextbinstart += bin_sizes[ii]; - inner_float_swap_loop<RandomAccessIter, Div_type> - (bins, nextbinstart, ii, log_divisor, div_min); - } - - // Return true if the list is sorted. Otherwise, find the minimum and - // maximum. Values are cast to Cast_type before comparison. - template <class RandomAccessIter, class Cast_type> - inline bool - is_sorted_or_find_extremes(RandomAccessIter current, RandomAccessIter last, - Cast_type & max, Cast_type & min) - { - min = max = cast_float_iter<Cast_type, RandomAccessIter>(current); - RandomAccessIter prev = current; - bool sorted = true; - while (++current < last) { - Cast_type value = cast_float_iter<Cast_type, RandomAccessIter>(current); - sorted &= *current >= *prev; - prev = current; - if (max < value) - max = value; - else if (value < min) - min = value; - } - return sorted; - } - - //Special-case sorting of positive floats with casting - template <class RandomAccessIter, class Div_type, class Size_type> - inline void - positive_float_sort_rec(RandomAccessIter first, RandomAccessIter last, - std::vector<RandomAccessIter> &bin_cache, unsigned cache_offset - , size_t *bin_sizes) - { - Div_type max, min; - if (is_sorted_or_find_extremes<RandomAccessIter, Div_type>(first, last, - max, min)) - return; - unsigned log_divisor = get_log_divisor<float_log_mean_bin_size>( - last - first, rough_log_2_size(Size_type(max - min))); - Div_type div_min = min >> log_divisor; - Div_type div_max = max >> log_divisor; - unsigned bin_count = unsigned(div_max - div_min) + 1; - unsigned cache_end; - RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset, - cache_end, bin_count); - - //Calculating the size of each bin - for (RandomAccessIter current = first; current != last;) - bin_sizes[unsigned((cast_float_iter<Div_type, RandomAccessIter>( - current++) >> log_divisor) - div_min)]++; - bins[0] = first; - for (unsigned u = 0; u < bin_count - 1; u++) - bins[u + 1] = bins[u] + bin_sizes[u]; - - - //Swap into place - RandomAccessIter nextbinstart = first; - for (unsigned u = 0; u < bin_count - 1; ++u) - float_swap_loop<RandomAccessIter, Div_type> - (bins, nextbinstart, u, bin_sizes, log_divisor, div_min); - bins[bin_count - 1] = last; - - //Return if we've completed bucketsorting - if (!log_divisor) - return; - - //Recursing - size_t max_count = get_min_count<float_log_mean_bin_size, - float_log_min_split_count, - float_log_finishing_count>(log_divisor); - RandomAccessIter lastPos = first; - for (unsigned u = cache_offset; u < cache_end; lastPos = bin_cache[u], - ++u) { - size_t count = bin_cache[u] - lastPos; - if (count < 2) - continue; - if (count < max_count) - std::sort(lastPos, bin_cache[u]); - else - positive_float_sort_rec<RandomAccessIter, Div_type, Size_type> - (lastPos, bin_cache[u], bin_cache, cache_end, bin_sizes); - } - } - - //Sorting negative floats - //Bins are iterated in reverse because max_neg_float = min_neg_int - template <class RandomAccessIter, class Div_type, class Size_type> - inline void - negative_float_sort_rec(RandomAccessIter first, RandomAccessIter last, - std::vector<RandomAccessIter> &bin_cache, - unsigned cache_offset, size_t *bin_sizes) - { - Div_type max, min; - if (is_sorted_or_find_extremes<RandomAccessIter, Div_type>(first, last, - max, min)) - return; - - unsigned log_divisor = get_log_divisor<float_log_mean_bin_size>( - last - first, rough_log_2_size(Size_type(max - min))); - Div_type div_min = min >> log_divisor; - Div_type div_max = max >> log_divisor; - unsigned bin_count = unsigned(div_max - div_min) + 1; - unsigned cache_end; - RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset, - cache_end, bin_count); - - //Calculating the size of each bin - for (RandomAccessIter current = first; current != last;) - bin_sizes[unsigned((cast_float_iter<Div_type, RandomAccessIter>( - current++) >> log_divisor) - div_min)]++; - bins[bin_count - 1] = first; - for (int ii = bin_count - 2; ii >= 0; --ii) - bins[ii] = bins[ii + 1] + bin_sizes[ii + 1]; - - //Swap into place - RandomAccessIter nextbinstart = first; - //The last bin will always have the correct elements in it - for (int ii = bin_count - 1; ii > 0; --ii) - float_swap_loop<RandomAccessIter, Div_type> - (bins, nextbinstart, ii, bin_sizes, log_divisor, div_min); - //Update the end position because we don't process the last bin - bin_cache[cache_offset] = last; - - //Return if we've completed bucketsorting - if (!log_divisor) - return; - - //Recursing - size_t max_count = get_min_count<float_log_mean_bin_size, - float_log_min_split_count, - float_log_finishing_count>(log_divisor); - RandomAccessIter lastPos = first; - for (int ii = cache_end - 1; ii >= static_cast<int>(cache_offset); - lastPos = bin_cache[ii], --ii) { - size_t count = bin_cache[ii] - lastPos; - if (count < 2) - continue; - if (count < max_count) - std::sort(lastPos, bin_cache[ii]); - else - negative_float_sort_rec<RandomAccessIter, Div_type, Size_type> - (lastPos, bin_cache[ii], bin_cache, cache_end, bin_sizes); - } - } - - //Sorting negative floats - //Bins are iterated in reverse order because max_neg_float = min_neg_int - template <class RandomAccessIter, class Div_type, class Right_shift, - class Size_type> - inline void - negative_float_sort_rec(RandomAccessIter first, RandomAccessIter last, - std::vector<RandomAccessIter> &bin_cache, unsigned cache_offset - , size_t *bin_sizes, Right_shift rshift) - { - Div_type max, min; - if (is_sorted_or_find_extremes(first, last, max, min, rshift)) - return; - unsigned log_divisor = get_log_divisor<float_log_mean_bin_size>( - last - first, rough_log_2_size(Size_type(max - min))); - Div_type div_min = min >> log_divisor; - Div_type div_max = max >> log_divisor; - unsigned bin_count = unsigned(div_max - div_min) + 1; - unsigned cache_end; - RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset, - cache_end, bin_count); - - //Calculating the size of each bin - for (RandomAccessIter current = first; current != last;) - bin_sizes[unsigned(rshift(*(current++), log_divisor) - div_min)]++; - bins[bin_count - 1] = first; - for (int ii = bin_count - 2; ii >= 0; --ii) - bins[ii] = bins[ii + 1] + bin_sizes[ii + 1]; - - //Swap into place - RandomAccessIter nextbinstart = first; - //The last bin will always have the correct elements in it - for (int ii = bin_count - 1; ii > 0; --ii) - swap_loop<RandomAccessIter, Div_type, Right_shift> - (bins, nextbinstart, ii, rshift, bin_sizes, log_divisor, div_min); - //Update the end position of the unprocessed last bin - bin_cache[cache_offset] = last; - - //Return if we've completed bucketsorting - if (!log_divisor) - return; - - //Recursing - size_t max_count = get_min_count<float_log_mean_bin_size, - float_log_min_split_count, - float_log_finishing_count>(log_divisor); - RandomAccessIter lastPos = first; - for (int ii = cache_end - 1; ii >= static_cast<int>(cache_offset); - lastPos = bin_cache[ii], --ii) { - size_t count = bin_cache[ii] - lastPos; - if (count < 2) - continue; - if (count < max_count) - std::sort(lastPos, bin_cache[ii]); - else - negative_float_sort_rec<RandomAccessIter, Div_type, Right_shift, - Size_type> - (lastPos, bin_cache[ii], bin_cache, cache_end, bin_sizes, rshift); - } - } - - template <class RandomAccessIter, class Div_type, class Right_shift, - class Compare, class Size_type> - inline void - negative_float_sort_rec(RandomAccessIter first, RandomAccessIter last, - std::vector<RandomAccessIter> &bin_cache, unsigned cache_offset, - size_t *bin_sizes, Right_shift rshift, Compare comp) - { - Div_type max, min; - if (is_sorted_or_find_extremes(first, last, max, min, rshift, comp)) - return; - unsigned log_divisor = get_log_divisor<float_log_mean_bin_size>( - last - first, rough_log_2_size(Size_type(max - min))); - Div_type div_min = min >> log_divisor; - Div_type div_max = max >> log_divisor; - unsigned bin_count = unsigned(div_max - div_min) + 1; - unsigned cache_end; - RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset, - cache_end, bin_count); - - //Calculating the size of each bin - for (RandomAccessIter current = first; current != last;) - bin_sizes[unsigned(rshift(*(current++), log_divisor) - div_min)]++; - bins[bin_count - 1] = first; - for (int ii = bin_count - 2; ii >= 0; --ii) - bins[ii] = bins[ii + 1] + bin_sizes[ii + 1]; - - //Swap into place - RandomAccessIter nextbinstart = first; - //The last bin will always have the correct elements in it - for (int ii = bin_count - 1; ii > 0; --ii) - swap_loop<RandomAccessIter, Div_type, Right_shift> - (bins, nextbinstart, ii, rshift, bin_sizes, log_divisor, div_min); - //Update the end position of the unprocessed last bin - bin_cache[cache_offset] = last; - - //Return if we've completed bucketsorting - if (!log_divisor) - return; - - //Recursing - size_t max_count = get_min_count<float_log_mean_bin_size, - float_log_min_split_count, - float_log_finishing_count>(log_divisor); - RandomAccessIter lastPos = first; - for (int ii = cache_end - 1; ii >= static_cast<int>(cache_offset); - lastPos = bin_cache[ii], --ii) { - size_t count = bin_cache[ii] - lastPos; - if (count < 2) - continue; - if (count < max_count) - std::sort(lastPos, bin_cache[ii], comp); - else - negative_float_sort_rec<RandomAccessIter, Div_type, Right_shift, - Compare, Size_type>(lastPos, bin_cache[ii], - bin_cache, cache_end, - bin_sizes, rshift, comp); - } - } - - //Casting special-case for floating-point sorting - template <class RandomAccessIter, class Div_type, class Size_type> - inline void - float_sort_rec(RandomAccessIter first, RandomAccessIter last, - std::vector<RandomAccessIter> &bin_cache, unsigned cache_offset - , size_t *bin_sizes) - { - Div_type max, min; - if (is_sorted_or_find_extremes<RandomAccessIter, Div_type>(first, last, - max, min)) - return; - unsigned log_divisor = get_log_divisor<float_log_mean_bin_size>( - last - first, rough_log_2_size(Size_type(max - min))); - Div_type div_min = min >> log_divisor; - Div_type div_max = max >> log_divisor; - unsigned bin_count = unsigned(div_max - div_min) + 1; - unsigned cache_end; - RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset, - cache_end, bin_count); - - //Calculating the size of each bin - for (RandomAccessIter current = first; current != last;) - bin_sizes[unsigned((cast_float_iter<Div_type, RandomAccessIter>( - current++) >> log_divisor) - div_min)]++; - //The index of the first positive bin - //Must be divided small enough to fit into an integer - unsigned first_positive = (div_min < 0) ? unsigned(-div_min) : 0; - //Resetting if all bins are negative - if (cache_offset + first_positive > cache_end) - first_positive = cache_end - cache_offset; - //Reversing the order of the negative bins - //Note that because of the negative/positive ordering direction flip - //We can not depend upon bin order and positions matching up - //so bin_sizes must be reused to contain the end of the bin - if (first_positive > 0) { - bins[first_positive - 1] = first; - for (int ii = first_positive - 2; ii >= 0; --ii) { - bins[ii] = first + bin_sizes[ii + 1]; - bin_sizes[ii] += bin_sizes[ii + 1]; - } - //Handling positives following negatives - if (first_positive < bin_count) { - bins[first_positive] = first + bin_sizes[0]; - bin_sizes[first_positive] += bin_sizes[0]; - } - } - else - bins[0] = first; - for (unsigned u = first_positive; u < bin_count - 1; u++) { - bins[u + 1] = first + bin_sizes[u]; - bin_sizes[u + 1] += bin_sizes[u]; - } - - //Swap into place - RandomAccessIter nextbinstart = first; - for (unsigned u = 0; u < bin_count; ++u) { - nextbinstart = first + bin_sizes[u]; - inner_float_swap_loop<RandomAccessIter, Div_type> - (bins, nextbinstart, u, log_divisor, div_min); - } - - if (!log_divisor) - return; - - //Handling negative values first - size_t max_count = get_min_count<float_log_mean_bin_size, - float_log_min_split_count, - float_log_finishing_count>(log_divisor); - RandomAccessIter lastPos = first; - for (int ii = cache_offset + first_positive - 1; - ii >= static_cast<int>(cache_offset); - lastPos = bin_cache[ii--]) { - size_t count = bin_cache[ii] - lastPos; - if (count < 2) - continue; - if (count < max_count) - std::sort(lastPos, bin_cache[ii]); - //sort negative values using reversed-bin spreadsort - else - negative_float_sort_rec<RandomAccessIter, Div_type, Size_type> - (lastPos, bin_cache[ii], bin_cache, cache_end, bin_sizes); - } - - for (unsigned u = cache_offset + first_positive; u < cache_end; - lastPos = bin_cache[u], ++u) { - size_t count = bin_cache[u] - lastPos; - if (count < 2) - continue; - if (count < max_count) - std::sort(lastPos, bin_cache[u]); - //sort positive values using normal spreadsort - else - positive_float_sort_rec<RandomAccessIter, Div_type, Size_type> - (lastPos, bin_cache[u], bin_cache, cache_end, bin_sizes); - } - } - - //Functor implementation for recursive sorting - template <class RandomAccessIter, class Div_type, class Right_shift - , class Size_type> - inline void - float_sort_rec(RandomAccessIter first, RandomAccessIter last, - std::vector<RandomAccessIter> &bin_cache, unsigned cache_offset - , size_t *bin_sizes, Right_shift rshift) - { - Div_type max, min; - if (is_sorted_or_find_extremes(first, last, max, min, rshift)) - return; - unsigned log_divisor = get_log_divisor<float_log_mean_bin_size>( - last - first, rough_log_2_size(Size_type(max - min))); - Div_type div_min = min >> log_divisor; - Div_type div_max = max >> log_divisor; - unsigned bin_count = unsigned(div_max - div_min) + 1; - unsigned cache_end; - RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset, - cache_end, bin_count); - - //Calculating the size of each bin - for (RandomAccessIter current = first; current != last;) - bin_sizes[unsigned(rshift(*(current++), log_divisor) - div_min)]++; - //The index of the first positive bin - unsigned first_positive = (div_min < 0) ? unsigned(-div_min) : 0; - //Resetting if all bins are negative - if (cache_offset + first_positive > cache_end) - first_positive = cache_end - cache_offset; - //Reversing the order of the negative bins - //Note that because of the negative/positive ordering direction flip - //We can not depend upon bin order and positions matching up - //so bin_sizes must be reused to contain the end of the bin - if (first_positive > 0) { - bins[first_positive - 1] = first; - for (int ii = first_positive - 2; ii >= 0; --ii) { - bins[ii] = first + bin_sizes[ii + 1]; - bin_sizes[ii] += bin_sizes[ii + 1]; - } - //Handling positives following negatives - if (static_cast<unsigned>(first_positive) < bin_count) { - bins[first_positive] = first + bin_sizes[0]; - bin_sizes[first_positive] += bin_sizes[0]; - } - } - else - bins[0] = first; - for (unsigned u = first_positive; u < bin_count - 1; u++) { - bins[u + 1] = first + bin_sizes[u]; - bin_sizes[u + 1] += bin_sizes[u]; - } - - //Swap into place - RandomAccessIter next_bin_start = first; - for (unsigned u = 0; u < bin_count; ++u) { - next_bin_start = first + bin_sizes[u]; - inner_swap_loop<RandomAccessIter, Div_type, Right_shift> - (bins, next_bin_start, u, rshift, log_divisor, div_min); - } - - //Return if we've completed bucketsorting - if (!log_divisor) - return; - - //Handling negative values first - size_t max_count = get_min_count<float_log_mean_bin_size, - float_log_min_split_count, - float_log_finishing_count>(log_divisor); - RandomAccessIter lastPos = first; - for (int ii = cache_offset + first_positive - 1; - ii >= static_cast<int>(cache_offset); - lastPos = bin_cache[ii--]) { - size_t count = bin_cache[ii] - lastPos; - if (count < 2) - continue; - if (count < max_count) - std::sort(lastPos, bin_cache[ii]); - //sort negative values using reversed-bin spreadsort - else - negative_float_sort_rec<RandomAccessIter, Div_type, - Right_shift, Size_type>(lastPos, bin_cache[ii], bin_cache, - cache_end, bin_sizes, rshift); - } - - for (unsigned u = cache_offset + first_positive; u < cache_end; - lastPos = bin_cache[u], ++u) { - size_t count = bin_cache[u] - lastPos; - if (count < 2) - continue; - if (count < max_count) - std::sort(lastPos, bin_cache[u]); - //sort positive values using normal spreadsort - else - spreadsort_rec<RandomAccessIter, Div_type, Right_shift, Size_type, - float_log_mean_bin_size, float_log_min_split_count, - float_log_finishing_count> - (lastPos, bin_cache[u], bin_cache, cache_end, bin_sizes, rshift); - } - } - - template <class RandomAccessIter, class Div_type, class Right_shift, - class Compare, class Size_type> - inline void - float_sort_rec(RandomAccessIter first, RandomAccessIter last, - std::vector<RandomAccessIter> &bin_cache, unsigned cache_offset, - size_t *bin_sizes, Right_shift rshift, Compare comp) - { - Div_type max, min; - if (is_sorted_or_find_extremes(first, last, max, min, rshift, comp)) - return; - unsigned log_divisor = get_log_divisor<float_log_mean_bin_size>( - last - first, rough_log_2_size(Size_type(max - min))); - Div_type div_min = min >> log_divisor; - Div_type div_max = max >> log_divisor; - unsigned bin_count = unsigned(div_max - div_min) + 1; - unsigned cache_end; - RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset, - cache_end, bin_count); - - //Calculating the size of each bin - for (RandomAccessIter current = first; current != last;) - bin_sizes[unsigned(rshift(*(current++), log_divisor) - div_min)]++; - //The index of the first positive bin - unsigned first_positive = - (div_min < 0) ? static_cast<unsigned>(-div_min) : 0; - //Resetting if all bins are negative - if (cache_offset + first_positive > cache_end) - first_positive = cache_end - cache_offset; - //Reversing the order of the negative bins - //Note that because of the negative/positive ordering direction flip - //We can not depend upon bin order and positions matching up - //so bin_sizes must be reused to contain the end of the bin - if (first_positive > 0) { - bins[first_positive - 1] = first; - for (int ii = first_positive - 2; ii >= 0; --ii) { - bins[ii] = first + bin_sizes[ii + 1]; - bin_sizes[ii] += bin_sizes[ii + 1]; - } - //Handling positives following negatives - if (static_cast<unsigned>(first_positive) < bin_count) { - bins[first_positive] = first + bin_sizes[0]; - bin_sizes[first_positive] += bin_sizes[0]; - } - } - else - bins[0] = first; - for (unsigned u = first_positive; u < bin_count - 1; u++) { - bins[u + 1] = first + bin_sizes[u]; - bin_sizes[u + 1] += bin_sizes[u]; - } - - //Swap into place - RandomAccessIter next_bin_start = first; - for (unsigned u = 0; u < bin_count; ++u) { - next_bin_start = first + bin_sizes[u]; - inner_swap_loop<RandomAccessIter, Div_type, Right_shift> - (bins, next_bin_start, u, rshift, log_divisor, div_min); - } - - //Return if we've completed bucketsorting - if (!log_divisor) - return; - - //Handling negative values first - size_t max_count = get_min_count<float_log_mean_bin_size, - float_log_min_split_count, - float_log_finishing_count>(log_divisor); - RandomAccessIter lastPos = first; - for (int ii = cache_offset + first_positive - 1; - ii >= static_cast<int>(cache_offset); - lastPos = bin_cache[ii--]) { - size_t count = bin_cache[ii] - lastPos; - if (count < 2) - continue; - if (count < max_count) - std::sort(lastPos, bin_cache[ii], comp); - //sort negative values using reversed-bin spreadsort - else - negative_float_sort_rec<RandomAccessIter, Div_type, Right_shift, - Compare, Size_type>(lastPos, bin_cache[ii], - bin_cache, cache_end, - bin_sizes, rshift, comp); - } - - for (unsigned u = cache_offset + first_positive; u < cache_end; - lastPos = bin_cache[u], ++u) { - size_t count = bin_cache[u] - lastPos; - if (count < 2) - continue; - if (count < max_count) - std::sort(lastPos, bin_cache[u], comp); - //sort positive values using normal spreadsort - else - spreadsort_rec<RandomAccessIter, Div_type, Right_shift, Compare, - Size_type, float_log_mean_bin_size, - float_log_min_split_count, float_log_finishing_count> - (lastPos, bin_cache[u], bin_cache, cache_end, bin_sizes, rshift, comp); - } - } - - //Checking whether the value type is a float, and trying a 32-bit integer - template <class RandomAccessIter> - inline typename boost::enable_if_c< sizeof(boost::uint32_t) == - sizeof(typename std::iterator_traits<RandomAccessIter>::value_type) - && std::numeric_limits<typename - std::iterator_traits<RandomAccessIter>::value_type>::is_iec559, - void >::type - float_sort(RandomAccessIter first, RandomAccessIter last) - { - size_t bin_sizes[1 << max_finishing_splits]; - std::vector<RandomAccessIter> bin_cache; - float_sort_rec<RandomAccessIter, boost::int32_t, boost::uint32_t> - (first, last, bin_cache, 0, bin_sizes); - } - - //Checking whether the value type is a double, and using a 64-bit integer - template <class RandomAccessIter> - inline typename boost::enable_if_c< sizeof(boost::uint64_t) == - sizeof(typename std::iterator_traits<RandomAccessIter>::value_type) - && std::numeric_limits<typename - std::iterator_traits<RandomAccessIter>::value_type>::is_iec559, - void >::type - float_sort(RandomAccessIter first, RandomAccessIter last) - { - size_t bin_sizes[1 << max_finishing_splits]; - std::vector<RandomAccessIter> bin_cache; - float_sort_rec<RandomAccessIter, boost::int64_t, boost::uint64_t> - (first, last, bin_cache, 0, bin_sizes); - } - - template <class RandomAccessIter> - inline typename boost::disable_if_c< (sizeof(boost::uint64_t) == - sizeof(typename std::iterator_traits<RandomAccessIter>::value_type) - || sizeof(boost::uint32_t) == - sizeof(typename std::iterator_traits<RandomAccessIter>::value_type)) - && std::numeric_limits<typename - std::iterator_traits<RandomAccessIter>::value_type>::is_iec559, - void >::type - float_sort(RandomAccessIter first, RandomAccessIter last) - { - BOOST_STATIC_WARNING(!(sizeof(boost::uint64_t) == - sizeof(typename std::iterator_traits<RandomAccessIter>::value_type) - || sizeof(boost::uint32_t) == - sizeof(typename std::iterator_traits<RandomAccessIter>::value_type)) - || !std::numeric_limits<typename - std::iterator_traits<RandomAccessIter>::value_type>::is_iec559); - std::sort(first, last); - } - - //These approaches require the user to do the typecast - //with rshift but default comparision - template <class RandomAccessIter, class Div_type, class Right_shift> - inline typename boost::enable_if_c< sizeof(size_t) >= sizeof(Div_type), - void >::type - float_sort(RandomAccessIter first, RandomAccessIter last, Div_type, - Right_shift rshift) - { - size_t bin_sizes[1 << max_finishing_splits]; - std::vector<RandomAccessIter> bin_cache; - float_sort_rec<RandomAccessIter, Div_type, Right_shift, size_t> - (first, last, bin_cache, 0, bin_sizes, rshift); - } - - //maximum integer size with rshift but default comparision - template <class RandomAccessIter, class Div_type, class Right_shift> - inline typename boost::enable_if_c< sizeof(size_t) < sizeof(Div_type) - && sizeof(boost::uintmax_t) >= sizeof(Div_type), void >::type - float_sort(RandomAccessIter first, RandomAccessIter last, Div_type, - Right_shift rshift) - { - size_t bin_sizes[1 << max_finishing_splits]; - std::vector<RandomAccessIter> bin_cache; - float_sort_rec<RandomAccessIter, Div_type, Right_shift, boost::uintmax_t> - (first, last, bin_cache, 0, bin_sizes, rshift); - } - - //sizeof(Div_type) doesn't match, so use std::sort - template <class RandomAccessIter, class Div_type, class Right_shift> - inline typename boost::disable_if_c< sizeof(boost::uintmax_t) >= - sizeof(Div_type), void >::type - float_sort(RandomAccessIter first, RandomAccessIter last, Div_type, - Right_shift rshift) - { - BOOST_STATIC_WARNING(sizeof(boost::uintmax_t) >= sizeof(Div_type)); - std::sort(first, last); - } - - //specialized comparison - template <class RandomAccessIter, class Div_type, class Right_shift, - class Compare> - inline typename boost::enable_if_c< sizeof(size_t) >= sizeof(Div_type), - void >::type - float_sort(RandomAccessIter first, RandomAccessIter last, Div_type, - Right_shift rshift, Compare comp) - { - size_t bin_sizes[1 << max_finishing_splits]; - std::vector<RandomAccessIter> bin_cache; - float_sort_rec<RandomAccessIter, Div_type, Right_shift, Compare, - size_t> - (first, last, bin_cache, 0, bin_sizes, rshift, comp); - } - - //max-sized integer with specialized comparison - template <class RandomAccessIter, class Div_type, class Right_shift, - class Compare> - inline typename boost::enable_if_c< sizeof(size_t) < sizeof(Div_type) - && sizeof(boost::uintmax_t) >= sizeof(Div_type), void >::type - float_sort(RandomAccessIter first, RandomAccessIter last, Div_type, - Right_shift rshift, Compare comp) - { - size_t bin_sizes[1 << max_finishing_splits]; - std::vector<RandomAccessIter> bin_cache; - float_sort_rec<RandomAccessIter, Div_type, Right_shift, Compare, - boost::uintmax_t> - (first, last, bin_cache, 0, bin_sizes, rshift, comp); - } - - //sizeof(Div_type) doesn't match, so use std::sort - template <class RandomAccessIter, class Div_type, class Right_shift, - class Compare> - inline typename boost::disable_if_c< sizeof(boost::uintmax_t) >= - sizeof(Div_type), void >::type - float_sort(RandomAccessIter first, RandomAccessIter last, Div_type, - Right_shift rshift, Compare comp) - { - BOOST_STATIC_WARNING(sizeof(boost::uintmax_t) >= sizeof(Div_type)); - std::sort(first, last, comp); - } - } -} -} -} - -#endif diff --git a/contrib/restricted/boost/boost/sort/spreadsort/detail/integer_sort.hpp b/contrib/restricted/boost/boost/sort/spreadsort/detail/integer_sort.hpp deleted file mode 100644 index 6d6886cfd96..00000000000 --- a/contrib/restricted/boost/boost/sort/spreadsort/detail/integer_sort.hpp +++ /dev/null @@ -1,494 +0,0 @@ -// Details for templated Spreadsort-based integer_sort. - -// Copyright Steven J. Ross 2001 - 2014. -// Distributed under the 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://www.boost.org/libs/sort for library home page. - -/* -Some improvements suggested by: -Phil Endecott and Frank Gennari -*/ - -#ifndef BOOST_SORT_SPREADSORT_DETAIL_INTEGER_SORT_HPP -#define BOOST_SORT_SPREADSORT_DETAIL_INTEGER_SORT_HPP -#include <algorithm> -#include <vector> -#include <limits> -#include <functional> -#include <boost/static_assert.hpp> -#include <boost/serialization/static_warning.hpp> -#include <boost/utility/enable_if.hpp> -#include <boost/sort/spreadsort/detail/constants.hpp> -#include <boost/sort/spreadsort/detail/spreadsort_common.hpp> -#include <boost/cstdint.hpp> - -namespace boost { -namespace sort { -namespace spreadsort { - namespace detail { - // Return true if the list is sorted. Otherwise, find the minimum and - // maximum using <. - template <class RandomAccessIter> - inline bool - is_sorted_or_find_extremes(RandomAccessIter current, RandomAccessIter last, - RandomAccessIter & max, RandomAccessIter & min) - { - min = max = current; - //This assumes we have more than 1 element based on prior checks. - while (!(*(current + 1) < *current)) { - //If everything is in sorted order, return - if (++current == last - 1) - return true; - } - - //The maximum is the last sorted element - max = current; - //Start from the first unsorted element - while (++current < last) { - if (*max < *current) - max = current; - else if (*current < *min) - min = current; - } - return false; - } - - // Return true if the list is sorted. Otherwise, find the minimum and - // maximum. - // Use a user-defined comparison operator - template <class RandomAccessIter, class Compare> - inline bool - is_sorted_or_find_extremes(RandomAccessIter current, RandomAccessIter last, - RandomAccessIter & max, RandomAccessIter & min, Compare comp) - { - min = max = current; - while (!comp(*(current + 1), *current)) { - //If everything is in sorted order, return - if (++current == last - 1) - return true; - } - - //The maximum is the last sorted element - max = current; - while (++current < last) { - if (comp(*max, *current)) - max = current; - else if (comp(*current, *min)) - min = current; - } - return false; - } - - //Gets a non-negative right bit shift to operate as a logarithmic divisor - template<unsigned log_mean_bin_size> - inline int - get_log_divisor(size_t count, int log_range) - { - int log_divisor; - //If we can finish in one iteration without exceeding either - //(2 to the max_finishing_splits) or n bins, do so - if ((log_divisor = log_range - rough_log_2_size(count)) <= 0 && - log_range <= max_finishing_splits) - log_divisor = 0; - else { - //otherwise divide the data into an optimized number of pieces - log_divisor += log_mean_bin_size; - //Cannot exceed max_splits or cache misses slow down bin lookups - if ((log_range - log_divisor) > max_splits) - log_divisor = log_range - max_splits; - } - return log_divisor; - } - - //Implementation for recursive integer sorting - template <class RandomAccessIter, class Div_type, class Size_type> - inline void - spreadsort_rec(RandomAccessIter first, RandomAccessIter last, - std::vector<RandomAccessIter> &bin_cache, unsigned cache_offset - , size_t *bin_sizes) - { - //This step is roughly 10% of runtime, but it helps avoid worst-case - //behavior and improve behavior with real data - //If you know the maximum and minimum ahead of time, you can pass those - //values in and skip this step for the first iteration - RandomAccessIter max, min; - if (is_sorted_or_find_extremes(first, last, max, min)) - return; - RandomAccessIter * target_bin; - unsigned log_divisor = get_log_divisor<int_log_mean_bin_size>( - last - first, rough_log_2_size(Size_type((*max >> 0) - (*min >> 0)))); - Div_type div_min = *min >> log_divisor; - Div_type div_max = *max >> log_divisor; - unsigned bin_count = unsigned(div_max - div_min) + 1; - unsigned cache_end; - RandomAccessIter * bins = - size_bins(bin_sizes, bin_cache, cache_offset, cache_end, bin_count); - - //Calculating the size of each bin; this takes roughly 10% of runtime - for (RandomAccessIter current = first; current != last;) - bin_sizes[size_t((*(current++) >> log_divisor) - div_min)]++; - //Assign the bin positions - bins[0] = first; - for (unsigned u = 0; u < bin_count - 1; u++) - bins[u + 1] = bins[u] + bin_sizes[u]; - - RandomAccessIter nextbinstart = first; - //Swap into place - //This dominates runtime, mostly in the swap and bin lookups - for (unsigned u = 0; u < bin_count - 1; ++u) { - RandomAccessIter * local_bin = bins + u; - nextbinstart += bin_sizes[u]; - //Iterating over each element in this bin - for (RandomAccessIter current = *local_bin; current < nextbinstart; - ++current) { - //Swapping elements in current into place until the correct - //element has been swapped in - for (target_bin = (bins + ((*current >> log_divisor) - div_min)); - target_bin != local_bin; - target_bin = bins + ((*current >> log_divisor) - div_min)) { - //3-way swap; this is about 1% faster than a 2-way swap - //The main advantage is less copies are involved per item - //put in the correct place - typename std::iterator_traits<RandomAccessIter>::value_type tmp; - RandomAccessIter b = (*target_bin)++; - RandomAccessIter * b_bin = bins + ((*b >> log_divisor) - div_min); - if (b_bin != local_bin) { - RandomAccessIter c = (*b_bin)++; - tmp = *c; - *c = *b; - } - else - tmp = *b; - *b = *current; - *current = tmp; - } - } - *local_bin = nextbinstart; - } - bins[bin_count - 1] = last; - - //If we've bucketsorted, the array is sorted and we should skip recursion - if (!log_divisor) - return; - //log_divisor is the remaining range; calculating the comparison threshold - size_t max_count = - get_min_count<int_log_mean_bin_size, int_log_min_split_count, - int_log_finishing_count>(log_divisor); - - //Recursing - RandomAccessIter lastPos = first; - for (unsigned u = cache_offset; u < cache_end; lastPos = bin_cache[u], - ++u) { - Size_type count = bin_cache[u] - lastPos; - //don't sort unless there are at least two items to Compare - if (count < 2) - continue; - //using std::sort if its worst-case is better - if (count < max_count) - std::sort(lastPos, bin_cache[u]); - else - spreadsort_rec<RandomAccessIter, Div_type, Size_type>(lastPos, - bin_cache[u], - bin_cache, - cache_end, - bin_sizes); - } - } - - //Generic bitshift-based 3-way swapping code - template <class RandomAccessIter, class Div_type, class Right_shift> - inline void inner_swap_loop(RandomAccessIter * bins, - const RandomAccessIter & next_bin_start, unsigned ii, Right_shift &rshift - , const unsigned log_divisor, const Div_type div_min) - { - RandomAccessIter * local_bin = bins + ii; - for (RandomAccessIter current = *local_bin; current < next_bin_start; - ++current) { - for (RandomAccessIter * target_bin = - (bins + (rshift(*current, log_divisor) - div_min)); - target_bin != local_bin; - target_bin = bins + (rshift(*current, log_divisor) - div_min)) { - typename std::iterator_traits<RandomAccessIter>::value_type tmp; - RandomAccessIter b = (*target_bin)++; - RandomAccessIter * b_bin = - bins + (rshift(*b, log_divisor) - div_min); - //Three-way swap; if the item to be swapped doesn't belong - //in the current bin, swap it to where it belongs - if (b_bin != local_bin) { - RandomAccessIter c = (*b_bin)++; - tmp = *c; - *c = *b; - } - //Note: we could increment current once the swap is done in this case - //but that seems to impair performance - else - tmp = *b; - *b = *current; - *current = tmp; - } - } - *local_bin = next_bin_start; - } - - //Standard swapping wrapper for ascending values - template <class RandomAccessIter, class Div_type, class Right_shift> - inline void swap_loop(RandomAccessIter * bins, - RandomAccessIter & next_bin_start, unsigned ii, Right_shift &rshift - , const size_t *bin_sizes - , const unsigned log_divisor, const Div_type div_min) - { - next_bin_start += bin_sizes[ii]; - inner_swap_loop<RandomAccessIter, Div_type, Right_shift>(bins, - next_bin_start, ii, rshift, log_divisor, div_min); - } - - //Functor implementation for recursive sorting - template <class RandomAccessIter, class Div_type, class Right_shift, - class Compare, class Size_type, unsigned log_mean_bin_size, - unsigned log_min_split_count, unsigned log_finishing_count> - inline void - spreadsort_rec(RandomAccessIter first, RandomAccessIter last, - std::vector<RandomAccessIter> &bin_cache, unsigned cache_offset - , size_t *bin_sizes, Right_shift rshift, Compare comp) - { - RandomAccessIter max, min; - if (is_sorted_or_find_extremes(first, last, max, min, comp)) - return; - unsigned log_divisor = get_log_divisor<log_mean_bin_size>(last - first, - rough_log_2_size(Size_type(rshift(*max, 0) - rshift(*min, 0)))); - Div_type div_min = rshift(*min, log_divisor); - Div_type div_max = rshift(*max, log_divisor); - unsigned bin_count = unsigned(div_max - div_min) + 1; - unsigned cache_end; - RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset, - cache_end, bin_count); - - //Calculating the size of each bin - for (RandomAccessIter current = first; current != last;) - bin_sizes[unsigned(rshift(*(current++), log_divisor) - div_min)]++; - bins[0] = first; - for (unsigned u = 0; u < bin_count - 1; u++) - bins[u + 1] = bins[u] + bin_sizes[u]; - - //Swap into place - RandomAccessIter next_bin_start = first; - for (unsigned u = 0; u < bin_count - 1; ++u) - swap_loop<RandomAccessIter, Div_type, Right_shift>(bins, next_bin_start, - u, rshift, bin_sizes, log_divisor, div_min); - bins[bin_count - 1] = last; - - //If we've bucketsorted, the array is sorted - if (!log_divisor) - return; - - //Recursing - size_t max_count = get_min_count<log_mean_bin_size, log_min_split_count, - log_finishing_count>(log_divisor); - RandomAccessIter lastPos = first; - for (unsigned u = cache_offset; u < cache_end; lastPos = bin_cache[u], - ++u) { - size_t count = bin_cache[u] - lastPos; - if (count < 2) - continue; - if (count < max_count) - std::sort(lastPos, bin_cache[u], comp); - else - spreadsort_rec<RandomAccessIter, Div_type, Right_shift, Compare, - Size_type, log_mean_bin_size, log_min_split_count, log_finishing_count> - (lastPos, bin_cache[u], bin_cache, cache_end, bin_sizes, rshift, comp); - } - } - - //Functor implementation for recursive sorting with only Shift overridden - template <class RandomAccessIter, class Div_type, class Right_shift, - class Size_type, unsigned log_mean_bin_size, - unsigned log_min_split_count, unsigned log_finishing_count> - inline void - spreadsort_rec(RandomAccessIter first, RandomAccessIter last, - std::vector<RandomAccessIter> &bin_cache, unsigned cache_offset - , size_t *bin_sizes, Right_shift rshift) - { - RandomAccessIter max, min; - if (is_sorted_or_find_extremes(first, last, max, min)) - return; - unsigned log_divisor = get_log_divisor<log_mean_bin_size>(last - first, - rough_log_2_size(Size_type(rshift(*max, 0) - rshift(*min, 0)))); - Div_type div_min = rshift(*min, log_divisor); - Div_type div_max = rshift(*max, log_divisor); - unsigned bin_count = unsigned(div_max - div_min) + 1; - unsigned cache_end; - RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset, - cache_end, bin_count); - - //Calculating the size of each bin - for (RandomAccessIter current = first; current != last;) - bin_sizes[unsigned(rshift(*(current++), log_divisor) - div_min)]++; - bins[0] = first; - for (unsigned u = 0; u < bin_count - 1; u++) - bins[u + 1] = bins[u] + bin_sizes[u]; - - //Swap into place - RandomAccessIter nextbinstart = first; - for (unsigned ii = 0; ii < bin_count - 1; ++ii) - swap_loop<RandomAccessIter, Div_type, Right_shift>(bins, nextbinstart, - ii, rshift, bin_sizes, log_divisor, div_min); - bins[bin_count - 1] = last; - - //If we've bucketsorted, the array is sorted - if (!log_divisor) - return; - - //Recursing - size_t max_count = get_min_count<log_mean_bin_size, log_min_split_count, - log_finishing_count>(log_divisor); - RandomAccessIter lastPos = first; - for (unsigned u = cache_offset; u < cache_end; lastPos = bin_cache[u], - ++u) { - size_t count = bin_cache[u] - lastPos; - if (count < 2) - continue; - if (count < max_count) - std::sort(lastPos, bin_cache[u]); - else - spreadsort_rec<RandomAccessIter, Div_type, Right_shift, Size_type, - log_mean_bin_size, log_min_split_count, log_finishing_count>(lastPos, - bin_cache[u], bin_cache, cache_end, bin_sizes, rshift); - } - } - - //Holds the bin vector and makes the initial recursive call - template <class RandomAccessIter, class Div_type> - //Only use spreadsort if the integer can fit in a size_t - inline typename boost::enable_if_c< sizeof(Div_type) <= sizeof(size_t), - void >::type - integer_sort(RandomAccessIter first, RandomAccessIter last, Div_type) - { - size_t bin_sizes[1 << max_finishing_splits]; - std::vector<RandomAccessIter> bin_cache; - spreadsort_rec<RandomAccessIter, Div_type, size_t>(first, last, - bin_cache, 0, bin_sizes); - } - - //Holds the bin vector and makes the initial recursive call - template <class RandomAccessIter, class Div_type> - //Only use spreadsort if the integer can fit in a uintmax_t - inline typename boost::enable_if_c< (sizeof(Div_type) > sizeof(size_t)) - && sizeof(Div_type) <= sizeof(boost::uintmax_t), void >::type - integer_sort(RandomAccessIter first, RandomAccessIter last, Div_type) - { - size_t bin_sizes[1 << max_finishing_splits]; - std::vector<RandomAccessIter> bin_cache; - spreadsort_rec<RandomAccessIter, Div_type, boost::uintmax_t>(first, - last, bin_cache, 0, bin_sizes); - } - - template <class RandomAccessIter, class Div_type> - inline typename boost::disable_if_c< sizeof(Div_type) <= sizeof(size_t) - || sizeof(Div_type) <= sizeof(boost::uintmax_t), void >::type - //defaulting to std::sort when integer_sort won't work - integer_sort(RandomAccessIter first, RandomAccessIter last, Div_type) - { - //Warning that we're using std::sort, even though integer_sort was called - BOOST_STATIC_WARNING( sizeof(Div_type) <= sizeof(size_t) ); - std::sort(first, last); - } - - - //Same for the full functor version - template <class RandomAccessIter, class Div_type, class Right_shift, - class Compare> - //Only use spreadsort if the integer can fit in a size_t - inline typename boost::enable_if_c< sizeof(Div_type) <= sizeof(size_t), - void >::type - integer_sort(RandomAccessIter first, RandomAccessIter last, Div_type, - Right_shift shift, Compare comp) - { - size_t bin_sizes[1 << max_finishing_splits]; - std::vector<RandomAccessIter> bin_cache; - spreadsort_rec<RandomAccessIter, Div_type, Right_shift, Compare, - size_t, int_log_mean_bin_size, int_log_min_split_count, - int_log_finishing_count> - (first, last, bin_cache, 0, bin_sizes, shift, comp); - } - - template <class RandomAccessIter, class Div_type, class Right_shift, - class Compare> - //Only use spreadsort if the integer can fit in a uintmax_t - inline typename boost::enable_if_c< (sizeof(Div_type) > sizeof(size_t)) - && sizeof(Div_type) <= sizeof(boost::uintmax_t), void >::type - integer_sort(RandomAccessIter first, RandomAccessIter last, Div_type, - Right_shift shift, Compare comp) - { - size_t bin_sizes[1 << max_finishing_splits]; - std::vector<RandomAccessIter> bin_cache; - spreadsort_rec<RandomAccessIter, Div_type, Right_shift, Compare, - boost::uintmax_t, int_log_mean_bin_size, - int_log_min_split_count, int_log_finishing_count> - (first, last, bin_cache, 0, bin_sizes, shift, comp); - } - - template <class RandomAccessIter, class Div_type, class Right_shift, - class Compare> - inline typename boost::disable_if_c< sizeof(Div_type) <= sizeof(size_t) - || sizeof(Div_type) <= sizeof(boost::uintmax_t), void >::type - //defaulting to std::sort when integer_sort won't work - integer_sort(RandomAccessIter first, RandomAccessIter last, Div_type, - Right_shift shift, Compare comp) - { - //Warning that we're using std::sort, even though integer_sort was called - BOOST_STATIC_WARNING( sizeof(Div_type) <= sizeof(size_t) ); - std::sort(first, last, comp); - } - - - //Same for the right shift version - template <class RandomAccessIter, class Div_type, class Right_shift> - //Only use spreadsort if the integer can fit in a size_t - inline typename boost::enable_if_c< sizeof(Div_type) <= sizeof(size_t), - void >::type - integer_sort(RandomAccessIter first, RandomAccessIter last, Div_type, - Right_shift shift) - { - size_t bin_sizes[1 << max_finishing_splits]; - std::vector<RandomAccessIter> bin_cache; - spreadsort_rec<RandomAccessIter, Div_type, Right_shift, size_t, - int_log_mean_bin_size, int_log_min_split_count, - int_log_finishing_count> - (first, last, bin_cache, 0, bin_sizes, shift); - } - - template <class RandomAccessIter, class Div_type, class Right_shift> - //Only use spreadsort if the integer can fit in a uintmax_t - inline typename boost::enable_if_c< (sizeof(Div_type) > sizeof(size_t)) - && sizeof(Div_type) <= sizeof(boost::uintmax_t), void >::type - integer_sort(RandomAccessIter first, RandomAccessIter last, Div_type, - Right_shift shift) - { - size_t bin_sizes[1 << max_finishing_splits]; - std::vector<RandomAccessIter> bin_cache; - spreadsort_rec<RandomAccessIter, Div_type, Right_shift, - boost::uintmax_t, int_log_mean_bin_size, - int_log_min_split_count, int_log_finishing_count> - (first, last, bin_cache, 0, bin_sizes, shift); - } - - template <class RandomAccessIter, class Div_type, class Right_shift> - inline typename boost::disable_if_c< sizeof(Div_type) <= sizeof(size_t) - || sizeof(Div_type) <= sizeof(boost::uintmax_t), void >::type - //defaulting to std::sort when integer_sort won't work - integer_sort(RandomAccessIter first, RandomAccessIter last, Div_type, - Right_shift shift) - { - //Warning that we're using std::sort, even though integer_sort was called - BOOST_STATIC_WARNING( sizeof(Div_type) <= sizeof(size_t) ); - std::sort(first, last); - } - } -} -} -} - -#endif diff --git a/contrib/restricted/boost/boost/sort/spreadsort/detail/spreadsort_common.hpp b/contrib/restricted/boost/boost/sort/spreadsort/detail/spreadsort_common.hpp deleted file mode 100644 index 7917fddae06..00000000000 --- a/contrib/restricted/boost/boost/sort/spreadsort/detail/spreadsort_common.hpp +++ /dev/null @@ -1,124 +0,0 @@ -// Contains get_min_count, the core optimization of the spreadsort algorithm. -// Also has other helper functions commonly useful across variants. - -// Copyright Steven J. Ross 2001 - 2014. -// Distributed under the 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://www.boost.org/libs/sort for library home page. - -/* -Some improvements suggested by: -Phil Endecott and Frank Gennari -*/ - -#ifndef BOOST_SORT_SPREADSORT_DETAIL_SPREAD_SORT_COMMON_HPP -#define BOOST_SORT_SPREADSORT_DETAIL_SPREAD_SORT_COMMON_HPP -#include <algorithm> -#include <vector> -#include <cstring> -#include <limits> -#include <functional> -#include <boost/static_assert.hpp> -#include <boost/serialization/static_warning.hpp> -#include <boost/sort/spreadsort/detail/constants.hpp> -#include <boost/cstdint.hpp> - -namespace boost { -namespace sort { -namespace spreadsort { - namespace detail { - //This only works on unsigned data types - template <typename T> - inline unsigned - rough_log_2_size(const T& input) - { - unsigned result = 0; - //The && is necessary on some compilers to avoid infinite loops - //it doesn't significantly impair performance - while ((input >> result) && (result < (8*sizeof(T)))) ++result; - return result; - } - - //Gets the minimum size to call spreadsort on to control worst-case runtime. - //This is called for a set of bins, instead of bin-by-bin, to minimize - //runtime overhead. - //This could be replaced by a lookup table of sizeof(Div_type)*8 but this - //function is more general. - template<unsigned log_mean_bin_size, - unsigned log_min_split_count, unsigned log_finishing_count> - inline size_t - get_min_count(unsigned log_range) - { - const size_t typed_one = 1; - const unsigned min_size = log_mean_bin_size + log_min_split_count; - //Assuring that constants have valid settings - BOOST_STATIC_ASSERT(log_min_split_count <= max_splits && - log_min_split_count > 0); - BOOST_STATIC_ASSERT(max_splits > 1 && - max_splits < (8 * sizeof(unsigned))); - BOOST_STATIC_ASSERT(max_finishing_splits >= max_splits && - max_finishing_splits < (8 * sizeof(unsigned))); - BOOST_STATIC_ASSERT(log_mean_bin_size >= 0); - BOOST_STATIC_ASSERT(log_finishing_count >= 0); - //if we can complete in one iteration, do so - //This first check allows the compiler to optimize never-executed code out - if (log_finishing_count < min_size) { - if (log_range <= min_size && log_range <= max_splits) { - //Return no smaller than a certain minimum limit - if (log_range <= log_finishing_count) - return typed_one << log_finishing_count; - return typed_one << log_range; - } - } - const unsigned base_iterations = max_splits - log_min_split_count; - //sum of n to n + x = ((x + 1) * (n + (n + x)))/2 + log_mean_bin_size - const unsigned base_range = - ((base_iterations + 1) * (max_splits + log_min_split_count))/2 - + log_mean_bin_size; - //Calculating the required number of iterations, and returning - //1 << (iteration_count + min_size) - if (log_range < base_range) { - unsigned result = log_min_split_count; - for (unsigned offset = min_size; offset < log_range; - offset += ++result); - //Preventing overflow; this situation shouldn't occur - if ((result + log_mean_bin_size) >= (8 * sizeof(size_t))) - return typed_one << ((8 * sizeof(size_t)) - 1); - return typed_one << (result + log_mean_bin_size); - } - //A quick division can calculate the worst-case runtime for larger ranges - unsigned remainder = log_range - base_range; - //the max_splits - 1 is used to calculate the ceiling of the division - unsigned bit_length = ((((max_splits - 1) + remainder)/max_splits) - + base_iterations + min_size); - //Preventing overflow; this situation shouldn't occur - if (bit_length >= (8 * sizeof(size_t))) - return typed_one << ((8 * sizeof(size_t)) - 1); - //n(log_range)/max_splits + C, optimizing worst-case performance - return typed_one << bit_length; - } - - // Resizes the bin cache and bin sizes, and initializes each bin size to 0. - // This generates the memory overhead to use in radix sorting. - template <class RandomAccessIter> - inline RandomAccessIter * - size_bins(size_t *bin_sizes, std::vector<RandomAccessIter> - &bin_cache, unsigned cache_offset, unsigned &cache_end, unsigned bin_count) - { - // Clear the bin sizes - for (size_t u = 0; u < bin_count; u++) - bin_sizes[u] = 0; - //Make sure there is space for the bins - cache_end = cache_offset + bin_count; - if (cache_end > bin_cache.size()) - bin_cache.resize(cache_end); - return &(bin_cache[cache_offset]); - } - } -} -} -} - -#endif diff --git a/contrib/restricted/boost/boost/sort/spreadsort/detail/string_sort.hpp b/contrib/restricted/boost/boost/sort/spreadsort/detail/string_sort.hpp deleted file mode 100644 index a548ebefa53..00000000000 --- a/contrib/restricted/boost/boost/sort/spreadsort/detail/string_sort.hpp +++ /dev/null @@ -1,819 +0,0 @@ -// Details for a templated general-case hybrid-radix string_sort. - -// Copyright Steven J. Ross 2001 - 2014. -// Distributed under the 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://www.boost.org/libs/sort for library home page. - -/* -Some improvements suggested by: -Phil Endecott and Frank Gennari -*/ - -#ifndef BOOST_SORT_SPREADSORT_DETAIL_SPREAD_SORT_HPP -#define BOOST_SORT_SPREADSORT_DETAIL_SPREAD_SORT_HPP -#include <algorithm> -#include <vector> -#include <cstring> -#include <limits> -#include <functional> -#include <boost/static_assert.hpp> -#include <boost/serialization/static_warning.hpp> -#include <boost/utility/enable_if.hpp> -#include <boost/sort/spreadsort/detail/constants.hpp> -#include <boost/sort/spreadsort/detail/spreadsort_common.hpp> -#include <boost/cstdint.hpp> - -namespace boost { -namespace sort { -namespace spreadsort { - namespace detail { - static const int max_step_size = 64; - - //Offsetting on identical characters. This function works a chunk of - //characters at a time for cache efficiency and optimal worst-case - //performance. - template<class RandomAccessIter, class Unsigned_char_type> - inline void - update_offset(RandomAccessIter first, RandomAccessIter finish, - size_t &char_offset) - { - const int char_size = sizeof(Unsigned_char_type); - size_t nextOffset = char_offset; - int step_size = max_step_size / char_size; - while (true) { - RandomAccessIter curr = first; - do { - //Ignore empties, but if the nextOffset would exceed the length or - //not match, exit; we've found the last matching character - //This will reduce the step_size if the current step doesn't match. - if ((*curr).size() > char_offset) { - if((*curr).size() <= (nextOffset + step_size)) { - step_size = (*curr).size() - nextOffset - 1; - if (step_size < 1) { - char_offset = nextOffset; - return; - } - } - const int step_byte_size = step_size * char_size; - if (memcmp(curr->data() + nextOffset, first->data() + nextOffset, - step_byte_size) != 0) { - if (step_size == 1) { - char_offset = nextOffset; - return; - } - step_size = (step_size > 4) ? 4 : 1; - continue; - } - } - ++curr; - } while (curr != finish); - nextOffset += step_size; - } - } - - //Offsetting on identical characters. This function works a character - //at a time for optimal worst-case performance. - template<class RandomAccessIter, class Get_char, class Get_length> - inline void - update_offset(RandomAccessIter first, RandomAccessIter finish, - size_t &char_offset, Get_char get_character, Get_length length) - { - size_t nextOffset = char_offset; - while (true) { - RandomAccessIter curr = first; - do { - //ignore empties, but if the nextOffset would exceed the length or - //not match, exit; we've found the last matching character - if (length(*curr) > char_offset && (length(*curr) <= (nextOffset + 1) - || get_character((*curr), nextOffset) != get_character((*first), nextOffset))) { - char_offset = nextOffset; - return; - } - } while (++curr != finish); - ++nextOffset; - } - } - - //This comparison functor assumes strings are identical up to char_offset - template<class Data_type, class Unsigned_char_type> - struct offset_less_than { - offset_less_than(size_t char_offset) : fchar_offset(char_offset){} - inline bool operator()(const Data_type &x, const Data_type &y) const - { - size_t minSize = (std::min)(x.size(), y.size()); - for (size_t u = fchar_offset; u < minSize; ++u) { - BOOST_STATIC_ASSERT(sizeof(x[u]) == sizeof(Unsigned_char_type)); - if (static_cast<Unsigned_char_type>(x[u]) != - static_cast<Unsigned_char_type>(y[u])) { - return static_cast<Unsigned_char_type>(x[u]) < - static_cast<Unsigned_char_type>(y[u]); - } - } - return x.size() < y.size(); - } - size_t fchar_offset; - }; - - //Compares strings assuming they are identical up to char_offset - template<class Data_type, class Unsigned_char_type> - struct offset_greater_than { - offset_greater_than(size_t char_offset) : fchar_offset(char_offset){} - inline bool operator()(const Data_type &x, const Data_type &y) const - { - size_t minSize = (std::min)(x.size(), y.size()); - for (size_t u = fchar_offset; u < minSize; ++u) { - BOOST_STATIC_ASSERT(sizeof(x[u]) == sizeof(Unsigned_char_type)); - if (static_cast<Unsigned_char_type>(x[u]) != - static_cast<Unsigned_char_type>(y[u])) { - return static_cast<Unsigned_char_type>(x[u]) > - static_cast<Unsigned_char_type>(y[u]); - } - } - return x.size() > y.size(); - } - size_t fchar_offset; - }; - - //This comparison functor assumes strings are identical up to char_offset - template<class Data_type, class Get_char, class Get_length> - struct offset_char_less_than { - offset_char_less_than(size_t char_offset) : fchar_offset(char_offset){} - inline bool operator()(const Data_type &x, const Data_type &y) const - { - size_t minSize = (std::min)(length(x), length(y)); - for (size_t u = fchar_offset; u < minSize; ++u) { - if (get_character(x, u) != get_character(y, u)) { - return get_character(x, u) < get_character(y, u); - } - } - return length(x) < length(y); - } - size_t fchar_offset; - Get_char get_character; - Get_length length; - }; - - //String sorting recursive implementation - template <class RandomAccessIter, class Unsigned_char_type> - inline void - string_sort_rec(RandomAccessIter first, RandomAccessIter last, - size_t char_offset, - std::vector<RandomAccessIter> &bin_cache, - unsigned cache_offset, size_t *bin_sizes) - { - typedef typename std::iterator_traits<RandomAccessIter>::value_type - Data_type; - //This section makes handling of long identical substrings much faster - //with a mild average performance impact. - //Iterate to the end of the empties. If all empty, return - while ((*first).size() <= char_offset) { - if (++first == last) - return; - } - RandomAccessIter finish = last - 1; - //Getting the last non-empty - for (;(*finish).size() <= char_offset; --finish); - ++finish; - //Offsetting on identical characters. This section works - //a few characters at a time for optimal worst-case performance. - update_offset<RandomAccessIter, Unsigned_char_type>(first, finish, - char_offset); - - const unsigned bin_count = (1 << (sizeof(Unsigned_char_type)*8)); - //Equal worst-case of radix and comparison is when bin_count = n*log(n). - const unsigned max_size = bin_count; - const unsigned membin_count = bin_count + 1; - unsigned cache_end; - RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset, - cache_end, membin_count) + 1; - - //Calculating the size of each bin; this takes roughly 10% of runtime - for (RandomAccessIter current = first; current != last; ++current) { - if ((*current).size() <= char_offset) { - bin_sizes[0]++; - } - else - bin_sizes[static_cast<Unsigned_char_type>((*current)[char_offset]) - + 1]++; - } - //Assign the bin positions - bin_cache[cache_offset] = first; - for (unsigned u = 0; u < membin_count - 1; u++) - bin_cache[cache_offset + u + 1] = - bin_cache[cache_offset + u] + bin_sizes[u]; - - //Swap into place - RandomAccessIter next_bin_start = first; - //handling empty bins - RandomAccessIter * local_bin = &(bin_cache[cache_offset]); - next_bin_start += bin_sizes[0]; - RandomAccessIter * target_bin; - //Iterating over each element in the bin of empties - for (RandomAccessIter current = *local_bin; current < next_bin_start; - ++current) { - //empties belong in this bin - while ((*current).size() > char_offset) { - target_bin = - bins + static_cast<Unsigned_char_type>((*current)[char_offset]); - iter_swap(current, (*target_bin)++); - } - } - *local_bin = next_bin_start; - //iterate backwards to find the last bin with elements in it - //this saves iterations in multiple loops - unsigned last_bin = bin_count - 1; - for (; last_bin && !bin_sizes[last_bin + 1]; --last_bin); - //This dominates runtime, mostly in the swap and bin lookups - for (unsigned u = 0; u < last_bin; ++u) { - local_bin = bins + u; - next_bin_start += bin_sizes[u + 1]; - //Iterating over each element in this bin - for (RandomAccessIter current = *local_bin; current < next_bin_start; - ++current) { - //Swapping into place until the correct element has been swapped in - for (target_bin = bins + static_cast<Unsigned_char_type> - ((*current)[char_offset]); target_bin != local_bin; - target_bin = bins + static_cast<Unsigned_char_type> - ((*current)[char_offset])) iter_swap(current, (*target_bin)++); - } - *local_bin = next_bin_start; - } - bins[last_bin] = last; - //Recursing - RandomAccessIter lastPos = bin_cache[cache_offset]; - //Skip this loop for empties - for (unsigned u = cache_offset + 1; u < cache_offset + last_bin + 2; - lastPos = bin_cache[u], ++u) { - size_t count = bin_cache[u] - lastPos; - //don't sort unless there are at least two items to Compare - if (count < 2) - continue; - //using std::sort if its worst-case is better - if (count < max_size) - std::sort(lastPos, bin_cache[u], - offset_less_than<Data_type, Unsigned_char_type>(char_offset + 1)); - else - string_sort_rec<RandomAccessIter, Unsigned_char_type>(lastPos, - bin_cache[u], char_offset + 1, bin_cache, cache_end, bin_sizes); - } - } - - //Sorts strings in reverse order, with empties at the end - template <class RandomAccessIter, class Unsigned_char_type> - inline void - reverse_string_sort_rec(RandomAccessIter first, RandomAccessIter last, - size_t char_offset, - std::vector<RandomAccessIter> &bin_cache, - unsigned cache_offset, - size_t *bin_sizes) - { - typedef typename std::iterator_traits<RandomAccessIter>::value_type - Data_type; - //This section makes handling of long identical substrings much faster - //with a mild average performance impact. - RandomAccessIter curr = first; - //Iterate to the end of the empties. If all empty, return - while ((*curr).size() <= char_offset) { - if (++curr == last) - return; - } - //Getting the last non-empty - while ((*(--last)).size() <= char_offset); - ++last; - //Offsetting on identical characters. This section works - //a few characters at a time for optimal worst-case performance. - update_offset<RandomAccessIter, Unsigned_char_type>(curr, last, - char_offset); - RandomAccessIter * target_bin; - - const unsigned bin_count = (1 << (sizeof(Unsigned_char_type)*8)); - //Equal worst-case of radix and comparison when bin_count = n*log(n). - const unsigned max_size = bin_count; - const unsigned membin_count = bin_count + 1; - const unsigned max_bin = bin_count - 1; - unsigned cache_end; - RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset, - cache_end, membin_count); - RandomAccessIter * end_bin = &(bin_cache[cache_offset + max_bin]); - - //Calculating the size of each bin; this takes roughly 10% of runtime - for (RandomAccessIter current = first; current != last; ++current) { - if ((*current).size() <= char_offset) { - bin_sizes[bin_count]++; - } - else - bin_sizes[max_bin - static_cast<Unsigned_char_type> - ((*current)[char_offset])]++; - } - //Assign the bin positions - bin_cache[cache_offset] = first; - for (unsigned u = 0; u < membin_count - 1; u++) - bin_cache[cache_offset + u + 1] = - bin_cache[cache_offset + u] + bin_sizes[u]; - - //Swap into place - RandomAccessIter next_bin_start = last; - //handling empty bins - RandomAccessIter * local_bin = &(bin_cache[cache_offset + bin_count]); - RandomAccessIter lastFull = *local_bin; - //Iterating over each element in the bin of empties - for (RandomAccessIter current = *local_bin; current < next_bin_start; - ++current) { - //empties belong in this bin - while ((*current).size() > char_offset) { - target_bin = - end_bin - static_cast<Unsigned_char_type>((*current)[char_offset]); - iter_swap(current, (*target_bin)++); - } - } - *local_bin = next_bin_start; - next_bin_start = first; - //iterate backwards to find the last non-empty bin - //this saves iterations in multiple loops - unsigned last_bin = max_bin; - for (; last_bin && !bin_sizes[last_bin]; --last_bin); - //This dominates runtime, mostly in the swap and bin lookups - for (unsigned u = 0; u < last_bin; ++u) { - local_bin = bins + u; - next_bin_start += bin_sizes[u]; - //Iterating over each element in this bin - for (RandomAccessIter current = *local_bin; current < next_bin_start; - ++current) { - //Swapping into place until the correct element has been swapped in - for (target_bin = - end_bin - static_cast<Unsigned_char_type>((*current)[char_offset]); - target_bin != local_bin; - target_bin = - end_bin - static_cast<Unsigned_char_type>((*current)[char_offset])) - iter_swap(current, (*target_bin)++); - } - *local_bin = next_bin_start; - } - bins[last_bin] = lastFull; - //Recursing - RandomAccessIter lastPos = first; - //Skip this loop for empties - for (unsigned u = cache_offset; u <= cache_offset + last_bin; - lastPos = bin_cache[u], ++u) { - size_t count = bin_cache[u] - lastPos; - //don't sort unless there are at least two items to Compare - if (count < 2) - continue; - //using std::sort if its worst-case is better - if (count < max_size) - std::sort(lastPos, bin_cache[u], offset_greater_than<Data_type, - Unsigned_char_type>(char_offset + 1)); - else - reverse_string_sort_rec<RandomAccessIter, Unsigned_char_type> - (lastPos, bin_cache[u], char_offset + 1, bin_cache, cache_end, bin_sizes); - } - } - - //String sorting recursive implementation - template <class RandomAccessIter, class Unsigned_char_type, class Get_char, - class Get_length> - inline void - string_sort_rec(RandomAccessIter first, RandomAccessIter last, - size_t char_offset, std::vector<RandomAccessIter> &bin_cache, - unsigned cache_offset, size_t *bin_sizes, - Get_char get_character, Get_length length) - { - typedef typename std::iterator_traits<RandomAccessIter>::value_type - Data_type; - //This section makes handling of long identical substrings much faster - //with a mild average performance impact. - //Iterate to the end of the empties. If all empty, return - while (length(*first) <= char_offset) { - if (++first == last) - return; - } - RandomAccessIter finish = last - 1; - //Getting the last non-empty - for (;length(*finish) <= char_offset; --finish); - ++finish; - update_offset(first, finish, char_offset, get_character, length); - - const unsigned bin_count = (1 << (sizeof(Unsigned_char_type)*8)); - //Equal worst-case of radix and comparison is when bin_count = n*log(n). - const unsigned max_size = bin_count; - const unsigned membin_count = bin_count + 1; - unsigned cache_end; - RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset, - cache_end, membin_count) + 1; - - //Calculating the size of each bin; this takes roughly 10% of runtime - for (RandomAccessIter current = first; current != last; ++current) { - if (length(*current) <= char_offset) { - bin_sizes[0]++; - } - else - bin_sizes[get_character((*current), char_offset) + 1]++; - } - //Assign the bin positions - bin_cache[cache_offset] = first; - for (unsigned u = 0; u < membin_count - 1; u++) - bin_cache[cache_offset + u + 1] = - bin_cache[cache_offset + u] + bin_sizes[u]; - - //Swap into place - RandomAccessIter next_bin_start = first; - //handling empty bins - RandomAccessIter * local_bin = &(bin_cache[cache_offset]); - next_bin_start += bin_sizes[0]; - RandomAccessIter * target_bin; - //Iterating over each element in the bin of empties - for (RandomAccessIter current = *local_bin; current < next_bin_start; - ++current) { - //empties belong in this bin - while (length(*current) > char_offset) { - target_bin = bins + get_character((*current), char_offset); - iter_swap(current, (*target_bin)++); - } - } - *local_bin = next_bin_start; - //iterate backwards to find the last bin with elements in it - //this saves iterations in multiple loops - unsigned last_bin = bin_count - 1; - for (; last_bin && !bin_sizes[last_bin + 1]; --last_bin); - //This dominates runtime, mostly in the swap and bin lookups - for (unsigned ii = 0; ii < last_bin; ++ii) { - local_bin = bins + ii; - next_bin_start += bin_sizes[ii + 1]; - //Iterating over each element in this bin - for (RandomAccessIter current = *local_bin; current < next_bin_start; - ++current) { - //Swapping into place until the correct element has been swapped in - for (target_bin = bins + get_character((*current), char_offset); - target_bin != local_bin; - target_bin = bins + get_character((*current), char_offset)) - iter_swap(current, (*target_bin)++); - } - *local_bin = next_bin_start; - } - bins[last_bin] = last; - - //Recursing - RandomAccessIter lastPos = bin_cache[cache_offset]; - //Skip this loop for empties - for (unsigned u = cache_offset + 1; u < cache_offset + last_bin + 2; - lastPos = bin_cache[u], ++u) { - size_t count = bin_cache[u] - lastPos; - //don't sort unless there are at least two items to Compare - if (count < 2) - continue; - //using std::sort if its worst-case is better - if (count < max_size) - std::sort(lastPos, bin_cache[u], offset_char_less_than<Data_type, - Get_char, Get_length>(char_offset + 1)); - else - string_sort_rec<RandomAccessIter, Unsigned_char_type, Get_char, - Get_length>(lastPos, bin_cache[u], char_offset + 1, bin_cache, - cache_end, bin_sizes, get_character, length); - } - } - - //String sorting recursive implementation - template <class RandomAccessIter, class Unsigned_char_type, class Get_char, - class Get_length, class Compare> - inline void - string_sort_rec(RandomAccessIter first, RandomAccessIter last, - size_t char_offset, std::vector<RandomAccessIter> &bin_cache, - unsigned cache_offset, size_t *bin_sizes, - Get_char get_character, Get_length length, Compare comp) - { - //This section makes handling of long identical substrings much faster - //with a mild average performance impact. - //Iterate to the end of the empties. If all empty, return - while (length(*first) <= char_offset) { - if (++first == last) - return; - } - RandomAccessIter finish = last - 1; - //Getting the last non-empty - for (;length(*finish) <= char_offset; --finish); - ++finish; - update_offset(first, finish, char_offset, get_character, length); - - const unsigned bin_count = (1 << (sizeof(Unsigned_char_type)*8)); - //Equal worst-case of radix and comparison is when bin_count = n*log(n). - const unsigned max_size = bin_count; - const unsigned membin_count = bin_count + 1; - unsigned cache_end; - RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset, - cache_end, membin_count) + 1; - - //Calculating the size of each bin; this takes roughly 10% of runtime - for (RandomAccessIter current = first; current != last; ++current) { - if (length(*current) <= char_offset) { - bin_sizes[0]++; - } - else - bin_sizes[get_character((*current), char_offset) + 1]++; - } - //Assign the bin positions - bin_cache[cache_offset] = first; - for (unsigned u = 0; u < membin_count - 1; u++) - bin_cache[cache_offset + u + 1] = - bin_cache[cache_offset + u] + bin_sizes[u]; - - //Swap into place - RandomAccessIter next_bin_start = first; - //handling empty bins - RandomAccessIter * local_bin = &(bin_cache[cache_offset]); - next_bin_start += bin_sizes[0]; - RandomAccessIter * target_bin; - //Iterating over each element in the bin of empties - for (RandomAccessIter current = *local_bin; current < next_bin_start; - ++current) { - //empties belong in this bin - while (length(*current) > char_offset) { - target_bin = bins + get_character((*current), char_offset); - iter_swap(current, (*target_bin)++); - } - } - *local_bin = next_bin_start; - //iterate backwards to find the last bin with elements in it - //this saves iterations in multiple loops - unsigned last_bin = bin_count - 1; - for (; last_bin && !bin_sizes[last_bin + 1]; --last_bin); - //This dominates runtime, mostly in the swap and bin lookups - for (unsigned u = 0; u < last_bin; ++u) { - local_bin = bins + u; - next_bin_start += bin_sizes[u + 1]; - //Iterating over each element in this bin - for (RandomAccessIter current = *local_bin; current < next_bin_start; - ++current) { - //Swapping into place until the correct element has been swapped in - for (target_bin = bins + get_character((*current), char_offset); - target_bin != local_bin; - target_bin = bins + get_character((*current), char_offset)) - iter_swap(current, (*target_bin)++); - } - *local_bin = next_bin_start; - } - bins[last_bin] = last; - - //Recursing - RandomAccessIter lastPos = bin_cache[cache_offset]; - //Skip this loop for empties - for (unsigned u = cache_offset + 1; u < cache_offset + last_bin + 2; - lastPos = bin_cache[u], ++u) { - size_t count = bin_cache[u] - lastPos; - //don't sort unless there are at least two items to Compare - if (count < 2) - continue; - //using std::sort if its worst-case is better - if (count < max_size) - std::sort(lastPos, bin_cache[u], comp); - else - string_sort_rec<RandomAccessIter, Unsigned_char_type, Get_char, - Get_length, Compare> - (lastPos, bin_cache[u], char_offset + 1, bin_cache, cache_end, - bin_sizes, get_character, length, comp); - } - } - - //Sorts strings in reverse order, with empties at the end - template <class RandomAccessIter, class Unsigned_char_type, class Get_char, - class Get_length, class Compare> - inline void - reverse_string_sort_rec(RandomAccessIter first, RandomAccessIter last, - size_t char_offset, std::vector<RandomAccessIter> &bin_cache, - unsigned cache_offset, size_t *bin_sizes, - Get_char get_character, Get_length length, Compare comp) - { - //This section makes handling of long identical substrings much faster - //with a mild average performance impact. - RandomAccessIter curr = first; - //Iterate to the end of the empties. If all empty, return - while (length(*curr) <= char_offset) { - if (++curr == last) - return; - } - //Getting the last non-empty - while (length(*(--last)) <= char_offset); - ++last; - //Offsetting on identical characters. This section works - //a character at a time for optimal worst-case performance. - update_offset(curr, last, char_offset, get_character, length); - - const unsigned bin_count = (1 << (sizeof(Unsigned_char_type)*8)); - //Equal worst-case of radix and comparison is when bin_count = n*log(n). - const unsigned max_size = bin_count; - const unsigned membin_count = bin_count + 1; - const unsigned max_bin = bin_count - 1; - unsigned cache_end; - RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset, - cache_end, membin_count); - RandomAccessIter *end_bin = &(bin_cache[cache_offset + max_bin]); - - //Calculating the size of each bin; this takes roughly 10% of runtime - for (RandomAccessIter current = first; current != last; ++current) { - if (length(*current) <= char_offset) { - bin_sizes[bin_count]++; - } - else - bin_sizes[max_bin - get_character((*current), char_offset)]++; - } - //Assign the bin positions - bin_cache[cache_offset] = first; - for (unsigned u = 0; u < membin_count - 1; u++) - bin_cache[cache_offset + u + 1] = - bin_cache[cache_offset + u] + bin_sizes[u]; - - //Swap into place - RandomAccessIter next_bin_start = last; - //handling empty bins - RandomAccessIter * local_bin = &(bin_cache[cache_offset + bin_count]); - RandomAccessIter lastFull = *local_bin; - RandomAccessIter * target_bin; - //Iterating over each element in the bin of empties - for (RandomAccessIter current = *local_bin; current < next_bin_start; - ++current) { - //empties belong in this bin - while (length(*current) > char_offset) { - target_bin = end_bin - get_character((*current), char_offset); - iter_swap(current, (*target_bin)++); - } - } - *local_bin = next_bin_start; - next_bin_start = first; - //iterate backwards to find the last bin with elements in it - //this saves iterations in multiple loops - unsigned last_bin = max_bin; - for (; last_bin && !bin_sizes[last_bin]; --last_bin); - //This dominates runtime, mostly in the swap and bin lookups - for (unsigned u = 0; u < last_bin; ++u) { - local_bin = bins + u; - next_bin_start += bin_sizes[u]; - //Iterating over each element in this bin - for (RandomAccessIter current = *local_bin; current < next_bin_start; - ++current) { - //Swapping into place until the correct element has been swapped in - for (target_bin = end_bin - get_character((*current), char_offset); - target_bin != local_bin; - target_bin = end_bin - get_character((*current), char_offset)) - iter_swap(current, (*target_bin)++); - } - *local_bin = next_bin_start; - } - bins[last_bin] = lastFull; - //Recursing - RandomAccessIter lastPos = first; - //Skip this loop for empties - for (unsigned u = cache_offset; u <= cache_offset + last_bin; - lastPos = bin_cache[u], ++u) { - size_t count = bin_cache[u] - lastPos; - //don't sort unless there are at least two items to Compare - if (count < 2) - continue; - //using std::sort if its worst-case is better - if (count < max_size) - std::sort(lastPos, bin_cache[u], comp); - else - reverse_string_sort_rec<RandomAccessIter, Unsigned_char_type, - Get_char, Get_length, Compare> - (lastPos, bin_cache[u], char_offset + 1, bin_cache, cache_end, - bin_sizes, get_character, length, comp); - } - } - - //Holds the bin vector and makes the initial recursive call - template <class RandomAccessIter, class Unsigned_char_type> - inline typename boost::enable_if_c< sizeof(Unsigned_char_type) <= 2, void - >::type - string_sort(RandomAccessIter first, RandomAccessIter last, - Unsigned_char_type) - { - size_t bin_sizes[(1 << (8 * sizeof(Unsigned_char_type))) + 1]; - std::vector<RandomAccessIter> bin_cache; - string_sort_rec<RandomAccessIter, Unsigned_char_type> - (first, last, 0, bin_cache, 0, bin_sizes); - } - - template <class RandomAccessIter, class Unsigned_char_type> - inline typename boost::disable_if_c< sizeof(Unsigned_char_type) <= 2, void - >::type - string_sort(RandomAccessIter first, RandomAccessIter last, - Unsigned_char_type) - { - //Warning that we're using std::sort, even though string_sort was called - BOOST_STATIC_WARNING( sizeof(Unsigned_char_type) <= 2 ); - std::sort(first, last); - } - - //Holds the bin vector and makes the initial recursive call - template <class RandomAccessIter, class Unsigned_char_type> - inline typename boost::enable_if_c< sizeof(Unsigned_char_type) <= 2, void - >::type - reverse_string_sort(RandomAccessIter first, RandomAccessIter last, - Unsigned_char_type) - { - size_t bin_sizes[(1 << (8 * sizeof(Unsigned_char_type))) + 1]; - std::vector<RandomAccessIter> bin_cache; - reverse_string_sort_rec<RandomAccessIter, Unsigned_char_type> - (first, last, 0, bin_cache, 0, bin_sizes); - } - - template <class RandomAccessIter, class Unsigned_char_type> - inline typename boost::disable_if_c< sizeof(Unsigned_char_type) <= 2, void - >::type - reverse_string_sort(RandomAccessIter first, RandomAccessIter last, - Unsigned_char_type) - { - typedef typename std::iterator_traits<RandomAccessIter>::value_type - Data_type; - //Warning that we're using std::sort, even though string_sort was called - BOOST_STATIC_WARNING( sizeof(Unsigned_char_type) <= 2 ); - std::sort(first, last, std::greater<Data_type>()); - } - - //Holds the bin vector and makes the initial recursive call - template <class RandomAccessIter, class Get_char, class Get_length, - class Unsigned_char_type> - inline typename boost::enable_if_c< sizeof(Unsigned_char_type) <= 2, void - >::type - string_sort(RandomAccessIter first, RandomAccessIter last, - Get_char get_character, Get_length length, Unsigned_char_type) - { - size_t bin_sizes[(1 << (8 * sizeof(Unsigned_char_type))) + 1]; - std::vector<RandomAccessIter> bin_cache; - string_sort_rec<RandomAccessIter, Unsigned_char_type, Get_char, - Get_length>(first, last, 0, bin_cache, 0, bin_sizes, get_character, length); - } - - template <class RandomAccessIter, class Get_char, class Get_length, - class Unsigned_char_type> - inline typename boost::disable_if_c< sizeof(Unsigned_char_type) <= 2, void - >::type - string_sort(RandomAccessIter first, RandomAccessIter last, - Get_char get_character, Get_length length, Unsigned_char_type) - { - //Warning that we're using std::sort, even though string_sort was called - BOOST_STATIC_WARNING( sizeof(Unsigned_char_type) <= 2 ); - std::sort(first, last); - } - - //Holds the bin vector and makes the initial recursive call - template <class RandomAccessIter, class Get_char, class Get_length, - class Compare, class Unsigned_char_type> - inline typename boost::enable_if_c< sizeof(Unsigned_char_type) <= 2, void - >::type - string_sort(RandomAccessIter first, RandomAccessIter last, - Get_char get_character, Get_length length, Compare comp, Unsigned_char_type) - { - size_t bin_sizes[(1 << (8 * sizeof(Unsigned_char_type))) + 1]; - std::vector<RandomAccessIter> bin_cache; - string_sort_rec<RandomAccessIter, Unsigned_char_type, Get_char - , Get_length, Compare> - (first, last, 0, bin_cache, 0, bin_sizes, get_character, length, comp); - } - - //disable_if_c was refusing to compile, so rewrote to use enable_if_c - template <class RandomAccessIter, class Get_char, class Get_length, - class Compare, class Unsigned_char_type> - inline typename boost::enable_if_c< (sizeof(Unsigned_char_type) > 2), void - >::type - string_sort(RandomAccessIter first, RandomAccessIter last, - Get_char get_character, Get_length length, Compare comp, Unsigned_char_type) - { - //Warning that we're using std::sort, even though string_sort was called - BOOST_STATIC_WARNING( sizeof(Unsigned_char_type) <= 2 ); - std::sort(first, last, comp); - } - - //Holds the bin vector and makes the initial recursive call - template <class RandomAccessIter, class Get_char, class Get_length, - class Compare, class Unsigned_char_type> - inline typename boost::enable_if_c< sizeof(Unsigned_char_type) <= 2, void - >::type - reverse_string_sort(RandomAccessIter first, RandomAccessIter last, - Get_char get_character, Get_length length, Compare comp, Unsigned_char_type) - { - size_t bin_sizes[(1 << (8 * sizeof(Unsigned_char_type))) + 1]; - std::vector<RandomAccessIter> bin_cache; - reverse_string_sort_rec<RandomAccessIter, Unsigned_char_type, Get_char, - Get_length, Compare> - (first, last, 0, bin_cache, 0, bin_sizes, get_character, length, comp); - } - - template <class RandomAccessIter, class Get_char, class Get_length, - class Compare, class Unsigned_char_type> - inline typename boost::disable_if_c< sizeof(Unsigned_char_type) <= 2, void - >::type - reverse_string_sort(RandomAccessIter first, RandomAccessIter last, - Get_char get_character, Get_length length, Compare comp, Unsigned_char_type) - { - //Warning that we're using std::sort, even though string_sort was called - BOOST_STATIC_WARNING( sizeof(Unsigned_char_type) <= 2 ); - std::sort(first, last, comp); - } - } -} -} -} - -#endif diff --git a/contrib/restricted/boost/boost/sort/spreadsort/float_sort.hpp b/contrib/restricted/boost/boost/sort/spreadsort/float_sort.hpp deleted file mode 100644 index d5310d19ce3..00000000000 --- a/contrib/restricted/boost/boost/sort/spreadsort/float_sort.hpp +++ /dev/null @@ -1,176 +0,0 @@ -//Templated Spreadsort-based implementation of float_sort and float_mem_cast - -// Copyright Steven J. Ross 2001 - 2014. -// Distributed under the 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://www.boost.org/libs/sort/ for library home page. - -/* -Some improvements suggested by: -Phil Endecott and Frank Gennari -float_mem_cast fix provided by: -Scott McMurray -*/ - -#ifndef BOOST_FLOAT_SORT_HPP -#define BOOST_FLOAT_SORT_HPP -#include <algorithm> -#include <vector> -#include <cstring> -#include <limits> -#include <boost/static_assert.hpp> -#include <boost/sort/spreadsort/detail/constants.hpp> -#include <boost/sort/spreadsort/detail/float_sort.hpp> -#include <boost/range/begin.hpp> -#include <boost/range/end.hpp> - -namespace boost { -namespace sort { -namespace spreadsort { - - /*! - \brief Casts a float to the specified integer type. - - \tparam Data_type Floating-point IEEE 754/IEC559 type. - \tparam Cast_type Integer type (same size) to which to cast. - - \par Example: - \code - struct rightshift { - int operator()(const DATA_TYPE &x, const unsigned offset) const { - return float_mem_cast<KEY_TYPE, CAST_TYPE>(x.key) >> offset; - } - }; - \endcode - */ - template<class Data_type, class Cast_type> - inline Cast_type - float_mem_cast(const Data_type & data) - { - // Only cast IEEE floating-point numbers, and only to a same-sized integer. - BOOST_STATIC_ASSERT(sizeof(Cast_type) == sizeof(Data_type)); - BOOST_STATIC_ASSERT(std::numeric_limits<Data_type>::is_iec559); - BOOST_STATIC_ASSERT(std::numeric_limits<Cast_type>::is_integer); - Cast_type result; - std::memcpy(&result, &data, sizeof(Cast_type)); - return result; - } - - - /*! - \brief @c float_sort with casting to the appropriate size. - - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - -Some performance plots of runtime vs. n and log(range) are provided:\n - <a href="../../doc/graph/windows_float_sort.htm"> windows_float_sort</a> - \n - <a href="../../doc/graph/osx_float_sort.htm"> osx_float_sort</a> - - - - \par A simple example of sorting some floating-point is: - \code - vector<float> vec; - vec.push_back(1.0); - vec.push_back(2.3); - vec.push_back(1.3); - spreadsort(vec.begin(), vec.end()); - \endcode - \par The sorted vector contains ascending values "1.0 1.3 2.3". - - */ - template <class RandomAccessIter> - inline void float_sort(RandomAccessIter first, RandomAccessIter last) - { - if (last - first < detail::min_sort_size) - std::sort(first, last); - else - detail::float_sort(first, last); - } - - /*! - \brief Floating-point sort algorithm using range. - - \param[in] range Range [first, last) for sorting. - - */ - template <class Range> - inline void float_sort(Range& range) - { - float_sort(boost::begin(range), boost::end(range)); - } - - /*! - \brief Floating-point sort algorithm using random access iterators with just right-shift functor. - - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - \param[in] rshift Functor that returns the result of shifting the value_type right a specified number of bits. - - */ - template <class RandomAccessIter, class Right_shift> - inline void float_sort(RandomAccessIter first, RandomAccessIter last, - Right_shift rshift) - { - if (last - first < detail::min_sort_size) - std::sort(first, last); - else - detail::float_sort(first, last, rshift(*first, 0), rshift); - } - - /*! - \brief Floating-point sort algorithm using range with just right-shift functor. - - \param[in] range Range [first, last) for sorting. - \param[in] rshift Functor that returns the result of shifting the value_type right a specified number of bits. - - */ - template <class Range, class Right_shift> - inline void float_sort(Range& range, Right_shift rshift) - { - float_sort(boost::begin(range), boost::end(range), rshift); - } - - - /*! - \brief Float sort algorithm using random access iterators with both right-shift and user-defined comparison operator. - - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - \param[in] rshift Functor that returns the result of shifting the value_type right a specified number of bits. - \param[in] comp A binary functor that returns whether the first element passed to it should go before the second in order. - */ - - template <class RandomAccessIter, class Right_shift, class Compare> - inline void float_sort(RandomAccessIter first, RandomAccessIter last, - Right_shift rshift, Compare comp) - { - if (last - first < detail::min_sort_size) - std::sort(first, last, comp); - else - detail::float_sort(first, last, rshift(*first, 0), rshift, comp); - } - - - /*! - \brief Float sort algorithm using range with both right-shift and user-defined comparison operator. - - \param[in] range Range [first, last) for sorting. - \param[in] rshift Functor that returns the result of shifting the value_type right a specified number of bits. - \param[in] comp A binary functor that returns whether the first element passed to it should go before the second in order. - */ - - template <class Range, class Right_shift, class Compare> - inline void float_sort(Range& range, Right_shift rshift, Compare comp) - { - float_sort(boost::begin(range), boost::end(range), rshift, comp); - } -} -} -} - -#endif diff --git a/contrib/restricted/boost/boost/sort/spreadsort/integer_sort.hpp b/contrib/restricted/boost/boost/sort/spreadsort/integer_sort.hpp deleted file mode 100644 index 6bf3f683e1d..00000000000 --- a/contrib/restricted/boost/boost/sort/spreadsort/integer_sort.hpp +++ /dev/null @@ -1,315 +0,0 @@ -//Templated Spreadsort-based implementation of integer_sort - -// Copyright Steven J. Ross 2001 - 2014. -// Distributed under the 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://www.boost.org/libs/sort/ for library home page. - -/* -Some improvements suggested by: -Phil Endecott and Frank Gennari - -Doxygen comments by Paul A. Bristow Jan 2015 - -*/ - -#ifndef BOOST_INTEGER_SORT_HPP -#define BOOST_INTEGER_SORT_HPP -#include <algorithm> -#include <vector> -#include <cstring> -#include <limits> -#include <boost/static_assert.hpp> -#include <boost/sort/spreadsort/detail/constants.hpp> -#include <boost/sort/spreadsort/detail/integer_sort.hpp> -#include <boost/range/begin.hpp> -#include <boost/range/end.hpp> - -namespace boost { -namespace sort { -namespace spreadsort { - //Top-level sorting call for integers. - - -/*! \brief Integer sort algorithm using random access iterators. - (All variants fall back to @c std::sort if the data size is too small, < @c detail::min_sort_size). - - \details @c integer_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c integer_sort is asymptotically faster -than pure comparison-based algorithms. @c s is @c max_splits, which defaults to 11, -so its worst-case with default settings for 32-bit integers is -<em> O(N * ((32/11) </em> slow radix-based iterations fast comparison-based iterations).\n\n -Some performance plots of runtime vs. n and log(range) are provided:\n - <a href="../../doc/graph/windows_integer_sort.htm"> windows_integer_sort</a> - \n - <a href="../../doc/graph/osx_integer_sort.htm"> osx_integer_sort</a> - - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - - \pre [@c first, @c last) is a valid range. - \pre @c RandomAccessIter @c value_type is mutable. - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable">LessThanComparable</a> - \pre @c RandomAccessIter @c value_type supports the @c operator>>, - which returns an integer-type right-shifted a specified number of bits. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). - -*/ - template <class RandomAccessIter> - inline void integer_sort(RandomAccessIter first, RandomAccessIter last) - { - // Don't sort if it's too small to optimize. - if (last - first < detail::min_sort_size) - std::sort(first, last); - else - detail::integer_sort(first, last, *first >> 0); - } - -/*! \brief Integer sort algorithm using range. - (All variants fall back to @c std::sort if the data size is too small, < @c detail::min_sort_size). - - \details @c integer_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c integer_sort is asymptotically faster -than pure comparison-based algorithms. @c s is @c max_splits, which defaults to 11, -so its worst-case with default settings for 32-bit integers is -<em> O(N * ((32/11) </em> slow radix-based iterations fast comparison-based iterations).\n\n -Some performance plots of runtime vs. n and log(range) are provided:\n - <a href="../../doc/graph/windows_integer_sort.htm"> windows_integer_sort</a> - \n - <a href="../../doc/graph/osx_integer_sort.htm"> osx_integer_sort</a> - - \param[in] range Range [first, last) for sorting. - - \pre [@c first, @c last) is a valid range. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). - -*/ -template <class Range> -inline void integer_sort(Range& range) -{ - integer_sort(boost::begin(range), boost::end(range)); -} - -/*! \brief Integer sort algorithm using random access iterators with both right-shift and user-defined comparison operator. - (All variants fall back to @c std::sort if the data size is too small, < @c detail::min_sort_size). - - \details @c integer_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c integer_sort is asymptotically faster -than pure comparison-based algorithms. @c s is @c max_splits, which defaults to 11, -so its worst-case with default settings for 32-bit integers is -<em> O(N * ((32/11) </em> slow radix-based iterations fast comparison-based iterations).\n\n -Some performance plots of runtime vs. n and log(range) are provided:\n - <a href="../../doc/graph/windows_integer_sort.htm"> windows_integer_sort</a> - \n - <a href="../../doc/graph/osx_integer_sort.htm"> osx_integer_sort</a> - - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - \param[in] shift Functor that returns the result of shifting the value_type right a specified number of bits. - \param[in] comp A binary functor that returns whether the first element passed to it should go before the second in order. - - \pre [@c first, @c last) is a valid range. - \pre @c RandomAccessIter @c value_type is mutable. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \return @c void. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, - or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). -*/ - template <class RandomAccessIter, class Right_shift, class Compare> - inline void integer_sort(RandomAccessIter first, RandomAccessIter last, - Right_shift shift, Compare comp) { - if (last - first < detail::min_sort_size) - std::sort(first, last, comp); - else - detail::integer_sort(first, last, shift(*first, 0), shift, comp); - } - -/*! \brief Integer sort algorithm using range with both right-shift and user-defined comparison operator. - (All variants fall back to @c std::sort if the data size is too small, < @c detail::min_sort_size). - - \details @c integer_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c integer_sort is asymptotically faster -than pure comparison-based algorithms. @c s is @c max_splits, which defaults to 11, -so its worst-case with default settings for 32-bit integers is -<em> O(N * ((32/11) </em> slow radix-based iterations fast comparison-based iterations).\n\n -Some performance plots of runtime vs. n and log(range) are provided:\n - <a href="../../doc/graph/windows_integer_sort.htm"> windows_integer_sort</a> - \n - <a href="../../doc/graph/osx_integer_sort.htm"> osx_integer_sort</a> - - \param[in] range Range [first, last) for sorting. - \param[in] shift Functor that returns the result of shifting the value_type right a specified number of bits. - \param[in] comp A binary functor that returns whether the first element passed to it should go before the second in order. - - \pre [@c first, @c last) is a valid range. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \return @c void. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, - or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). -*/ -template <class Range, class Right_shift, class Compare> -inline void integer_sort(Range& range, Right_shift shift, Compare comp) -{ - integer_sort(boost::begin(range), boost::end(range), shift, comp); -} - -/*! \brief Integer sort algorithm using random access iterators with just right-shift functor. - (All variants fall back to @c std::sort if the data size is too small, < @c detail::min_sort_size). - - \details @c integer_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n - -\par Performance: -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c integer_sort is asymptotically faster -than pure comparison-based algorithms. @c s is @c max_splits, which defaults to 11, -so its worst-case with default settings for 32-bit integers is -<em> O(N * ((32/11) </em> slow radix-based iterations fast comparison-based iterations).\n\n -Some performance plots of runtime vs. n and log(range) are provided:\n - * <a href="../../doc/graph/windows_integer_sort.htm"> windows_integer_sort</a>\n - * <a href="../../doc/graph/osx_integer_sort.htm"> osx_integer_sort</a> - - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - \param[in] shift A functor that returns the result of shifting the value_type right a specified number of bits. - - \pre [@c first, @c last) is a valid range. - \pre @c RandomAccessIter @c value_type is mutable. - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable">LessThanComparable</a> - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, - or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). - -*/ - template <class RandomAccessIter, class Right_shift> - inline void integer_sort(RandomAccessIter first, RandomAccessIter last, - Right_shift shift) { - if (last - first < detail::min_sort_size) - std::sort(first, last); - else - detail::integer_sort(first, last, shift(*first, 0), shift); - } - - -/*! \brief Integer sort algorithm using range with just right-shift functor. - (All variants fall back to @c std::sort if the data size is too small, < @c detail::min_sort_size). - - \details @c integer_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n - -\par Performance: -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c integer_sort is asymptotically faster -than pure comparison-based algorithms. @c s is @c max_splits, which defaults to 11, -so its worst-case with default settings for 32-bit integers is -<em> O(N * ((32/11) </em> slow radix-based iterations fast comparison-based iterations).\n\n -Some performance plots of runtime vs. n and log(range) are provided:\n - * <a href="../../doc/graph/windows_integer_sort.htm"> windows_integer_sort</a>\n - * <a href="../../doc/graph/osx_integer_sort.htm"> osx_integer_sort</a> - - \param[in] range Range [first, last) for sorting. - \param[in] shift A functor that returns the result of shifting the value_type right a specified number of bits. - - \pre [@c first, @c last) is a valid range. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, - or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). - -*/ -template <class Range, class Right_shift> -inline void integer_sort(Range& range, Right_shift shift) -{ - integer_sort(boost::begin(range), boost::end(range), shift); -} -} -} -} - -#endif - diff --git a/contrib/restricted/boost/boost/sort/spreadsort/spreadsort.hpp b/contrib/restricted/boost/boost/sort/spreadsort/spreadsort.hpp deleted file mode 100644 index 49f20ed147a..00000000000 --- a/contrib/restricted/boost/boost/sort/spreadsort/spreadsort.hpp +++ /dev/null @@ -1,169 +0,0 @@ -// Templated generic hybrid sorting - -// Copyright Steven J. Ross 2001 - 2009. -// Distributed under the 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://www.boost.org/libs/sort/ for library home page. - -/* -Some improvements suggested by: -Phil Endecott and Frank Gennari -float_mem_cast fix provided by: -Scott McMurray - Range support provided by: - Alexander Zaitsev -*/ - -#ifndef BOOST_SORT_SPREADSORT_HPP -#define BOOST_SORT_SPREADSORT_HPP -#include <algorithm> -#include <vector> -#include <cstring> -#include <string> -#include <limits> -#include <boost/type_traits.hpp> -#include <boost/sort/spreadsort/integer_sort.hpp> -#include <boost/sort/spreadsort/float_sort.hpp> -#include <boost/sort/spreadsort/string_sort.hpp> -#include <boost/range/begin.hpp> -#include <boost/range/end.hpp> - -namespace boost { -namespace sort { - -/*! Namespace for spreadsort sort variants for different data types. -\note Use hyperlinks (coloured) to get detailed information about functions. -*/ -namespace spreadsort { - - /*! - \brief Generic @c spreadsort variant detecting integer-type elements so call to @c integer_sort. - \details If the data type provided is an integer, @c integer_sort is used. - \note Sorting other data types requires picking between @c integer_sort, @c float_sort and @c string_sort directly, - as @c spreadsort won't accept types that don't have the appropriate @c type_traits. - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - - \pre [@c first, @c last) is a valid range. - \pre @c RandomAccessIter @c value_type is mutable. - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable">LessThanComparable</a> - \pre @c RandomAccessIter @c value_type supports the @c operator>>, - which returns an integer-type right-shifted a specified number of bits. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - */ - - template <class RandomAccessIter> - inline typename boost::enable_if_c< std::numeric_limits< - typename std::iterator_traits<RandomAccessIter>::value_type >::is_integer, - void >::type - spreadsort(RandomAccessIter first, RandomAccessIter last) - { - integer_sort(first, last); - } - - /*! - \brief Generic @c spreadsort variant detecting float element type so call to @c float_sort. - \details If the data type provided is a float or castable-float, @c float_sort is used. - \note Sorting other data types requires picking between @c integer_sort, @c float_sort and @c string_sort directly, - as @c spreadsort won't accept types that don't have the appropriate @c type_traits. - - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - - \pre [@c first, @c last) is a valid range. - \pre @c RandomAccessIter @c value_type is mutable. - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable">LessThanComparable</a> - \pre @c RandomAccessIter @c value_type supports the @c operator>>, - which returns an integer-type right-shifted a specified number of bits. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - */ - - template <class RandomAccessIter> - inline typename boost::enable_if_c< !std::numeric_limits< - typename std::iterator_traits<RandomAccessIter>::value_type >::is_integer - && std::numeric_limits< - typename std::iterator_traits<RandomAccessIter>::value_type >::is_iec559, - void >::type - spreadsort(RandomAccessIter first, RandomAccessIter last) - { - float_sort(first, last); - } - - /*! - \brief Generic @c spreadsort variant detecting string element type so call to @c string_sort for @c std::strings. - \details If the data type provided is a string, @c string_sort is used. - \note Sorting other data types requires picking between @c integer_sort, @c float_sort and @c string_sort directly, - as @c spreadsort won't accept types that don't have the appropriate @c type_traits. - - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - - \pre [@c first, @c last) is a valid range. - \pre @c RandomAccessIter @c value_type is mutable. - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable">LessThanComparable</a> - \pre @c RandomAccessIter @c value_type supports the @c operator>>, - which returns an integer-type right-shifted a specified number of bits. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - */ - - template <class RandomAccessIter> - inline typename boost::enable_if_c< - is_same<typename std::iterator_traits<RandomAccessIter>::value_type, - typename std::string>::value, void >::type - spreadsort(RandomAccessIter first, RandomAccessIter last) - { - string_sort(first, last); - } - - /*! - \brief Generic @c spreadsort variant detecting string element type so call to @c string_sort for @c std::wstrings. - \details If the data type provided is a wstring, @c string_sort is used. - \note Sorting other data types requires picking between @c integer_sort, @c float_sort and @c string_sort directly, - as @c spreadsort won't accept types that don't have the appropriate @c type_traits. Also, 2-byte wide-characters are the limit above which string_sort is inefficient, so on platforms with wider characters, this will not accept wstrings. - - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - - \pre [@c first, @c last) is a valid range. - \pre @c RandomAccessIter @c value_type is mutable. - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable">LessThanComparable</a> - \pre @c RandomAccessIter @c value_type supports the @c operator>>, - which returns an integer-type right-shifted a specified number of bits. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - */ - template <class RandomAccessIter> - inline typename boost::enable_if_c< - is_same<typename std::iterator_traits<RandomAccessIter>::value_type, - typename std::wstring>::value && - sizeof(wchar_t) == 2, void >::type - spreadsort(RandomAccessIter first, RandomAccessIter last) - { - boost::uint16_t unused = 0; - string_sort(first, last, unused); - } - -/*! -\brief Generic @c spreadsort variant detects value_type and calls required sort function. -\note Sorting other data types requires picking between @c integer_sort, @c float_sort and @c string_sort directly, -as @c spreadsort won't accept types that don't have the appropriate @c type_traits. - -\param[in] range Range [first, last) for sorting. - -\pre [@c first, @c last) is a valid range. -\post The elements in the range [@c first, @c last) are sorted in ascending order. -*/ - -template <class Range> -void spreadsort(Range& range) -{ - spreadsort(boost::begin(range), boost::end(range)); -} - - -} // namespace spreadsort -} // namespace sort -} // namespace boost - -#endif diff --git a/contrib/restricted/boost/boost/sort/spreadsort/string_sort.hpp b/contrib/restricted/boost/boost/sort/spreadsort/string_sort.hpp deleted file mode 100644 index daaa054b6c9..00000000000 --- a/contrib/restricted/boost/boost/sort/spreadsort/string_sort.hpp +++ /dev/null @@ -1,741 +0,0 @@ -//Templated hybrid string_sort - -// Copyright Steven J. Ross 2001 - 2009. -// Distributed under the 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://www.boost.org/libs/sort/ for library home page. - -/* -Some improvements suggested by: -Phil Endecott and Frank Gennari -*/ - -#ifndef BOOST_STRING_SORT_HPP -#define BOOST_STRING_SORT_HPP -#include <algorithm> -#include <vector> -#include <cstring> -#include <limits> -#include <boost/static_assert.hpp> -#include <boost/sort/spreadsort/detail/constants.hpp> -#include <boost/sort/spreadsort/detail/string_sort.hpp> -#include <boost/range/begin.hpp> -#include <boost/range/end.hpp> - -namespace boost { -namespace sort { -namespace spreadsort { - -/*! \brief String sort algorithm using random access iterators, allowing character-type overloads.\n - (All variants fall back to @c std::sort if the data size is too small, < @c detail::min_sort_size). - - \details @c string_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n -\par -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c string_sort is asymptotically faster -than pure comparison-based algorithms. \n\n -Some performance plots of runtime vs. n and log(range) are provided:\n -<a href="../../doc/graph/windows_string_sort.htm"> windows_string_sort</a>\n -<a href="../../doc/graph/osx_string_sort.htm"> osx_string_sort</a> - - \tparam RandomAccessIter <a href="http://www.cplusplus.com/reference/iterator/RandomAccessIterator/">Random access iterator</a> - \tparam Unsigned_char_type Unsigned character type used for string. - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - \param[in] unused value with the same type as the result of the [] operator, defining the Unsigned_char_type. The actual value is unused. - - \pre [@c first, @c last) is a valid range. - \pre @c RandomAccessIter @c value_type is mutable. - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable">LessThanComparable</a> - \pre @c RandomAccessIter @c value_type supports the @c operator>>, - which returns an integer-type right-shifted a specified number of bits. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, - or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). - -*/ - - template <class RandomAccessIter, class Unsigned_char_type> - inline void string_sort(RandomAccessIter first, RandomAccessIter last, - Unsigned_char_type unused) - { - //Don't sort if it's too small to optimize - if (last - first < detail::min_sort_size) - std::sort(first, last); - else - detail::string_sort(first, last, unused); - } - -/*! \brief String sort algorithm using range, allowing character-type overloads.\n - (All variants fall back to @c std::sort if the data size is too small, < @c detail::min_sort_size). - - \details @c string_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n -\par -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c string_sort is asymptotically faster -than pure comparison-based algorithms. \n\n -Some performance plots of runtime vs. n and log(range) are provided:\n -<a href="../../doc/graph/windows_string_sort.htm"> windows_string_sort</a>\n -<a href="../../doc/graph/osx_string_sort.htm"> osx_string_sort</a> - - \tparam Unsigned_char_type Unsigned character type used for string. - \param[in] range Range [first, last) for sorting. - \param[in] unused value with the same type as the result of the [] operator, defining the Unsigned_char_type. The actual value is unused. - - \pre [@c first, @c last) is a valid range. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, - or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). - -*/ - -template <class Range, class Unsigned_char_type> -inline void string_sort(Range& range, Unsigned_char_type unused) -{ - string_sort(boost::begin(range), boost::end(range), unused); -} - -/*! \brief String sort algorithm using random access iterators, wraps using default of unsigned char. - (All variants fall back to @c std::sort if the data size is too small, < @c detail::min_sort_size). - - \details @c string_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c string_sort is asymptotically faster -than pure comparison-based algorithms. \n\n -Some performance plots of runtime vs. n and log(range) are provided:\n - <a href="../../doc/graph/windows_string_sort.htm"> windows_string_sort</a> - \n - <a href="../../doc/graph/osx_string_sort.htm"> osx_string_sort</a> - - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - - \pre [@c first, @c last) is a valid range. - \pre @c RandomAccessIter @c value_type is mutable. - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable">LessThanComparable</a> - \pre @c RandomAccessIter @c value_type supports the @c operator>>, - which returns an integer-type right-shifted a specified number of bits. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, - or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). - -*/ - template <class RandomAccessIter> - inline void string_sort(RandomAccessIter first, RandomAccessIter last) - { - unsigned char unused = '\0'; - string_sort(first, last, unused); - } - -/*! \brief String sort algorithm using range, wraps using default of unsigned char. - (All variants fall back to @c std::sort if the data size is too small, < @c detail::min_sort_size). - - \details @c string_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c string_sort is asymptotically faster -than pure comparison-based algorithms. \n\n -Some performance plots of runtime vs. n and log(range) are provided:\n - <a href="../../doc/graph/windows_string_sort.htm"> windows_string_sort</a> - \n - <a href="../../doc/graph/osx_string_sort.htm"> osx_string_sort</a> - - \param[in] range Range [first, last) for sorting. - - \pre [@c first, @c last) is a valid range. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, - or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). - -*/ -template <class Range> -inline void string_sort(Range& range) -{ - string_sort(boost::begin(range), boost::end(range)); -} - -/*! \brief String sort algorithm using random access iterators, allowing character-type overloads. - - (All variants fall back to @c std::sort if the data size is too small, < detail::min_sort_size). - - \details @c string_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n -\par -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c string_sort is asymptotically faster -than pure comparison-based algorithms. \n\n -Some performance plots of runtime vs. n and log(range) are provided:\n -<a href="../../doc/graph/windows_string_sort.htm"> windows_string_sort</a>\n -<a href="../../doc/graph/osx_string_sort.htm"> osx_string_sort</a> - - - \tparam RandomAccessIter <a href="http://www.cplusplus.com/reference/iterator/RandomAccessIterator/">Random access iterator</a> - \tparam Comp Functor type to use for comparison. - \tparam Unsigned_char_type Unsigned character type used for string. - - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - \param[in] comp A binary functor that returns whether the first element passed to it should go before the second in order. - \param[in] unused value with the same type as the result of the [] operator, defining the Unsigned_char_type. The actual value is unused. - - \pre [@c first, @c last) is a valid range. - \pre @c RandomAccessIter @c value_type is mutable. - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable">LessThanComparable</a> - \pre @c RandomAccessIter @c value_type supports the @c operator>>, - which returns an integer-type right-shifted a specified number of bits. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \return @c void. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, - or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). -*/ - template <class RandomAccessIter, class Compare, class Unsigned_char_type> - inline void reverse_string_sort(RandomAccessIter first, - RandomAccessIter last, Compare comp, Unsigned_char_type unused) - { - //Don't sort if it's too small to optimize. - if (last - first < detail::min_sort_size) - std::sort(first, last, comp); - else - detail::reverse_string_sort(first, last, unused); - } - -/*! \brief String sort algorithm using range, allowing character-type overloads. - - (All variants fall back to @c std::sort if the data size is too small, < detail::min_sort_size). - - \details @c string_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c string_sort is asymptotically faster -than pure comparison-based algorithms. \n\n -Some performance plots of runtime vs. n and log(range) are provided:\n - <a href="../../doc/graph/windows_integer_sort.htm"> windows_integer_sort</a> - \n - <a href="../../doc/graph/osx_integer_sort.htm"> osx_integer_sort</a> - - - \tparam Comp Functor type to use for comparison. - \tparam Unsigned_char_type Unsigned character type used for string. - - \param[in] range Range [first, last) for sorting. - \param[in] comp A binary functor that returns whether the first element passed to it should go before the second in order. - \param[in] unused value with the same type as the result of the [] operator, defining the Unsigned_char_type. The actual value is unused. - - \pre [@c first, @c last) is a valid range. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \return @c void. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, - or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). -*/ -template <class Range, class Compare, class Unsigned_char_type> -inline void reverse_string_sort(Range& range, Compare comp, Unsigned_char_type unused) -{ - reverse_string_sort(boost::begin(range), boost::end(range), comp, unused); -} - -/*! \brief String sort algorithm using random access iterators, wraps using default of @c unsigned char. - - (All variants fall back to @c std::sort if the data size is too small, < @c detail::min_sort_size). - - \details @c string_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n -\par -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c string_sort is asymptotically faster -than pure comparison-based algorithms.\n\n -Some performance plots of runtime vs. n and log(range) are provided:\n -<a href="../../doc/graph/windows_string_sort.htm"> windows_string_sort</a>\n -<a href="../../doc/graph/osx_string_sort.htm"> osx_string_sort</a> - - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - \param[in] comp A binary functor that returns whether the first element passed to it should go before the second in order. - - \pre [@c first, @c last) is a valid range. - \pre @c RandomAccessIter @c value_type is mutable. - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable">LessThanComparable</a> - \pre @c RandomAccessIter @c value_type supports the @c operator>>, - which returns an integer-type right-shifted a specified number of bits. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \return @c void. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, - or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). -*/ - template <class RandomAccessIter, class Compare> - inline void reverse_string_sort(RandomAccessIter first, - RandomAccessIter last, Compare comp) - { - unsigned char unused = '\0'; - reverse_string_sort(first, last, comp, unused); - } - -/*! \brief String sort algorithm using range, wraps using default of @c unsigned char. - - (All variants fall back to @c std::sort if the data size is too small, < @c detail::min_sort_size). - - \details @c string_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n -\par -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c string_sort is asymptotically faster -than pure comparison-based algorithms. \n\n -Some performance plots of runtime vs. n and log(range) are provided:\n -<a href="../../doc/graph/windows_string_sort.htm"> windows_string_sort</a>\n -<a href="../../doc/graph/osx_string_sort.htm"> osx_string_sort</a> - - \param[in] range Range [first, last) for sorting. - \param[in] comp A binary functor that returns whether the first element passed to it should go before the second in order. - - \pre [@c first, @c last) is a valid range. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \return @c void. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, - or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). -*/ -template <class Range, class Compare> -inline void reverse_string_sort(Range& range, Compare comp) -{ - reverse_string_sort(boost::begin(range), boost::end(range), comp); -} - -/*! \brief String sort algorithm using random access iterators, wraps using default of @c unsigned char. - - (All variants fall back to @c std::sort if the data size is too small, < @c detail::min_sort_size). - - \details @c string_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n -\par -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c string_sort is asymptotically faster -than pure comparison-based algorithms. \n\n -Some performance plots of runtime vs. n and log(range) are provided:\n -<a href="../../doc/graph/windows_string_sort.htm"> windows_string_sort</a>\n -<a href="../../doc/graph/osx_string_sort.htm"> osx_string_sort</a> - - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - \param[in] get_character Bracket functor equivalent to @c operator[], taking a number corresponding to the character offset. - \param[in] length Functor to get the length of the string in characters. - - \pre [@c first, @c last) is a valid range. - \pre @c RandomAccessIter @c value_type is mutable. - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable">LessThanComparable</a> - \pre @c RandomAccessIter @c value_type supports the @c operator>>, - which returns an integer-type right-shifted a specified number of bits. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \return @c void. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, - or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). - -*/ - template <class RandomAccessIter, class Get_char, class Get_length> - inline void string_sort(RandomAccessIter first, RandomAccessIter last, - Get_char get_character, Get_length length) - { - //Don't sort if it's too small to optimize - if (last - first < detail::min_sort_size) - std::sort(first, last); - else { - //skipping past empties, which allows us to get the character type - //.empty() is not used so as not to require a user declaration of it - while (!length(*first)) { - if (++first == last) - return; - } - detail::string_sort(first, last, get_character, length, get_character((*first), 0)); - } - } - -/*! \brief String sort algorithm using range, wraps using default of @c unsigned char. - - (All variants fall back to @c std::sort if the data size is too small, < @c detail::min_sort_size). - - \details @c string_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n -\par -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c string_sort is asymptotically faster -than pure comparison-based algorithms. \n\n -Some performance plots of runtime vs. n and log(range) are provided:\n -<a href="../../doc/graph/windows_string_sort.htm"> windows_string_sort</a>\n -<a href="../../doc/graph/osx_string_sort.htm"> osx_string_sort</a> - - \param[in] range Range [first, last) for sorting. - \param[in] get_character Bracket functor equivalent to @c operator[], taking a number corresponding to the character offset. - \param[in] length Functor to get the length of the string in characters. - - \pre [@c first, @c last) is a valid range. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \return @c void. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, - or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). - -*/ -template <class Range, class Get_char, class Get_length> -inline void string_sort(Range& range, Get_char get_character, Get_length length) -{ - string_sort(boost::begin(range), boost::end(range), get_character, length); -} - - -/*! \brief String sort algorithm using random access iterators, wraps using default of @c unsigned char. - - (All variants fall back to @c std::sort if the data size is too small, < @c detail::min_sort_size). - - \details @c string_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n -\par -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c string_sort is asymptotically faster -than pure comparison-based algorithms. \n\n -Some performance plots of runtime vs. n and log(range) are provided:\n -<a href="../../doc/graph/windows_string_sort.htm"> windows_string_sort</a>\n -<a href="../../doc/graph/osx_string_sort.htm"> osx_string_sort</a> - - - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - \param[in] get_character Bracket functor equivalent to @c operator[], taking a number corresponding to the character offset. - \param[in] length Functor to get the length of the string in characters. - \param[in] comp A binary functor that returns whether the first element passed to it should go before the second in order. - - - \pre [@c first, @c last) is a valid range. - \pre @c RandomAccessIter @c value_type is mutable. - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable">LessThanComparable</a> - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \return @c void. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, - or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). - -*/ - template <class RandomAccessIter, class Get_char, class Get_length, - class Compare> - inline void string_sort(RandomAccessIter first, RandomAccessIter last, - Get_char get_character, Get_length length, Compare comp) - { - //Don't sort if it's too small to optimize - if (last - first < detail::min_sort_size) - std::sort(first, last, comp); - else { - //skipping past empties, which allows us to get the character type - //.empty() is not used so as not to require a user declaration of it - while (!length(*first)) { - if (++first == last) - return; - } - detail::string_sort(first, last, get_character, length, comp, - get_character((*first), 0)); - } - } - -/*! \brief String sort algorithm using range, wraps using default of @c unsigned char. - - (All variants fall back to @c std::sort if the data size is too small, < @c detail::min_sort_size). - - \details @c string_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n -\par -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c string_sort is asymptotically faster -than pure comparison-based algorithms. \n\n -Some performance plots of runtime vs. n and log(range) are provided:\n -<a href="../../doc/graph/windows_string_sort.htm"> windows_string_sort</a>\n -<a href="../../doc/graph/osx_string_sort.htm"> osx_string_sort</a> - - - \param[in] range Range [first, last) for sorting. - \param[in] get_character Bracket functor equivalent to @c operator[], taking a number corresponding to the character offset. - \param[in] length Functor to get the length of the string in characters. - \param[in] comp A binary functor that returns whether the first element passed to it should go before the second in order. - - - \pre [@c first, @c last) is a valid range. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \return @c void. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, - or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). - -*/ -template <class Range, class Get_char, class Get_length, class Compare> -inline void string_sort(Range& range, - Get_char get_character, Get_length length, Compare comp) -{ - string_sort(boost::begin(range), boost::end(range), get_character, length, comp); -} - -/*! \brief Reverse String sort algorithm using random access iterators. - - (All variants fall back to @c std::sort if the data size is too small, < @c detail::min_sort_size). - - \details @c string_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n -\par -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c string_sort is asymptotically faster -than pure comparison-based algorithms. \n\n -Some performance plots of runtime vs. n and log(range) are provided:\n -<a href="../../doc/graph/windows_string_sort.htm"> windows_string_sort</a>\n -<a href="../../doc/graph/osx_string_sort.htm"> osx_string_sort</a> - - - \param[in] first Iterator pointer to first element. - \param[in] last Iterator pointing to one beyond the end of data. - \param[in] get_character Bracket functor equivalent to @c operator[], taking a number corresponding to the character offset. - \param[in] length Functor to get the length of the string in characters. - \param[in] comp A binary functor that returns whether the first element passed to it should go before the second in order. - - - \pre [@c first, @c last) is a valid range. - \pre @c RandomAccessIter @c value_type is mutable. - \pre @c RandomAccessIter @c value_type is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable">LessThanComparable</a> - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \return @c void. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, - or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). - -*/ - template <class RandomAccessIter, class Get_char, class Get_length, - class Compare> - inline void reverse_string_sort(RandomAccessIter first, - RandomAccessIter last, Get_char get_character, Get_length length, Compare comp) - { - //Don't sort if it's too small to optimize - if (last - first < detail::min_sort_size) - std::sort(first, last, comp); - else { - //skipping past empties, which allows us to get the character type - //.empty() is not used so as not to require a user declaration of it - while (!length(*(--last))) { - //If there is just one non-empty at the beginning, this is sorted - if (first == last) - return; - } - //making last just after the end of the non-empty part of the array - detail::reverse_string_sort(first, last + 1, get_character, length, comp, - get_character((*last), 0)); - } - } - -/*! \brief Reverse String sort algorithm using range. - - (All variants fall back to @c std::sort if the data size is too small, < @c detail::min_sort_size). - - \details @c string_sort is a fast templated in-place hybrid radix/comparison algorithm, -which in testing tends to be roughly 50% to 2X faster than @c std::sort for large tests (>=100kB).\n -\par -Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, -so @c string_sort is asymptotically faster -than pure comparison-based algorithms. \n\n -Some performance plots of runtime vs. n and log(range) are provided:\n -<a href="../../doc/graph/windows_string_sort.htm"> windows_string_sort</a>\n -<a href="../../doc/graph/osx_string_sort.htm"> osx_string_sort</a> - - - \param[in] range Range [first, last) for sorting. - \param[in] get_character Bracket functor equivalent to @c operator[], taking a number corresponding to the character offset. - \param[in] length Functor to get the length of the string in characters. - \param[in] comp A binary functor that returns whether the first element passed to it should go before the second in order. - - - \pre [@c first, @c last) is a valid range. - \post The elements in the range [@c first, @c last) are sorted in ascending order. - - \return @c void. - - \throws std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), - the right shift, subtraction of right-shifted elements, functors, - or any operations on iterators throw. - - \warning Throwing an exception may cause data loss. This will also throw if a small vector resize throws, in which case there will be no data loss. - \warning Invalid arguments cause undefined behaviour. - \note @c spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data type, - enabling faster generic-programming. - - \remark The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: - \remark * N is @c last - @c first, - \remark * K is the log of the range in bits (32 for 32-bit integers using their full range), - \remark * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size). - -*/ -template <class Range, class Get_char, class Get_length, - class Compare> -inline void reverse_string_sort(Range& range, Get_char get_character, Get_length length, Compare comp) -{ - reverse_string_sort(boost::begin(range), boost::end(range), get_character, length, comp); -} -} -} -} - -#endif diff --git a/contrib/restricted/boost/boost/statechart/asynchronous_state_machine.hpp b/contrib/restricted/boost/boost/statechart/asynchronous_state_machine.hpp deleted file mode 100644 index 4870457e76f..00000000000 --- a/contrib/restricted/boost/boost/statechart/asynchronous_state_machine.hpp +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef BOOST_STATECHART_ASYNCHRONOUS_STATE_MACHINE_HPP_INCLUDED -#define BOOST_STATECHART_ASYNCHRONOUS_STATE_MACHINE_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2006 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/state_machine.hpp> -#include <boost/statechart/fifo_scheduler.hpp> -#include <boost/statechart/null_exception_translator.hpp> -#include <boost/statechart/event_processor.hpp> - -#include <memory> // std::allocator - - -namespace boost -{ -namespace statechart -{ - - - -class event_base; - - - -////////////////////////////////////////////////////////////////////////////// -template< class MostDerived, - class InitialState, - class Scheduler = fifo_scheduler<>, - class Allocator = std::allocator< void >, - class ExceptionTranslator = null_exception_translator > -class asynchronous_state_machine : public state_machine< - MostDerived, InitialState, Allocator, ExceptionTranslator >, - public event_processor< Scheduler > -{ - typedef state_machine< MostDerived, - InitialState, Allocator, ExceptionTranslator > machine_base; - typedef event_processor< Scheduler > processor_base; - protected: - ////////////////////////////////////////////////////////////////////////// - typedef asynchronous_state_machine my_base; - - asynchronous_state_machine( typename processor_base::my_context ctx ) : - processor_base( ctx ) - { - } - - virtual ~asynchronous_state_machine() {} - - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - void terminate() - { - processor_base::terminate(); - } - - private: - ////////////////////////////////////////////////////////////////////////// - virtual void initiate_impl() - { - machine_base::initiate(); - } - - virtual void process_event_impl( const event_base & evt ) - { - machine_base::process_event( evt ); - } - - virtual void terminate_impl() - { - machine_base::terminate(); - } -}; - - - -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/custom_reaction.hpp b/contrib/restricted/boost/boost/statechart/custom_reaction.hpp deleted file mode 100644 index e143a4044ca..00000000000 --- a/contrib/restricted/boost/boost/statechart/custom_reaction.hpp +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef BOOST_STATECHART_CUSTOM_REACTION_HPP_INCLUDED -#define BOOST_STATECHART_CUSTOM_REACTION_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2006 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/result.hpp> - -#include <boost/polymorphic_cast.hpp> // boost::polymorphic_downcast - - - -namespace boost -{ -namespace statechart -{ - - - -class event_base; - -////////////////////////////////////////////////////////////////////////////// -template< class Event > -class custom_reaction -{ - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - template< class State, class EventBase, class IdType > - static detail::reaction_result react( - State & stt, const EventBase & evt, const IdType & eventType ) - { - if ( eventType == Event::static_type() ) - { - return detail::result_utility::get_result( - stt.react( *polymorphic_downcast< const Event * >( &evt ) ) ); - } - else - { - return detail::no_reaction; - } - } -}; - -template<> -class custom_reaction< event_base > -{ - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - template< class State, class EventBase, class IdType > - static detail::reaction_result react( - State & stt, const EventBase & evt, const IdType & ) - { - return detail::result_utility::get_result( stt.react( evt ) ); - } -}; - - - -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/deep_history.hpp b/contrib/restricted/boost/boost/statechart/deep_history.hpp deleted file mode 100644 index 4a108d047d4..00000000000 --- a/contrib/restricted/boost/boost/statechart/deep_history.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef BOOST_STATECHART_DEEP_HISTORY_HPP_INCLUDED -#define BOOST_STATECHART_DEEP_HISTORY_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2006 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/mpl/bool.hpp> -#include <boost/static_assert.hpp> - - - -namespace boost -{ -namespace statechart -{ - - - -////////////////////////////////////////////////////////////////////////////// -template< class DefaultState > -class deep_history -{ - public: - ////////////////////////////////////////////////////////////////////////// - // If you receive a - // "use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'" or similar - // compiler error here then you forgot to pass either - // statechart::has_deep_history or statechart::has_full_history as the - // last parameter of DefaultState's context. - BOOST_STATIC_ASSERT( DefaultState::context_type::deep_history::value ); - - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - typedef typename DefaultState::outermost_context_base_type - outermost_context_base_type; - typedef typename DefaultState::context_type context_type; - typedef typename DefaultState::context_ptr_type context_ptr_type; - typedef typename DefaultState::context_type_list context_type_list; - typedef typename DefaultState::orthogonal_position orthogonal_position; - - static void deep_construct( - const context_ptr_type & pContext, - outermost_context_base_type & outermostContextBase ) - { - outermostContextBase.template construct_with_deep_history< - DefaultState >( pContext ); - } -}; - - - -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/deferral.hpp b/contrib/restricted/boost/boost/statechart/deferral.hpp deleted file mode 100644 index 8bb6f7259d4..00000000000 --- a/contrib/restricted/boost/boost/statechart/deferral.hpp +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef BOOST_STATECHART_DEFERRAL_HPP_INCLUDED -#define BOOST_STATECHART_DEFERRAL_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2006 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/result.hpp> - - - -namespace boost -{ -namespace statechart -{ - - - -class event_base; - -////////////////////////////////////////////////////////////////////////////// -template< class Event > -class deferral -{ - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - template< class State, class EventBase, class IdType > - static detail::reaction_result react( - State & stt, const EventBase &, const IdType & eventType ) - { - if ( eventType == Event::static_type() ) - { - return detail::result_utility::get_result( stt.defer_event() ); - } - else - { - return detail::no_reaction; - } - } -}; - -template<> -class deferral< event_base > -{ - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - template< class State, class EventBase, class IdType > - static detail::reaction_result react( - State & stt, const EventBase &, const IdType & ) - { - return detail::result_utility::get_result( stt.defer_event() ); - } -}; - - - -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/detail/avoid_unused_warning.hpp b/contrib/restricted/boost/boost/statechart/detail/avoid_unused_warning.hpp deleted file mode 100644 index 1c002a46b14..00000000000 --- a/contrib/restricted/boost/boost/statechart/detail/avoid_unused_warning.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef BOOST_STATECHART_DETAIL_AVOID_UNUSED_WARNING_HPP_INCLUDED -#define BOOST_STATECHART_DETAIL_AVOID_UNUSED_WARNING_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2006 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -namespace boost -{ -namespace statechart -{ -namespace detail -{ - - - -template< typename T > -inline void avoid_unused_warning( const T & ) {} - - - -} // namespace detail -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/detail/constructor.hpp b/contrib/restricted/boost/boost/statechart/detail/constructor.hpp deleted file mode 100644 index 0cc317af2dd..00000000000 --- a/contrib/restricted/boost/boost/statechart/detail/constructor.hpp +++ /dev/null @@ -1,139 +0,0 @@ -#ifndef BOOST_STATECHART_DETAIL_CONSTRUCTOR_HPP_INCLUDED -#define BOOST_STATECHART_DETAIL_CONSTRUCTOR_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2006 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/mpl/eval_if.hpp> -#include <boost/mpl/identity.hpp> -#include <boost/mpl/equal_to.hpp> -#include <boost/mpl/size.hpp> -#include <boost/mpl/front.hpp> -#include <boost/mpl/advance.hpp> -#include <boost/mpl/find.hpp> -#include <boost/mpl/push_front.hpp> -#include <boost/mpl/pop_front.hpp> -#include <boost/mpl/erase.hpp> -#include <boost/mpl/reverse.hpp> -#include <boost/mpl/long.hpp> - - - -namespace boost -{ -namespace statechart -{ -namespace detail -{ - - - -template< class ContextList, class OutermostContextBase > -struct constructor; - -////////////////////////////////////////////////////////////////////////////// -template< class ContextList, class OutermostContextBase > -struct outer_constructor -{ - typedef typename mpl::front< ContextList >::type to_construct; - typedef typename to_construct::context_ptr_type context_ptr_type; - typedef typename to_construct::inner_context_ptr_type - inner_context_ptr_type; - - typedef typename to_construct::inner_initial_list inner_initial_list; - typedef typename mpl::pop_front< ContextList >::type inner_context_list; - typedef typename mpl::front< inner_context_list >::type::orthogonal_position - inner_orthogonal_position; - typedef typename mpl::advance< - typename mpl::begin< inner_initial_list >::type, - inner_orthogonal_position >::type to_construct_iter; - - typedef typename mpl::erase< - inner_initial_list, - to_construct_iter, - typename mpl::end< inner_initial_list >::type - >::type first_inner_initial_list; - - typedef typename mpl::erase< - inner_initial_list, - typename mpl::begin< inner_initial_list >::type, - typename mpl::next< to_construct_iter >::type - >::type last_inner_initial_list; - - static void construct( - const context_ptr_type & pContext, - OutermostContextBase & outermostContextBase ) - { - const inner_context_ptr_type pInnerContext = - to_construct::shallow_construct( pContext, outermostContextBase ); - to_construct::template deep_construct_inner< - first_inner_initial_list >( pInnerContext, outermostContextBase ); - constructor< inner_context_list, OutermostContextBase >::construct( - pInnerContext, outermostContextBase ); - to_construct::template deep_construct_inner< - last_inner_initial_list >( pInnerContext, outermostContextBase ); - } -}; - -////////////////////////////////////////////////////////////////////////////// -template< class ContextList, class OutermostContextBase > -struct inner_constructor -{ - typedef typename mpl::front< ContextList >::type to_construct; - typedef typename to_construct::context_ptr_type context_ptr_type; - - static void construct( - const context_ptr_type & pContext, - OutermostContextBase & outermostContextBase ) - { - to_construct::deep_construct( pContext, outermostContextBase ); - } -}; - -////////////////////////////////////////////////////////////////////////////// -template< class ContextList, class OutermostContextBase > -struct constructor_impl : public mpl::eval_if< - mpl::equal_to< mpl::size< ContextList >, mpl::long_< 1 > >, - mpl::identity< inner_constructor< ContextList, OutermostContextBase > >, - mpl::identity< outer_constructor< ContextList, OutermostContextBase > > > -{ -}; - - -////////////////////////////////////////////////////////////////////////////// -template< class ContextList, class OutermostContextBase > -struct constructor : - constructor_impl< ContextList, OutermostContextBase >::type {}; - -////////////////////////////////////////////////////////////////////////////// -template< class CommonContext, class DestinationState > -struct make_context_list -{ - typedef typename mpl::reverse< typename mpl::push_front< - typename mpl::erase< - typename DestinationState::context_type_list, - typename mpl::find< - typename DestinationState::context_type_list, - CommonContext - >::type, - typename mpl::end< - typename DestinationState::context_type_list - >::type - >::type, - DestinationState - >::type >::type type; -}; - - - -} // namespace detail -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/detail/counted_base.hpp b/contrib/restricted/boost/boost/statechart/detail/counted_base.hpp deleted file mode 100644 index 4266f30203d..00000000000 --- a/contrib/restricted/boost/boost/statechart/detail/counted_base.hpp +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef BOOST_STATECHART_DETAIL_COUNTED_BASE_HPP_INCLUDED -#define BOOST_STATECHART_DETAIL_COUNTED_BASE_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2006 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/detail/atomic_count.hpp> -#include <boost/config.hpp> // BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP - - - -namespace boost -{ -namespace statechart -{ -namespace detail -{ - - - -template< bool NeedsLocking > -struct count_base -{ - count_base() : count_( 0 ) {} - mutable boost::detail::atomic_count count_; -}; - -template<> -struct count_base< false > -{ - count_base() : count_( 0 ) {} - mutable long count_; -}; - -////////////////////////////////////////////////////////////////////////////// -template< bool NeedsLocking = true > -class counted_base : private count_base< NeedsLocking > -{ - typedef count_base< NeedsLocking > base_type; - public: - ////////////////////////////////////////////////////////////////////////// - bool ref_counted() const - { - return base_type::count_ != 0; - } - - long ref_count() const - { - return base_type::count_; - } - - protected: - ////////////////////////////////////////////////////////////////////////// - counted_base() {} - ~counted_base() {} - - // do nothing copy implementation is intentional (the number of - // referencing pointers of the source and the destination is not changed - // through the copy operation) - counted_base( const counted_base & ) : base_type() {} - counted_base & operator=( const counted_base & ) { return *this; } - - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - void add_ref() const - { - ++base_type::count_; - } - - bool release() const - { - BOOST_ASSERT( base_type::count_ > 0 ); - return --base_type::count_ == 0; - } -}; - - - -} // namespace detail -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/detail/leaf_state.hpp b/contrib/restricted/boost/boost/statechart/detail/leaf_state.hpp deleted file mode 100644 index adbcb2f33f3..00000000000 --- a/contrib/restricted/boost/boost/statechart/detail/leaf_state.hpp +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef BOOST_STATECHART_DETAIL_LEAF_STATE_HPP_INCLUDED -#define BOOST_STATECHART_DETAIL_LEAF_STATE_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2006 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/detail/state_base.hpp> - - - -namespace boost -{ -namespace statechart -{ -namespace detail -{ - - - -////////////////////////////////////////////////////////////////////////////// -template< class Allocator, class RttiPolicy > -class leaf_state : public state_base< Allocator, RttiPolicy > -{ - typedef state_base< Allocator, RttiPolicy > base_type; - protected: - ////////////////////////////////////////////////////////////////////////// - leaf_state( typename RttiPolicy::id_provider_type idProvider ) : - base_type( idProvider ) - { - } - - ~leaf_state() {} - - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - void set_list_position( - typename base_type::state_list_type::iterator listPosition ) - { - listPosition_ = listPosition; - } - - typedef typename base_type::leaf_state_ptr_type - direct_state_base_ptr_type; - - virtual void remove_from_state_list( - typename base_type::state_list_type::iterator & statesEnd, - typename base_type::node_state_base_ptr_type & pOutermostUnstableState, - bool performFullExit ) - { - --statesEnd; - swap( *listPosition_, *statesEnd ); - ( *listPosition_ )->set_list_position( listPosition_ ); - direct_state_base_ptr_type & pState = *statesEnd; - // Because the list owns the leaf_state, this leads to the immediate - // termination of this state. - pState->exit_impl( pState, pOutermostUnstableState, performFullExit ); - } - - virtual void exit_impl( - direct_state_base_ptr_type & pSelf, - typename base_type::node_state_base_ptr_type & pOutermostUnstableState, - bool performFullExit ) = 0; - - private: - ////////////////////////////////////////////////////////////////////////// - typename base_type::state_list_type::iterator listPosition_; -}; - - - -} // namespace detail -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/detail/memory.hpp b/contrib/restricted/boost/boost/statechart/detail/memory.hpp deleted file mode 100644 index 69d75183a22..00000000000 --- a/contrib/restricted/boost/boost/statechart/detail/memory.hpp +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef BOOST_STATECHART_DETAIL_MEMORY_HPP_INCLUDED -#define BOOST_STATECHART_DETAIL_MEMORY_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2005-2006 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/detail/avoid_unused_warning.hpp> - -#include <boost/assert.hpp> -#include <boost/detail/allocator_utilities.hpp> - -#include <cstddef> // std::size_t - - - -namespace boost -{ -namespace statechart -{ -namespace detail -{ - - - -template< class MostDerived, class Allocator > -void * allocate( std::size_t size ) -{ - avoid_unused_warning( size ); - // The assert below fails when memory is allocated for an event<>, - // simple_state<> or state<> subtype object, *and* the first template - // parameter passed to one of these templates is not equal to the most- - // derived object being constructed. - // The following examples apply to all these subtypes: - // // Example 1 - // struct A {}; - // struct B : sc::simple_state< A, /* ... */ > - // // Above, the first template parameter must be equal to the most- - // // derived type - // - // // Example 2 - // struct A : sc::event< A > - // struct B : A { /* ... */ }; - // void f() { delete new B(); } - // // Above the most-derived type being constructed is B, but A was passed - // // as the most-derived type to event<>. - BOOST_ASSERT( size == sizeof( MostDerived ) ); - return typename boost::detail::allocator::rebind_to< - Allocator, MostDerived - >::type().allocate( 1, static_cast< MostDerived * >( 0 ) ); -} - -template< class MostDerived, class Allocator > -void deallocate( void * pObject ) -{ - return typename boost::detail::allocator::rebind_to< - Allocator, MostDerived - >::type().deallocate( static_cast< MostDerived * >( pObject ), 1 ); -} - - - -} // namespace detail -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/detail/node_state.hpp b/contrib/restricted/boost/boost/statechart/detail/node_state.hpp deleted file mode 100644 index a7208322502..00000000000 --- a/contrib/restricted/boost/boost/statechart/detail/node_state.hpp +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef BOOST_STATECHART_DETAIL_NODE_STATE_HPP_INCLUDED -#define BOOST_STATECHART_DETAIL_NODE_STATE_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2006 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/detail/state_base.hpp> - -#include <boost/intrusive_ptr.hpp> -#include <boost/assert.hpp> // BOOST_ASSERT - -#include <algorithm> // std::find_if - - - -namespace boost -{ -namespace statechart -{ -namespace detail -{ - - - -template< class Allocator, class RttiPolicy > -class node_state_base : public state_base< Allocator, RttiPolicy > -{ - typedef state_base< Allocator, RttiPolicy > base_type; - protected: - ////////////////////////////////////////////////////////////////////////// - node_state_base( typename RttiPolicy::id_provider_type idProvider ) : - base_type( idProvider ) - { - } - - ~node_state_base() {} - - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - typedef base_type state_base_type; - typedef intrusive_ptr< node_state_base > direct_state_base_ptr_type; - virtual void exit_impl( - direct_state_base_ptr_type & pSelf, - typename base_type::node_state_base_ptr_type & pOutermostUnstableState, - bool performFullExit ) = 0; -}; - -////////////////////////////////////////////////////////////////////////////// -template< class OrthogonalRegionCount, class Allocator, class RttiPolicy > -class node_state : public node_state_base< Allocator, RttiPolicy > -{ - typedef node_state_base< Allocator, RttiPolicy > base_type; - protected: - ////////////////////////////////////////////////////////////////////////// - node_state( typename RttiPolicy::id_provider_type idProvider ) : - base_type( idProvider ) - { - for ( orthogonal_position_type pos = 0; - pos < OrthogonalRegionCount::value; ++pos ) - { - pInnerStates[ pos ] = 0; - } - } - - ~node_state() {} - - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - typedef typename base_type::state_base_type state_base_type; - - void add_inner_state( orthogonal_position_type position, - state_base_type * pInnerState ) - { - BOOST_ASSERT( ( position < OrthogonalRegionCount::value ) && - ( pInnerStates[ position ] == 0 ) ); - pInnerStates[ position ] = pInnerState; - } - - void remove_inner_state( orthogonal_position_type position ) - { - BOOST_ASSERT( position < OrthogonalRegionCount::value ); - pInnerStates[ position ] = 0; - } - - virtual void remove_from_state_list( - typename state_base_type::state_list_type::iterator & statesEnd, - typename state_base_type::node_state_base_ptr_type & - pOutermostUnstableState, - bool performFullExit ) - { - state_base_type ** const pPastEnd = - &pInnerStates[ OrthogonalRegionCount::value ]; - // We must not iterate past the last inner state because *this* state - // will no longer exist when the last inner state has been removed - state_base_type ** const pFirstNonNull = std::find_if( - &pInnerStates[ 0 ], pPastEnd, &node_state::is_not_null ); - - if ( pFirstNonNull == pPastEnd ) - { - // The state does not have inner states but is still alive, this must - // be the outermost unstable state then. - BOOST_ASSERT( get_pointer( pOutermostUnstableState ) == this ); - typename state_base_type::node_state_base_ptr_type pSelf = - pOutermostUnstableState; - pSelf->exit_impl( pSelf, pOutermostUnstableState, performFullExit ); - } - else - { - // Destroy inner states in the reverse order of construction - for ( state_base_type ** pState = pPastEnd; pState != pFirstNonNull; ) - { - --pState; - - // An inner orthogonal state might have been terminated long before, - // that's why we have to check for 0 pointers - if ( *pState != 0 ) - { - ( *pState )->remove_from_state_list( - statesEnd, pOutermostUnstableState, performFullExit ); - } - } - } - } - - typedef typename base_type::direct_state_base_ptr_type - direct_state_base_ptr_type; - - private: - ////////////////////////////////////////////////////////////////////////// - static bool is_not_null( const state_base_type * pInner ) - { - return pInner != 0; - } - - state_base_type * pInnerStates[ OrthogonalRegionCount::value ]; -}; - - - -} // namespace detail -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/detail/reaction_dispatcher.hpp b/contrib/restricted/boost/boost/statechart/detail/reaction_dispatcher.hpp deleted file mode 100644 index 160a4569d2c..00000000000 --- a/contrib/restricted/boost/boost/statechart/detail/reaction_dispatcher.hpp +++ /dev/null @@ -1,121 +0,0 @@ -#ifndef BOOST_STATECHART_REACTION_DISPATCHER_HPP_INCLUDED -#define BOOST_STATECHART_REACTION_DISPATCHER_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2008 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/result.hpp> - -#include <boost/mpl/if.hpp> - -#include <boost/polymorphic_cast.hpp> // boost::polymorphic_downcast -#include <boost/type_traits/is_same.hpp> - - - -namespace boost -{ -namespace statechart -{ -namespace detail -{ - - - -////////////////////////////////////////////////////////////////////////////// -template< class Event > -struct no_context -{ - void no_function( const Event & ); -}; - -////////////////////////////////////////////////////////////////////////////// -template< - class Reactions, class State, class EventBase, class Event, - class ActionContext, class IdType > -class reaction_dispatcher -{ - private: - struct without_action - { - static result react( State & stt, const EventBase & ) - { - return Reactions::react_without_action( stt ); - } - }; - - struct base_with_action - { - static result react( State & stt, const EventBase & evt ) - { - return Reactions::react_with_action( stt, evt ); - } - }; - - struct base - { - static result react( - State & stt, const EventBase & evt, const IdType & ) - { - typedef typename mpl::if_< - is_same< ActionContext, detail::no_context< Event > >, - without_action, base_with_action - >::type reaction; - return reaction::react( stt, evt ); - } - }; - - struct derived_with_action - { - static result react( State & stt, const EventBase & evt ) - { - return Reactions::react_with_action( - stt, *polymorphic_downcast< const Event * >( &evt ) ); - } - }; - - struct derived - { - static result react( - State & stt, const EventBase & evt, const IdType & eventType ) - { - if ( eventType == Event::static_type() ) - { - typedef typename mpl::if_< - is_same< ActionContext, detail::no_context< Event > >, - without_action, derived_with_action - >::type reaction; - return reaction::react( stt, evt ); - } - else - { - return detail::result_utility::make_result( detail::no_reaction ); - } - } - }; - - public: - static reaction_result react( - State & stt, const EventBase & evt, const IdType & eventType ) - { - typedef typename mpl::if_< - is_same< Event, EventBase >, base, derived - >::type reaction; - return result_utility::get_result( - reaction::react( stt, evt, eventType ) ); - } -}; - - - -} // namespace detail -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/detail/rtti_policy.hpp b/contrib/restricted/boost/boost/statechart/detail/rtti_policy.hpp deleted file mode 100644 index f12fb05745f..00000000000 --- a/contrib/restricted/boost/boost/statechart/detail/rtti_policy.hpp +++ /dev/null @@ -1,208 +0,0 @@ -#ifndef BOOST_STATECHART_DETAIL_RTTI_POLICY_HPP_INCLUDED -#define BOOST_STATECHART_DETAIL_RTTI_POLICY_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2008 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/assert.hpp> -#include <boost/config.hpp> // BOOST_MSVC -#include <boost/detail/workaround.hpp> - -#include <typeinfo> // std::type_info - - - -namespace boost -{ -namespace statechart -{ -namespace detail -{ - - - -////////////////////////////////////////////////////////////////////////////// -struct id_provider -{ - const void * pCustomId_; - #if defined( BOOST_ENABLE_ASSERT_HANDLER ) || !defined( NDEBUG ) - const std::type_info * pCustomIdType_; - #endif -}; - -template< class MostDerived > -struct id_holder -{ - static id_provider idProvider_; -}; - -template< class MostDerived > -id_provider id_holder< MostDerived >::idProvider_; - - - -////////////////////////////////////////////////////////////////////////////// -struct rtti_policy -{ - #ifdef BOOST_STATECHART_USE_NATIVE_RTTI - class id_type - { - public: - //////////////////////////////////////////////////////////////////////// - explicit id_type( const std::type_info & id ) : id_( id ) {} - - bool operator==( id_type right ) const - { - return ( id_ == right.id_ ) != 0; - } - bool operator!=( id_type right ) const { return !( *this == right ); } - - bool operator<( id_type right ) const - { - return id_.before( right.id_ ) != 0; - } - bool operator>( id_type right ) const { return right < *this; } - bool operator>=( id_type right ) const { return !( *this < right ); } - bool operator<=( id_type right ) const { return !( right < *this ); } - - private: - //////////////////////////////////////////////////////////////////////// - const std::type_info & id_; - }; - - typedef bool id_provider_type; // dummy - #else - typedef const void * id_type; - typedef const id_provider * id_provider_type; - #endif - - //////////////////////////////////////////////////////////////////////////// - template< class Base > - class rtti_base_type : public Base - { - public: - //////////////////////////////////////////////////////////////////////// - typedef rtti_policy::id_type id_type; - - id_type dynamic_type() const - { - #ifdef BOOST_STATECHART_USE_NATIVE_RTTI - return id_type( typeid( *this ) ); - #else - return idProvider_; - #endif - } - - #ifndef BOOST_STATECHART_USE_NATIVE_RTTI - template< typename CustomId > - const CustomId * custom_dynamic_type_ptr() const - { - BOOST_ASSERT( - ( idProvider_->pCustomId_ == 0 ) || - ( *idProvider_->pCustomIdType_ == typeid( CustomId ) ) ); - return static_cast< const CustomId * >( idProvider_->pCustomId_ ); - } - #endif - - protected: - #ifdef BOOST_STATECHART_USE_NATIVE_RTTI - rtti_base_type( id_provider_type ) {} - - //////////////////////////////////////////////////////////////////////// - #if BOOST_WORKAROUND( __GNUC__, BOOST_TESTED_AT( 4 ) ) - // We make the destructor virtual for GCC because with this compiler - // there is currently no way to disable the "has virtual functions but - // non-virtual destructor" warning on a class by class basis. Although - // it can be done on the compiler command line with - // -Wno-non-virtual-dtor, this is undesirable as this would also - // suppress legitimate warnings for types that are not states. - virtual ~rtti_base_type() {} - #else - ~rtti_base_type() {} - #endif - - private: - //////////////////////////////////////////////////////////////////////// - // For typeid( *this ) to return a value that corresponds to the most- - // derived type, we need to have a vptr. Since this type does not - // contain any virtual functions we need to artificially declare one so. - virtual void dummy() {} - #else - rtti_base_type( - id_provider_type idProvider - ) : - idProvider_( idProvider ) - { - } - - ~rtti_base_type() {} - - private: - //////////////////////////////////////////////////////////////////////// - id_provider_type idProvider_; - #endif - }; - - //////////////////////////////////////////////////////////////////////////// - template< class MostDerived, class Base > - class rtti_derived_type : public Base - { - public: - //////////////////////////////////////////////////////////////////////// - static id_type static_type() - { - #ifdef BOOST_STATECHART_USE_NATIVE_RTTI - return id_type( typeid( const MostDerived ) ); - #else - return &id_holder< MostDerived >::idProvider_; - #endif - } - - #ifndef BOOST_STATECHART_USE_NATIVE_RTTI - template< class CustomId > - static const CustomId * custom_static_type_ptr() - { - BOOST_ASSERT( - ( id_holder< MostDerived >::idProvider_.pCustomId_ == 0 ) || - ( *id_holder< MostDerived >::idProvider_.pCustomIdType_ == - typeid( CustomId ) ) ); - return static_cast< const CustomId * >( - id_holder< MostDerived >::idProvider_.pCustomId_ ); - } - - template< class CustomId > - static void custom_static_type_ptr( const CustomId * pCustomId ) - { - #if defined( BOOST_ENABLE_ASSERT_HANDLER ) || !defined( NDEBUG ) - id_holder< MostDerived >::idProvider_.pCustomIdType_ = - &typeid( CustomId ); - #endif - id_holder< MostDerived >::idProvider_.pCustomId_ = pCustomId; - } - #endif - - protected: - //////////////////////////////////////////////////////////////////////// - ~rtti_derived_type() {} - - #ifdef BOOST_STATECHART_USE_NATIVE_RTTI - rtti_derived_type() : Base( false ) {} - #else - rtti_derived_type() : Base( &id_holder< MostDerived >::idProvider_ ) {} - #endif - }; -}; - - - -} // namespace detail -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/detail/state_base.hpp b/contrib/restricted/boost/boost/statechart/detail/state_base.hpp deleted file mode 100644 index 18eda5ae9f3..00000000000 --- a/contrib/restricted/boost/boost/statechart/detail/state_base.hpp +++ /dev/null @@ -1,191 +0,0 @@ -#ifndef BOOST_STATECHART_DETAIL_STATE_BASE_HPP_INCLUDED -#define BOOST_STATECHART_DETAIL_STATE_BASE_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2008 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/result.hpp> -#include <boost/statechart/event.hpp> - -#include <boost/statechart/detail/counted_base.hpp> - -#include <boost/intrusive_ptr.hpp> -#include <boost/noncopyable.hpp> -#include <boost/assert.hpp> -#include <boost/config.hpp> // BOOST_MSVC - -#include <boost/detail/workaround.hpp> -#include <boost/detail/allocator_utilities.hpp> - -#ifdef BOOST_MSVC -# pragma warning( push ) -# pragma warning( disable: 4702 ) // unreachable code (in release mode only) -#endif - -#include <list> - -#ifdef BOOST_MSVC -# pragma warning( pop ) -#endif - - - -namespace boost -{ -namespace statechart -{ -namespace detail -{ - - - -template< class Allocator, class RttiPolicy > -class leaf_state; -template< class Allocator, class RttiPolicy > -class node_state_base; - -typedef unsigned char orthogonal_position_type; - - - -////////////////////////////////////////////////////////////////////////////// -template< class Allocator, class RttiPolicy > -class state_base : - #ifndef NDEBUG - noncopyable, - #endif - public RttiPolicy::template rtti_base_type< - // Derived class objects will be created, handled and destroyed by exactly - // one thread --> locking is not necessary - counted_base< false > > -{ - typedef typename RttiPolicy::template rtti_base_type< - counted_base< false > > base_type; - - public: - ////////////////////////////////////////////////////////////////////////// - void exit() {} - - virtual const state_base * outer_state_ptr() const = 0; - - protected: - ////////////////////////////////////////////////////////////////////////// - state_base( typename RttiPolicy::id_provider_type idProvider ) : - base_type( idProvider ), - deferredEvents_( false ) - { - } - - #if BOOST_WORKAROUND( __GNUC__, BOOST_TESTED_AT( 4 ) ) - // We make the destructor virtual for GCC because with this compiler there - // is currently no way to disable the "has virtual functions but - // non-virtual destructor" warning on a class by class basis. Although it - // can be done on the compiler command line with -Wno-non-virtual-dtor, - // this is undesirable as this would also suppress legitimate warnings for - // types that are not states. - virtual ~state_base() {} - #else - // This destructor is not virtual for performance reasons. The library - // ensures that a state object is never deleted through a state_base - // pointer but only through a pointer to the most-derived type. - ~state_base() {} - #endif - - protected: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only protected because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - void defer_event() - { - deferredEvents_ = true; - } - - bool deferred_events() const - { - return deferredEvents_; - } - - template< class Context > - void set_context( orthogonal_position_type position, Context * pContext ) - { - pContext->add_inner_state( position, this ); - } - - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - virtual detail::reaction_result react_impl( - const event_base & evt, - typename RttiPolicy::id_type eventType ) = 0; - - typedef intrusive_ptr< node_state_base< Allocator, RttiPolicy > > - node_state_base_ptr_type; - typedef intrusive_ptr< leaf_state< Allocator, RttiPolicy > > - leaf_state_ptr_type; - typedef std::list< - leaf_state_ptr_type, - typename boost::detail::allocator::rebind_to< - Allocator, leaf_state_ptr_type >::type - > state_list_type; - - virtual void remove_from_state_list( - typename state_list_type::iterator & statesEnd, - node_state_base_ptr_type & pOutermostUnstableState, - bool performFullExit ) = 0; - - private: - ////////////////////////////////////////////////////////////////////////// - bool deferredEvents_; -}; - - - -#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP -} // namespace detail -} // namespace statechart -#endif - - - -template< class Allocator, class RttiPolicy > -inline void intrusive_ptr_add_ref( - const ::boost::statechart::detail::state_base< Allocator, RttiPolicy > * pBase ) -{ - pBase->add_ref(); -} - -template< class Allocator, class RttiPolicy > -inline void intrusive_ptr_release( - const ::boost::statechart::detail::state_base< Allocator, RttiPolicy > * pBase ) -{ - if ( pBase->release() ) - { - // The state_base destructor is *not* virtual for performance reasons - // but intrusive_ptr< state_base > objects are nevertheless used to point - // to states. This assert ensures that such a pointer is never the last - // one referencing a state object. - BOOST_ASSERT( false ); - } -} - - - -#ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP -} // namespace detail -} // namespace statechart -#endif - - - -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/event.hpp b/contrib/restricted/boost/boost/statechart/event.hpp deleted file mode 100644 index c62432c11d2..00000000000 --- a/contrib/restricted/boost/boost/statechart/event.hpp +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef BOOST_STATECHART_EVENT_HPP_INCLUDED -#define BOOST_STATECHART_EVENT_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2007 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/event_base.hpp> -#include <boost/statechart/detail/rtti_policy.hpp> -#include <boost/statechart/detail/memory.hpp> - -#include <boost/polymorphic_cast.hpp> // boost::polymorphic_downcast - -#include <memory> // std::allocator - - - -namespace boost -{ -namespace statechart -{ - - - -////////////////////////////////////////////////////////////////////////////// -template< class MostDerived, class Allocator = std::allocator< void > > -class event : public detail::rtti_policy::rtti_derived_type< - MostDerived, event_base > -{ - public: - ////////////////////////////////////////////////////////////////////////// - // Compiler-generated copy constructor and copy assignment operator are - // fine - - void * operator new( std::size_t size ) - { - return detail::allocate< MostDerived, Allocator >( size ); - } - - void * operator new( std::size_t, void * p ) - { - return p; - } - - void operator delete( void * pEvent ) - { - detail::deallocate< MostDerived, Allocator >( pEvent ); - } - - void operator delete( void * pEvent, void * p ) - { - } - - protected: - ////////////////////////////////////////////////////////////////////////// - event() {} - virtual ~event() {} - - private: - ////////////////////////////////////////////////////////////////////////// - virtual intrusive_ptr< const event_base > clone() const - { - return intrusive_ptr< const event_base >( new MostDerived( - *polymorphic_downcast< const MostDerived * >( this ) ) ); - } -}; - - - -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/event_base.hpp b/contrib/restricted/boost/boost/statechart/event_base.hpp deleted file mode 100644 index 1e1711a8a1e..00000000000 --- a/contrib/restricted/boost/boost/statechart/event_base.hpp +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef BOOST_STATECHART_EVENT_BASE_HPP_INCLUDED -#define BOOST_STATECHART_EVENT_BASE_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2006 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/detail/rtti_policy.hpp> -#include <boost/statechart/detail/counted_base.hpp> - -#include <boost/assert.hpp> -#include <boost/intrusive_ptr.hpp> -#include <boost/config.hpp> - - - -namespace boost -{ -namespace statechart -{ -namespace detail -{ - - - -// This helper is necessary because there doesn't seem to be consensus among -// compilers on how a friend declaration for a function in another namespace -// has to look like. -class delete_helper -{ - public: - template< class T > - static void delete_object( const T * pObject ) - { - delete pObject; - } -}; - - - -} // namespace detail - - - -////////////////////////////////////////////////////////////////////////////// -class event_base : public detail::rtti_policy::rtti_base_type< - detail::counted_base<> > -{ - typedef detail::rtti_policy::rtti_base_type< - detail::counted_base<> > base_type; - public: - ////////////////////////////////////////////////////////////////////////// - intrusive_ptr< const event_base > intrusive_from_this() const; - - protected: - ////////////////////////////////////////////////////////////////////////// - event_base( detail::rtti_policy::id_provider_type idProvider ) : - base_type( idProvider ) - { - } - - virtual ~event_base() {} - - private: - ////////////////////////////////////////////////////////////////////////// - virtual intrusive_ptr< const event_base > clone() const = 0; - - friend class detail::delete_helper; -}; - - - -#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP -} // namespace statechart -#endif - - - -inline void intrusive_ptr_add_ref( const ::boost::statechart::event_base * pBase ) -{ - pBase->add_ref(); -} - -inline void intrusive_ptr_release( const ::boost::statechart::event_base * pBase ) -{ - if ( pBase->release() ) - { - ::boost::statechart::detail::delete_helper::delete_object( pBase ); - } -} - - - -#ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP -} // namespace statechart -#endif -namespace statechart -{ - - - -// We're implementing this here so that GCC3.4.2 can find -// intrusive_ptr_add_ref, which is indirectly called from the intrusive_ptr -// ctor. -inline intrusive_ptr< const event_base > event_base::intrusive_from_this() const -{ - if ( base_type::ref_counted() ) - { - return intrusive_ptr< const event_base >( this ); - } - else - { - return clone(); - } -} - - - -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/event_processor.hpp b/contrib/restricted/boost/boost/statechart/event_processor.hpp deleted file mode 100644 index f764a6dc475..00000000000 --- a/contrib/restricted/boost/boost/statechart/event_processor.hpp +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef BOOST_STATECHART_EVENT_PROCESSOR_INCLUDED -#define BOOST_STATECHART_EVENT_PROCESSOR_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2008 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -namespace boost -{ -namespace statechart -{ - - - -class event_base; - - - -////////////////////////////////////////////////////////////////////////////// -template< class Scheduler > -class event_processor -{ - public: - ////////////////////////////////////////////////////////////////////////// - virtual ~event_processor() {} - - Scheduler & my_scheduler() const - { - return myScheduler_; - } - - typedef typename Scheduler::processor_handle processor_handle; - - processor_handle my_handle() const - { - return myHandle_; - } - - void initiate() - { - initiate_impl(); - } - - void process_event( const event_base & evt ) - { - process_event_impl( evt ); - } - - void terminate() - { - terminate_impl(); - } - - protected: - ////////////////////////////////////////////////////////////////////////// - typedef const typename Scheduler::processor_context & my_context; - - event_processor( my_context ctx ) : - myScheduler_( ctx.my_scheduler() ), - myHandle_( ctx.my_handle() ) - { - } - - private: - ////////////////////////////////////////////////////////////////////////// - virtual void initiate_impl() = 0; - virtual void process_event_impl( const event_base & evt ) = 0; - virtual void terminate_impl() = 0; - - // avoids C4512 (assignment operator could not be generated) - event_processor & operator=( const event_processor & ); - - Scheduler & myScheduler_; - const processor_handle myHandle_; -}; - - - -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/exception_translator.hpp b/contrib/restricted/boost/boost/statechart/exception_translator.hpp deleted file mode 100644 index a030468e03c..00000000000 --- a/contrib/restricted/boost/boost/statechart/exception_translator.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef BOOST_STATECHART_EXCEPTION_TRANSLATOR_HPP_INCLUDED -#define BOOST_STATECHART_EXCEPTION_TRANSLATOR_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2006 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/event.hpp> -#include <boost/statechart/result.hpp> - - - -namespace boost -{ -namespace statechart -{ - - - -////////////////////////////////////////////////////////////////////////////// -class exception_thrown : public event< exception_thrown > {}; - - - -////////////////////////////////////////////////////////////////////////////// -template< class ExceptionEvent = exception_thrown > -class exception_translator -{ - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - template< class Action, class ExceptionEventHandler > - result operator()( Action action, ExceptionEventHandler eventHandler ) - { - try - { - return action(); - } - catch ( ... ) - { - return eventHandler( ExceptionEvent() ); - } - } -}; - - - -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/fifo_scheduler.hpp b/contrib/restricted/boost/boost/statechart/fifo_scheduler.hpp deleted file mode 100644 index c645d862bb3..00000000000 --- a/contrib/restricted/boost/boost/statechart/fifo_scheduler.hpp +++ /dev/null @@ -1,203 +0,0 @@ -#ifndef BOOST_STATECHART_FIFO_SCHEDULER_HPP_INCLUDED -#define BOOST_STATECHART_FIFO_SCHEDULER_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2006 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/event_base.hpp> -#include <boost/statechart/fifo_worker.hpp> -#include <boost/statechart/processor_container.hpp> - -#include <boost/intrusive_ptr.hpp> -#include <boost/noncopyable.hpp> -#include <boost/config.hpp> // BOOST_HAS_THREADS - - - -namespace boost -{ -namespace statechart -{ - - - -////////////////////////////////////////////////////////////////////////////// -template< - class FifoWorker = fifo_worker<>, - class Allocator = std::allocator< void > > -class fifo_scheduler : noncopyable -{ - typedef processor_container< - fifo_scheduler, typename FifoWorker::work_item, Allocator > container; - public: - ////////////////////////////////////////////////////////////////////////// - #ifdef BOOST_HAS_THREADS - fifo_scheduler( bool waitOnEmptyQueue = false ) : - worker_( waitOnEmptyQueue ) - { - } - #endif - - typedef typename container::processor_handle processor_handle; - typedef typename container::processor_context processor_context; - - template< class Processor > - processor_handle create_processor() - { - processor_handle result; - work_item item = - container_.template create_processor< Processor >( result, *this ); - worker_.queue_work_item( item ); - return result; - } - - template< class Processor, typename Arg1 > - processor_handle create_processor( Arg1 arg1 ) - { - processor_handle result; - work_item item = container_.template create_processor< Processor >( - result, *this, arg1 ); - worker_.queue_work_item( item ); - return result; - } - - template< class Processor, typename Arg1, typename Arg2 > - processor_handle create_processor( Arg1 arg1, Arg2 arg2 ) - { - processor_handle result; - work_item item = container_.template create_processor< Processor >( - result, *this, arg1, arg2 ); - worker_.queue_work_item( item ); - return result; - } - - template< class Processor, typename Arg1, typename Arg2, typename Arg3 > - processor_handle create_processor( Arg1 arg1, Arg2 arg2, Arg3 arg3 ) - { - processor_handle result; - work_item item = container_.template create_processor< Processor >( - result, *this, arg1, arg2, arg3 ); - worker_.queue_work_item( item ); - return result; - } - - template< - class Processor, typename Arg1, typename Arg2, - typename Arg3, typename Arg4 > - processor_handle create_processor( - Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4 ) - { - processor_handle result; - work_item item = container_.template create_processor< Processor >( - result, *this, arg1, arg2, arg3, arg4 ); - worker_.queue_work_item( item ); - return result; - } - - template< - class Processor, typename Arg1, typename Arg2, - typename Arg3, typename Arg4, typename Arg5 > - processor_handle create_processor( - Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5 ) - { - processor_handle result; - work_item item = container_.template create_processor< Processor >( - result, *this, arg1, arg2, arg3, arg4, arg5 ); - worker_.queue_work_item( item ); - return result; - } - - template< - class Processor, typename Arg1, typename Arg2, - typename Arg3, typename Arg4, typename Arg5, typename Arg6 > - processor_handle create_processor( - Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6 ) - { - processor_handle result; - work_item item = container_.template create_processor< Processor >( - result, *this, arg1, arg2, arg3, arg4, arg5, arg6 ); - worker_.queue_work_item( item ); - return result; - } - - void destroy_processor( const processor_handle & processor ) - { - work_item item = container_.destroy_processor( processor ); - worker_.queue_work_item( item ); - } - - void initiate_processor( const processor_handle & processor ) - { - work_item item = container_.initiate_processor( processor ); - worker_.queue_work_item( item ); - } - - void terminate_processor( const processor_handle & processor ) - { - work_item item = container_.terminate_processor( processor ); - worker_.queue_work_item( item ); - } - - typedef intrusive_ptr< const event_base > event_ptr_type; - - void queue_event( - const processor_handle & processor, const event_ptr_type & pEvent ) - { - work_item item = container_.queue_event( processor, pEvent ); - worker_.queue_work_item( item ); - } - - typedef typename FifoWorker::work_item work_item; - - // We take a non-const reference so that we can move (i.e. swap) the item - // into the queue, what avoids copying the (possibly heap-allocated) - // implementation object inside work_item. - void queue_work_item( work_item & item ) - { - worker_.queue_work_item( item ); - } - - // Convenience overload so that temporary objects can be passed directly - // instead of having to create a work_item object first. Under most - // circumstances, this will lead to one unnecessary copy of the - // function implementation object. - void queue_work_item( const work_item & item ) - { - worker_.queue_work_item( item ); - } - - void terminate() - { - worker_.terminate(); - } - - // Is not mutex-protected! Must only be called from the thread that also - // calls operator(). - bool terminated() const - { - return worker_.terminated(); - } - - unsigned long operator()( unsigned long maxEventCount = 0 ) - { - return worker_( maxEventCount ); - } - - private: - ////////////////////////////////////////////////////////////////////////// - container container_; - FifoWorker worker_; -}; - - - -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/fifo_worker.hpp b/contrib/restricted/boost/boost/statechart/fifo_worker.hpp deleted file mode 100644 index 5f42d377895..00000000000 --- a/contrib/restricted/boost/boost/statechart/fifo_worker.hpp +++ /dev/null @@ -1,208 +0,0 @@ -#ifndef BOOST_STATECHART_FIFO_WORKER_HPP_INCLUDED -#define BOOST_STATECHART_FIFO_WORKER_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2008 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/assert.hpp> -#include <boost/noncopyable.hpp> -#include <boost/function/function0.hpp> -#include <boost/bind.hpp> -// BOOST_HAS_THREADS, BOOST_MSVC -#include <boost/config.hpp> - -#include <boost/detail/allocator_utilities.hpp> - -#ifdef BOOST_HAS_THREADS -# ifdef BOOST_MSVC -# pragma warning( push ) - // "conditional expression is constant" in basic_timed_mutex.hpp -# pragma warning( disable: 4127 ) - // "conversion from 'int' to 'unsigned short'" in microsec_time_clock.hpp -# pragma warning( disable: 4244 ) - // "... needs to have dll-interface to be used by clients of class ..." -# pragma warning( disable: 4251 ) - // "... assignment operator could not be generated" -# pragma warning( disable: 4512 ) - // "Function call with parameters that may be unsafe" in - // condition_variable.hpp -# pragma warning( disable: 4996 ) -# endif - -# include <boost/thread/mutex.hpp> -# include <boost/thread/condition.hpp> - -# ifdef BOOST_MSVC -# pragma warning( pop ) -# endif -#endif - -#include <list> -#include <memory> // std::allocator - - -namespace boost -{ -namespace statechart -{ - - - -template< class Allocator = std::allocator< void > > -class fifo_worker : noncopyable -{ - public: - ////////////////////////////////////////////////////////////////////////// - #ifdef BOOST_HAS_THREADS - fifo_worker( bool waitOnEmptyQueue = false ) : - waitOnEmptyQueue_( waitOnEmptyQueue ), - #else - fifo_worker() : - #endif - terminated_( false ) - { - } - - typedef function0< void > work_item; - - // We take a non-const reference so that we can move (i.e. swap) the item - // into the queue, what avoids copying the (possibly heap-allocated) - // implementation object inside work_item. - void queue_work_item( work_item & item ) - { - if ( item.empty() ) - { - return; - } - - #ifdef BOOST_HAS_THREADS - mutex::scoped_lock lock( mutex_ ); - #endif - - workQueue_.push_back( work_item() ); - workQueue_.back().swap( item ); - - #ifdef BOOST_HAS_THREADS - queueNotEmpty_.notify_one(); - #endif - } - - // Convenience overload so that temporary objects can be passed directly - // instead of having to create a work_item object first. Under most - // circumstances, this will lead to one unnecessary copy of the - // function implementation object. - void queue_work_item( const work_item & item ) - { - work_item copy = item; - queue_work_item( copy ); - } - - void terminate() - { - work_item item = boost::bind( &fifo_worker::terminate_impl, this ); - queue_work_item( item ); - } - - // Is not mutex-protected! Must only be called from the thread that also - // calls operator(). - bool terminated() const - { - return terminated_; - } - - unsigned long operator()( unsigned long maxItemCount = 0 ) - { - unsigned long itemCount = 0; - - while ( !terminated() && - ( ( maxItemCount == 0 ) || ( itemCount < maxItemCount ) ) ) - { - work_item item = dequeue_item(); - - if ( item.empty() ) - { - // item can only be empty when the queue is empty, which only - // happens in ST builds or when users pass false to the fifo_worker - // constructor - return itemCount; - } - - item(); - ++itemCount; - } - - return itemCount; - } - - private: - ////////////////////////////////////////////////////////////////////////// - work_item dequeue_item() - { - #ifdef BOOST_HAS_THREADS - mutex::scoped_lock lock( mutex_ ); - - if ( !waitOnEmptyQueue_ && workQueue_.empty() ) - { - return work_item(); - } - - while ( workQueue_.empty() ) - { - queueNotEmpty_.wait( lock ); - } - #else - // If the queue happens to run empty in a single-threaded system, - // waiting for new work items (which means to loop indefinitely!) is - // pointless as there is no way that new work items could find their way - // into the queue. The only sensible thing is to exit the loop and - // return to the caller in this case. - // Users can then queue new work items before calling operator() again. - if ( workQueue_.empty() ) - { - return work_item(); - } - #endif - - // Optimization: Swap rather than assign to avoid the copy of the - // implementation object inside function - work_item result; - result.swap( workQueue_.front() ); - workQueue_.pop_front(); - return result; - } - - void terminate_impl() - { - terminated_ = true; - } - - - typedef std::list< - work_item, - typename boost::detail::allocator::rebind_to< - Allocator, work_item >::type - > work_queue_type; - - work_queue_type workQueue_; - - #ifdef BOOST_HAS_THREADS - mutex mutex_; - condition queueNotEmpty_; - const bool waitOnEmptyQueue_; - #endif - - bool terminated_; -}; - - - -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/history.hpp b/contrib/restricted/boost/boost/statechart/history.hpp deleted file mode 100644 index 7365c632f22..00000000000 --- a/contrib/restricted/boost/boost/statechart/history.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef BOOST_STATECHART_HISTORY_HPP_INCLUDED -#define BOOST_STATECHART_HISTORY_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2006 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/shallow_history.hpp> -#include <boost/statechart/deep_history.hpp> - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/in_state_reaction.hpp b/contrib/restricted/boost/boost/statechart/in_state_reaction.hpp deleted file mode 100644 index 73f5028264a..00000000000 --- a/contrib/restricted/boost/boost/statechart/in_state_reaction.hpp +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef BOOST_STATECHART_IN_STATE_REACTION_HPP_INCLUDED -#define BOOST_STATECHART_IN_STATE_REACTION_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2005-2008 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/result.hpp> - -#include <boost/statechart/detail/reaction_dispatcher.hpp> - - - -namespace boost -{ -namespace statechart -{ - - - -class event_base; - -////////////////////////////////////////////////////////////////////////////// -template< class Event, - class ReactionContext = detail::no_context< Event >, - void ( ReactionContext::*pAction )( const Event & ) = - &detail::no_context< Event >::no_function > -class in_state_reaction -{ - private: - ////////////////////////////////////////////////////////////////////////// - template< class State > - struct reactions - { - static result react_without_action( State & stt ) - { - return stt.discard_event(); - } - - static result react_with_action( State & stt, const Event & evt ) - { - ( stt.template context< ReactionContext >().*pAction )( evt ); - return react_without_action( stt ); - } - }; - - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - template< class State, class EventBase, class IdType > - static detail::reaction_result react( - State & stt, const EventBase & evt, const IdType & eventType ) - { - typedef detail::reaction_dispatcher< - reactions< State >, State, EventBase, Event, ReactionContext, IdType - > dispatcher; - return dispatcher::react( stt, evt, eventType ); - } -}; - - - -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/null_exception_translator.hpp b/contrib/restricted/boost/boost/statechart/null_exception_translator.hpp deleted file mode 100644 index f44accfefe6..00000000000 --- a/contrib/restricted/boost/boost/statechart/null_exception_translator.hpp +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef BOOST_STATECHART_NULL_EXCEPTION_TRANSLATOR_HPP_INCLUDED -#define BOOST_STATECHART_NULL_EXCEPTION_TRANSLATOR_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2006 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/result.hpp> - - - -namespace boost -{ -namespace statechart -{ - - - -////////////////////////////////////////////////////////////////////////////// -class null_exception_translator -{ - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - template< class Action, class ExceptionEventHandler > - result operator()( Action action, ExceptionEventHandler ) - { - return action(); - } -}; - - - -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/processor_container.hpp b/contrib/restricted/boost/boost/statechart/processor_container.hpp deleted file mode 100644 index e8104b685b8..00000000000 --- a/contrib/restricted/boost/boost/statechart/processor_container.hpp +++ /dev/null @@ -1,438 +0,0 @@ -#ifndef BOOST_STATECHART_PROCESSOR_CONTAINER_HPP_INCLUDED -#define BOOST_STATECHART_PROCESSOR_CONTAINER_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2008 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/event_base.hpp> -#include <boost/statechart/event_processor.hpp> - -#include <boost/assert.hpp> -#include <boost/ref.hpp> -#include <boost/noncopyable.hpp> -#include <boost/intrusive_ptr.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> -#include <boost/bind.hpp> -#include <boost/config.hpp> // BOOST_INTEL - -#include <boost/detail/workaround.hpp> -#include <boost/detail/allocator_utilities.hpp> - -#include <set> -#include <memory> // std::allocator, std::unique_ptr - - - -namespace boost -{ -namespace statechart -{ -namespace detail -{ - template<bool IsReferenceWrapper> - struct unwrap_impl - { - template< typename T > - struct apply { typedef T type; }; - }; - - template<> - struct unwrap_impl<true> - { - template< typename T > - struct apply { typedef typename T::type & type; }; - }; - - template<typename T> - struct unwrap - { - typedef typename unwrap_impl< - is_reference_wrapper< T >::value >::template apply< T >::type type; - }; -} - - -template< - class Scheduler, - class WorkItem, - class Allocator = std::allocator< void > > -class processor_container : noncopyable -{ - typedef event_processor< Scheduler > processor_base_type; -#ifdef BOOST_NO_AUTO_PTR - typedef std::unique_ptr< processor_base_type > processor_holder_type; -#else - typedef std::auto_ptr< processor_base_type > processor_holder_type; -#endif - typedef shared_ptr< processor_holder_type > processor_holder_ptr_type; - - public: - ////////////////////////////////////////////////////////////////////////// - typedef weak_ptr< processor_holder_type > processor_handle; - - class processor_context - { - processor_context( - Scheduler & scheduler, const processor_handle & handle - ) : - scheduler_( scheduler ), - handle_( handle ) - { - } - - #if BOOST_WORKAROUND( BOOST_INTEL, BOOST_TESTED_AT( 800 ) ) - public: - // for some reason Intel 8.0 seems to think that the following functions - // are inaccessible from event_processor<>::event_processor - #endif - - Scheduler & my_scheduler() const { return scheduler_; } - const processor_handle & my_handle() const { return handle_; } - - #if BOOST_WORKAROUND( BOOST_INTEL, BOOST_TESTED_AT( 800 ) ) - private: - #endif - - // avoids C4512 (assignment operator could not be generated) - processor_context & operator=( const processor_context & ); - - Scheduler & scheduler_; - const processor_handle handle_; - - friend class processor_container; - friend class event_processor< Scheduler >; - }; - - template< class Processor > - WorkItem create_processor( processor_handle & handle, Scheduler & scheduler ) - { - processor_holder_ptr_type pProcessor = make_processor_holder(); - handle = pProcessor; - typedef void ( processor_container::*impl_fun_ptr )( - const processor_holder_ptr_type &, const processor_context & ); - impl_fun_ptr pImpl = - &processor_container::template create_processor_impl0< Processor >; - return WorkItem( - boost::bind( pImpl, this, pProcessor, - processor_context( scheduler, handle ) ), - Allocator() ); - } - - template< class Processor, typename Arg1 > - WorkItem create_processor( - processor_handle & handle, Scheduler & scheduler, Arg1 arg1 ) - { - processor_holder_ptr_type pProcessor = make_processor_holder(); - handle = pProcessor; - typedef typename detail::unwrap< Arg1 >::type arg1_type; - typedef void ( processor_container::*impl_fun_ptr )( - const processor_holder_ptr_type &, const processor_context &, - arg1_type ); - impl_fun_ptr pImpl = - &processor_container::template create_processor_impl1< - Processor, arg1_type >; - return WorkItem( - boost::bind( pImpl, this, pProcessor, processor_context( scheduler, handle ), - arg1 ), - Allocator() ); - } - - template< class Processor, typename Arg1, typename Arg2 > - WorkItem create_processor( - processor_handle & handle, Scheduler & scheduler, Arg1 arg1, Arg2 arg2 ) - { - processor_holder_ptr_type pProcessor = make_processor_holder(); - handle = pProcessor; - typedef typename detail::unwrap< Arg1 >::type arg1_type; - typedef typename detail::unwrap< Arg2 >::type arg2_type; - typedef void ( processor_container::*impl_fun_ptr )( - const processor_holder_ptr_type &, const processor_context &, - arg1_type, arg2_type ); - impl_fun_ptr pImpl = - &processor_container::template create_processor_impl2< - Processor, arg1_type, arg2_type >; - return WorkItem( - boost::bind( pImpl, this, pProcessor, processor_context( scheduler, handle ), - arg1, arg2 ), - Allocator() ); - } - - template< class Processor, typename Arg1, typename Arg2, typename Arg3 > - WorkItem create_processor( - processor_handle & handle, Scheduler & scheduler, - Arg1 arg1, Arg2 arg2, Arg3 arg3 ) - { - processor_holder_ptr_type pProcessor = make_processor_holder(); - handle = pProcessor; - typedef typename detail::unwrap< Arg1 >::type arg1_type; - typedef typename detail::unwrap< Arg2 >::type arg2_type; - typedef typename detail::unwrap< Arg3 >::type arg3_type; - typedef void ( processor_container::*impl_fun_ptr )( - const processor_holder_ptr_type &, const processor_context &, - arg1_type, arg2_type, arg3_type ); - impl_fun_ptr pImpl = - &processor_container::template create_processor_impl3< - Processor, arg1_type, arg2_type, arg3_type >; - return WorkItem( - boost::bind( pImpl, this, pProcessor, processor_context( scheduler, handle ), - arg1, arg2, arg3 ), - Allocator() ); - } - - template< - class Processor, typename Arg1, typename Arg2, - typename Arg3, typename Arg4 > - WorkItem create_processor( - processor_handle & handle, Scheduler & scheduler, - Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4 ) - { - processor_holder_ptr_type pProcessor = make_processor_holder(); - handle = pProcessor; - typedef typename detail::unwrap< Arg1 >::type arg1_type; - typedef typename detail::unwrap< Arg2 >::type arg2_type; - typedef typename detail::unwrap< Arg3 >::type arg3_type; - typedef typename detail::unwrap< Arg4 >::type arg4_type; - typedef void ( processor_container::*impl_fun_ptr )( - const processor_holder_ptr_type &, const processor_context &, - arg1_type, arg2_type, arg3_type, arg4_type ); - impl_fun_ptr pImpl = - &processor_container::template create_processor_impl4< - Processor, arg1_type, arg2_type, arg3_type, arg4_type >; - return WorkItem( - boost::bind( pImpl, this, pProcessor, processor_context( scheduler, handle ), - arg1, arg2, arg3, arg4 ), - Allocator() ); - } - - template< - class Processor, typename Arg1, typename Arg2, - typename Arg3, typename Arg4, typename Arg5 > - WorkItem create_processor( - processor_handle & handle, Scheduler & scheduler, - Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5 ) - { - processor_holder_ptr_type pProcessor = make_processor_holder(); - handle = pProcessor; - typedef typename detail::unwrap< Arg1 >::type arg1_type; - typedef typename detail::unwrap< Arg2 >::type arg2_type; - typedef typename detail::unwrap< Arg3 >::type arg3_type; - typedef typename detail::unwrap< Arg4 >::type arg4_type; - typedef typename detail::unwrap< Arg5 >::type arg5_type; - typedef void ( processor_container::*impl_fun_ptr )( - const processor_holder_ptr_type &, const processor_context &, - arg1_type, arg2_type, arg3_type, arg4_type, arg5_type ); - impl_fun_ptr pImpl = - &processor_container::template create_processor_impl5< - Processor, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type >; - return WorkItem( - boost::bind( pImpl, this, pProcessor, processor_context( scheduler, handle ), - arg1, arg2, arg3, arg4, arg5 ), - Allocator() ); - } - - template< - class Processor, typename Arg1, typename Arg2, - typename Arg3, typename Arg4, typename Arg5, typename Arg6 > - WorkItem create_processor( - processor_handle & handle, Scheduler & scheduler, - Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6 ) - { - processor_holder_ptr_type pProcessor = make_processor_holder(); - handle = pProcessor; - typedef typename detail::unwrap< Arg1 >::type arg1_type; - typedef typename detail::unwrap< Arg2 >::type arg2_type; - typedef typename detail::unwrap< Arg3 >::type arg3_type; - typedef typename detail::unwrap< Arg4 >::type arg4_type; - typedef typename detail::unwrap< Arg5 >::type arg5_type; - typedef typename detail::unwrap< Arg6 >::type arg6_type; - typedef void ( processor_container::*impl_fun_ptr )( - const processor_holder_ptr_type &, const processor_context &, - arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type ); - impl_fun_ptr pImpl = - &processor_container::template create_processor_impl6< - Processor, - arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type >; - return WorkItem( - boost::bind( pImpl, this, pProcessor, processor_context( scheduler, handle ), - arg1, arg2, arg3, arg4, arg5, arg6 ), - Allocator() ); - } - - WorkItem destroy_processor( const processor_handle & processor ) - { - return WorkItem( - boost::bind( &processor_container::destroy_processor_impl, this, processor ), - Allocator() ); - } - - WorkItem initiate_processor( const processor_handle & processor ) - { - return WorkItem( - boost::bind( &processor_container::initiate_processor_impl, this, - processor ), - Allocator() ); - } - - WorkItem terminate_processor( const processor_handle & processor ) - { - return WorkItem( - boost::bind( &processor_container::terminate_processor_impl, this, - processor ), - Allocator() ); - } - - typedef intrusive_ptr< const event_base > event_ptr_type; - - WorkItem queue_event( - const processor_handle & processor, const event_ptr_type & pEvent ) - { - BOOST_ASSERT( pEvent.get() != 0 ); - - return WorkItem( - boost::bind( &processor_container::queue_event_impl, this, processor, - pEvent ), - Allocator() ); - } - - private: - ////////////////////////////////////////////////////////////////////////// - processor_holder_ptr_type make_processor_holder() - { - return processor_holder_ptr_type( new processor_holder_type() ); - } - - template< class Processor > - void create_processor_impl0( - const processor_holder_ptr_type & pProcessor, - const processor_context & context ) - { - processorSet_.insert( pProcessor ); - *pProcessor = processor_holder_type( new Processor( context ) ); - } - - template< class Processor, typename Arg1 > - void create_processor_impl1( - const processor_holder_ptr_type & pProcessor, - const processor_context & context, Arg1 arg1 ) - { - processorSet_.insert( pProcessor ); - *pProcessor = processor_holder_type( new Processor( context, arg1 ) ); - } - - template< class Processor, typename Arg1, typename Arg2 > - void create_processor_impl2( - const processor_holder_ptr_type & pProcessor, - const processor_context & context, Arg1 arg1, Arg2 arg2 ) - { - processorSet_.insert( pProcessor ); - *pProcessor = processor_holder_type( new Processor( context, arg1, arg2 ) ); - } - - template< class Processor, typename Arg1, typename Arg2, typename Arg3 > - void create_processor_impl3( - const processor_holder_ptr_type & pProcessor, - const processor_context & context, Arg1 arg1, Arg2 arg2, Arg3 arg3 ) - { - processorSet_.insert( pProcessor ); - *pProcessor = processor_holder_type( new Processor( context, arg1, arg2, arg3 ) ); - } - - template< - class Processor, typename Arg1, typename Arg2, - typename Arg3, typename Arg4 > - void create_processor_impl4( - const processor_holder_ptr_type & pProcessor, - const processor_context & context, - Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4 ) - { - processorSet_.insert( pProcessor ); - *pProcessor = processor_holder_type( new Processor( context, arg1, arg2, arg3, arg4 ) ); - } - - template< - class Processor, typename Arg1, typename Arg2, - typename Arg3, typename Arg4, typename Arg5 > - void create_processor_impl5( - const processor_holder_ptr_type & pProcessor, - const processor_context & context, - Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5 ) - { - processorSet_.insert( pProcessor ); - *pProcessor = processor_holder_type( new Processor( context, arg1, arg2, arg3, arg4, arg5 ) ); - } - - template< - class Processor, typename Arg1, typename Arg2, - typename Arg3, typename Arg4, typename Arg5, typename Arg6 > - void create_processor_impl6( - const processor_holder_ptr_type & pProcessor, - const processor_context & context, - Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6 ) - { - processorSet_.insert( pProcessor ); - *pProcessor = processor_holder_type( new Processor( context, arg1, arg2, arg3, arg4, arg5, arg6 ) ); - } - - void destroy_processor_impl( const processor_handle & processor ) - { - const processor_holder_ptr_type pProcessor = processor.lock(); - - if ( pProcessor != 0 ) - { - processorSet_.erase( pProcessor ); - } - } - - void initiate_processor_impl( const processor_handle & processor ) - { - const processor_holder_ptr_type pProcessor = processor.lock(); - - if ( pProcessor != 0 ) - { - ( *pProcessor )->initiate(); - } - } - - void terminate_processor_impl( const processor_handle & processor ) - { - const processor_holder_ptr_type pProcessor = processor.lock(); - - if ( pProcessor != 0 ) - { - ( *pProcessor )->terminate(); - } - } - - void queue_event_impl( - const processor_handle & processor, const event_ptr_type & pEvent ) - { - const processor_holder_ptr_type pProcessor = processor.lock(); - - if ( pProcessor != 0 ) - { - ( *pProcessor )->process_event( *pEvent ); - } - } - - typedef std::set< - processor_holder_ptr_type, - std::less< processor_holder_ptr_type >, - typename boost::detail::allocator::rebind_to< - Allocator, processor_holder_ptr_type >::type - > event_processor_set_type; - - event_processor_set_type processorSet_; -}; - - -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/result.hpp b/contrib/restricted/boost/boost/statechart/result.hpp deleted file mode 100644 index 6843ba358a1..00000000000 --- a/contrib/restricted/boost/boost/statechart/result.hpp +++ /dev/null @@ -1,122 +0,0 @@ -#ifndef BOOST_STATECHART_RESULT_HPP_INCLUDED -#define BOOST_STATECHART_RESULT_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2010 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/assert.hpp> - - - -namespace boost -{ -namespace statechart -{ -namespace detail -{ - - - -////////////////////////////////////////////////////////////////////////////// -enum reaction_result -{ - no_reaction, - do_forward_event, - do_discard_event, - do_defer_event, - consumed -}; - -struct result_utility; - -////////////////////////////////////////////////////////////////////////////// -class safe_reaction_result -{ - public: - ////////////////////////////////////////////////////////////////////////// - safe_reaction_result( const safe_reaction_result & other ) : - reactionResult_( other.reactionResult_ ) - { - // This assert fails when an attempt is made to make multiple copies of - // a result value. This makes little sense, given the requirement that - // an obtained result value must be returned out of the react function. - BOOST_ASSERT( reactionResult_ != consumed ); - other.reactionResult_ = consumed; - } - - ~safe_reaction_result() - { - // This assert fails when an obtained result value is not returned out - // of the react() function. This can happen if the user accidentally - // makes more than one call to reaction functions inside react() or - // accidentally makes one or more calls to reaction functions outside - // react() - BOOST_ASSERT( reactionResult_ == consumed ); - } - - private: - ////////////////////////////////////////////////////////////////////////// - safe_reaction_result( reaction_result reactionResult ) : - reactionResult_( reactionResult ) - { - } - - operator reaction_result() const - { - const reaction_result val = reactionResult_; - reactionResult_ = consumed; - return val; - } - - safe_reaction_result & operator=( const safe_reaction_result & ); - - mutable reaction_result reactionResult_; - - friend struct result_utility; -}; - - - -} // namespace detail - - - -#ifdef NDEBUG - typedef detail::reaction_result result; -#else - typedef detail::safe_reaction_result result; -#endif - - -namespace detail -{ - - - -////////////////////////////////////////////////////////////////////////////// -struct result_utility -{ - static ::boost::statechart::result make_result( reaction_result value ) - { - return value; - } - - static reaction_result get_result( ::boost::statechart::result value ) - { - return value; - } -}; - - - -} // namespace detail -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/shallow_history.hpp b/contrib/restricted/boost/boost/statechart/shallow_history.hpp deleted file mode 100644 index fabc423a219..00000000000 --- a/contrib/restricted/boost/boost/statechart/shallow_history.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef BOOST_STATECHART_SHALLOW_HISTORY_HPP_INCLUDED -#define BOOST_STATECHART_SHALLOW_HISTORY_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2006 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/mpl/bool.hpp> -#include <boost/static_assert.hpp> - - - -namespace boost -{ -namespace statechart -{ - - - -////////////////////////////////////////////////////////////////////////////// -template< class DefaultState > -class shallow_history -{ - public: - ////////////////////////////////////////////////////////////////////////// - // If you receive a - // "use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'" or similar - // compiler error here then you forgot to pass either - // statechart::has_deep_history or statechart::has_full_history as the - // last parameter of DefaultState's context. - BOOST_STATIC_ASSERT( DefaultState::context_type::shallow_history::value ); - - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - typedef typename DefaultState::outermost_context_base_type - outermost_context_base_type; - typedef typename DefaultState::context_type context_type; - typedef typename DefaultState::context_ptr_type context_ptr_type; - typedef typename DefaultState::context_type_list context_type_list; - typedef typename DefaultState::orthogonal_position orthogonal_position; - - static void deep_construct( - const context_ptr_type & pContext, - outermost_context_base_type & outermostContextBase ) - { - outermostContextBase.template construct_with_shallow_history< - DefaultState >( pContext ); - } -}; - - - -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/simple_state.hpp b/contrib/restricted/boost/boost/statechart/simple_state.hpp deleted file mode 100644 index eb1d4380545..00000000000 --- a/contrib/restricted/boost/boost/statechart/simple_state.hpp +++ /dev/null @@ -1,998 +0,0 @@ -#ifndef BOOST_STATECHART_SIMPLE_STATE_HPP_INCLUDED -#define BOOST_STATECHART_SIMPLE_STATE_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2010 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/event.hpp> - -#include <boost/statechart/detail/leaf_state.hpp> -#include <boost/statechart/detail/node_state.hpp> -#include <boost/statechart/detail/constructor.hpp> -#include <boost/statechart/detail/memory.hpp> - -#include <boost/mpl/eval_if.hpp> -#include <boost/mpl/if.hpp> -#include <boost/mpl/identity.hpp> -#include <boost/mpl/is_sequence.hpp> -#include <boost/mpl/list.hpp> -#include <boost/mpl/empty.hpp> -#include <boost/mpl/size.hpp> -#include <boost/mpl/front.hpp> -#include <boost/mpl/at.hpp> -#include <boost/mpl/find.hpp> -#include <boost/mpl/find_if.hpp> -#include <boost/mpl/contains.hpp> -#include <boost/mpl/distance.hpp> -#include <boost/mpl/deref.hpp> -#include <boost/mpl/pop_front.hpp> -#include <boost/mpl/push_front.hpp> -#include <boost/mpl/clear.hpp> -#include <boost/mpl/placeholders.hpp> -#include <boost/mpl/bool.hpp> -#include <boost/mpl/integral_c.hpp> -#include <boost/mpl/less.hpp> -#include <boost/mpl/equal_to.hpp> -#include <boost/mpl/not.hpp> -#include <boost/mpl/or.hpp> - -#include <boost/mpl/plus.hpp> -#include <boost/mpl/max_element.hpp> -#include <boost/mpl/greater.hpp> - -#include <boost/get_pointer.hpp> -#include <boost/intrusive_ptr.hpp> -#include <boost/assert.hpp> -#include <boost/type_traits/is_base_of.hpp> -#include <boost/type_traits/is_same.hpp> -#include <boost/static_assert.hpp> -#include <boost/polymorphic_cast.hpp> // boost::polymorphic_downcast - -#include <cstddef> // std::size_t - - - -namespace boost -{ -namespace statechart -{ -namespace detail -{ - - - -////////////////////////////////////////////////////////////////////////////// -template< class T > -struct make_list : public mpl::eval_if< - mpl::is_sequence< T >, - mpl::identity< T >, - mpl::identity< mpl::list< T > > > {}; - -////////////////////////////////////////////////////////////////////////////// -template< class MostDerived, class Context, class InnerInitial > -struct simple_state_base_type -{ - private: - typedef typename Context::outermost_context_base_type::allocator_type - allocator_type; - typedef typename Context::outermost_context_base_type::rtti_policy_type - rtti_policy_type; - typedef typename detail::make_list< InnerInitial >::type - inner_initial_list; - typedef typename mpl::size< inner_initial_list >::type - inner_initial_list_size; - - public: - typedef typename mpl::eval_if< - mpl::empty< inner_initial_list >, - mpl::identity< typename rtti_policy_type:: - template rtti_derived_type< MostDerived, leaf_state< - allocator_type, - rtti_policy_type > > >, - mpl::identity< typename rtti_policy_type:: - template rtti_derived_type< MostDerived, node_state< - inner_initial_list_size, - allocator_type, - rtti_policy_type > > > >::type type; -}; - - -////////////////////////////////////////////////////////////////////////////// -struct no_transition_function -{ - template< class CommonContext > - void operator()( CommonContext & ) const {} -}; - -template< class TransitionContext, class Event > -class transition_function -{ - public: - transition_function( - void ( TransitionContext::*pTransitionAction )( const Event & ), - const Event & evt - ) : - pTransitionAction_( pTransitionAction ), - evt_( evt ) - { - } - - template< class CommonContext > - void operator()( CommonContext & commonContext ) const - { - ( commonContext.template context< TransitionContext >() - .*pTransitionAction_ )( evt_ ); - } - - private: - // avoids C4512 (assignment operator could not be generated) - transition_function & operator=( const transition_function & ); - - void ( TransitionContext::*pTransitionAction_ )( const Event & ); - const Event & evt_; -}; - - -template< bool contextHasInheritedDeepHistory, bool contextHasDeepHistory > -struct deep_history_storer -{ - template< class HistorizedState, class LeafState, class Context > - static void store_deep_history( Context & ) {} -}; - -template<> -struct deep_history_storer< true, false > -{ - template< class HistorizedState, class LeafState, class Context > - static void store_deep_history( Context & ctx ) - { - ctx.template store_deep_history_impl< LeafState >(); - } -}; - -template<> -struct deep_history_storer< true, true > -{ - template< class HistorizedState, class LeafState, class Context > - static void store_deep_history( Context & ctx ) - { - ctx.outermost_context_base().template store_deep_history< - HistorizedState, LeafState >(); - ctx.template store_deep_history_impl< LeafState >(); - } -}; - - - -} // namespace detail - - - -////////////////////////////////////////////////////////////////////////////// -enum history_mode -{ - has_no_history, - has_shallow_history, - has_deep_history, - has_full_history // shallow & deep -}; - - - -////////////////////////////////////////////////////////////////////////////// -template< class MostDerived, - class Context, - class InnerInitial = mpl::list<>, - history_mode historyMode = has_no_history > -class simple_state : public detail::simple_state_base_type< MostDerived, - typename Context::inner_context_type, InnerInitial >::type -{ - typedef typename detail::simple_state_base_type< - MostDerived, typename Context::inner_context_type, - InnerInitial >::type base_type; - - public: - ////////////////////////////////////////////////////////////////////////// - typedef mpl::list<> reactions; - - typedef typename Context::inner_context_type context_type; - - template< detail::orthogonal_position_type innerOrthogonalPosition > - struct orthogonal - { - typedef mpl::integral_c< - detail::orthogonal_position_type, - innerOrthogonalPosition > inner_orthogonal_position; - typedef MostDerived inner_context_type; - }; - - typedef typename context_type::outermost_context_type - outermost_context_type; - - outermost_context_type & outermost_context() - { - // This assert fails when an attempt is made to access the state machine - // from a constructor of a state that is *not* a subtype of state<>. - // To correct this, derive from state<> instead of simple_state<>. - BOOST_ASSERT( get_pointer( pContext_ ) != 0 ); - return pContext_->outermost_context(); - } - - const outermost_context_type & outermost_context() const - { - // This assert fails when an attempt is made to access the state machine - // from a constructor of a state that is *not* a subtype of state<>. - // To correct this, derive from state<> instead of simple_state<>. - BOOST_ASSERT( get_pointer( pContext_ ) != 0 ); - return pContext_->outermost_context(); - } - - template< class OtherContext > - OtherContext & context() - { - typedef typename mpl::if_< - is_base_of< OtherContext, MostDerived >, - context_impl_this_context, - context_impl_other_context - >::type impl; - return impl::template context_impl< OtherContext >( *this ); - } - - template< class OtherContext > - const OtherContext & context() const - { - typedef typename mpl::if_< - is_base_of< OtherContext, MostDerived >, - context_impl_this_context, - context_impl_other_context - >::type impl; - return impl::template context_impl< OtherContext >( *this ); - } - - template< class Target > - Target state_cast() const - { - return outermost_context_base().template state_cast< Target >(); - } - - template< class Target > - Target state_downcast() const - { - return outermost_context_base().template state_downcast< Target >(); - } - - typedef typename context_type::state_base_type state_base_type; - typedef typename context_type::state_iterator state_iterator; - - state_iterator state_begin() const - { - return outermost_context_base().state_begin(); - } - - state_iterator state_end() const - { - return outermost_context_base().state_end(); - } - - - typedef typename context_type::event_base_ptr_type event_base_ptr_type; - - void post_event( const event_base_ptr_type & pEvent ) - { - outermost_context_base().post_event_impl( pEvent ); - } - - void post_event( const event_base & evt ) - { - outermost_context_base().post_event_impl( evt ); - } - - result discard_event() - { - return detail::result_utility::make_result( detail::do_discard_event ); - } - - result forward_event() - { - return detail::result_utility::make_result( detail::do_forward_event ); - } - - result defer_event() - { - this->state_base_type::defer_event(); - return detail::result_utility::make_result( detail::do_defer_event ); - } - - template< class DestinationState > - result transit() - { - return transit_impl< DestinationState, outermost_context_type >( - detail::no_transition_function() ); - } - - template< class DestinationState, class TransitionContext, class Event > - result transit( - void ( TransitionContext::*pTransitionAction )( const Event & ), - const Event & evt ) - { - return transit_impl< DestinationState, TransitionContext >( - detail::transition_function< TransitionContext, Event >( - pTransitionAction, evt ) ); - } - - result terminate() - { - outermost_context_base().terminate_as_reaction( *this ); - return detail::result_utility::make_result( detail::do_discard_event ); - } - - template< - class HistoryContext, - detail::orthogonal_position_type orthogonalPosition > - void clear_shallow_history() - { - outermost_context_base().template clear_shallow_history< - HistoryContext, orthogonalPosition >(); - } - - template< - class HistoryContext, - detail::orthogonal_position_type orthogonalPosition > - void clear_deep_history() - { - outermost_context_base().template clear_deep_history< - HistoryContext, orthogonalPosition >(); - } - - const event_base * triggering_event() const - { - return outermost_context_base().triggering_event(); - } - - protected: - ////////////////////////////////////////////////////////////////////////// - simple_state() : pContext_( 0 ) {} - - ~simple_state() - { - // As a result of a throwing derived class constructor, this destructor - // can be called before the context is set. - if ( get_pointer( pContext_ ) != 0 ) - { - if ( this->deferred_events() ) - { - outermost_context_base().release_events(); - } - - pContext_->remove_inner_state( orthogonal_position::value ); - } - } - - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - typedef typename Context::inner_orthogonal_position orthogonal_position; - - // If you receive a - // "use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'" or similar - // compiler error here then either this state resides in a non-existent - // orthogonal region of the outer state or the outer state does not have - // inner states. - BOOST_STATIC_ASSERT( ( mpl::less< - orthogonal_position, - typename context_type::no_of_orthogonal_regions >::value ) ); - - typedef MostDerived inner_context_type; - typedef mpl::integral_c< detail::orthogonal_position_type, 0 > - inner_orthogonal_position; - - typedef typename context_type::event_base_type event_base_type; - typedef typename context_type::rtti_policy_type rtti_policy_type; - - typedef typename context_type::outermost_context_base_type - outermost_context_base_type; - typedef typename context_type::inner_context_ptr_type context_ptr_type; - typedef typename context_type::state_list_type state_list_type; - typedef intrusive_ptr< inner_context_type > inner_context_ptr_type; - typedef typename detail::make_list< InnerInitial >::type - inner_initial_list; - typedef typename mpl::size< inner_initial_list >::type - inner_initial_list_size; - typedef mpl::integral_c< - detail::orthogonal_position_type, - inner_initial_list_size::value > no_of_orthogonal_regions; - typedef typename mpl::push_front< - typename context_type::context_type_list, - context_type >::type context_type_list; - - // If you receive a - // "use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'" or similar - // compiler error here then the direct or indirect context of this state - // has deep history _and_ this state has two or more orthogonal regions. - // Boost.Statechart does not currently support deep history in a state whose - // direct or indirect inner states have two or more orthogonal regions. - // Please consult the documentation on how to work around this limitation. - BOOST_STATIC_ASSERT( ( mpl::or_< - mpl::less< - no_of_orthogonal_regions, - mpl::integral_c< detail::orthogonal_position_type, 2 > >, - mpl::not_< - typename context_type::inherited_deep_history > >::value ) ); - - typedef mpl::bool_< ( historyMode & has_shallow_history ) != 0 > - shallow_history; - typedef typename context_type::shallow_history stores_shallow_history; - - typedef mpl::bool_< ( historyMode & has_deep_history ) != 0 > - deep_history; - typedef typename mpl::or_< - deep_history, - typename context_type::inherited_deep_history - >::type inherited_deep_history; - typedef typename mpl::and_< - inherited_deep_history, - mpl::empty< inner_initial_list > >::type stores_deep_history; - - void * operator new( std::size_t size ) - { - return detail::allocate< MostDerived, - typename outermost_context_type::allocator_type >( size ); - } - - void operator delete( void * pState ) - { - detail::deallocate< MostDerived, - typename outermost_context_type::allocator_type >( pState ); - } - - outermost_context_base_type & outermost_context_base() - { - // This assert fails when an attempt is made to access the state machine - // from a constructor of a state that is *not* a subtype of state<>. - // To correct this, derive from state<> instead of simple_state<>. - BOOST_ASSERT( get_pointer( pContext_ ) != 0 ); - return pContext_->outermost_context_base(); - } - - const outermost_context_base_type & outermost_context_base() const - { - // This assert fails when an attempt is made to access the state machine - // from a constructor of a state that is *not* a subtype of state<>. - // To correct this, derive from state<> instead of simple_state<>. - BOOST_ASSERT( get_pointer( pContext_ ) != 0 ); - return pContext_->outermost_context_base(); - } - - virtual const state_base_type * outer_state_ptr() const - { - typedef typename mpl::if_< - is_same< outermost_context_type, context_type >, - outer_state_ptr_impl_outermost, - outer_state_ptr_impl_non_outermost - >::type impl; - return impl::outer_state_ptr_impl( *this ); - } - - virtual detail::reaction_result react_impl( - const event_base_type & evt, - typename rtti_policy_type::id_type eventType ) - { - typedef typename detail::make_list< - typename MostDerived::reactions >::type reaction_list; - detail::reaction_result reactionResult = - local_react< reaction_list >( evt, eventType ); - - // At this point we can only safely access pContext_ if the handler did - // not return do_discard_event! - if ( reactionResult == detail::do_forward_event ) - { - // TODO: The following call to react_impl of our outer state should - // be made with a context_type:: prefix to call directly instead of - // virtually. For some reason the compiler complains... - reactionResult = pContext_->react_impl( evt, eventType ); - } - - return reactionResult; - } - - virtual void exit_impl( - typename base_type::direct_state_base_ptr_type & pSelf, - typename state_base_type::node_state_base_ptr_type & - pOutermostUnstableState, - bool performFullExit ) - { - inner_context_ptr_type pMostDerivedSelf = - polymorphic_downcast< MostDerived * >( this ); - pSelf = 0; - exit_impl( pMostDerivedSelf, pOutermostUnstableState, performFullExit ); - } - - void exit_impl( - inner_context_ptr_type & pSelf, - typename state_base_type::node_state_base_ptr_type & - pOutermostUnstableState, - bool performFullExit ) - { - switch ( this->ref_count() ) - { - case 2: - if ( get_pointer( pOutermostUnstableState ) == - static_cast< state_base_type * >( this ) ) - { - pContext_->set_outermost_unstable_state( - pOutermostUnstableState ); - BOOST_FALLTHROUGH; - } - else - { - break; - } - case 1: - { - if ( get_pointer( pOutermostUnstableState ) == 0 ) - { - pContext_->set_outermost_unstable_state( - pOutermostUnstableState ); - } - - if ( performFullExit ) - { - pSelf->exit(); - check_store_shallow_history< stores_shallow_history >(); - check_store_deep_history< stores_deep_history >(); - } - - context_ptr_type pContext = pContext_; - pSelf = 0; - pContext->exit_impl( - pContext, pOutermostUnstableState, performFullExit ); - break; - } - default: - break; - } - } - - void set_outermost_unstable_state( - typename state_base_type::node_state_base_ptr_type & - pOutermostUnstableState ) - { - pOutermostUnstableState = this; - } - - template< class OtherContext > - const typename OtherContext::inner_context_ptr_type & context_ptr() const - { - typedef typename mpl::if_< - is_same< OtherContext, context_type >, - context_ptr_impl_my_context, - context_ptr_impl_other_context - >::type impl; - - return impl::template context_ptr_impl< OtherContext >( *this ); - } - - static void initial_deep_construct( - outermost_context_base_type & outermostContextBase ) - { - deep_construct( &outermostContextBase, outermostContextBase ); - } - - static void deep_construct( - const context_ptr_type & pContext, - outermost_context_base_type & outermostContextBase ) - { - const inner_context_ptr_type pInnerContext( - shallow_construct( pContext, outermostContextBase ) ); - deep_construct_inner< inner_initial_list >( - pInnerContext, outermostContextBase ); - } - - static inner_context_ptr_type shallow_construct( - const context_ptr_type & pContext, - outermost_context_base_type & outermostContextBase ) - { - const inner_context_ptr_type pInnerContext( new MostDerived ); - pInnerContext->set_context( pContext ); - outermostContextBase.add( pInnerContext ); - return pInnerContext; - } - - void set_context( const context_ptr_type & pContext ) - { - BOOST_ASSERT( get_pointer( pContext ) != 0 ); - pContext_ = pContext; - base_type::set_context( - orthogonal_position::value, get_pointer( pContext ) ); - } - - template< class InnerList > - static void deep_construct_inner( - const inner_context_ptr_type & pInnerContext, - outermost_context_base_type & outermostContextBase ) - { - typedef typename mpl::if_< - mpl::empty< InnerList >, - deep_construct_inner_impl_empty, - deep_construct_inner_impl_non_empty - >::type impl; - impl::template deep_construct_inner_impl< InnerList >( - pInnerContext, outermostContextBase ); - } - - template< class LeafState > - void store_deep_history_impl() - { - detail::deep_history_storer< - context_type::inherited_deep_history::value, - context_type::deep_history::value - >::template store_deep_history< MostDerived, LeafState >( - *pContext_ ); - } - - private: - ////////////////////////////////////////////////////////////////////////// - struct context_ptr_impl_other_context - { - template< class OtherContext, class State > - static const typename OtherContext::inner_context_ptr_type & - context_ptr_impl( const State & stt ) - { - // This assert fails when an attempt is made to access an outer - // context from a constructor of a state that is *not* a subtype of - // state<>. To correct this, derive from state<> instead of - // simple_state<>. - BOOST_ASSERT( get_pointer( stt.pContext_ ) != 0 ); - return stt.pContext_->template context_ptr< OtherContext >(); - } - }; - friend struct context_ptr_impl_other_context; - - struct context_ptr_impl_my_context - { - template< class OtherContext, class State > - static const typename OtherContext::inner_context_ptr_type & - context_ptr_impl( const State & stt ) - { - // This assert fails when an attempt is made to access an outer - // context from a constructor of a state that is *not* a subtype of - // state<>. To correct this, derive from state<> instead of - // simple_state<>. - BOOST_ASSERT( get_pointer( stt.pContext_ ) != 0 ); - return stt.pContext_; - } - }; - friend struct context_ptr_impl_my_context; - - struct context_impl_other_context - { - template< class OtherContext, class State > - static OtherContext & context_impl( State & stt ) - { - // This assert fails when an attempt is made to access an outer - // context from a constructor of a state that is *not* a subtype of - // state<>. To correct this, derive from state<> instead of - // simple_state<>. - BOOST_ASSERT( get_pointer( stt.pContext_ ) != 0 ); - return stt.pContext_->template context< OtherContext >(); - } - }; - friend struct context_impl_other_context; - - struct context_impl_this_context - { - template< class OtherContext, class State > - static OtherContext & context_impl( State & stt ) - { - return *polymorphic_downcast< MostDerived * >( &stt ); - } - }; - friend struct context_impl_this_context; - - template< class DestinationState, - class TransitionContext, - class TransitionAction > - result transit_impl( const TransitionAction & transitionAction ) - { - typedef typename mpl::find_if< - context_type_list, - mpl::contains< - typename DestinationState::context_type_list, - mpl::placeholders::_ > >::type common_context_iter; - typedef typename mpl::deref< common_context_iter >::type - common_context_type; - typedef typename mpl::distance< - typename mpl::begin< context_type_list >::type, - common_context_iter >::type termination_state_position; - typedef typename mpl::push_front< context_type_list, MostDerived >::type - possible_transition_contexts; - typedef typename mpl::at< - possible_transition_contexts, - termination_state_position >::type termination_state_type; - - termination_state_type & terminationState( - context< termination_state_type >() ); - const typename - common_context_type::inner_context_ptr_type pCommonContext( - terminationState.template context_ptr< common_context_type >() ); - outermost_context_base_type & outermostContextBase( - pCommonContext->outermost_context_base() ); - - #ifdef BOOST_STATECHART_RELAX_TRANSITION_CONTEXT - typedef typename mpl::distance< - typename mpl::begin< possible_transition_contexts >::type, - typename mpl::find< - possible_transition_contexts, TransitionContext >::type - >::type proposed_transition_context_position; - - typedef typename mpl::plus< - termination_state_position, - mpl::long_< 1 > - >::type uml_transition_context_position; - - typedef typename mpl::deref< typename mpl::max_element< - mpl::list< - proposed_transition_context_position, - uml_transition_context_position >, - mpl::greater< mpl::placeholders::_, mpl::placeholders::_ > - >::type >::type real_transition_context_position; - - typedef typename mpl::at< - possible_transition_contexts, - real_transition_context_position >::type real_transition_context_type; - - #ifdef BOOST_MSVC - # pragma warning( push ) - # pragma warning( disable: 4127 ) // conditional expression is constant - #endif - if ( ( proposed_transition_context_position::value == 0 ) && - ( inner_initial_list_size::value == 0 ) ) - { - transitionAction( *polymorphic_downcast< MostDerived * >( this ) ); - outermostContextBase.terminate_as_part_of_transit( terminationState ); - } - else if ( proposed_transition_context_position::value >= - uml_transition_context_position::value ) - { - real_transition_context_type & transitionContext = - context< real_transition_context_type >(); - outermostContextBase.terminate_as_part_of_transit( terminationState ); - transitionAction( transitionContext ); - } - else - { - typename real_transition_context_type::inner_context_ptr_type - pTransitionContext = context_ptr< real_transition_context_type >(); - outermostContextBase.terminate_as_part_of_transit( - *pTransitionContext ); - transitionAction( *pTransitionContext ); - pTransitionContext = 0; - outermostContextBase.terminate_as_part_of_transit( terminationState ); - } - #ifdef BOOST_MSVC - # pragma warning( pop ) - #endif - #else - outermostContextBase.terminate_as_part_of_transit( terminationState ); - transitionAction( *pCommonContext ); - #endif - - typedef typename detail::make_context_list< - common_context_type, DestinationState >::type context_list_type; - - // If you receive a - // "use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'" or - // similar compiler error here then you tried to make an invalid - // transition between different orthogonal regions. - BOOST_STATIC_ASSERT( ( mpl::equal_to< - typename termination_state_type::orthogonal_position, - typename mpl::front< context_list_type >::type::orthogonal_position - >::value ) ); - - detail::constructor< - context_list_type, outermost_context_base_type >::construct( - pCommonContext, outermostContextBase ); - - return detail::result_utility::make_result( detail::do_discard_event ); - } - - struct local_react_impl_non_empty - { - template< class ReactionList, class State > - static detail::reaction_result local_react_impl( - State & stt, - const event_base_type & evt, - typename rtti_policy_type::id_type eventType ) - { - detail::reaction_result reactionResult = - mpl::front< ReactionList >::type::react( - *polymorphic_downcast< MostDerived * >( &stt ), - evt, eventType ); - - if ( reactionResult == detail::no_reaction ) - { - reactionResult = stt.template local_react< - typename mpl::pop_front< ReactionList >::type >( - evt, eventType ); - } - - return reactionResult; - } - }; - friend struct local_react_impl_non_empty; - - struct local_react_impl_empty - { - template< class ReactionList, class State > - static detail::reaction_result local_react_impl( - State &, const event_base_type &, typename rtti_policy_type::id_type ) - { - return detail::do_forward_event; - } - }; - - template< class ReactionList > - detail::reaction_result local_react( - const event_base_type & evt, - typename rtti_policy_type::id_type eventType ) - { - typedef typename mpl::if_< - mpl::empty< ReactionList >, - local_react_impl_empty, - local_react_impl_non_empty - >::type impl; - return impl::template local_react_impl< ReactionList >( - *this, evt, eventType ); - } - - struct outer_state_ptr_impl_non_outermost - { - template< class State > - static const state_base_type * outer_state_ptr_impl( const State & stt ) - { - return get_pointer( stt.pContext_ ); - } - }; - friend struct outer_state_ptr_impl_non_outermost; - - struct outer_state_ptr_impl_outermost - { - template< class State > - static const state_base_type * outer_state_ptr_impl( const State & ) - { - return 0; - } - }; - - struct deep_construct_inner_impl_non_empty - { - template< class InnerList > - static void deep_construct_inner_impl( - const inner_context_ptr_type & pInnerContext, - outermost_context_base_type & outermostContextBase ) - { - typedef typename mpl::front< InnerList >::type current_inner; - - // If you receive a - // "use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'" or - // similar compiler error here then there is a mismatch between the - // orthogonal position of a state and its position in the inner - // initial list of its outer state. - BOOST_STATIC_ASSERT( ( is_same< - current_inner, - typename mpl::at< - typename current_inner::context_type::inner_initial_list, - typename current_inner::orthogonal_position >::type >::value ) ); - - current_inner::deep_construct( pInnerContext, outermostContextBase ); - deep_construct_inner< typename mpl::pop_front< InnerList >::type >( - pInnerContext, outermostContextBase ); - } - }; - - struct deep_construct_inner_impl_empty - { - template< class InnerList > - static void deep_construct_inner_impl( - const inner_context_ptr_type &, outermost_context_base_type & ) {} - }; - - struct check_store_shallow_history_impl_no - { - template< class State > - static void check_store_shallow_history_impl( State & ) {} - }; - - struct check_store_shallow_history_impl_yes - { - template< class State > - static void check_store_shallow_history_impl( State & stt ) - { - stt.outermost_context_base().template store_shallow_history< - MostDerived >(); - } - }; - friend struct check_store_shallow_history_impl_yes; - - template< class StoreShallowHistory > - void check_store_shallow_history() - { - typedef typename mpl::if_< - StoreShallowHistory, - check_store_shallow_history_impl_yes, - check_store_shallow_history_impl_no - >::type impl; - impl::check_store_shallow_history_impl( *this ); - } - - struct check_store_deep_history_impl_no - { - template< class State > - static void check_store_deep_history_impl( State & ) {} - }; - - struct check_store_deep_history_impl_yes - { - template< class State > - static void check_store_deep_history_impl( State & stt ) - { - stt.template store_deep_history_impl< MostDerived >(); - } - }; - friend struct check_store_deep_history_impl_yes; - - template< class StoreDeepHistory > - void check_store_deep_history() - { - typedef typename mpl::if_< - StoreDeepHistory, - check_store_deep_history_impl_yes, - check_store_deep_history_impl_no - >::type impl; - impl::check_store_deep_history_impl( *this ); - } - - - context_ptr_type pContext_; -}; - - - -#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP -} // namespace statechart -#endif - - - -template< class MostDerived, class Context, - class InnerInitial, history_mode historyMode > -inline void intrusive_ptr_release( const ::boost::statechart::simple_state< - MostDerived, Context, InnerInitial, historyMode > * pBase ) -{ - if ( pBase->release() ) - { - // The cast is necessary because the simple_state destructor is non- - // virtual (and inaccessible from this context) - delete polymorphic_downcast< const MostDerived * >( pBase ); - } -} - - - -#ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP -} // namespace statechart -#endif - - - -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/state.hpp b/contrib/restricted/boost/boost/statechart/state.hpp deleted file mode 100644 index ab9ea0aa1a9..00000000000 --- a/contrib/restricted/boost/boost/statechart/state.hpp +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef BOOST_STATECHART_STATE_HPP_INCLUDED -#define BOOST_STATECHART_STATE_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2006 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/simple_state.hpp> - -#include <boost/mpl/list.hpp> - - - -namespace boost -{ -namespace statechart -{ - - - -template< class MostDerived, - class Context, - class InnerInitial = mpl::list<>, - history_mode historyMode = has_no_history > -class state : public simple_state< - MostDerived, Context, InnerInitial, historyMode > -{ - typedef simple_state< MostDerived, Context, InnerInitial, historyMode > - base_type; - - protected: - ////////////////////////////////////////////////////////////////////////// - struct my_context - { - my_context( typename base_type::context_ptr_type pContext ) : - pContext_( pContext ) - { - } - - typename base_type::context_ptr_type pContext_; - }; - - typedef state my_base; - - state( my_context ctx ) - { - this->set_context( ctx.pContext_ ); - } - - ~state() {} - - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - // See base class for documentation - typedef typename base_type::outermost_context_base_type - outermost_context_base_type; - typedef typename base_type::inner_context_ptr_type inner_context_ptr_type; - typedef typename base_type::context_ptr_type context_ptr_type; - typedef typename base_type::inner_initial_list inner_initial_list; - - static void initial_deep_construct( - outermost_context_base_type & outermostContextBase ) - { - deep_construct( &outermostContextBase, outermostContextBase ); - } - - // See base class for documentation - static void deep_construct( - const context_ptr_type & pContext, - outermost_context_base_type & outermostContextBase ) - { - const inner_context_ptr_type pInnerContext( - shallow_construct( pContext, outermostContextBase ) ); - base_type::template deep_construct_inner< inner_initial_list >( - pInnerContext, outermostContextBase ); - } - - static inner_context_ptr_type shallow_construct( - const context_ptr_type & pContext, - outermost_context_base_type & outermostContextBase ) - { - const inner_context_ptr_type pInnerContext( - new MostDerived( my_context( pContext ) ) ); - outermostContextBase.add( pInnerContext ); - return pInnerContext; - } -}; - - - -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/state_machine.hpp b/contrib/restricted/boost/boost/statechart/state_machine.hpp deleted file mode 100644 index f03f5f8521b..00000000000 --- a/contrib/restricted/boost/boost/statechart/state_machine.hpp +++ /dev/null @@ -1,1091 +0,0 @@ -#ifndef BOOST_STATECHART_STATE_MACHINE_HPP_INCLUDED -#define BOOST_STATECHART_STATE_MACHINE_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2010 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/event.hpp> -#include <boost/statechart/null_exception_translator.hpp> -#include <boost/statechart/result.hpp> - -#include <boost/statechart/detail/rtti_policy.hpp> -#include <boost/statechart/detail/state_base.hpp> -#include <boost/statechart/detail/leaf_state.hpp> -#include <boost/statechart/detail/node_state.hpp> -#include <boost/statechart/detail/constructor.hpp> -#include <boost/statechart/detail/avoid_unused_warning.hpp> - -#include <boost/mpl/list.hpp> -#include <boost/mpl/clear.hpp> -#include <boost/mpl/if.hpp> -#include <boost/mpl/at.hpp> -#include <boost/mpl/integral_c.hpp> -#include <boost/mpl/minus.hpp> -#include <boost/mpl/equal_to.hpp> - -#include <boost/intrusive_ptr.hpp> -#include <boost/type_traits/is_pointer.hpp> -#include <boost/type_traits/remove_reference.hpp> -#include <boost/noncopyable.hpp> -#include <boost/assert.hpp> -#include <boost/static_assert.hpp> -#include <boost/polymorphic_cast.hpp> // boost::polymorphic_downcast -// BOOST_NO_EXCEPTIONS, BOOST_MSVC, BOOST_MSVC_STD_ITERATOR -#include <boost/config.hpp> - -#include <boost/detail/allocator_utilities.hpp> - -#ifdef BOOST_MSVC -# pragma warning( push ) -# pragma warning( disable: 4702 ) // unreachable code (in release mode only) -#endif - -#include <map> - -#ifdef BOOST_MSVC -# pragma warning( pop ) -#endif - -#include <memory> // std::allocator -#include <typeinfo> // std::bad_cast -#include <functional> // std::less -#include <iterator> - - - -namespace boost -{ -namespace statechart -{ -namespace detail -{ - - - -////////////////////////////////////////////////////////////////////////////// -template< class StateBaseType, class EventBaseType, class IdType > -class send_function -{ - public: - ////////////////////////////////////////////////////////////////////////// - send_function( - StateBaseType & toState, - const EventBaseType & evt, - IdType eventType - ) : - toState_( toState ), evt_( evt ), eventType_( eventType ) - { - } - - result operator()() - { - return detail::result_utility::make_result( - toState_.react_impl( evt_, eventType_ ) ); - } - - private: - ////////////////////////////////////////////////////////////////////////// - // avoids C4512 (assignment operator could not be generated) - send_function & operator=( const send_function & ); - - StateBaseType & toState_; - const EventBaseType & evt_; - IdType eventType_; -}; - - -////////////////////////////////////////////////////////////////////////////// -struct state_cast_impl_pointer_target -{ - public: - ////////////////////////////////////////////////////////////////////////// - template< class StateBaseType > - static const StateBaseType * deref_if_necessary( - const StateBaseType * pState ) - { - return pState; - } - - template< class Target, class IdType > - static IdType type_id() - { - Target p = 0; - return type_id_impl< IdType >( p ); - } - - static bool found( const void * pFound ) - { - return pFound != 0; - } - - template< class Target > - static Target not_found() - { - return 0; - } - - private: - ////////////////////////////////////////////////////////////////////////// - template< class IdType, class Type > - static IdType type_id_impl( const Type * ) - { - return Type::static_type(); - } -}; - -struct state_cast_impl_reference_target -{ - template< class StateBaseType > - static const StateBaseType & deref_if_necessary( - const StateBaseType * pState ) - { - return *pState; - } - - template< class Target, class IdType > - static IdType type_id() - { - return remove_reference< Target >::type::static_type(); - } - - template< class Dummy > - static bool found( const Dummy & ) - { - return true; - } - - template< class Target > - static Target not_found() - { - throw std::bad_cast(); - } -}; - -template< class Target > -struct state_cast_impl : public mpl::if_< - is_pointer< Target >, - state_cast_impl_pointer_target, - state_cast_impl_reference_target ->::type {}; - - -////////////////////////////////////////////////////////////////////////////// -template< class RttiPolicy > -class history_key -{ - public: - ////////////////////////////////////////////////////////////////////////// - template< class HistorizedState > - static history_key make_history_key() - { - return history_key( - HistorizedState::context_type::static_type(), - HistorizedState::orthogonal_position::value ); - } - - typename RttiPolicy::id_type history_context_type() const - { - return historyContextType_; - } - - friend bool operator<( - const history_key & left, const history_key & right ) - { - return - std::less< typename RttiPolicy::id_type >()( - left.historyContextType_, right.historyContextType_ ) || - ( ( left.historyContextType_ == right.historyContextType_ ) && - ( left.historizedOrthogonalRegion_ < - right.historizedOrthogonalRegion_ ) ); - } - - private: - ////////////////////////////////////////////////////////////////////////// - history_key( - typename RttiPolicy::id_type historyContextType, - orthogonal_position_type historizedOrthogonalRegion - ) : - historyContextType_( historyContextType ), - historizedOrthogonalRegion_( historizedOrthogonalRegion ) - { - } - - // avoids C4512 (assignment operator could not be generated) - history_key & operator=( const history_key & ); - - const typename RttiPolicy::id_type historyContextType_; - const orthogonal_position_type historizedOrthogonalRegion_; -}; - - - -} // namespace detail - - - -////////////////////////////////////////////////////////////////////////////// -template< class MostDerived, - class InitialState, - class Allocator = std::allocator< void >, - class ExceptionTranslator = null_exception_translator > -class state_machine : noncopyable -{ - public: - ////////////////////////////////////////////////////////////////////////// - typedef Allocator allocator_type; - typedef detail::rtti_policy rtti_policy_type; - typedef event_base event_base_type; - typedef intrusive_ptr< const event_base_type > event_base_ptr_type; - - void initiate() - { - terminate(); - - { - terminator guard( *this, 0 ); - detail::result_utility::get_result( translator_( - initial_construct_function( *this ), - exception_event_handler( *this ) ) ); - guard.dismiss(); - } - - process_queued_events(); - } - - void terminate() - { - terminator guard( *this, 0 ); - detail::result_utility::get_result( translator_( - terminate_function( *this ), - exception_event_handler( *this ) ) ); - guard.dismiss(); - } - - bool terminated() const - { - return pOutermostState_ == 0; - } - - void process_event( const event_base_type & evt ) - { - if ( send_event( evt ) == detail::do_defer_event ) - { - deferredEventQueue_.push_back( evt.intrusive_from_this() ); - } - - process_queued_events(); - } - - template< class Target > - Target state_cast() const - { - typedef detail::state_cast_impl< Target > impl; - - for ( typename state_list_type::const_iterator pCurrentLeafState = - currentStates_.begin(); - pCurrentLeafState != currentStatesEnd_; - ++pCurrentLeafState ) - { - const state_base_type * pCurrentState( - get_pointer( *pCurrentLeafState ) ); - - while ( pCurrentState != 0 ) - { - // The unnecessary try/catch overhead for pointer targets is - // typically small compared to the cycles dynamic_cast needs - #ifndef BOOST_NO_EXCEPTIONS - try - #endif - { - Target result = dynamic_cast< Target >( - impl::deref_if_necessary( pCurrentState ) ); - - if ( impl::found( result ) ) - { - return result; - } - } - #ifndef BOOST_NO_EXCEPTIONS - // Intentionally swallow std::bad_cast exceptions. We'll throw one - // ourselves when we fail to find a state that can be cast to Target - catch ( const std::bad_cast & ) {} - #endif - - pCurrentState = pCurrentState->outer_state_ptr(); - } - } - - return impl::template not_found< Target >(); - } - - template< class Target > - Target state_downcast() const - { - typedef detail::state_cast_impl< Target > impl; - - typename rtti_policy_type::id_type targetType = - impl::template type_id< Target, rtti_policy_type::id_type >(); - - for ( typename state_list_type::const_iterator pCurrentLeafState = - currentStates_.begin(); - pCurrentLeafState != currentStatesEnd_; - ++pCurrentLeafState ) - { - const state_base_type * pCurrentState( - get_pointer( *pCurrentLeafState ) ); - - while ( pCurrentState != 0 ) - { - if ( pCurrentState->dynamic_type() == targetType ) - { - return static_cast< Target >( - impl::deref_if_necessary( pCurrentState ) ); - } - - pCurrentState = pCurrentState->outer_state_ptr(); - } - } - - return impl::template not_found< Target >(); - } - - typedef detail::state_base< allocator_type, rtti_policy_type > - state_base_type; - - class state_iterator : public std::iterator< - std::forward_iterator_tag, - state_base_type, std::ptrdiff_t - #ifndef BOOST_MSVC_STD_ITERATOR - , const state_base_type *, const state_base_type & - #endif - > - { - public: - ////////////////////////////////////////////////////////////////////// - explicit state_iterator( - typename state_base_type::state_list_type::const_iterator - baseIterator - ) : baseIterator_( baseIterator ) {} - - const state_base_type & operator*() const { return **baseIterator_; } - const state_base_type * operator->() const - { - return &**baseIterator_; - } - - state_iterator & operator++() { ++baseIterator_; return *this; } - state_iterator operator++( int ) - { - return state_iterator( baseIterator_++ ); - } - - bool operator==( const state_iterator & right ) const - { - return baseIterator_ == right.baseIterator_; - } - bool operator!=( const state_iterator & right ) const - { - return !( *this == right ); - } - - private: - typename state_base_type::state_list_type::const_iterator - baseIterator_; - }; - - state_iterator state_begin() const - { - return state_iterator( currentStates_.begin() ); - } - - state_iterator state_end() const - { - return state_iterator( currentStatesEnd_ ); - } - - void unconsumed_event( const event_base & ) {} - - protected: - ////////////////////////////////////////////////////////////////////////// - state_machine() : - currentStatesEnd_( currentStates_.end() ), - pOutermostState_( 0 ), - isInnermostCommonOuter_( false ), - performFullExit_( true ), - pTriggeringEvent_( 0 ) - { - } - - // This destructor was only made virtual so that that - // polymorphic_downcast can be used to cast to MostDerived. - virtual ~state_machine() - { - terminate_impl( false ); - } - - void post_event( const event_base_ptr_type & pEvent ) - { - post_event_impl( pEvent ); - } - - void post_event( const event_base & evt ) - { - post_event_impl( evt ); - } - - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be protected. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - template< - class HistoryContext, - detail::orthogonal_position_type orthogonalPosition > - void clear_shallow_history() - { - // If you receive a - // "use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'" or - // similar compiler error here then you tried to clear shallow history - // for a state that does not have shallow history. That is, the state - // does not pass either statechart::has_shallow_history or - // statechart::has_full_history to its base class template. - BOOST_STATIC_ASSERT( HistoryContext::shallow_history::value ); - - typedef typename mpl::at_c< - typename HistoryContext::inner_initial_list, - orthogonalPosition >::type historized_state; - - store_history_impl( - shallowHistoryMap_, - history_key_type::make_history_key< historized_state >(), - 0 ); - } - - template< - class HistoryContext, - detail::orthogonal_position_type orthogonalPosition > - void clear_deep_history() - { - // If you receive a - // "use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'" or - // similar compiler error here then you tried to clear deep history for - // a state that does not have deep history. That is, the state does not - // pass either statechart::has_deep_history or - // statechart::has_full_history to its base class template - BOOST_STATIC_ASSERT( HistoryContext::deep_history::value ); - - typedef typename mpl::at_c< - typename HistoryContext::inner_initial_list, - orthogonalPosition >::type historized_state; - - store_history_impl( - deepHistoryMap_, - history_key_type::make_history_key< historized_state >(), - 0 ); - } - - const event_base_type * triggering_event() const - { - return pTriggeringEvent_; - } - - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - typedef MostDerived inner_context_type; - typedef mpl::integral_c< detail::orthogonal_position_type, 0 > - inner_orthogonal_position; - typedef mpl::integral_c< detail::orthogonal_position_type, 1 > - no_of_orthogonal_regions; - - typedef MostDerived outermost_context_type; - typedef state_machine outermost_context_base_type; - typedef state_machine * inner_context_ptr_type; - typedef typename state_base_type::node_state_base_ptr_type - node_state_base_ptr_type; - typedef typename state_base_type::leaf_state_ptr_type leaf_state_ptr_type; - typedef typename state_base_type::state_list_type state_list_type; - - typedef mpl::clear< mpl::list<> >::type context_type_list; - - typedef mpl::bool_< false > shallow_history; - typedef mpl::bool_< false > deep_history; - typedef mpl::bool_< false > inherited_deep_history; - - void post_event_impl( const event_base_ptr_type & pEvent ) - { - BOOST_ASSERT( get_pointer( pEvent ) != 0 ); - eventQueue_.push_back( pEvent ); - } - - void post_event_impl( const event_base & evt ) - { - post_event_impl( evt.intrusive_from_this() ); - } - - detail::reaction_result react_impl( - const event_base_type &, - typename rtti_policy_type::id_type ) - { - return detail::do_forward_event; - } - - void exit_impl( - inner_context_ptr_type &, - typename state_base_type::node_state_base_ptr_type &, - bool ) {} - - void set_outermost_unstable_state( - typename state_base_type::node_state_base_ptr_type & - pOutermostUnstableState ) - { - pOutermostUnstableState = 0; - } - - // Returns a reference to the context identified by the template - // parameter. This can either be _this_ object or one of its direct or - // indirect contexts. - template< class Context > - Context & context() - { - // As we are in the outermost context here, only this object can be - // returned. - return *polymorphic_downcast< MostDerived * >( this ); - } - - template< class Context > - const Context & context() const - { - // As we are in the outermost context here, only this object can be - // returned. - return *polymorphic_downcast< const MostDerived * >( this ); - } - - outermost_context_type & outermost_context() - { - return *polymorphic_downcast< MostDerived * >( this ); - } - - const outermost_context_type & outermost_context() const - { - return *polymorphic_downcast< const MostDerived * >( this ); - } - - outermost_context_base_type & outermost_context_base() - { - return *this; - } - - const outermost_context_base_type & outermost_context_base() const - { - return *this; - } - - void terminate_as_reaction( state_base_type & theState ) - { - terminate_impl( theState, performFullExit_ ); - pOutermostUnstableState_ = 0; - } - - void terminate_as_part_of_transit( state_base_type & theState ) - { - terminate_impl( theState, performFullExit_ ); - isInnermostCommonOuter_ = true; - } - - void terminate_as_part_of_transit( state_machine & ) - { - terminate_impl( *pOutermostState_, performFullExit_ ); - isInnermostCommonOuter_ = true; - } - - - template< class State > - void add( const intrusive_ptr< State > & pState ) - { - // The second dummy argument is necessary because the call to the - // overloaded function add_impl would otherwise be ambiguous. - node_state_base_ptr_type pNewOutermostUnstableStateCandidate = - add_impl( pState, *pState ); - - if ( isInnermostCommonOuter_ || - ( is_in_highest_orthogonal_region< State >() && - ( get_pointer( pOutermostUnstableState_ ) == - pState->State::outer_state_ptr() ) ) ) - { - isInnermostCommonOuter_ = false; - pOutermostUnstableState_ = pNewOutermostUnstableStateCandidate; - } - } - - - void add_inner_state( - detail::orthogonal_position_type position, - state_base_type * pOutermostState ) - { - BOOST_ASSERT( position == 0 ); - detail::avoid_unused_warning( position ); - pOutermostState_ = pOutermostState; - } - - void remove_inner_state( detail::orthogonal_position_type position ) - { - BOOST_ASSERT( position == 0 ); - detail::avoid_unused_warning( position ); - pOutermostState_ = 0; - } - - - void release_events() - { - eventQueue_.splice( eventQueue_.begin(), deferredEventQueue_ ); - } - - - template< class HistorizedState > - void store_shallow_history() - { - // 5.2.10.6 declares that reinterpret_casting a function pointer to a - // different function pointer and back must yield the same value. The - // following reinterpret_cast is the first half of such a sequence. - store_history_impl( - shallowHistoryMap_, - history_key_type::make_history_key< HistorizedState >(), - reinterpret_cast< void (*)() >( &HistorizedState::deep_construct ) ); - } - - template< class DefaultState > - void construct_with_shallow_history( - const typename DefaultState::context_ptr_type & pContext ) - { - construct_with_history_impl< DefaultState >( - shallowHistoryMap_, pContext ); - } - - - template< class HistorizedState, class LeafState > - void store_deep_history() - { - typedef typename detail::make_context_list< - typename HistorizedState::context_type, - LeafState >::type history_context_list; - typedef detail::constructor< - history_context_list, outermost_context_base_type > constructor_type; - // 5.2.10.6 declares that reinterpret_casting a function pointer to a - // different function pointer and back must yield the same value. The - // following reinterpret_cast is the first half of such a sequence. - store_history_impl( - deepHistoryMap_, - history_key_type::make_history_key< HistorizedState >(), - reinterpret_cast< void (*)() >( &constructor_type::construct ) ); - } - - template< class DefaultState > - void construct_with_deep_history( - const typename DefaultState::context_ptr_type & pContext ) - { - construct_with_history_impl< DefaultState >( - deepHistoryMap_, pContext ); - } - - private: // implementation - ////////////////////////////////////////////////////////////////////////// - void initial_construct() - { - InitialState::initial_deep_construct( - *polymorphic_downcast< MostDerived * >( this ) ); - } - - class initial_construct_function - { - public: - ////////////////////////////////////////////////////////////////////// - initial_construct_function( state_machine & machine ) : - machine_( machine ) - { - } - - result operator()() - { - machine_.initial_construct(); - return detail::result_utility::make_result( - detail::do_discard_event ); // there is nothing to be consumed - } - - private: - ////////////////////////////////////////////////////////////////////// - // avoids C4512 (assignment operator could not be generated) - initial_construct_function & operator=( - const initial_construct_function & ); - - state_machine & machine_; - }; - friend class initial_construct_function; - - class terminate_function - { - public: - ////////////////////////////////////////////////////////////////////// - terminate_function( state_machine & machine ) : machine_( machine ) {} - - result operator()() - { - machine_.terminate_impl( true ); - return detail::result_utility::make_result( - detail::do_discard_event ); // there is nothing to be consumed - } - - private: - ////////////////////////////////////////////////////////////////////// - // avoids C4512 (assignment operator could not be generated) - terminate_function & operator=( const terminate_function & ); - - state_machine & machine_; - }; - friend class terminate_function; - - template< class ExceptionEvent > - detail::reaction_result handle_exception_event( - const ExceptionEvent & exceptionEvent, - state_base_type * pCurrentState ) - { - if ( terminated() ) - { - // there is no state that could handle the exception -> bail out - throw; - } - - // If we are stable, an event handler has thrown. - // Otherwise, either a state constructor, a transition action or an exit - // function has thrown and the state machine is now in an invalid state. - // This situation can be resolved by the exception event handler - // function by orderly transiting to another state or terminating. - // As a result of this, the machine must not be unstable when this - // function is left. - state_base_type * const pOutermostUnstableState = - get_pointer( pOutermostUnstableState_ ); - state_base_type * const pHandlingState = pOutermostUnstableState == 0 ? - pCurrentState : pOutermostUnstableState; - - BOOST_ASSERT( pHandlingState != 0 ); - terminator guard( *this, &exceptionEvent ); - // There is another scope guard up the call stack, which will terminate - // the machine. So this guard only sets the triggering event. - guard.dismiss(); - - // Setting a member variable to a special value for the duration of a - // call surely looks like a kludge (normally it should be a parameter of - // the call). However, in this case it is unavoidable because the call - // below could result in a call to user code where passing through an - // additional bool parameter is not acceptable. - performFullExit_ = false; - const detail::reaction_result reactionResult = pHandlingState->react_impl( - exceptionEvent, exceptionEvent.dynamic_type() ); - // If the above call throws then performFullExit_ will obviously not be - // set back to true. In this case the termination triggered by the - // scope guard further up in the call stack will take care of this. - performFullExit_ = true; - - if ( ( reactionResult != detail::do_discard_event ) || - ( get_pointer( pOutermostUnstableState_ ) != 0 ) ) - { - throw; - } - - return detail::do_discard_event; - } - - class exception_event_handler - { - public: - ////////////////////////////////////////////////////////////////////// - exception_event_handler( - state_machine & machine, - state_base_type * pCurrentState = 0 - ) : - machine_( machine ), - pCurrentState_( pCurrentState ) - { - } - - template< class ExceptionEvent > - result operator()( - const ExceptionEvent & exceptionEvent ) - { - return detail::result_utility::make_result( - machine_.handle_exception_event( - exceptionEvent, pCurrentState_ ) ); - } - - private: - ////////////////////////////////////////////////////////////////////// - // avoids C4512 (assignment operator could not be generated) - exception_event_handler & operator=( - const exception_event_handler & ); - - state_machine & machine_; - state_base_type * pCurrentState_; - }; - friend class exception_event_handler; - - class terminator - { - public: - ////////////////////////////////////////////////////////////////////// - terminator( - state_machine & machine, const event_base * pNewTriggeringEvent ) : - machine_( machine ), - pOldTriggeringEvent_(machine_.pTriggeringEvent_), - dismissed_( false ) - { - machine_.pTriggeringEvent_ = pNewTriggeringEvent; - } - - ~terminator() - { - if ( !dismissed_ ) { machine_.terminate_impl( false ); } - machine_.pTriggeringEvent_ = pOldTriggeringEvent_; - } - - void dismiss() { dismissed_ = true; } - - private: - ////////////////////////////////////////////////////////////////////// - // avoids C4512 (assignment operator could not be generated) - terminator & operator=( const terminator & ); - - state_machine & machine_; - const event_base_type * const pOldTriggeringEvent_; - bool dismissed_; - }; - friend class terminator; - - - detail::reaction_result send_event( const event_base_type & evt ) - { - terminator guard( *this, &evt ); - BOOST_ASSERT( get_pointer( pOutermostUnstableState_ ) == 0 ); - const typename rtti_policy_type::id_type eventType = evt.dynamic_type(); - detail::reaction_result reactionResult = detail::do_forward_event; - - for ( - typename state_list_type::iterator pState = currentStates_.begin(); - ( reactionResult == detail::do_forward_event ) && - ( pState != currentStatesEnd_ ); - ++pState ) - { - // CAUTION: The following statement could modify our state list! - // We must not continue iterating if the event was consumed - reactionResult = detail::result_utility::get_result( translator_( - detail::send_function< - state_base_type, event_base_type, rtti_policy_type::id_type >( - **pState, evt, eventType ), - exception_event_handler( *this, get_pointer( *pState ) ) ) ); - } - - guard.dismiss(); - - if ( reactionResult == detail::do_forward_event ) - { - polymorphic_downcast< MostDerived * >( this )->unconsumed_event( evt ); - } - - return reactionResult; - } - - - void process_queued_events() - { - while ( !eventQueue_.empty() ) - { - event_base_ptr_type pEvent = eventQueue_.front(); - eventQueue_.pop_front(); - - if ( send_event( *pEvent ) == detail::do_defer_event ) - { - deferredEventQueue_.push_back( pEvent ); - } - } - } - - - void terminate_impl( bool performFullExit ) - { - performFullExit_ = true; - - if ( !terminated() ) - { - terminate_impl( *pOutermostState_, performFullExit ); - } - - eventQueue_.clear(); - deferredEventQueue_.clear(); - shallowHistoryMap_.clear(); - deepHistoryMap_.clear(); - } - - void terminate_impl( state_base_type & theState, bool performFullExit ) - { - isInnermostCommonOuter_ = false; - - // If pOutermostUnstableState_ == 0, we know for sure that - // currentStates_.size() > 0, otherwise theState couldn't be alive any - // more - if ( get_pointer( pOutermostUnstableState_ ) != 0 ) - { - theState.remove_from_state_list( - currentStatesEnd_, pOutermostUnstableState_, performFullExit ); - } - // Optimization: We want to find out whether currentStates_ has size 1 - // and if yes use the optimized implementation below. Since - // list<>::size() is implemented quite inefficiently in some std libs - // it is best to just decrement the currentStatesEnd_ here and - // increment it again, if the test failed. - else if ( currentStates_.begin() == --currentStatesEnd_ ) - { - // The machine is stable and there is exactly one innermost state. - // The following optimization is only correct for a stable machine - // without orthogonal regions. - leaf_state_ptr_type & pState = *currentStatesEnd_; - pState->exit_impl( - pState, pOutermostUnstableState_, performFullExit ); - } - else - { - BOOST_ASSERT( currentStates_.size() > 1 ); - // The machine is stable and there are multiple innermost states - theState.remove_from_state_list( - ++currentStatesEnd_, pOutermostUnstableState_, performFullExit ); - } - } - - - node_state_base_ptr_type add_impl( - const leaf_state_ptr_type & pState, - detail::leaf_state< allocator_type, rtti_policy_type > & ) - { - if ( currentStatesEnd_ == currentStates_.end() ) - { - pState->set_list_position( - currentStates_.insert( currentStatesEnd_, pState ) ); - } - else - { - *currentStatesEnd_ = pState; - pState->set_list_position( currentStatesEnd_ ); - ++currentStatesEnd_; - } - - return 0; - } - - node_state_base_ptr_type add_impl( - const node_state_base_ptr_type & pState, - state_base_type & ) - { - return pState; - } - - template< class State > - static bool is_in_highest_orthogonal_region() - { - return mpl::equal_to< - typename State::orthogonal_position, - mpl::minus< - typename State::context_type::no_of_orthogonal_regions, - mpl::integral_c< detail::orthogonal_position_type, 1 > > - >::value; - } - - - typedef detail::history_key< rtti_policy_type > history_key_type; - - typedef std::map< - history_key_type, void (*)(), - std::less< history_key_type >, - typename boost::detail::allocator::rebind_to< - allocator_type, std::pair< const history_key_type, void (*)() > - >::type - > history_map_type; - - void store_history_impl( - history_map_type & historyMap, - const history_key_type & historyId, - void (*pConstructFunction)() ) - { - historyMap[ historyId ] = pConstructFunction; - } - - template< class DefaultState > - void construct_with_history_impl( - history_map_type & historyMap, - const typename DefaultState::context_ptr_type & pContext ) - { - typename history_map_type::iterator pFoundSlot = historyMap.find( - history_key_type::make_history_key< DefaultState >() ); - - if ( ( pFoundSlot == historyMap.end() ) || ( pFoundSlot->second == 0 ) ) - { - // We have never entered this state before or history was cleared - DefaultState::deep_construct( - pContext, *polymorphic_downcast< MostDerived * >( this ) ); - } - else - { - typedef void construct_function( - const typename DefaultState::context_ptr_type &, - typename DefaultState::outermost_context_base_type & ); - // 5.2.10.6 declares that reinterpret_casting a function pointer to a - // different function pointer and back must yield the same value. The - // following reinterpret_cast is the second half of such a sequence. - construct_function * const pConstructFunction = - reinterpret_cast< construct_function * >( pFoundSlot->second ); - (*pConstructFunction)( - pContext, *polymorphic_downcast< MostDerived * >( this ) ); - } - } - - typedef std::list< - event_base_ptr_type, - typename boost::detail::allocator::rebind_to< - allocator_type, event_base_ptr_type >::type - > event_queue_type; - - typedef std::map< - const state_base_type *, event_queue_type, - std::less< const state_base_type * >, - typename boost::detail::allocator::rebind_to< - allocator_type, - std::pair< const state_base_type * const, event_queue_type > - >::type - > deferred_map_type; - - - event_queue_type eventQueue_; - event_queue_type deferredEventQueue_; - state_list_type currentStates_; - typename state_list_type::iterator currentStatesEnd_; - state_base_type * pOutermostState_; - bool isInnermostCommonOuter_; - node_state_base_ptr_type pOutermostUnstableState_; - ExceptionTranslator translator_; - bool performFullExit_; - history_map_type shallowHistoryMap_; - history_map_type deepHistoryMap_; - const event_base_type * pTriggeringEvent_; -}; - - - -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/termination.hpp b/contrib/restricted/boost/boost/statechart/termination.hpp deleted file mode 100644 index f740e9235b8..00000000000 --- a/contrib/restricted/boost/boost/statechart/termination.hpp +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef BOOST_STATECHART_TERMINATION_HPP_INCLUDED -#define BOOST_STATECHART_TERMINATION_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2006 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/result.hpp> - - - -namespace boost -{ -namespace statechart -{ - - - -class event_base; - -////////////////////////////////////////////////////////////////////////////// -template< class Event > -class termination -{ - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - template< class State, class EventBase, class IdType > - static detail::reaction_result react( - State & stt, const EventBase &, const IdType & eventType ) - { - if ( eventType == Event::static_type() ) - { - return detail::result_utility::get_result( stt.terminate() ); - } - else - { - return detail::no_reaction; - } - } -}; - -template<> -class termination< event_base > -{ - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - template< class State, class EventBase, class IdType > - static detail::reaction_result react( - State & stt, const EventBase &, const IdType & ) - { - return detail::result_utility::get_result( stt.terminate() ); - } -}; - - - -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/boost/statechart/transition.hpp b/contrib/restricted/boost/boost/statechart/transition.hpp deleted file mode 100644 index 76337edc14e..00000000000 --- a/contrib/restricted/boost/boost/statechart/transition.hpp +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef BOOST_STATECHART_TRANSITION_HPP_INCLUDED -#define BOOST_STATECHART_TRANSITION_HPP_INCLUDED -////////////////////////////////////////////////////////////////////////////// -// Copyright 2002-2008 Andreas Huber Doenni -// Distributed under the Boost Software License, Version 1.0. (See accompany- -// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -////////////////////////////////////////////////////////////////////////////// - - - -#include <boost/statechart/result.hpp> - -#include <boost/statechart/detail/reaction_dispatcher.hpp> - - - -namespace boost -{ -namespace statechart -{ - - - -////////////////////////////////////////////////////////////////////////////// -template< class Event, class Destination, - class TransitionContext = detail::no_context< Event >, - void ( TransitionContext::*pTransitionAction )( const Event & ) = - &detail::no_context< Event >::no_function > -class transition -{ - private: - ////////////////////////////////////////////////////////////////////////// - template< class State > - struct reactions - { - static result react_without_action( State & stt ) - { - return stt.template transit< Destination >(); - } - - static result react_with_action( State & stt, const Event & evt ) - { - return stt.template transit< Destination >( pTransitionAction, evt ); - } - }; - - public: - ////////////////////////////////////////////////////////////////////////// - // The following declarations should be private. - // They are only public because many compilers lack template friends. - ////////////////////////////////////////////////////////////////////////// - template< class State, class EventBase, class IdType > - static detail::reaction_result react( - State & stt, const EventBase & evt, const IdType & eventType ) - { - typedef detail::reaction_dispatcher< - reactions< State >, State, EventBase, Event, TransitionContext, IdType - > dispatcher; - return dispatcher::react( stt, evt, eventType ); - } -}; - - - -} // namespace statechart -} // namespace boost - - - -#endif diff --git a/contrib/restricted/boost/lockfree/CMakeLists.txt b/contrib/restricted/boost/lockfree/CMakeLists.txt new file mode 100644 index 00000000000..f317103ca97 --- /dev/null +++ b/contrib/restricted/boost/lockfree/CMakeLists.txt @@ -0,0 +1,31 @@ + +# This file was gererated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(restricted-boost-lockfree INTERFACE) +target_include_directories(restricted-boost-lockfree INTERFACE + ${CMAKE_SOURCE_DIR}/contrib/restricted/boost/lockfree/include +) +target_link_libraries(restricted-boost-lockfree INTERFACE + contrib-libs-cxxsupp + yutil + restricted-boost-align + restricted-boost-array + restricted-boost-assert + restricted-boost-atomic + restricted-boost-config + restricted-boost-core + restricted-boost-integer + restricted-boost-mpl + restricted-boost-parameter + restricted-boost-predef + restricted-boost-static_assert + restricted-boost-tuple + restricted-boost-type_traits + restricted-boost-utility +) |