| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352 |
- //
- // execution/any_executor.hpp
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~
- //
- // Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
- //
- // Distributed under the Boost Software License, Version 1.0. (See accompanying
- // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- //
- #ifndef ASIO_EXECUTION_ANY_EXECUTOR_HPP
- #define ASIO_EXECUTION_ANY_EXECUTOR_HPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
- #include "asio/detail/config.hpp"
- #include <new>
- #include <typeinfo>
- #include "asio/detail/assert.hpp"
- #include "asio/detail/cstddef.hpp"
- #include "asio/detail/executor_function.hpp"
- #include "asio/detail/memory.hpp"
- #include "asio/detail/non_const_lvalue.hpp"
- #include "asio/detail/scoped_ptr.hpp"
- #include "asio/detail/type_traits.hpp"
- #include "asio/detail/throw_exception.hpp"
- #include "asio/detail/variadic_templates.hpp"
- #include "asio/execution/bad_executor.hpp"
- #include "asio/execution/blocking.hpp"
- #include "asio/execution/execute.hpp"
- #include "asio/execution/executor.hpp"
- #include "asio/prefer.hpp"
- #include "asio/query.hpp"
- #include "asio/require.hpp"
- #include "asio/detail/push_options.hpp"
- namespace asio {
- #if defined(GENERATING_DOCUMENTATION)
- namespace execution {
- /// Polymorphic executor wrapper.
- template <typename... SupportableProperties>
- class any_executor
- {
- public:
- /// Default constructor.
- any_executor() noexcept;
- /// Construct in an empty state. Equivalent effects to default constructor.
- any_executor(nullptr_t) noexcept;
- /// Copy constructor.
- any_executor(const any_executor& e) noexcept;
- /// Move constructor.
- any_executor(any_executor&& e) noexcept;
- /// Construct to point to the same target as another any_executor.
- template <class... OtherSupportableProperties>
- any_executor(any_executor<OtherSupportableProperties...> e);
- /// Construct a polymorphic wrapper for the specified executor.
- template <typename Executor>
- any_executor(Executor e);
- /// Assignment operator.
- any_executor& operator=(const any_executor& e) noexcept;
- /// Move assignment operator.
- any_executor& operator=(any_executor&& e) noexcept;
- /// Assignment operator that sets the polymorphic wrapper to the empty state.
- any_executor& operator=(nullptr_t);
- /// Assignment operator to create a polymorphic wrapper for the specified
- /// executor.
- template <typename Executor>
- any_executor& operator=(Executor e);
- /// Destructor.
- ~any_executor();
- /// Swap targets with another polymorphic wrapper.
- void swap(any_executor& other) noexcept;
- /// Obtain a polymorphic wrapper with the specified property.
- /**
- * Do not call this function directly. It is intended for use with the
- * asio::require and asio::prefer customisation points.
- *
- * For example:
- * @code execution::any_executor<execution::blocking_t::possibly_t> ex = ...;
- * auto ex2 = asio::requre(ex, execution::blocking.possibly); @endcode
- */
- template <typename Property>
- any_executor require(Property) const;
- /// Obtain a polymorphic wrapper with the specified property.
- /**
- * Do not call this function directly. It is intended for use with the
- * asio::prefer customisation point.
- *
- * For example:
- * @code execution::any_executor<execution::blocking_t::possibly_t> ex = ...;
- * auto ex2 = asio::prefer(ex, execution::blocking.possibly); @endcode
- */
- template <typename Property>
- any_executor prefer(Property) const;
- /// Obtain the value associated with the specified property.
- /**
- * Do not call this function directly. It is intended for use with the
- * asio::query customisation point.
- *
- * For example:
- * @code execution::any_executor<execution::occupancy_t> ex = ...;
- * size_t n = asio::query(ex, execution::occupancy); @endcode
- */
- template <typename Property>
- typename Property::polymorphic_query_result_type query(Property) const;
- /// Execute the function on the target executor.
- /**
- * Do not call this function directly. It is intended for use with the
- * execution::execute customisation point.
- *
- * For example:
- * @code execution::any_executor<> ex = ...;
- * execution::execute(ex, my_function_object); @endcode
- *
- * Throws asio::bad_executor if the polymorphic wrapper has no target.
- */
- template <typename Function>
- void execute(Function&& f) const;
- /// Obtain the underlying execution context.
- /**
- * This function is provided for backward compatibility. It is automatically
- * defined when the @c SupportableProperties... list includes a property of
- * type <tt>execution::context_as<U></tt>, for some type <tt>U</tt>.
- */
- automatically_determined context() const;
- /// Determine whether the wrapper has a target executor.
- /**
- * @returns @c true if the polymorphic wrapper has a target executor,
- * otherwise false.
- */
- explicit operator bool() const noexcept;
- /// Get the type of the target executor.
- const type_info& target_type() const noexcept;
- /// Get a pointer to the target executor.
- template <typename Executor> Executor* target() noexcept;
- /// Get a pointer to the target executor.
- template <typename Executor> const Executor* target() const noexcept;
- };
- /// Equality operator.
- /**
- * @relates any_executor
- */
- template <typename... SupportableProperties>
- bool operator==(const any_executor<SupportableProperties...>& a,
- const any_executor<SupportableProperties...>& b) noexcept;
- /// Equality operator.
- /**
- * @relates any_executor
- */
- template <typename... SupportableProperties>
- bool operator==(const any_executor<SupportableProperties...>& a,
- nullptr_t) noexcept;
- /// Equality operator.
- /**
- * @relates any_executor
- */
- template <typename... SupportableProperties>
- bool operator==(nullptr_t,
- const any_executor<SupportableProperties...>& b) noexcept;
- /// Inequality operator.
- /**
- * @relates any_executor
- */
- template <typename... SupportableProperties>
- bool operator!=(const any_executor<SupportableProperties...>& a,
- const any_executor<SupportableProperties...>& b) noexcept;
- /// Inequality operator.
- /**
- * @relates any_executor
- */
- template <typename... SupportableProperties>
- bool operator!=(const any_executor<SupportableProperties...>& a,
- nullptr_t) noexcept;
- /// Inequality operator.
- /**
- * @relates any_executor
- */
- template <typename... SupportableProperties>
- bool operator!=(nullptr_t,
- const any_executor<SupportableProperties...>& b) noexcept;
- } // namespace execution
- #else // defined(GENERATING_DOCUMENTATION)
- namespace execution {
- #if !defined(ASIO_EXECUTION_ANY_EXECUTOR_FWD_DECL)
- #define ASIO_EXECUTION_ANY_EXECUTOR_FWD_DECL
- #if defined(ASIO_HAS_VARIADIC_TEMPLATES)
- template <typename... SupportableProperties>
- class any_executor;
- #else // defined(ASIO_HAS_VARIADIC_TEMPLATES)
- template <typename = void, typename = void, typename = void,
- typename = void, typename = void, typename = void,
- typename = void, typename = void, typename = void>
- class any_executor;
- #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES)
- #endif // !defined(ASIO_EXECUTION_ANY_EXECUTOR_FWD_DECL)
- template <typename U>
- struct context_as_t;
- namespace detail {
- // Traits used to detect whether a property is requirable or preferable, taking
- // into account that T::is_requirable or T::is_preferable may not not be well
- // formed.
- template <typename T, typename = void>
- struct is_requirable : false_type {};
- template <typename T>
- struct is_requirable<T, typename enable_if<T::is_requirable>::type> :
- true_type {};
- template <typename T, typename = void>
- struct is_preferable : false_type {};
- template <typename T>
- struct is_preferable<T, typename enable_if<T::is_preferable>::type> :
- true_type {};
- // Trait used to detect context_as property, for backward compatibility.
- template <typename T>
- struct is_context_as : false_type {};
- template <typename U>
- struct is_context_as<context_as_t<U> > : true_type {};
- // Helper template to:
- // - Check if a target can supply the supportable properties.
- // - Find the first convertible-from-T property in the list.
- template <std::size_t I, typename Props>
- struct supportable_properties;
- template <std::size_t I, typename Prop>
- struct supportable_properties<I, void(Prop)>
- {
- template <typename T>
- struct is_valid_target : integral_constant<bool,
- (
- is_requirable<Prop>::value
- ? can_require<T, Prop>::value
- : true
- )
- &&
- (
- is_preferable<Prop>::value
- ? can_prefer<T, Prop>::value
- : true
- )
- &&
- (
- !is_requirable<Prop>::value && !is_preferable<Prop>::value
- ? can_query<T, Prop>::value
- : true
- )
- >
- {
- };
- struct found
- {
- ASIO_STATIC_CONSTEXPR(bool, value = true);
- typedef Prop type;
- typedef typename Prop::polymorphic_query_result_type query_result_type;
- ASIO_STATIC_CONSTEXPR(std::size_t, index = I);
- };
- struct not_found
- {
- ASIO_STATIC_CONSTEXPR(bool, value = false);
- };
- template <typename T>
- struct find_convertible_property :
- conditional<
- is_same<T, Prop>::value || is_convertible<T, Prop>::value,
- found,
- not_found
- >::type {};
- template <typename T>
- struct find_convertible_requirable_property :
- conditional<
- is_requirable<Prop>::value
- && (is_same<T, Prop>::value || is_convertible<T, Prop>::value),
- found,
- not_found
- >::type {};
- template <typename T>
- struct find_convertible_preferable_property :
- conditional<
- is_preferable<Prop>::value
- && (is_same<T, Prop>::value || is_convertible<T, Prop>::value),
- found,
- not_found
- >::type {};
- struct find_context_as_property :
- conditional<
- is_context_as<Prop>::value,
- found,
- not_found
- >::type {};
- };
- #if defined(ASIO_HAS_VARIADIC_TEMPLATES)
- template <std::size_t I, typename Head, typename... Tail>
- struct supportable_properties<I, void(Head, Tail...)>
- {
- template <typename T>
- struct is_valid_target : integral_constant<bool,
- (
- supportable_properties<I,
- void(Head)>::template is_valid_target<T>::value
- &&
- supportable_properties<I + 1,
- void(Tail...)>::template is_valid_target<T>::value
- )
- >
- {
- };
- template <typename T>
- struct find_convertible_property :
- conditional<
- is_convertible<T, Head>::value,
- typename supportable_properties<I, void(Head)>::found,
- typename supportable_properties<I + 1,
- void(Tail...)>::template find_convertible_property<T>
- >::type {};
- template <typename T>
- struct find_convertible_requirable_property :
- conditional<
- is_requirable<Head>::value
- && is_convertible<T, Head>::value,
- typename supportable_properties<I, void(Head)>::found,
- typename supportable_properties<I + 1,
- void(Tail...)>::template find_convertible_requirable_property<T>
- >::type {};
- template <typename T>
- struct find_convertible_preferable_property :
- conditional<
- is_preferable<Head>::value
- && is_convertible<T, Head>::value,
- typename supportable_properties<I, void(Head)>::found,
- typename supportable_properties<I + 1,
- void(Tail...)>::template find_convertible_preferable_property<T>
- >::type {};
- struct find_context_as_property :
- conditional<
- is_context_as<Head>::value,
- typename supportable_properties<I, void(Head)>::found,
- typename supportable_properties<I + 1,
- void(Tail...)>::find_context_as_property
- >::type {};
- };
- #else // defined(ASIO_HAS_VARIADIC_TEMPLATES)
- #define ASIO_PRIVATE_ANY_EXECUTOR_PROPS_BASE_DEF(n) \
- template <std::size_t I, \
- typename Head, ASIO_VARIADIC_TPARAMS(n)> \
- struct supportable_properties<I, \
- void(Head, ASIO_VARIADIC_TARGS(n))> \
- { \
- template <typename T> \
- struct is_valid_target : integral_constant<bool, \
- ( \
- supportable_properties<I, \
- void(Head)>::template is_valid_target<T>::value \
- && \
- supportable_properties<I + 1, \
- void(ASIO_VARIADIC_TARGS(n))>::template \
- is_valid_target<T>::value \
- ) \
- > \
- { \
- }; \
- \
- template <typename T> \
- struct find_convertible_property : \
- conditional< \
- is_convertible<T, Head>::value, \
- typename supportable_properties<I, void(Head)>::found, \
- typename supportable_properties<I + 1, \
- void(ASIO_VARIADIC_TARGS(n))>::template \
- find_convertible_property<T> \
- >::type {}; \
- \
- template <typename T> \
- struct find_convertible_requirable_property : \
- conditional< \
- is_requirable<Head>::value \
- && is_convertible<T, Head>::value, \
- typename supportable_properties<I, void(Head)>::found, \
- typename supportable_properties<I + 1, \
- void(ASIO_VARIADIC_TARGS(n))>::template \
- find_convertible_requirable_property<T> \
- >::type {}; \
- \
- template <typename T> \
- struct find_convertible_preferable_property : \
- conditional< \
- is_preferable<Head>::value \
- && is_convertible<T, Head>::value, \
- typename supportable_properties<I, void(Head)>::found, \
- typename supportable_properties<I + 1, \
- void(ASIO_VARIADIC_TARGS(n))>::template \
- find_convertible_preferable_property<T> \
- >::type {}; \
- \
- struct find_context_as_property : \
- conditional< \
- is_context_as<Head>::value, \
- typename supportable_properties<I, void(Head)>::found, \
- typename supportable_properties<I + 1, void( \
- ASIO_VARIADIC_TARGS(n))>::find_context_as_property \
- >::type {}; \
- }; \
- /**/
- ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_ANY_EXECUTOR_PROPS_BASE_DEF)
- #undef ASIO_PRIVATE_ANY_EXECUTOR_PROPS_BASE_DEF
- #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES)
- template <typename T, typename Props>
- struct is_valid_target_executor :
- conditional<
- is_executor<T>::value,
- typename supportable_properties<0, Props>::template is_valid_target<T>,
- false_type
- >::type
- {
- };
- template <typename Props>
- struct is_valid_target_executor<int, Props> : false_type
- {
- };
- class any_executor_base
- {
- public:
- any_executor_base() ASIO_NOEXCEPT
- : object_fns_(object_fns_table<void>()),
- target_(0),
- target_fns_(target_fns_table<void>())
- {
- }
- template <ASIO_EXECUTION_EXECUTOR Executor>
- any_executor_base(Executor ex, false_type)
- : target_fns_(target_fns_table<Executor>(
- any_executor_base::query_blocking(ex,
- can_query<const Executor&, const execution::blocking_t&>())
- == execution::blocking.always))
- {
- any_executor_base::construct_object(ex,
- integral_constant<bool,
- sizeof(Executor) <= sizeof(object_type)
- && alignment_of<Executor>::value <= alignment_of<object_type>::value
- >());
- }
- template <ASIO_EXECUTION_EXECUTOR Executor>
- any_executor_base(Executor other, true_type)
- : object_fns_(object_fns_table<asio::detail::shared_ptr<void> >()),
- target_fns_(other.target_fns_)
- {
- asio::detail::shared_ptr<Executor> p =
- asio::detail::make_shared<Executor>(
- ASIO_MOVE_CAST(Executor)(other));
- target_ = p->template target<void>();
- new (&object_) asio::detail::shared_ptr<void>(
- ASIO_MOVE_CAST(asio::detail::shared_ptr<Executor>)(p));
- }
- any_executor_base(const any_executor_base& other) ASIO_NOEXCEPT
- : object_fns_(other.object_fns_),
- target_fns_(other.target_fns_)
- {
- object_fns_->copy(*this, other);
- }
- ~any_executor_base() ASIO_NOEXCEPT
- {
- object_fns_->destroy(*this);
- }
- any_executor_base& operator=(
- const any_executor_base& other) ASIO_NOEXCEPT
- {
- if (this != &other)
- {
- object_fns_->destroy(*this);
- object_fns_ = other.object_fns_;
- target_fns_ = other.target_fns_;
- object_fns_->copy(*this, other);
- }
- return *this;
- }
- any_executor_base& operator=(nullptr_t) ASIO_NOEXCEPT
- {
- object_fns_->destroy(*this);
- target_ = 0;
- object_fns_ = object_fns_table<void>();
- target_fns_ = target_fns_table<void>();
- return *this;
- }
- #if defined(ASIO_HAS_MOVE)
- any_executor_base(any_executor_base&& other) ASIO_NOEXCEPT
- : object_fns_(other.object_fns_),
- target_fns_(other.target_fns_)
- {
- other.object_fns_ = object_fns_table<void>();
- other.target_fns_ = target_fns_table<void>();
- object_fns_->move(*this, other);
- other.target_ = 0;
- }
- any_executor_base& operator=(
- any_executor_base&& other) ASIO_NOEXCEPT
- {
- if (this != &other)
- {
- object_fns_->destroy(*this);
- object_fns_ = other.object_fns_;
- other.object_fns_ = object_fns_table<void>();
- target_fns_ = other.target_fns_;
- other.target_fns_ = target_fns_table<void>();
- object_fns_->move(*this, other);
- other.target_ = 0;
- }
- return *this;
- }
- #endif // defined(ASIO_HAS_MOVE)
- void swap(any_executor_base& other) ASIO_NOEXCEPT
- {
- if (this != &other)
- {
- any_executor_base tmp(ASIO_MOVE_CAST(any_executor_base)(other));
- other = ASIO_MOVE_CAST(any_executor_base)(*this);
- *this = ASIO_MOVE_CAST(any_executor_base)(tmp);
- }
- }
- template <typename F>
- void execute(ASIO_MOVE_ARG(F) f) const
- {
- if (target_fns_->blocking_execute != 0)
- {
- asio::detail::non_const_lvalue<F> f2(f);
- target_fns_->blocking_execute(*this, function_view(f2.value));
- }
- else
- {
- target_fns_->execute(*this,
- function(ASIO_MOVE_CAST(F)(f), std::allocator<void>()));
- }
- }
- template <typename Executor>
- Executor* target()
- {
- return static_cast<Executor*>(target_);
- }
- template <typename Executor>
- const Executor* target() const
- {
- return static_cast<Executor*>(target_);
- }
- #if !defined(ASIO_NO_TYPEID)
- const std::type_info& target_type() const
- #else // !defined(ASIO_NO_TYPEID)
- const void* target_type() const
- #endif // !defined(ASIO_NO_TYPEID)
- {
- return target_fns_->target_type();
- }
- struct unspecified_bool_type_t {};
- typedef void (*unspecified_bool_type)(unspecified_bool_type_t);
- static void unspecified_bool_true(unspecified_bool_type_t) {}
- operator unspecified_bool_type() const ASIO_NOEXCEPT
- {
- return target_ ? &any_executor_base::unspecified_bool_true : 0;
- }
- bool operator!() const ASIO_NOEXCEPT
- {
- return target_ == 0;
- }
- protected:
- bool equality_helper(const any_executor_base& other) const ASIO_NOEXCEPT
- {
- if (target_ == other.target_)
- return true;
- if (target_ && !other.target_)
- return false;
- if (!target_ && other.target_)
- return false;
- if (target_fns_ != other.target_fns_)
- return false;
- return target_fns_->equal(*this, other);
- }
- template <typename Ex>
- Ex& object()
- {
- return *static_cast<Ex*>(static_cast<void*>(&object_));
- }
- template <typename Ex>
- const Ex& object() const
- {
- return *static_cast<const Ex*>(static_cast<const void*>(&object_));
- }
- struct object_fns
- {
- void (*destroy)(any_executor_base&);
- void (*copy)(any_executor_base&, const any_executor_base&);
- void (*move)(any_executor_base&, any_executor_base&);
- const void* (*target)(const any_executor_base&);
- };
- static void destroy_void(any_executor_base&)
- {
- }
- static void copy_void(any_executor_base& ex1, const any_executor_base&)
- {
- ex1.target_ = 0;
- }
- static void move_void(any_executor_base& ex1, any_executor_base&)
- {
- ex1.target_ = 0;
- }
- static const void* target_void(const any_executor_base&)
- {
- return 0;
- }
- template <typename Obj>
- static const object_fns* object_fns_table(
- typename enable_if<
- is_same<Obj, void>::value
- >::type* = 0)
- {
- static const object_fns fns =
- {
- &any_executor_base::destroy_void,
- &any_executor_base::copy_void,
- &any_executor_base::move_void,
- &any_executor_base::target_void
- };
- return &fns;
- }
- static void destroy_shared(any_executor_base& ex)
- {
- typedef asio::detail::shared_ptr<void> type;
- ex.object<type>().~type();
- }
- static void copy_shared(any_executor_base& ex1, const any_executor_base& ex2)
- {
- typedef asio::detail::shared_ptr<void> type;
- new (&ex1.object_) type(ex2.object<type>());
- ex1.target_ = ex2.target_;
- }
- static void move_shared(any_executor_base& ex1, any_executor_base& ex2)
- {
- typedef asio::detail::shared_ptr<void> type;
- new (&ex1.object_) type(ASIO_MOVE_CAST(type)(ex2.object<type>()));
- ex1.target_ = ex2.target_;
- ex2.object<type>().~type();
- }
- static const void* target_shared(const any_executor_base& ex)
- {
- typedef asio::detail::shared_ptr<void> type;
- return ex.object<type>().get();
- }
- template <typename Obj>
- static const object_fns* object_fns_table(
- typename enable_if<
- is_same<Obj, asio::detail::shared_ptr<void> >::value
- >::type* = 0)
- {
- static const object_fns fns =
- {
- &any_executor_base::destroy_shared,
- &any_executor_base::copy_shared,
- &any_executor_base::move_shared,
- &any_executor_base::target_shared
- };
- return &fns;
- }
- template <typename Obj>
- static void destroy_object(any_executor_base& ex)
- {
- ex.object<Obj>().~Obj();
- }
- template <typename Obj>
- static void copy_object(any_executor_base& ex1, const any_executor_base& ex2)
- {
- new (&ex1.object_) Obj(ex2.object<Obj>());
- ex1.target_ = &ex1.object<Obj>();
- }
- template <typename Obj>
- static void move_object(any_executor_base& ex1, any_executor_base& ex2)
- {
- new (&ex1.object_) Obj(ASIO_MOVE_CAST(Obj)(ex2.object<Obj>()));
- ex1.target_ = &ex1.object<Obj>();
- ex2.object<Obj>().~Obj();
- }
- template <typename Obj>
- static const void* target_object(const any_executor_base& ex)
- {
- return &ex.object<Obj>();
- }
- template <typename Obj>
- static const object_fns* object_fns_table(
- typename enable_if<
- !is_same<Obj, void>::value
- && !is_same<Obj, asio::detail::shared_ptr<void> >::value
- >::type* = 0)
- {
- static const object_fns fns =
- {
- &any_executor_base::destroy_object<Obj>,
- &any_executor_base::copy_object<Obj>,
- &any_executor_base::move_object<Obj>,
- &any_executor_base::target_object<Obj>
- };
- return &fns;
- }
- typedef asio::detail::executor_function function;
- typedef asio::detail::executor_function_view function_view;
- struct target_fns
- {
- #if !defined(ASIO_NO_TYPEID)
- const std::type_info& (*target_type)();
- #else // !defined(ASIO_NO_TYPEID)
- const void* (*target_type)();
- #endif // !defined(ASIO_NO_TYPEID)
- bool (*equal)(const any_executor_base&, const any_executor_base&);
- void (*execute)(const any_executor_base&, ASIO_MOVE_ARG(function));
- void (*blocking_execute)(const any_executor_base&, function_view);
- };
- #if !defined(ASIO_NO_TYPEID)
- static const std::type_info& target_type_void()
- {
- return typeid(void);
- }
- #else // !defined(ASIO_NO_TYPEID)
- static const void* target_type_void()
- {
- return 0;
- }
- #endif // !defined(ASIO_NO_TYPEID)
- static bool equal_void(const any_executor_base&, const any_executor_base&)
- {
- return true;
- }
- static void execute_void(const any_executor_base&,
- ASIO_MOVE_ARG(function))
- {
- bad_executor ex;
- asio::detail::throw_exception(ex);
- }
- static void blocking_execute_void(const any_executor_base&, function_view)
- {
- bad_executor ex;
- asio::detail::throw_exception(ex);
- }
- template <typename Ex>
- static const target_fns* target_fns_table(
- typename enable_if<
- is_same<Ex, void>::value
- >::type* = 0)
- {
- static const target_fns fns =
- {
- &any_executor_base::target_type_void,
- &any_executor_base::equal_void,
- &any_executor_base::execute_void,
- &any_executor_base::blocking_execute_void
- };
- return &fns;
- }
- #if !defined(ASIO_NO_TYPEID)
- template <typename Ex>
- static const std::type_info& target_type_ex()
- {
- return typeid(Ex);
- }
- #else // !defined(ASIO_NO_TYPEID)
- template <typename Ex>
- static const void* target_type_ex()
- {
- static int unique_id;
- return &unique_id;
- }
- #endif // !defined(ASIO_NO_TYPEID)
- template <typename Ex>
- static bool equal_ex(const any_executor_base& ex1,
- const any_executor_base& ex2)
- {
- return *ex1.target<Ex>() == *ex2.target<Ex>();
- }
- template <typename Ex>
- static void execute_ex(const any_executor_base& ex,
- ASIO_MOVE_ARG(function) f)
- {
- execution::execute(*ex.target<Ex>(), ASIO_MOVE_CAST(function)(f));
- }
- template <typename Ex>
- static void blocking_execute_ex(const any_executor_base& ex, function_view f)
- {
- execution::execute(*ex.target<Ex>(), f);
- }
- template <typename Ex>
- static const target_fns* target_fns_table(bool is_always_blocking,
- typename enable_if<
- !is_same<Ex, void>::value
- >::type* = 0)
- {
- static const target_fns fns_with_execute =
- {
- &any_executor_base::target_type_ex<Ex>,
- &any_executor_base::equal_ex<Ex>,
- &any_executor_base::execute_ex<Ex>,
- 0
- };
- static const target_fns fns_with_blocking_execute =
- {
- &any_executor_base::target_type_ex<Ex>,
- &any_executor_base::equal_ex<Ex>,
- 0,
- &any_executor_base::blocking_execute_ex<Ex>
- };
- return is_always_blocking ? &fns_with_blocking_execute : &fns_with_execute;
- }
- #if defined(ASIO_MSVC)
- # pragma warning (push)
- # pragma warning (disable:4702)
- #endif // defined(ASIO_MSVC)
- static void query_fn_void(void*, const void*, const void*)
- {
- bad_executor ex;
- asio::detail::throw_exception(ex);
- }
- template <typename Ex, class Prop>
- static void query_fn_non_void(void*, const void* ex, const void* prop,
- typename enable_if<
- asio::can_query<const Ex&, const Prop&>::value
- && is_same<typename Prop::polymorphic_query_result_type, void>::value
- >::type*)
- {
- asio::query(*static_cast<const Ex*>(ex),
- *static_cast<const Prop*>(prop));
- }
- template <typename Ex, class Prop>
- static void query_fn_non_void(void*, const void*, const void*,
- typename enable_if<
- !asio::can_query<const Ex&, const Prop&>::value
- && is_same<typename Prop::polymorphic_query_result_type, void>::value
- >::type*)
- {
- }
- template <typename Ex, class Prop>
- static void query_fn_non_void(void* result, const void* ex, const void* prop,
- typename enable_if<
- asio::can_query<const Ex&, const Prop&>::value
- && !is_same<typename Prop::polymorphic_query_result_type, void>::value
- && is_reference<typename Prop::polymorphic_query_result_type>::value
- >::type*)
- {
- *static_cast<typename remove_reference<
- typename Prop::polymorphic_query_result_type>::type**>(result)
- = &static_cast<typename Prop::polymorphic_query_result_type>(
- asio::query(*static_cast<const Ex*>(ex),
- *static_cast<const Prop*>(prop)));
- }
- template <typename Ex, class Prop>
- static void query_fn_non_void(void*, const void*, const void*,
- typename enable_if<
- !asio::can_query<const Ex&, const Prop&>::value
- && !is_same<typename Prop::polymorphic_query_result_type, void>::value
- && is_reference<typename Prop::polymorphic_query_result_type>::value
- >::type*)
- {
- std::terminate(); // Combination should not be possible.
- }
- template <typename Ex, class Prop>
- static void query_fn_non_void(void* result, const void* ex, const void* prop,
- typename enable_if<
- asio::can_query<const Ex&, const Prop&>::value
- && !is_same<typename Prop::polymorphic_query_result_type, void>::value
- && is_scalar<typename Prop::polymorphic_query_result_type>::value
- >::type*)
- {
- *static_cast<typename Prop::polymorphic_query_result_type*>(result)
- = static_cast<typename Prop::polymorphic_query_result_type>(
- asio::query(*static_cast<const Ex*>(ex),
- *static_cast<const Prop*>(prop)));
- }
- template <typename Ex, class Prop>
- static void query_fn_non_void(void* result, const void*, const void*,
- typename enable_if<
- !asio::can_query<const Ex&, const Prop&>::value
- && !is_same<typename Prop::polymorphic_query_result_type, void>::value
- && is_scalar<typename Prop::polymorphic_query_result_type>::value
- >::type*)
- {
- *static_cast<typename Prop::polymorphic_query_result_type*>(result)
- = typename Prop::polymorphic_query_result_type();
- }
- template <typename Ex, class Prop>
- static void query_fn_non_void(void* result, const void* ex, const void* prop,
- typename enable_if<
- asio::can_query<const Ex&, const Prop&>::value
- && !is_same<typename Prop::polymorphic_query_result_type, void>::value
- && !is_reference<typename Prop::polymorphic_query_result_type>::value
- && !is_scalar<typename Prop::polymorphic_query_result_type>::value
- >::type*)
- {
- *static_cast<typename Prop::polymorphic_query_result_type**>(result)
- = new typename Prop::polymorphic_query_result_type(
- asio::query(*static_cast<const Ex*>(ex),
- *static_cast<const Prop*>(prop)));
- }
- template <typename Ex, class Prop>
- static void query_fn_non_void(void* result, const void*, const void*, ...)
- {
- *static_cast<typename Prop::polymorphic_query_result_type**>(result)
- = new typename Prop::polymorphic_query_result_type();
- }
- template <typename Ex, class Prop>
- static void query_fn_impl(void* result, const void* ex, const void* prop,
- typename enable_if<
- is_same<Ex, void>::value
- >::type*)
- {
- query_fn_void(result, ex, prop);
- }
- template <typename Ex, class Prop>
- static void query_fn_impl(void* result, const void* ex, const void* prop,
- typename enable_if<
- !is_same<Ex, void>::value
- >::type*)
- {
- query_fn_non_void<Ex, Prop>(result, ex, prop, 0);
- }
- template <typename Ex, class Prop>
- static void query_fn(void* result, const void* ex, const void* prop)
- {
- query_fn_impl<Ex, Prop>(result, ex, prop, 0);
- }
- template <typename Poly, typename Ex, class Prop>
- static Poly require_fn_impl(const void*, const void*,
- typename enable_if<
- is_same<Ex, void>::value
- >::type*)
- {
- bad_executor ex;
- asio::detail::throw_exception(ex);
- return Poly();
- }
- template <typename Poly, typename Ex, class Prop>
- static Poly require_fn_impl(const void* ex, const void* prop,
- typename enable_if<
- !is_same<Ex, void>::value && Prop::is_requirable
- >::type*)
- {
- return asio::require(*static_cast<const Ex*>(ex),
- *static_cast<const Prop*>(prop));
- }
- template <typename Poly, typename Ex, class Prop>
- static Poly require_fn_impl(const void*, const void*, ...)
- {
- return Poly();
- }
- template <typename Poly, typename Ex, class Prop>
- static Poly require_fn(const void* ex, const void* prop)
- {
- return require_fn_impl<Poly, Ex, Prop>(ex, prop, 0);
- }
- template <typename Poly, typename Ex, class Prop>
- static Poly prefer_fn_impl(const void*, const void*,
- typename enable_if<
- is_same<Ex, void>::value
- >::type*)
- {
- bad_executor ex;
- asio::detail::throw_exception(ex);
- return Poly();
- }
- template <typename Poly, typename Ex, class Prop>
- static Poly prefer_fn_impl(const void* ex, const void* prop,
- typename enable_if<
- !is_same<Ex, void>::value && Prop::is_preferable
- >::type*)
- {
- return asio::prefer(*static_cast<const Ex*>(ex),
- *static_cast<const Prop*>(prop));
- }
- template <typename Poly, typename Ex, class Prop>
- static Poly prefer_fn_impl(const void*, const void*, ...)
- {
- return Poly();
- }
- template <typename Poly, typename Ex, class Prop>
- static Poly prefer_fn(const void* ex, const void* prop)
- {
- return prefer_fn_impl<Poly, Ex, Prop>(ex, prop, 0);
- }
- template <typename Poly>
- struct prop_fns
- {
- void (*query)(void*, const void*, const void*);
- Poly (*require)(const void*, const void*);
- Poly (*prefer)(const void*, const void*);
- };
- #if defined(ASIO_MSVC)
- # pragma warning (pop)
- #endif // defined(ASIO_MSVC)
- private:
- template <typename Executor>
- static execution::blocking_t query_blocking(const Executor& ex, true_type)
- {
- return asio::query(ex, execution::blocking);
- }
- template <typename Executor>
- static execution::blocking_t query_blocking(const Executor&, false_type)
- {
- return execution::blocking_t();
- }
- template <typename Executor>
- void construct_object(Executor& ex, true_type)
- {
- object_fns_ = object_fns_table<Executor>();
- target_ = new (&object_) Executor(ASIO_MOVE_CAST(Executor)(ex));
- }
- template <typename Executor>
- void construct_object(Executor& ex, false_type)
- {
- object_fns_ = object_fns_table<asio::detail::shared_ptr<void> >();
- asio::detail::shared_ptr<Executor> p =
- asio::detail::make_shared<Executor>(
- ASIO_MOVE_CAST(Executor)(ex));
- target_ = p.get();
- new (&object_) asio::detail::shared_ptr<void>(
- ASIO_MOVE_CAST(asio::detail::shared_ptr<Executor>)(p));
- }
- /*private:*/public:
- // template <typename...> friend class any_executor;
- typedef aligned_storage<
- sizeof(asio::detail::shared_ptr<void>) + sizeof(void*),
- alignment_of<asio::detail::shared_ptr<void> >::value
- >::type object_type;
- object_type object_;
- const object_fns* object_fns_;
- void* target_;
- const target_fns* target_fns_;
- };
- template <typename Derived, typename Property, typename = void>
- struct any_executor_context
- {
- };
- #if !defined(ASIO_NO_TS_EXECUTORS)
- template <typename Derived, typename Property>
- struct any_executor_context<Derived, Property,
- typename enable_if<Property::value>::type>
- {
- typename Property::query_result_type context() const
- {
- return static_cast<const Derived*>(this)->query(typename Property::type());
- }
- };
- #endif // !defined(ASIO_NO_TS_EXECUTORS)
- } // namespace detail
- template <>
- class any_executor<> : public detail::any_executor_base
- {
- public:
- any_executor() ASIO_NOEXCEPT
- : detail::any_executor_base()
- {
- }
- any_executor(nullptr_t) ASIO_NOEXCEPT
- : detail::any_executor_base()
- {
- }
- template <typename Executor>
- any_executor(Executor ex,
- typename enable_if<
- conditional<
- !is_same<Executor, any_executor>::value
- && !is_base_of<detail::any_executor_base, Executor>::value,
- is_executor<Executor>,
- false_type
- >::type::value
- >::type* = 0)
- : detail::any_executor_base(
- ASIO_MOVE_CAST(Executor)(ex), false_type())
- {
- }
- #if defined(ASIO_HAS_VARIADIC_TEMPLATES)
- template <typename... OtherSupportableProperties>
- any_executor(any_executor<OtherSupportableProperties...> other)
- : detail::any_executor_base(
- static_cast<const detail::any_executor_base&>(other))
- {
- }
- #else // defined(ASIO_HAS_VARIADIC_TEMPLATES)
- template <typename U0, typename U1, typename U2, typename U3,
- typename U4, typename U5, typename U6, typename U7>
- any_executor(any_executor<U0, U1, U2, U3, U4, U5, U6, U7> other)
- : detail::any_executor_base(
- static_cast<const detail::any_executor_base&>(other))
- {
- }
- #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES)
- any_executor(const any_executor& other) ASIO_NOEXCEPT
- : detail::any_executor_base(
- static_cast<const detail::any_executor_base&>(other))
- {
- }
- any_executor& operator=(const any_executor& other) ASIO_NOEXCEPT
- {
- if (this != &other)
- {
- detail::any_executor_base::operator=(
- static_cast<const detail::any_executor_base&>(other));
- }
- return *this;
- }
- any_executor& operator=(nullptr_t p) ASIO_NOEXCEPT
- {
- detail::any_executor_base::operator=(p);
- return *this;
- }
- #if defined(ASIO_HAS_MOVE)
- any_executor(any_executor&& other) ASIO_NOEXCEPT
- : detail::any_executor_base(
- static_cast<any_executor_base&&>(
- static_cast<any_executor_base&>(other)))
- {
- }
- any_executor& operator=(any_executor&& other) ASIO_NOEXCEPT
- {
- if (this != &other)
- {
- detail::any_executor_base::operator=(
- static_cast<detail::any_executor_base&&>(
- static_cast<detail::any_executor_base&>(other)));
- }
- return *this;
- }
- #endif // defined(ASIO_HAS_MOVE)
- void swap(any_executor& other) ASIO_NOEXCEPT
- {
- detail::any_executor_base::swap(
- static_cast<detail::any_executor_base&>(other));
- }
- using detail::any_executor_base::execute;
- using detail::any_executor_base::target;
- using detail::any_executor_base::target_type;
- using detail::any_executor_base::operator unspecified_bool_type;
- using detail::any_executor_base::operator!;
- bool equality_helper(const any_executor& other) const ASIO_NOEXCEPT
- {
- return any_executor_base::equality_helper(other);
- }
- template <typename AnyExecutor1, typename AnyExecutor2>
- friend typename enable_if<
- is_base_of<any_executor, AnyExecutor1>::value
- || is_base_of<any_executor, AnyExecutor2>::value,
- bool
- >::type operator==(const AnyExecutor1& a,
- const AnyExecutor2& b) ASIO_NOEXCEPT
- {
- return static_cast<const any_executor&>(a).equality_helper(b);
- }
- template <typename AnyExecutor>
- friend typename enable_if<
- is_same<AnyExecutor, any_executor>::value,
- bool
- >::type operator==(const AnyExecutor& a, nullptr_t) ASIO_NOEXCEPT
- {
- return !a;
- }
- template <typename AnyExecutor>
- friend typename enable_if<
- is_same<AnyExecutor, any_executor>::value,
- bool
- >::type operator==(nullptr_t, const AnyExecutor& b) ASIO_NOEXCEPT
- {
- return !b;
- }
- template <typename AnyExecutor1, typename AnyExecutor2>
- friend typename enable_if<
- is_base_of<any_executor, AnyExecutor1>::value
- || is_base_of<any_executor, AnyExecutor2>::value,
- bool
- >::type operator!=(const AnyExecutor1& a,
- const AnyExecutor2& b) ASIO_NOEXCEPT
- {
- return !static_cast<const any_executor&>(a).equality_helper(b);
- }
- template <typename AnyExecutor>
- friend typename enable_if<
- is_same<AnyExecutor, any_executor>::value,
- bool
- >::type operator!=(const AnyExecutor& a, nullptr_t) ASIO_NOEXCEPT
- {
- return !!a;
- }
- template <typename AnyExecutor>
- friend typename enable_if<
- is_same<AnyExecutor, any_executor>::value,
- bool
- >::type operator!=(nullptr_t, const AnyExecutor& b) ASIO_NOEXCEPT
- {
- return !!b;
- }
- };
- inline void swap(any_executor<>& a, any_executor<>& b) ASIO_NOEXCEPT
- {
- return a.swap(b);
- }
- #if defined(ASIO_HAS_VARIADIC_TEMPLATES)
- template <typename... SupportableProperties>
- class any_executor :
- public detail::any_executor_base,
- public detail::any_executor_context<
- any_executor<SupportableProperties...>,
- typename detail::supportable_properties<
- 0, void(SupportableProperties...)>::find_context_as_property>
- {
- public:
- any_executor() ASIO_NOEXCEPT
- : detail::any_executor_base(),
- prop_fns_(prop_fns_table<void>())
- {
- }
- any_executor(nullptr_t) ASIO_NOEXCEPT
- : detail::any_executor_base(),
- prop_fns_(prop_fns_table<void>())
- {
- }
- template <typename Executor>
- any_executor(Executor ex,
- typename enable_if<
- conditional<
- !is_same<Executor, any_executor>::value
- && !is_base_of<detail::any_executor_base, Executor>::value,
- detail::is_valid_target_executor<
- Executor, void(SupportableProperties...)>,
- false_type
- >::type::value
- >::type* = 0)
- : detail::any_executor_base(
- ASIO_MOVE_CAST(Executor)(ex), false_type()),
- prop_fns_(prop_fns_table<Executor>())
- {
- }
- template <typename... OtherSupportableProperties>
- any_executor(any_executor<OtherSupportableProperties...> other,
- typename enable_if<
- conditional<
- !is_same<
- any_executor<OtherSupportableProperties...>,
- any_executor
- >::value,
- typename detail::supportable_properties<
- 0, void(SupportableProperties...)>::template is_valid_target<
- any_executor<OtherSupportableProperties...> >,
- false_type
- >::type::value
- >::type* = 0)
- : detail::any_executor_base(ASIO_MOVE_CAST(
- any_executor<OtherSupportableProperties...>)(other), true_type()),
- prop_fns_(prop_fns_table<any_executor<OtherSupportableProperties...> >())
- {
- }
- any_executor(const any_executor& other) ASIO_NOEXCEPT
- : detail::any_executor_base(
- static_cast<const detail::any_executor_base&>(other)),
- prop_fns_(other.prop_fns_)
- {
- }
- any_executor& operator=(const any_executor& other) ASIO_NOEXCEPT
- {
- if (this != &other)
- {
- prop_fns_ = other.prop_fns_;
- detail::any_executor_base::operator=(
- static_cast<const detail::any_executor_base&>(other));
- }
- return *this;
- }
- any_executor& operator=(nullptr_t p) ASIO_NOEXCEPT
- {
- prop_fns_ = prop_fns_table<void>();
- detail::any_executor_base::operator=(p);
- return *this;
- }
- #if defined(ASIO_HAS_MOVE)
- any_executor(any_executor&& other) ASIO_NOEXCEPT
- : detail::any_executor_base(
- static_cast<any_executor_base&&>(
- static_cast<any_executor_base&>(other))),
- prop_fns_(other.prop_fns_)
- {
- other.prop_fns_ = prop_fns_table<void>();
- }
- any_executor& operator=(any_executor&& other) ASIO_NOEXCEPT
- {
- if (this != &other)
- {
- prop_fns_ = other.prop_fns_;
- detail::any_executor_base::operator=(
- static_cast<detail::any_executor_base&&>(
- static_cast<detail::any_executor_base&>(other)));
- }
- return *this;
- }
- #endif // defined(ASIO_HAS_MOVE)
- void swap(any_executor& other) ASIO_NOEXCEPT
- {
- if (this != &other)
- {
- detail::any_executor_base::swap(
- static_cast<detail::any_executor_base&>(other));
- const prop_fns<any_executor>* tmp_prop_fns = other.prop_fns_;
- other.prop_fns_ = prop_fns_;
- prop_fns_ = tmp_prop_fns;
- }
- }
- using detail::any_executor_base::execute;
- using detail::any_executor_base::target;
- using detail::any_executor_base::target_type;
- using detail::any_executor_base::operator unspecified_bool_type;
- using detail::any_executor_base::operator!;
- bool equality_helper(const any_executor& other) const ASIO_NOEXCEPT
- {
- return any_executor_base::equality_helper(other);
- }
- template <typename AnyExecutor1, typename AnyExecutor2>
- friend typename enable_if<
- is_base_of<any_executor, AnyExecutor1>::value
- || is_base_of<any_executor, AnyExecutor2>::value,
- bool
- >::type operator==(const AnyExecutor1& a,
- const AnyExecutor2& b) ASIO_NOEXCEPT
- {
- return static_cast<const any_executor&>(a).equality_helper(b);
- }
- template <typename AnyExecutor>
- friend typename enable_if<
- is_same<AnyExecutor, any_executor>::value,
- bool
- >::type operator==(const AnyExecutor& a, nullptr_t) ASIO_NOEXCEPT
- {
- return !a;
- }
- template <typename AnyExecutor>
- friend typename enable_if<
- is_same<AnyExecutor, any_executor>::value,
- bool
- >::type operator==(nullptr_t, const AnyExecutor& b) ASIO_NOEXCEPT
- {
- return !b;
- }
- template <typename AnyExecutor1, typename AnyExecutor2>
- friend typename enable_if<
- is_base_of<any_executor, AnyExecutor1>::value
- || is_base_of<any_executor, AnyExecutor2>::value,
- bool
- >::type operator!=(const AnyExecutor1& a,
- const AnyExecutor2& b) ASIO_NOEXCEPT
- {
- return !static_cast<const any_executor&>(a).equality_helper(b);
- }
- template <typename AnyExecutor>
- friend typename enable_if<
- is_same<AnyExecutor, any_executor>::value,
- bool
- >::type operator!=(const AnyExecutor& a, nullptr_t) ASIO_NOEXCEPT
- {
- return !!a;
- }
- template <typename AnyExecutor>
- friend typename enable_if<
- is_same<AnyExecutor, any_executor>::value,
- bool
- >::type operator!=(nullptr_t, const AnyExecutor& b) ASIO_NOEXCEPT
- {
- return !!b;
- }
- template <typename T>
- struct find_convertible_property :
- detail::supportable_properties<
- 0, void(SupportableProperties...)>::template
- find_convertible_property<T> {};
- template <typename Property>
- void query(const Property& p,
- typename enable_if<
- is_same<
- typename find_convertible_property<Property>::query_result_type,
- void
- >::value
- >::type* = 0) const
- {
- typedef find_convertible_property<Property> found;
- prop_fns_[found::index].query(0, object_fns_->target(*this),
- &static_cast<const typename found::type&>(p));
- }
- template <typename Property>
- typename find_convertible_property<Property>::query_result_type
- query(const Property& p,
- typename enable_if<
- !is_same<
- typename find_convertible_property<Property>::query_result_type,
- void
- >::value
- &&
- is_reference<
- typename find_convertible_property<Property>::query_result_type
- >::value
- >::type* = 0) const
- {
- typedef find_convertible_property<Property> found;
- typename remove_reference<
- typename found::query_result_type>::type* result = 0;
- prop_fns_[found::index].query(&result, object_fns_->target(*this),
- &static_cast<const typename found::type&>(p));
- return *result;
- }
- template <typename Property>
- typename find_convertible_property<Property>::query_result_type
- query(const Property& p,
- typename enable_if<
- !is_same<
- typename find_convertible_property<Property>::query_result_type,
- void
- >::value
- &&
- is_scalar<
- typename find_convertible_property<Property>::query_result_type
- >::value
- >::type* = 0) const
- {
- typedef find_convertible_property<Property> found;
- typename found::query_result_type result;
- prop_fns_[found::index].query(&result, object_fns_->target(*this),
- &static_cast<const typename found::type&>(p));
- return result;
- }
- template <typename Property>
- typename find_convertible_property<Property>::query_result_type
- query(const Property& p,
- typename enable_if<
- !is_same<
- typename find_convertible_property<Property>::query_result_type,
- void
- >::value
- &&
- !is_reference<
- typename find_convertible_property<Property>::query_result_type
- >::value
- &&
- !is_scalar<
- typename find_convertible_property<Property>::query_result_type
- >::value
- >::type* = 0) const
- {
- typedef find_convertible_property<Property> found;
- typename found::query_result_type* result;
- prop_fns_[found::index].query(&result, object_fns_->target(*this),
- &static_cast<const typename found::type&>(p));
- return *asio::detail::scoped_ptr<
- typename found::query_result_type>(result);
- }
- template <typename T>
- struct find_convertible_requirable_property :
- detail::supportable_properties<
- 0, void(SupportableProperties...)>::template
- find_convertible_requirable_property<T> {};
- template <typename Property>
- any_executor require(const Property& p,
- typename enable_if<
- find_convertible_requirable_property<Property>::value
- >::type* = 0) const
- {
- typedef find_convertible_requirable_property<Property> found;
- return prop_fns_[found::index].require(object_fns_->target(*this),
- &static_cast<const typename found::type&>(p));
- }
- template <typename T>
- struct find_convertible_preferable_property :
- detail::supportable_properties<
- 0, void(SupportableProperties...)>::template
- find_convertible_preferable_property<T> {};
- template <typename Property>
- any_executor prefer(const Property& p,
- typename enable_if<
- find_convertible_preferable_property<Property>::value
- >::type* = 0) const
- {
- typedef find_convertible_preferable_property<Property> found;
- return prop_fns_[found::index].prefer(object_fns_->target(*this),
- &static_cast<const typename found::type&>(p));
- }
- //private:
- template <typename Ex>
- static const prop_fns<any_executor>* prop_fns_table()
- {
- static const prop_fns<any_executor> fns[] =
- {
- {
- &detail::any_executor_base::query_fn<
- Ex, SupportableProperties>,
- &detail::any_executor_base::require_fn<
- any_executor, Ex, SupportableProperties>,
- &detail::any_executor_base::prefer_fn<
- any_executor, Ex, SupportableProperties>
- }...
- };
- return fns;
- }
- const prop_fns<any_executor>* prop_fns_;
- };
- template <typename... SupportableProperties>
- inline void swap(any_executor<SupportableProperties...>& a,
- any_executor<SupportableProperties...>& b) ASIO_NOEXCEPT
- {
- return a.swap(b);
- }
- #else // defined(ASIO_HAS_VARIADIC_TEMPLATES)
- #define ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS(n) \
- ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_##n
- #define ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_1 \
- { \
- &detail::any_executor_base::query_fn<Ex, T1>, \
- &detail::any_executor_base::require_fn<any_executor, Ex, T1>, \
- &detail::any_executor_base::prefer_fn<any_executor, Ex, T1> \
- }
- #define ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_2 \
- ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_1, \
- { \
- &detail::any_executor_base::query_fn<Ex, T2>, \
- &detail::any_executor_base::require_fn<any_executor, Ex, T2>, \
- &detail::any_executor_base::prefer_fn<any_executor, Ex, T2> \
- }
- #define ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_3 \
- ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_2, \
- { \
- &detail::any_executor_base::query_fn<Ex, T3>, \
- &detail::any_executor_base::require_fn<any_executor, Ex, T3>, \
- &detail::any_executor_base::prefer_fn<any_executor, Ex, T3> \
- }
- #define ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_4 \
- ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_3, \
- { \
- &detail::any_executor_base::query_fn<Ex, T4>, \
- &detail::any_executor_base::require_fn<any_executor, Ex, T4>, \
- &detail::any_executor_base::prefer_fn<any_executor, Ex, T4> \
- }
- #define ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_5 \
- ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_4, \
- { \
- &detail::any_executor_base::query_fn<Ex, T5>, \
- &detail::any_executor_base::require_fn<any_executor, Ex, T5>, \
- &detail::any_executor_base::prefer_fn<any_executor, Ex, T5> \
- }
- #define ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_6 \
- ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_5, \
- { \
- &detail::any_executor_base::query_fn<Ex, T6>, \
- &detail::any_executor_base::require_fn<any_executor, Ex, T6>, \
- &detail::any_executor_base::prefer_fn<any_executor, Ex, T6> \
- }
- #define ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_7 \
- ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_6, \
- { \
- &detail::any_executor_base::query_fn<Ex, T7>, \
- &detail::any_executor_base::require_fn<any_executor, Ex, T7>, \
- &detail::any_executor_base::prefer_fn<any_executor, Ex, T7> \
- }
- #define ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_8 \
- ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_7, \
- { \
- &detail::any_executor_base::query_fn<Ex, T8>, \
- &detail::any_executor_base::require_fn<any_executor, Ex, T8>, \
- &detail::any_executor_base::prefer_fn<any_executor, Ex, T8> \
- }
- #if defined(ASIO_HAS_MOVE)
- # define ASIO_PRIVATE_ANY_EXECUTOR_MOVE_OPS \
- any_executor(any_executor&& other) ASIO_NOEXCEPT \
- : detail::any_executor_base( \
- static_cast<any_executor_base&&>( \
- static_cast<any_executor_base&>(other))), \
- prop_fns_(other.prop_fns_) \
- { \
- other.prop_fns_ = prop_fns_table<void>(); \
- } \
- \
- any_executor& operator=(any_executor&& other) ASIO_NOEXCEPT \
- { \
- if (this != &other) \
- { \
- prop_fns_ = other.prop_fns_; \
- detail::any_executor_base::operator=( \
- static_cast<detail::any_executor_base&&>( \
- static_cast<detail::any_executor_base&>(other))); \
- } \
- return *this; \
- } \
- /**/
- #else // defined(ASIO_HAS_MOVE)
- # define ASIO_PRIVATE_ANY_EXECUTOR_MOVE_OPS
- #endif // defined(ASIO_HAS_MOVE)
- #define ASIO_PRIVATE_ANY_EXECUTOR_DEF(n) \
- template <ASIO_VARIADIC_TPARAMS(n)> \
- class any_executor<ASIO_VARIADIC_TARGS(n)> : \
- public detail::any_executor_base, \
- public detail::any_executor_context< \
- any_executor<ASIO_VARIADIC_TARGS(n)>, \
- typename detail::supportable_properties< \
- 0, void(ASIO_VARIADIC_TARGS(n))>::find_context_as_property> \
- { \
- public: \
- any_executor() ASIO_NOEXCEPT \
- : detail::any_executor_base(), \
- prop_fns_(prop_fns_table<void>()) \
- { \
- } \
- \
- any_executor(nullptr_t) ASIO_NOEXCEPT \
- : detail::any_executor_base(), \
- prop_fns_(prop_fns_table<void>()) \
- { \
- } \
- \
- template <ASIO_EXECUTION_EXECUTOR Executor> \
- any_executor(Executor ex, \
- typename enable_if< \
- conditional< \
- !is_same<Executor, any_executor>::value \
- && !is_base_of<detail::any_executor_base, Executor>::value, \
- detail::is_valid_target_executor< \
- Executor, void(ASIO_VARIADIC_TARGS(n))>, \
- false_type \
- >::type::value \
- >::type* = 0) \
- : detail::any_executor_base(ASIO_MOVE_CAST( \
- Executor)(ex), false_type()), \
- prop_fns_(prop_fns_table<Executor>()) \
- { \
- } \
- \
- any_executor(const any_executor& other) ASIO_NOEXCEPT \
- : detail::any_executor_base( \
- static_cast<const detail::any_executor_base&>(other)), \
- prop_fns_(other.prop_fns_) \
- { \
- } \
- \
- any_executor(any_executor<> other) \
- : detail::any_executor_base(ASIO_MOVE_CAST( \
- any_executor<>)(other), true_type()), \
- prop_fns_(prop_fns_table<any_executor<> >()) \
- { \
- } \
- \
- template <typename OtherAnyExecutor> \
- any_executor(OtherAnyExecutor other, \
- typename enable_if< \
- conditional< \
- !is_same<OtherAnyExecutor, any_executor>::value \
- && is_base_of<detail::any_executor_base, \
- OtherAnyExecutor>::value, \
- typename detail::supportable_properties< \
- 0, void(ASIO_VARIADIC_TARGS(n))>::template \
- is_valid_target<OtherAnyExecutor>, \
- false_type \
- >::type::value \
- >::type* = 0) \
- : detail::any_executor_base(ASIO_MOVE_CAST( \
- OtherAnyExecutor)(other), true_type()), \
- prop_fns_(prop_fns_table<OtherAnyExecutor>()) \
- { \
- } \
- \
- any_executor& operator=(const any_executor& other) ASIO_NOEXCEPT \
- { \
- if (this != &other) \
- { \
- prop_fns_ = other.prop_fns_; \
- detail::any_executor_base::operator=( \
- static_cast<const detail::any_executor_base&>(other)); \
- } \
- return *this; \
- } \
- \
- any_executor& operator=(nullptr_t p) ASIO_NOEXCEPT \
- { \
- prop_fns_ = prop_fns_table<void>(); \
- detail::any_executor_base::operator=(p); \
- return *this; \
- } \
- \
- ASIO_PRIVATE_ANY_EXECUTOR_MOVE_OPS \
- \
- void swap(any_executor& other) ASIO_NOEXCEPT \
- { \
- if (this != &other) \
- { \
- detail::any_executor_base::swap( \
- static_cast<detail::any_executor_base&>(other)); \
- const prop_fns<any_executor>* tmp_prop_fns = other.prop_fns_; \
- other.prop_fns_ = prop_fns_; \
- prop_fns_ = tmp_prop_fns; \
- } \
- } \
- \
- using detail::any_executor_base::execute; \
- using detail::any_executor_base::target; \
- using detail::any_executor_base::target_type; \
- using detail::any_executor_base::operator unspecified_bool_type; \
- using detail::any_executor_base::operator!; \
- \
- bool equality_helper(const any_executor& other) const ASIO_NOEXCEPT \
- { \
- return any_executor_base::equality_helper(other); \
- } \
- \
- template <typename AnyExecutor1, typename AnyExecutor2> \
- friend typename enable_if< \
- is_base_of<any_executor, AnyExecutor1>::value \
- || is_base_of<any_executor, AnyExecutor2>::value, \
- bool \
- >::type operator==(const AnyExecutor1& a, \
- const AnyExecutor2& b) ASIO_NOEXCEPT \
- { \
- return static_cast<const any_executor&>(a).equality_helper(b); \
- } \
- \
- template <typename AnyExecutor> \
- friend typename enable_if< \
- is_same<AnyExecutor, any_executor>::value, \
- bool \
- >::type operator==(const AnyExecutor& a, nullptr_t) ASIO_NOEXCEPT \
- { \
- return !a; \
- } \
- \
- template <typename AnyExecutor> \
- friend typename enable_if< \
- is_same<AnyExecutor, any_executor>::value, \
- bool \
- >::type operator==(nullptr_t, const AnyExecutor& b) ASIO_NOEXCEPT \
- { \
- return !b; \
- } \
- \
- template <typename AnyExecutor1, typename AnyExecutor2> \
- friend typename enable_if< \
- is_base_of<any_executor, AnyExecutor1>::value \
- || is_base_of<any_executor, AnyExecutor2>::value, \
- bool \
- >::type operator!=(const AnyExecutor1& a, \
- const AnyExecutor2& b) ASIO_NOEXCEPT \
- { \
- return !static_cast<const any_executor&>(a).equality_helper(b); \
- } \
- \
- template <typename AnyExecutor> \
- friend typename enable_if< \
- is_same<AnyExecutor, any_executor>::value, \
- bool \
- >::type operator!=(const AnyExecutor& a, nullptr_t) ASIO_NOEXCEPT \
- { \
- return !!a; \
- } \
- \
- template <typename AnyExecutor> \
- friend typename enable_if< \
- is_same<AnyExecutor, any_executor>::value, \
- bool \
- >::type operator!=(nullptr_t, const AnyExecutor& b) ASIO_NOEXCEPT \
- { \
- return !!b; \
- } \
- \
- template <typename T> \
- struct find_convertible_property : \
- detail::supportable_properties< \
- 0, void(ASIO_VARIADIC_TARGS(n))>::template \
- find_convertible_property<T> {}; \
- \
- template <typename Property> \
- void query(const Property& p, \
- typename enable_if< \
- is_same< \
- typename find_convertible_property<Property>::query_result_type, \
- void \
- >::value \
- >::type* = 0) const \
- { \
- typedef find_convertible_property<Property> found; \
- prop_fns_[found::index].query(0, object_fns_->target(*this), \
- &static_cast<const typename found::type&>(p)); \
- } \
- \
- template <typename Property> \
- typename find_convertible_property<Property>::query_result_type \
- query(const Property& p, \
- typename enable_if< \
- !is_same< \
- typename find_convertible_property<Property>::query_result_type, \
- void \
- >::value \
- && \
- is_reference< \
- typename find_convertible_property<Property>::query_result_type \
- >::value \
- >::type* = 0) const \
- { \
- typedef find_convertible_property<Property> found; \
- typename remove_reference< \
- typename found::query_result_type>::type* result; \
- prop_fns_[found::index].query(&result, object_fns_->target(*this), \
- &static_cast<const typename found::type&>(p)); \
- return *result; \
- } \
- \
- template <typename Property> \
- typename find_convertible_property<Property>::query_result_type \
- query(const Property& p, \
- typename enable_if< \
- !is_same< \
- typename find_convertible_property<Property>::query_result_type, \
- void \
- >::value \
- && \
- is_scalar< \
- typename find_convertible_property<Property>::query_result_type \
- >::value \
- >::type* = 0) const \
- { \
- typedef find_convertible_property<Property> found; \
- typename found::query_result_type result; \
- prop_fns_[found::index].query(&result, object_fns_->target(*this), \
- &static_cast<const typename found::type&>(p)); \
- return result; \
- } \
- \
- template <typename Property> \
- typename find_convertible_property<Property>::query_result_type \
- query(const Property& p, \
- typename enable_if< \
- !is_same< \
- typename find_convertible_property<Property>::query_result_type, \
- void \
- >::value \
- && \
- !is_reference< \
- typename find_convertible_property<Property>::query_result_type \
- >::value \
- && \
- !is_scalar< \
- typename find_convertible_property<Property>::query_result_type \
- >::value \
- >::type* = 0) const \
- { \
- typedef find_convertible_property<Property> found; \
- typename found::query_result_type* result; \
- prop_fns_[found::index].query(&result, object_fns_->target(*this), \
- &static_cast<const typename found::type&>(p)); \
- return *asio::detail::scoped_ptr< \
- typename found::query_result_type>(result); \
- } \
- \
- template <typename T> \
- struct find_convertible_requirable_property : \
- detail::supportable_properties< \
- 0, void(ASIO_VARIADIC_TARGS(n))>::template \
- find_convertible_requirable_property<T> {}; \
- \
- template <typename Property> \
- any_executor require(const Property& p, \
- typename enable_if< \
- find_convertible_requirable_property<Property>::value \
- >::type* = 0) const \
- { \
- typedef find_convertible_requirable_property<Property> found; \
- return prop_fns_[found::index].require(object_fns_->target(*this), \
- &static_cast<const typename found::type&>(p)); \
- } \
- \
- template <typename T> \
- struct find_convertible_preferable_property : \
- detail::supportable_properties< \
- 0, void(ASIO_VARIADIC_TARGS(n))>::template \
- find_convertible_preferable_property<T> {}; \
- \
- template <typename Property> \
- any_executor prefer(const Property& p, \
- typename enable_if< \
- find_convertible_preferable_property<Property>::value \
- >::type* = 0) const \
- { \
- typedef find_convertible_preferable_property<Property> found; \
- return prop_fns_[found::index].prefer(object_fns_->target(*this), \
- &static_cast<const typename found::type&>(p)); \
- } \
- \
- template <typename Ex> \
- static const prop_fns<any_executor>* prop_fns_table() \
- { \
- static const prop_fns<any_executor> fns[] = \
- { \
- ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS(n) \
- }; \
- return fns; \
- } \
- \
- const prop_fns<any_executor>* prop_fns_; \
- typedef detail::supportable_properties<0, \
- void(ASIO_VARIADIC_TARGS(n))> supportable_properties_type; \
- }; \
- \
- template <ASIO_VARIADIC_TPARAMS(n)> \
- inline void swap(any_executor<ASIO_VARIADIC_TARGS(n)>& a, \
- any_executor<ASIO_VARIADIC_TARGS(n)>& b) ASIO_NOEXCEPT \
- { \
- return a.swap(b); \
- } \
- /**/
- ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_ANY_EXECUTOR_DEF)
- #undef ASIO_PRIVATE_ANY_EXECUTOR_DEF
- #undef ASIO_PRIVATE_ANY_EXECUTOR_MOVE_OPS
- #undef ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS
- #undef ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_1
- #undef ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_2
- #undef ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_3
- #undef ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_4
- #undef ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_5
- #undef ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_6
- #undef ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_7
- #undef ASIO_PRIVATE_ANY_EXECUTOR_PROP_FNS_8
- #endif // if defined(ASIO_HAS_VARIADIC_TEMPLATES)
- } // namespace execution
- namespace traits {
- #if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
- #if defined(ASIO_HAS_VARIADIC_TEMPLATES)
- template <typename... SupportableProperties>
- struct equality_comparable<execution::any_executor<SupportableProperties...> >
- {
- static const bool is_valid = true;
- static const bool is_noexcept = true;
- };
- #else // defined(ASIO_HAS_VARIADIC_TEMPLATES)
- template <>
- struct equality_comparable<execution::any_executor<> >
- {
- static const bool is_valid = true;
- static const bool is_noexcept = true;
- };
- #define ASIO_PRIVATE_ANY_EXECUTOR_EQUALITY_COMPARABLE_DEF(n) \
- template <ASIO_VARIADIC_TPARAMS(n)> \
- struct equality_comparable< \
- execution::any_executor<ASIO_VARIADIC_TARGS(n)> > \
- { \
- static const bool is_valid = true; \
- static const bool is_noexcept = true; \
- }; \
- /**/
- ASIO_VARIADIC_GENERATE(
- ASIO_PRIVATE_ANY_EXECUTOR_EQUALITY_COMPARABLE_DEF)
- #undef ASIO_PRIVATE_ANY_EXECUTOR_EQUALITY_COMPARABLE_DEF
- #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES)
- #endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
- #if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
- #if defined(ASIO_HAS_VARIADIC_TEMPLATES)
- template <typename F, typename... SupportableProperties>
- struct execute_member<execution::any_executor<SupportableProperties...>, F>
- {
- static const bool is_valid = true;
- static const bool is_noexcept = false;
- typedef void result_type;
- };
- #else // defined(ASIO_HAS_VARIADIC_TEMPLATES)
- template <typename F>
- struct execute_member<execution::any_executor<>, F>
- {
- static const bool is_valid = true;
- static const bool is_noexcept = false;
- typedef void result_type;
- };
- #define ASIO_PRIVATE_ANY_EXECUTOR_EXECUTE_MEMBER_DEF(n) \
- template <typename F, ASIO_VARIADIC_TPARAMS(n)> \
- struct execute_member< \
- execution::any_executor<ASIO_VARIADIC_TARGS(n)>, F> \
- { \
- static const bool is_valid = true; \
- static const bool is_noexcept = false; \
- typedef void result_type; \
- }; \
- /**/
- ASIO_VARIADIC_GENERATE(
- ASIO_PRIVATE_ANY_EXECUTOR_EXECUTE_MEMBER_DEF)
- #undef ASIO_PRIVATE_ANY_EXECUTOR_EXECUTE_MEMBER_DEF
- #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES)
- #endif // !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
- #if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
- #if defined(ASIO_HAS_VARIADIC_TEMPLATES)
- template <typename Prop, typename... SupportableProperties>
- struct query_member<
- execution::any_executor<SupportableProperties...>, Prop,
- typename enable_if<
- execution::detail::supportable_properties<
- 0, void(SupportableProperties...)>::template
- find_convertible_property<Prop>::value
- >::type>
- {
- static const bool is_valid = true;
- static const bool is_noexcept = false;
- typedef typename execution::detail::supportable_properties<
- 0, void(SupportableProperties...)>::template
- find_convertible_property<Prop>::query_result_type result_type;
- };
- #else // defined(ASIO_HAS_VARIADIC_TEMPLATES)
- #define ASIO_PRIVATE_ANY_EXECUTOR_QUERY_MEMBER_DEF(n) \
- template <typename Prop, ASIO_VARIADIC_TPARAMS(n)> \
- struct query_member< \
- execution::any_executor<ASIO_VARIADIC_TARGS(n)>, Prop, \
- typename enable_if< \
- execution::detail::supportable_properties< \
- 0, void(ASIO_VARIADIC_TARGS(n))>::template \
- find_convertible_property<Prop>::value \
- >::type> \
- { \
- static const bool is_valid = true; \
- static const bool is_noexcept = false; \
- typedef typename execution::detail::supportable_properties< \
- 0, void(ASIO_VARIADIC_TARGS(n))>::template \
- find_convertible_property<Prop>::query_result_type result_type; \
- }; \
- /**/
- ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_ANY_EXECUTOR_QUERY_MEMBER_DEF)
- #undef ASIO_PRIVATE_ANY_EXECUTOR_QUERY_MEMBER_DEF
- #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES)
- #endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
- #if !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
- #if defined(ASIO_HAS_VARIADIC_TEMPLATES)
- template <typename Prop, typename... SupportableProperties>
- struct require_member<
- execution::any_executor<SupportableProperties...>, Prop,
- typename enable_if<
- execution::detail::supportable_properties<
- 0, void(SupportableProperties...)>::template
- find_convertible_requirable_property<Prop>::value
- >::type>
- {
- static const bool is_valid = true;
- static const bool is_noexcept = false;
- typedef execution::any_executor<SupportableProperties...> result_type;
- };
- #else // defined(ASIO_HAS_VARIADIC_TEMPLATES)
- #define ASIO_PRIVATE_ANY_EXECUTOR_REQUIRE_MEMBER_DEF(n) \
- template <typename Prop, ASIO_VARIADIC_TPARAMS(n)> \
- struct require_member< \
- execution::any_executor<ASIO_VARIADIC_TARGS(n)>, Prop, \
- typename enable_if< \
- execution::detail::supportable_properties< \
- 0, void(ASIO_VARIADIC_TARGS(n))>::template \
- find_convertible_requirable_property<Prop>::value \
- >::type> \
- { \
- static const bool is_valid = true; \
- static const bool is_noexcept = false; \
- typedef execution::any_executor<ASIO_VARIADIC_TARGS(n)> result_type; \
- }; \
- /**/
- ASIO_VARIADIC_GENERATE(
- ASIO_PRIVATE_ANY_EXECUTOR_REQUIRE_MEMBER_DEF)
- #undef ASIO_PRIVATE_ANY_EXECUTOR_REQUIRE_MEMBER_DEF
- #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES)
- #endif // !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
- #if !defined(ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT)
- #if defined(ASIO_HAS_VARIADIC_TEMPLATES)
- template <typename Prop, typename... SupportableProperties>
- struct prefer_member<
- execution::any_executor<SupportableProperties...>, Prop,
- typename enable_if<
- execution::detail::supportable_properties<
- 0, void(SupportableProperties...)>::template
- find_convertible_preferable_property<Prop>::value
- >::type>
- {
- static const bool is_valid = true;
- static const bool is_noexcept = false;
- typedef execution::any_executor<SupportableProperties...> result_type;
- };
- #else // defined(ASIO_HAS_VARIADIC_TEMPLATES)
- #define ASIO_PRIVATE_ANY_EXECUTOR_PREFER_FREE_DEF(n) \
- template <typename Prop, ASIO_VARIADIC_TPARAMS(n)> \
- struct prefer_member< \
- execution::any_executor<ASIO_VARIADIC_TARGS(n)>, Prop, \
- typename enable_if< \
- execution::detail::supportable_properties< \
- 0, void(ASIO_VARIADIC_TARGS(n))>::template \
- find_convertible_preferable_property<Prop>::value \
- >::type> \
- { \
- static const bool is_valid = true; \
- static const bool is_noexcept = false; \
- typedef execution::any_executor<ASIO_VARIADIC_TARGS(n)> result_type; \
- }; \
- /**/
- ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_ANY_EXECUTOR_PREFER_FREE_DEF)
- #undef ASIO_PRIVATE_ANY_EXECUTOR_PREFER_FREE_DEF
- #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES)
- #endif // !defined(ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT)
- } // namespace traits
- #endif // defined(GENERATING_DOCUMENTATION)
- } // namespace asio
- #include "asio/detail/pop_options.hpp"
- #endif // ASIO_EXECUTION_ANY_EXECUTOR_HPP
|