arg_list.hpp 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331
  1. // Copyright Daniel Wallin, David Abrahams 2005.
  2. // Copyright Cromwell D. Enage 2017.
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef ARG_LIST_050329_HPP
  7. #define ARG_LIST_050329_HPP
  8. namespace boost { namespace parameter { namespace aux {
  9. //
  10. // Structures used to build the tuple of actual arguments. The tuple is a
  11. // nested cons-style list of arg_list specializations terminated by an
  12. // empty_arg_list.
  13. //
  14. // Each specialization of arg_list is derived from its successor in the
  15. // list type. This feature is used along with using declarations to build
  16. // member function overload sets that can match against keywords.
  17. //
  18. // MPL sequence support
  19. struct arg_list_tag;
  20. template <typename T>
  21. struct get_reference
  22. {
  23. typedef typename T::reference type;
  24. };
  25. }}} // namespace boost::parameter::aux
  26. #include <boost/parameter/config.hpp>
  27. #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
  28. namespace boost { namespace parameter { namespace aux {
  29. struct value_type_is_void
  30. {
  31. };
  32. struct value_type_is_not_void
  33. {
  34. };
  35. }}} // namespace boost::parameter::aux
  36. #endif
  37. #include <boost/parameter/aux_/void.hpp>
  38. #include <boost/parameter/aux_/yesno.hpp>
  39. #include <boost/parameter/aux_/result_of0.hpp>
  40. #include <boost/parameter/aux_/default.hpp>
  41. #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
  42. #include <utility>
  43. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  44. #include <boost/mp11/integral.hpp>
  45. #include <boost/mp11/list.hpp>
  46. #include <boost/mp11/utility.hpp>
  47. #include <type_traits>
  48. #endif
  49. namespace boost { namespace parameter { namespace aux {
  50. // Terminates arg_list<> and represents an empty list. Since this is just
  51. // the terminating case, you might want to look at arg_list first to get a
  52. // feel for what's really happening here.
  53. struct empty_arg_list
  54. {
  55. struct tagged_arg
  56. {
  57. typedef ::boost::parameter::void_ value_type;
  58. };
  59. // Variadic constructor also serves as default constructor.
  60. template <typename ...Args>
  61. inline BOOST_CONSTEXPR empty_arg_list(Args&&...)
  62. {
  63. }
  64. // A metafunction class that, given a keyword and a default type,
  65. // returns the appropriate result type for a keyword lookup given
  66. // that default.
  67. struct binding
  68. {
  69. template <typename KW, typename Default, typename Reference>
  70. struct apply
  71. {
  72. typedef Default type;
  73. };
  74. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  75. template <typename KW, typename Default, typename Reference>
  76. using fn = Default;
  77. #endif
  78. };
  79. // Terminator for has_key, indicating that the keyword is unique.
  80. template <typename KW>
  81. static ::boost::parameter::aux::no_tag has_key(KW*);
  82. // If either of these operators are called, it means there is no
  83. // argument in the list that matches the supplied keyword. Just
  84. // return the default value.
  85. template <typename K, typename Default>
  86. inline BOOST_CONSTEXPR Default&
  87. operator[](::boost::parameter::aux::default_<K,Default> x) const
  88. {
  89. return x.value;
  90. }
  91. template <typename K, typename Default>
  92. inline BOOST_CONSTEXPR Default&&
  93. operator[](::boost::parameter::aux::default_r_<K,Default> x) const
  94. {
  95. return ::std::forward<Default>(x.value);
  96. }
  97. // If this operator is called, it means there is no argument in the
  98. // list that matches the supplied keyword. Just evaluate and return
  99. // the default value.
  100. template <typename K, typename F>
  101. inline BOOST_CONSTEXPR
  102. typename ::boost::parameter::aux::result_of0<F>::type
  103. operator[](BOOST_PARAMETER_lazy_default_fallback<K,F> x) const
  104. {
  105. return x.compute_default();
  106. }
  107. // No argument corresponding to ParameterRequirements::key_type
  108. // was found if we match this overload, so unless that parameter
  109. // has a default, we indicate that the actual arguments don't
  110. // match the function's requirements.
  111. template <typename ParameterRequirements, typename ArgPack>
  112. static typename ParameterRequirements::has_default
  113. satisfies(ParameterRequirements*, ArgPack*);
  114. // MPL sequence support
  115. typedef ::boost::parameter::aux::empty_arg_list type; // convenience
  116. // For dispatching to sequence intrinsics
  117. typedef ::boost::parameter::aux::arg_list_tag tag;
  118. };
  119. }}} // namespace boost::parameter::aux
  120. #include <boost/parameter/aux_/preprocessor/nullptr.hpp>
  121. #include <boost/parameter/aux_/yesno.hpp>
  122. #include <boost/parameter/aux_/is_maybe.hpp>
  123. #include <boost/parameter/aux_/tagged_argument_fwd.hpp>
  124. #include <boost/parameter/aux_/parameter_requirements.hpp>
  125. #include <boost/parameter/aux_/augment_predicate.hpp>
  126. #include <boost/parameter/keyword_fwd.hpp>
  127. #include <boost/mpl/bool.hpp>
  128. #include <boost/mpl/if.hpp>
  129. #include <boost/mpl/eval_if.hpp>
  130. #include <boost/mpl/apply_wrap.hpp>
  131. #include <boost/mpl/assert.hpp>
  132. #include <boost/type_traits/is_same.hpp>
  133. #include <boost/core/enable_if.hpp>
  134. namespace boost { namespace parameter { namespace aux {
  135. // A tuple of tagged arguments, terminated with empty_arg_list. Every
  136. // TaggedArg is an instance of tagged_argument<> or
  137. // tagged_argument_rref<>.
  138. template <
  139. typename TaggedArg
  140. , typename Next = ::boost::parameter::aux::empty_arg_list
  141. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  142. , typename EmitsErrors = ::boost::mp11::mp_true
  143. #else
  144. , typename EmitsErrors = ::boost::mpl::true_
  145. #endif
  146. >
  147. class arg_list : public Next
  148. {
  149. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  150. using _holds_maybe = typename ::boost::parameter::aux
  151. ::is_maybe<typename TaggedArg::value_type>::type;
  152. #else
  153. typedef typename ::boost::parameter::aux
  154. ::is_maybe<typename TaggedArg::value_type>::type _holds_maybe;
  155. #endif
  156. TaggedArg arg; // Stores the argument
  157. public:
  158. typedef TaggedArg tagged_arg;
  159. typedef ::boost::parameter::aux::arg_list<TaggedArg,Next> self;
  160. typedef typename TaggedArg::key_type key_type;
  161. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  162. using reference = typename ::boost::mp11::mp_if<
  163. _holds_maybe
  164. , ::boost::parameter::aux
  165. ::get_reference<typename TaggedArg::value_type>
  166. , ::boost::parameter::aux::get_reference<TaggedArg>
  167. >::type;
  168. using value_type = ::boost::mp11
  169. ::mp_if<_holds_maybe,reference,typename TaggedArg::value_type>;
  170. #else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
  171. typedef typename ::boost::mpl::eval_if<
  172. _holds_maybe
  173. , ::boost::parameter::aux
  174. ::get_reference<typename TaggedArg::value_type>
  175. , ::boost::parameter::aux::get_reference<TaggedArg>
  176. >::type reference;
  177. typedef typename ::boost::mpl::if_<
  178. _holds_maybe
  179. , reference
  180. , typename TaggedArg::value_type
  181. >::type value_type;
  182. #endif // BOOST_PARAMETER_CAN_USE_MP11
  183. // Create a new list by prepending arg to a copy of tail. Used when
  184. // incrementally building this structure with the comma operator.
  185. inline BOOST_CONSTEXPR arg_list(
  186. TaggedArg const& head
  187. , Next const& tail
  188. ) : Next(tail), arg(head)
  189. {
  190. }
  191. // Store the arguments in successive nodes of this list.
  192. // Use tag dispatching to determine whether to forward all arguments
  193. // to the Next constructor, or store the first argument and forward
  194. // the rest. -- Cromwell D. Enage
  195. template <typename A0>
  196. inline BOOST_CONSTEXPR arg_list(
  197. ::boost::parameter::aux::value_type_is_not_void
  198. , A0&& a0
  199. ) : Next(
  200. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  201. ::boost::mp11::mp_if<
  202. ::std::is_same<
  203. #else
  204. typename ::boost::mpl::if_<
  205. ::boost::is_same<
  206. #endif
  207. typename Next::tagged_arg::value_type
  208. , ::boost::parameter::void_
  209. >
  210. , ::boost::parameter::aux::value_type_is_void
  211. , ::boost::parameter::aux::value_type_is_not_void
  212. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  213. >()
  214. #else
  215. >::type()
  216. #endif
  217. )
  218. , arg(::std::forward<A0>(a0))
  219. {
  220. }
  221. template <typename ...Args>
  222. inline BOOST_CONSTEXPR arg_list(
  223. ::boost::parameter::aux::value_type_is_void
  224. , Args&&... args
  225. ) : Next(
  226. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  227. ::boost::mp11::mp_if<
  228. ::std::is_same<
  229. #else
  230. typename ::boost::mpl::if_<
  231. ::boost::is_same<
  232. #endif
  233. typename Next::tagged_arg::value_type
  234. , ::boost::parameter::void_
  235. >
  236. , ::boost::parameter::aux::value_type_is_void
  237. , ::boost::parameter::aux::value_type_is_not_void
  238. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  239. >()
  240. #else
  241. >::type()
  242. #endif
  243. , ::std::forward<Args>(args)...
  244. )
  245. , arg(::boost::parameter::aux::void_reference())
  246. {
  247. }
  248. template <typename A0, typename A1, typename ...Args>
  249. inline BOOST_CONSTEXPR arg_list(
  250. ::boost::parameter::aux::value_type_is_not_void
  251. , A0&& a0
  252. , A1&& a1
  253. , Args&&... args
  254. ) : Next(
  255. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  256. ::boost::mp11::mp_if<
  257. ::std::is_same<
  258. #else
  259. typename ::boost::mpl::if_<
  260. ::boost::is_same<
  261. #endif
  262. typename Next::tagged_arg::value_type
  263. , ::boost::parameter::void_
  264. >
  265. , ::boost::parameter::aux::value_type_is_void
  266. , ::boost::parameter::aux::value_type_is_not_void
  267. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  268. >()
  269. #else
  270. >::type()
  271. #endif
  272. , ::std::forward<A1>(a1)
  273. , ::std::forward<Args>(args)...
  274. )
  275. , arg(::std::forward<A0>(a0))
  276. {
  277. }
  278. // A metafunction class that, given a keyword and a default type,
  279. // returns the appropriate result type for a keyword lookup given
  280. // that default.
  281. struct binding
  282. {
  283. typedef typename Next::binding next_binding;
  284. template <typename KW, typename Default, typename Reference>
  285. struct apply
  286. {
  287. typedef typename ::boost::mpl::eval_if<
  288. ::boost::is_same<KW,key_type>
  289. , ::boost::mpl::if_<Reference,reference,value_type>
  290. , ::boost::mpl
  291. ::apply_wrap3<next_binding,KW,Default,Reference>
  292. >::type type;
  293. };
  294. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  295. template <typename KW, typename Default, typename Reference>
  296. using fn = ::boost::mp11::mp_if<
  297. ::std::is_same<KW,key_type>
  298. , ::boost::mp11::mp_if<Reference,reference,value_type>
  299. , ::boost::mp11::mp_apply_q<
  300. next_binding
  301. , ::boost::mp11::mp_list<KW,Default,Reference>
  302. >
  303. >;
  304. #endif
  305. };
  306. // Overload for key_type, so the assert below will fire
  307. // if the same keyword is used again.
  308. static ::boost::parameter::aux::yes_tag has_key(key_type*);
  309. using Next::has_key;
  310. private:
  311. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  312. using _has_unique_key = ::boost::mp11::mp_bool<
  313. #else
  314. typedef ::boost::mpl::bool_<
  315. #endif
  316. sizeof(
  317. Next::has_key(
  318. static_cast<key_type*>(BOOST_PARAMETER_AUX_PP_NULLPTR)
  319. )
  320. ) == sizeof(::boost::parameter::aux::no_tag)
  321. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  322. >;
  323. #else
  324. > _has_unique_key;
  325. #endif
  326. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  327. static_assert(
  328. !(EmitsErrors::value) || (_has_unique_key::value)
  329. , "duplicate keyword"
  330. );
  331. #else
  332. BOOST_MPL_ASSERT_MSG(
  333. !(EmitsErrors::value) || (_has_unique_key::value)
  334. , duplicate_keyword
  335. , (key_type)
  336. );
  337. #endif
  338. //
  339. // Begin implementation of indexing operators
  340. // for looking up specific arguments by name.
  341. //
  342. // Helpers that handle the case when TaggedArg is empty<T>.
  343. template <typename D>
  344. inline BOOST_CONSTEXPR reference
  345. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  346. get_default(D const&, ::boost::mp11::mp_false) const
  347. #else
  348. get_default(D const&, ::boost::mpl::false_) const
  349. #endif
  350. {
  351. return this->arg.get_value();
  352. }
  353. template <typename D>
  354. inline BOOST_CONSTEXPR reference
  355. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  356. get_default(D const& d, ::boost::mp11::mp_true) const
  357. #else
  358. get_default(D const& d, ::boost::mpl::true_) const
  359. #endif
  360. {
  361. return (
  362. this->arg.get_value()
  363. ? this->arg.get_value().get()
  364. : this->arg.get_value().construct(d.value)
  365. );
  366. }
  367. public:
  368. inline BOOST_CONSTEXPR reference
  369. operator[](::boost::parameter::keyword<key_type> const&) const
  370. {
  371. #if !defined(BOOST_NO_CXX14_CONSTEXPR)
  372. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  373. static_assert(!_holds_maybe::value, "must not hold maybe");
  374. #elif !( \
  375. BOOST_WORKAROUND(BOOST_GCC, >= 40700) && \
  376. BOOST_WORKAROUND(BOOST_GCC, < 40900) \
  377. ) && !BOOST_WORKAROUND(BOOST_GCC, >= 50000) && \
  378. !BOOST_WORKAROUND(BOOST_MSVC, < 1910)
  379. BOOST_MPL_ASSERT_NOT((_holds_maybe));
  380. #endif
  381. #endif
  382. return this->arg.get_value();
  383. }
  384. template <typename Default>
  385. inline BOOST_CONSTEXPR reference
  386. operator[](
  387. ::boost::parameter::aux::default_<key_type,Default> const& d
  388. ) const
  389. {
  390. return this->get_default(d, _holds_maybe());
  391. }
  392. template <typename Default>
  393. inline BOOST_CONSTEXPR reference
  394. operator[](
  395. ::boost::parameter::aux::default_r_<key_type,Default> const& d
  396. ) const
  397. {
  398. return this->get_default(d, _holds_maybe());
  399. }
  400. template <typename Default>
  401. inline BOOST_CONSTEXPR reference
  402. operator[](
  403. BOOST_PARAMETER_lazy_default_fallback<key_type,Default> const&
  404. ) const
  405. {
  406. #if !defined(BOOST_NO_CXX14_CONSTEXPR)
  407. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  408. static_assert(!_holds_maybe::value, "must not hold maybe");
  409. #elif !( \
  410. BOOST_WORKAROUND(BOOST_GCC, >= 40700) && \
  411. BOOST_WORKAROUND(BOOST_GCC, < 40900) \
  412. ) && !BOOST_WORKAROUND(BOOST_GCC, >= 50000) && \
  413. !BOOST_WORKAROUND(BOOST_MSVC, < 1910)
  414. BOOST_MPL_ASSERT_NOT((_holds_maybe));
  415. #endif
  416. #endif
  417. return this->arg.get_value();
  418. }
  419. // Builds an overload set including operator[]s defined
  420. // in base classes.
  421. using Next::operator[];
  422. //
  423. // End of indexing support
  424. //
  425. // For parameter_requirements matching this node's key_type, return
  426. // a bool constant wrapper indicating whether the requirements are
  427. // satisfied by TaggedArg. Used only for compile-time computation
  428. // and never really called, so a declaration is enough.
  429. template <typename HasDefault, typename Predicate, typename ArgPack>
  430. static typename ::boost::lazy_enable_if<
  431. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  432. ::boost::mp11::mp_if<
  433. EmitsErrors
  434. , ::boost::mp11::mp_true
  435. , _has_unique_key
  436. >
  437. , ::boost::parameter::aux::augment_predicate_mp11<
  438. #else
  439. typename ::boost::mpl::if_<
  440. EmitsErrors
  441. , ::boost::mpl::true_
  442. , _has_unique_key
  443. >::type
  444. , ::boost::parameter::aux::augment_predicate<
  445. #endif
  446. Predicate
  447. , reference
  448. , key_type
  449. , value_type
  450. , ArgPack
  451. >
  452. >::type
  453. satisfies(
  454. ::boost::parameter::aux::parameter_requirements<
  455. key_type
  456. , Predicate
  457. , HasDefault
  458. >*
  459. , ArgPack*
  460. );
  461. // Builds an overload set including satisfies functions defined
  462. // in base classes.
  463. using Next::satisfies;
  464. // Comma operator to compose argument list without using parameters<>.
  465. // Useful for argument lists with undetermined length.
  466. template <typename KW, typename T2>
  467. inline BOOST_CONSTEXPR ::boost::parameter::aux::arg_list<
  468. ::boost::parameter::aux::tagged_argument<KW,T2>
  469. , self
  470. >
  471. operator,(
  472. ::boost::parameter::aux::tagged_argument<KW,T2> const& x
  473. ) const
  474. {
  475. return ::boost::parameter::aux::arg_list<
  476. ::boost::parameter::aux::tagged_argument<KW,T2>
  477. , self
  478. >(x, *this);
  479. }
  480. template <typename KW, typename T2>
  481. inline BOOST_CONSTEXPR ::boost::parameter::aux::arg_list<
  482. ::boost::parameter::aux::tagged_argument_rref<KW,T2>
  483. , self
  484. >
  485. operator,(
  486. ::boost::parameter::aux::tagged_argument_rref<KW,T2> const& x
  487. ) const
  488. {
  489. return ::boost::parameter::aux::arg_list<
  490. ::boost::parameter::aux::tagged_argument_rref<KW,T2>
  491. , self
  492. >(x, *this);
  493. }
  494. // MPL sequence support
  495. typedef self type; // Convenience for users
  496. typedef Next tail_type; // For the benefit of iterators
  497. // For dispatching to sequence intrinsics
  498. typedef ::boost::parameter::aux::arg_list_tag tag;
  499. };
  500. }}} // namespace boost::parameter::aux
  501. #else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
  502. #include <boost/preprocessor/repetition/enum_params.hpp>
  503. #include <boost/preprocessor/facilities/intercept.hpp>
  504. namespace boost { namespace parameter { namespace aux {
  505. // Terminates arg_list<> and represents an empty list. Since this is just
  506. // the terminating case, you might want to look at arg_list first to get a
  507. // feel for what's really happening here.
  508. struct empty_arg_list
  509. {
  510. inline BOOST_CONSTEXPR empty_arg_list()
  511. {
  512. }
  513. // Constructor taking BOOST_PARAMETER_COMPOSE_MAX_ARITY empty_arg_list
  514. // arguments; this makes initialization.
  515. inline BOOST_CONSTEXPR empty_arg_list(
  516. BOOST_PP_ENUM_PARAMS(
  517. BOOST_PARAMETER_COMPOSE_MAX_ARITY
  518. , ::boost::parameter::void_ BOOST_PP_INTERCEPT
  519. )
  520. )
  521. {
  522. }
  523. // A metafunction class that, given a keyword and a default type,
  524. // returns the appropriate result type for a keyword lookup given
  525. // that default.
  526. struct binding
  527. {
  528. template <typename KW, typename Default, typename Reference>
  529. struct apply
  530. {
  531. typedef Default type;
  532. };
  533. };
  534. // Terminator for has_key, indicating that the keyword is unique.
  535. template <typename KW>
  536. static ::boost::parameter::aux::no_tag has_key(KW*);
  537. #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
  538. // The overload set technique doesn't work with these older compilers,
  539. // so they need some explicit handholding.
  540. // A metafunction class that, given a keyword, returns the type of the
  541. // base sublist whose get() function can produce the value for that key.
  542. struct key_owner
  543. {
  544. template <typename KW>
  545. struct apply
  546. {
  547. typedef ::boost::parameter::aux::empty_arg_list type;
  548. };
  549. };
  550. #endif // Borland workarounds needed
  551. // If either of these operators are called, it means there is no
  552. // argument in the list that matches the supplied keyword. Just
  553. // return the default value.
  554. template <typename K, typename Default>
  555. inline BOOST_CONSTEXPR Default&
  556. operator[](::boost::parameter::aux::default_<K,Default> x) const
  557. {
  558. return x.value;
  559. }
  560. // If this operator is called, it means there is no argument in the
  561. // list that matches the supplied keyword. Just evaluate and return
  562. // the default value.
  563. template <typename K, typename F>
  564. inline BOOST_CONSTEXPR
  565. typename ::boost::parameter::aux::result_of0<F>::type
  566. operator[](BOOST_PARAMETER_lazy_default_fallback<K,F> x) const
  567. {
  568. return x.compute_default();
  569. }
  570. // No argument corresponding to ParameterRequirements::key_type
  571. // was found if we match this overload, so unless that parameter
  572. // has a default, we indicate that the actual arguments don't
  573. // match the function's requirements.
  574. template <typename ParameterRequirements, typename ArgPack>
  575. static typename ParameterRequirements::has_default
  576. satisfies(ParameterRequirements*, ArgPack*);
  577. // MPL sequence support
  578. typedef ::boost::parameter::aux::empty_arg_list type; // convenience
  579. // For dispatching to sequence intrinsics
  580. typedef ::boost::parameter::aux::arg_list_tag tag;
  581. };
  582. }}} // namespace boost::parameter::aux
  583. #include <boost/parameter/aux_/yesno.hpp>
  584. #include <boost/parameter/aux_/is_maybe.hpp>
  585. #include <boost/parameter/aux_/tagged_argument_fwd.hpp>
  586. #include <boost/parameter/aux_/parameter_requirements.hpp>
  587. #include <boost/parameter/aux_/augment_predicate.hpp>
  588. #include <boost/parameter/keyword_fwd.hpp>
  589. #include <boost/mpl/bool.hpp>
  590. #include <boost/mpl/if.hpp>
  591. #include <boost/mpl/eval_if.hpp>
  592. #include <boost/mpl/apply_wrap.hpp>
  593. #include <boost/mpl/assert.hpp>
  594. #include <boost/type_traits/is_same.hpp>
  595. #include <boost/preprocessor/repetition/enum_binary_params.hpp>
  596. #include <boost/preprocessor/repetition/enum_shifted_params.hpp>
  597. #if !defined(BOOST_NO_SFINAE) && !BOOST_WORKAROUND(BOOST_MSVC, < 1800)
  598. #include <boost/core/enable_if.hpp>
  599. #endif
  600. #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
  601. #include <boost/parameter/aux_/preprocessor/nullptr.hpp>
  602. #endif
  603. namespace boost { namespace parameter { namespace aux {
  604. // A tuple of tagged arguments, terminated with empty_arg_list. Every
  605. // TaggedArg is an instance of tagged_argument<>.
  606. template <
  607. typename TaggedArg
  608. , typename Next = ::boost::parameter::aux::empty_arg_list
  609. , typename EmitsErrors = ::boost::mpl::true_
  610. >
  611. class arg_list : public Next
  612. {
  613. typedef typename ::boost::parameter::aux
  614. ::is_maybe<typename TaggedArg::value_type>::type _holds_maybe;
  615. TaggedArg arg; // Stores the argument
  616. public:
  617. typedef TaggedArg tagged_arg;
  618. typedef ::boost::parameter::aux::arg_list<TaggedArg,Next> self;
  619. typedef typename TaggedArg::key_type key_type;
  620. typedef typename ::boost::mpl::eval_if<
  621. _holds_maybe
  622. , ::boost::parameter::aux
  623. ::get_reference<typename TaggedArg::value_type>
  624. , ::boost::parameter::aux::get_reference<TaggedArg>
  625. >::type reference;
  626. typedef typename ::boost::mpl::if_<
  627. _holds_maybe
  628. , reference
  629. , typename TaggedArg::value_type
  630. >::type value_type;
  631. // Create a new list by prepending arg to a copy of tail. Used when
  632. // incrementally building this structure with the comma operator.
  633. inline BOOST_CONSTEXPR arg_list(
  634. TaggedArg const& head
  635. , Next const& tail
  636. ) : Next(tail), arg(head)
  637. {
  638. }
  639. // Store the arguments in successive nodes of this list.
  640. template <
  641. // typename A0, typename A1, ...
  642. BOOST_PP_ENUM_PARAMS(
  643. BOOST_PARAMETER_COMPOSE_MAX_ARITY
  644. , typename A
  645. )
  646. >
  647. inline BOOST_CONSTEXPR arg_list(
  648. // A0& a0, A1& a1, ...
  649. BOOST_PP_ENUM_BINARY_PARAMS(
  650. BOOST_PARAMETER_COMPOSE_MAX_ARITY
  651. , A
  652. , & a
  653. )
  654. ) : Next(
  655. // a1, a2, ...
  656. BOOST_PP_ENUM_SHIFTED_PARAMS(
  657. BOOST_PARAMETER_COMPOSE_MAX_ARITY
  658. , a
  659. )
  660. , ::boost::parameter::aux::void_reference()
  661. )
  662. , arg(a0)
  663. {
  664. }
  665. // A metafunction class that, given a keyword and a default type,
  666. // returns the appropriate result type for a keyword lookup given
  667. // that default.
  668. struct binding
  669. {
  670. typedef typename Next::binding next_binding;
  671. template <typename KW, typename Default, typename Reference>
  672. struct apply
  673. {
  674. typedef typename ::boost::mpl::eval_if<
  675. ::boost::is_same<KW,key_type>
  676. , ::boost::mpl::if_<Reference,reference,value_type>
  677. , ::boost::mpl::apply_wrap3<
  678. next_binding
  679. , KW
  680. , Default
  681. , Reference
  682. >
  683. >::type type;
  684. };
  685. };
  686. #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
  687. // Overload for key_type, so the assert below will fire
  688. // if the same keyword is used again.
  689. static ::boost::parameter::aux::yes_tag has_key(key_type*);
  690. using Next::has_key;
  691. private:
  692. #if defined(BOOST_NO_SFINAE) || BOOST_WORKAROUND(BOOST_MSVC, < 1800)
  693. BOOST_MPL_ASSERT_MSG(
  694. sizeof(
  695. Next::has_key(
  696. static_cast<key_type*>(BOOST_PARAMETER_AUX_PP_NULLPTR)
  697. )
  698. ) == sizeof(::boost::parameter::aux::no_tag)
  699. , duplicate_keyword
  700. , (key_type)
  701. );
  702. #else
  703. typedef ::boost::mpl::bool_<
  704. sizeof(
  705. Next::has_key(
  706. static_cast<key_type*>(BOOST_PARAMETER_AUX_PP_NULLPTR)
  707. )
  708. ) == sizeof(::boost::parameter::aux::no_tag)
  709. > _has_unique_key;
  710. BOOST_MPL_ASSERT_MSG(
  711. !(EmitsErrors::value) || (_has_unique_key::value)
  712. , duplicate_keyword
  713. , (key_type)
  714. );
  715. #endif // SFINAE/MSVC workarounds needed
  716. #endif // Borland workarounds not needed
  717. private:
  718. //
  719. // Begin implementation of indexing operators
  720. // for looking up specific arguments by name.
  721. //
  722. // Helpers that handle the case when TaggedArg is empty<T>.
  723. template <typename D>
  724. inline BOOST_CONSTEXPR reference
  725. get_default(D const&, ::boost::mpl::false_) const
  726. {
  727. return this->arg.get_value();
  728. }
  729. template <typename D>
  730. inline BOOST_CONSTEXPR reference
  731. get_default(D const& d, ::boost::mpl::true_) const
  732. {
  733. return (
  734. this->arg.get_value()
  735. ? this->arg.get_value().get()
  736. : this->arg.get_value().construct(d.value)
  737. );
  738. }
  739. public:
  740. #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
  741. // These older compilers don't support the overload set creation
  742. // idiom well, so we need to do all the return type calculation
  743. // for the compiler and dispatch through an outer function template.
  744. // A metafunction class that, given a keyword, returns the base
  745. // sublist whose get() function can produce the value for that key.
  746. struct key_owner
  747. {
  748. typedef typename Next::key_owner next_key_owner;
  749. template <typename KW>
  750. struct apply
  751. {
  752. typedef typename ::boost::mpl::eval_if<
  753. ::boost::is_same<KW,key_type>
  754. , ::boost::mpl::identity<
  755. ::boost::parameter::aux::arg_list<TaggedArg,Next>
  756. >
  757. , ::boost::mpl::apply_wrap1<next_key_owner,KW>
  758. >::type type;
  759. };
  760. };
  761. // Outer indexing operators that dispatch to the right node's
  762. // get() function.
  763. template <typename KW>
  764. inline BOOST_CONSTEXPR typename ::boost::mpl::apply_wrap3<
  765. binding
  766. , KW
  767. , ::boost::parameter::void_
  768. , ::boost::mpl::true_
  769. >::type
  770. operator[](::boost::parameter::keyword<KW> const& x) const
  771. {
  772. typename ::boost::mpl::apply_wrap1<key_owner,KW>::type const&
  773. sublist = *this;
  774. return sublist.get(x);
  775. }
  776. template <typename KW, typename Default>
  777. inline BOOST_CONSTEXPR typename ::boost::mpl::apply_wrap3<
  778. binding
  779. , KW
  780. , Default&
  781. , ::boost::mpl::true_
  782. >::type
  783. operator[](
  784. ::boost::parameter::aux::default_<KW,Default> const& x
  785. ) const
  786. {
  787. typename ::boost::mpl::apply_wrap1<key_owner,KW>::type const&
  788. sublist = *this;
  789. return sublist.get(x);
  790. }
  791. template <typename KW, typename F>
  792. inline BOOST_CONSTEXPR typename ::boost::mpl::apply_wrap3<
  793. binding
  794. , KW
  795. , typename ::boost::parameter::aux::result_of0<F>::type
  796. , ::boost::mpl::true_
  797. >::type
  798. operator[](
  799. BOOST_PARAMETER_lazy_default_fallback<KW,F> const& x
  800. ) const
  801. {
  802. typename ::boost::mpl::apply_wrap1<key_owner,KW>::type const&
  803. sublist = *this;
  804. return sublist.get(x);
  805. }
  806. // These just return the stored value; when empty_arg_list is reached,
  807. // indicating no matching argument was passed, the default is
  808. // returned, or if no default_ or lazy_default was passed, compilation
  809. // fails.
  810. inline BOOST_CONSTEXPR reference
  811. get(::boost::parameter::keyword<key_type> const&) const
  812. {
  813. BOOST_MPL_ASSERT_NOT((_holds_maybe));
  814. return this->arg.get_value();
  815. }
  816. template <typename Default>
  817. inline BOOST_CONSTEXPR reference
  818. get(
  819. ::boost::parameter::aux::default_<key_type,Default> const& d
  820. ) const
  821. {
  822. return this->get_default(d, _holds_maybe());
  823. }
  824. template <typename Default>
  825. inline BOOST_CONSTEXPR reference
  826. get(
  827. BOOST_PARAMETER_lazy_default_fallback<key_type,Default> const&
  828. ) const
  829. {
  830. return this->arg.get_value();
  831. }
  832. #else // !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
  833. inline BOOST_CONSTEXPR reference
  834. operator[](::boost::parameter::keyword<key_type> const&) const
  835. {
  836. BOOST_MPL_ASSERT_NOT((_holds_maybe));
  837. return this->arg.get_value();
  838. }
  839. template <typename Default>
  840. inline BOOST_CONSTEXPR reference
  841. operator[](
  842. ::boost::parameter::aux::default_<key_type,Default> const& d
  843. ) const
  844. {
  845. return this->get_default(d, _holds_maybe());
  846. }
  847. template <typename Default>
  848. inline BOOST_CONSTEXPR reference
  849. operator[](
  850. BOOST_PARAMETER_lazy_default_fallback<key_type,Default> const&
  851. ) const
  852. {
  853. BOOST_MPL_ASSERT_NOT((_holds_maybe));
  854. return this->arg.get_value();
  855. }
  856. // Builds an overload set including operator[]s defined
  857. // in base classes.
  858. using Next::operator[];
  859. //
  860. // End of indexing support
  861. //
  862. // For parameter_requirements matching this node's key_type, return
  863. // a bool constant wrapper indicating whether the requirements are
  864. // satisfied by TaggedArg. Used only for compile-time computation
  865. // and never really called, so a declaration is enough.
  866. template <typename HasDefault, typename Predicate, typename ArgPack>
  867. static typename
  868. #if !defined(BOOST_NO_SFINAE) && !BOOST_WORKAROUND(BOOST_MSVC, < 1800)
  869. ::boost::lazy_enable_if<
  870. typename ::boost::mpl::if_<
  871. EmitsErrors
  872. , ::boost::mpl::true_
  873. , _has_unique_key
  874. >::type,
  875. #endif
  876. ::boost::parameter::aux::augment_predicate<
  877. Predicate
  878. , reference
  879. , key_type
  880. , value_type
  881. , ArgPack
  882. #if !defined(BOOST_NO_SFINAE) && !BOOST_WORKAROUND(BOOST_MSVC, < 1800)
  883. >
  884. #endif
  885. >::type
  886. satisfies(
  887. ::boost::parameter::aux::parameter_requirements<
  888. key_type
  889. , Predicate
  890. , HasDefault
  891. >*
  892. , ArgPack*
  893. );
  894. // Builds an overload set including satisfies functions defined
  895. // in base classes.
  896. using Next::satisfies;
  897. #endif // Borland workarounds needed
  898. // Comma operator to compose argument list without using parameters<>.
  899. // Useful for argument lists with undetermined length.
  900. template <typename KW, typename T2>
  901. inline BOOST_CONSTEXPR ::boost::parameter::aux::arg_list<
  902. ::boost::parameter::aux::tagged_argument<KW,T2>
  903. , self
  904. >
  905. operator,(
  906. ::boost::parameter::aux::tagged_argument<KW,T2> const& x
  907. ) const
  908. {
  909. return ::boost::parameter::aux::arg_list<
  910. ::boost::parameter::aux::tagged_argument<KW,T2>
  911. , self
  912. >(x, *this);
  913. }
  914. // MPL sequence support
  915. typedef self type; // Convenience for users
  916. typedef Next tail_type; // For the benefit of iterators
  917. // For dispatching to sequence intrinsics
  918. typedef ::boost::parameter::aux::arg_list_tag tag;
  919. };
  920. }}} // namespace boost::parameter::aux
  921. #endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING
  922. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  923. namespace boost { namespace parameter { namespace aux {
  924. template <typename ...ArgTuples>
  925. struct arg_list_cons;
  926. template <>
  927. struct arg_list_cons<>
  928. {
  929. using type = ::boost::parameter::aux::empty_arg_list;
  930. };
  931. template <typename ArgTuple0, typename ...Tuples>
  932. struct arg_list_cons<ArgTuple0,Tuples...>
  933. {
  934. using type = ::boost::parameter::aux::arg_list<
  935. typename ArgTuple0::tagged_arg
  936. , typename ::boost::parameter::aux::arg_list_cons<Tuples...>::type
  937. , typename ArgTuple0::emits_errors
  938. >;
  939. };
  940. template <
  941. typename Keyword
  942. , typename TaggedArg
  943. , typename EmitsErrors = ::boost::mp11::mp_true
  944. >
  945. struct flat_like_arg_tuple
  946. {
  947. using tagged_arg = TaggedArg;
  948. using emits_errors = EmitsErrors;
  949. };
  950. template <typename ...ArgTuples>
  951. class flat_like_arg_list
  952. : public ::boost::parameter::aux::arg_list_cons<ArgTuples...>::type
  953. {
  954. using _base_type = typename ::boost::parameter::aux
  955. ::arg_list_cons<ArgTuples...>::type;
  956. public:
  957. inline BOOST_CONSTEXPR flat_like_arg_list(
  958. typename _base_type::tagged_arg const& head
  959. , typename _base_type::tail_type const& tail
  960. ) : _base_type(head, tail)
  961. {
  962. }
  963. template <typename ...Args>
  964. inline BOOST_CONSTEXPR flat_like_arg_list(Args&&... args)
  965. : _base_type(::std::forward<Args>(args)...)
  966. {
  967. }
  968. using _base_type::operator[];
  969. using _base_type::satisfies;
  970. // Comma operator to compose argument list without using parameters<>.
  971. // Useful for argument lists with undetermined length.
  972. template <typename TaggedArg>
  973. inline BOOST_CONSTEXPR ::boost::parameter::aux::flat_like_arg_list<
  974. ::boost::parameter::aux::flat_like_arg_tuple<
  975. typename TaggedArg::base_type::key_type
  976. , typename TaggedArg::base_type
  977. >
  978. , ArgTuples...
  979. >
  980. operator,(TaggedArg const& x) const
  981. {
  982. return ::boost::parameter::aux::flat_like_arg_list<
  983. ::boost::parameter::aux::flat_like_arg_tuple<
  984. typename TaggedArg::base_type::key_type
  985. , typename TaggedArg::base_type
  986. >
  987. , ArgTuples...
  988. >(
  989. static_cast<typename TaggedArg::base_type const&>(x)
  990. , static_cast<_base_type const&>(*this)
  991. );
  992. }
  993. };
  994. template <>
  995. class flat_like_arg_list<>
  996. : public ::boost::parameter::aux::empty_arg_list
  997. {
  998. using _base_type = ::boost::parameter::aux::empty_arg_list;
  999. public:
  1000. template <typename ...Args>
  1001. inline BOOST_CONSTEXPR flat_like_arg_list(Args&&... args)
  1002. : _base_type(::std::forward<Args>(args)...)
  1003. {
  1004. }
  1005. using _base_type::operator[];
  1006. using _base_type::satisfies;
  1007. // Comma operator to compose argument list without using parameters<>.
  1008. // Useful for argument lists with undetermined length.
  1009. template <typename TaggedArg>
  1010. inline BOOST_CONSTEXPR ::boost::parameter::aux::flat_like_arg_list<
  1011. ::boost::parameter::aux::flat_like_arg_tuple<
  1012. typename TaggedArg::base_type::key_type
  1013. , typename TaggedArg::base_type
  1014. >
  1015. >
  1016. operator,(TaggedArg const& x) const
  1017. {
  1018. return ::boost::parameter::aux::flat_like_arg_list<
  1019. ::boost::parameter::aux::flat_like_arg_tuple<
  1020. typename TaggedArg::base_type::key_type
  1021. , typename TaggedArg::base_type
  1022. >
  1023. >(
  1024. static_cast<typename TaggedArg::base_type const&>(x)
  1025. , static_cast<_base_type const&>(*this)
  1026. );
  1027. }
  1028. };
  1029. }}} // namespace boost::parameter::aux
  1030. #endif // BOOST_PARAMETER_CAN_USE_MP11
  1031. #include <boost/mpl/iterator_tags.hpp>
  1032. namespace boost { namespace parameter { namespace aux {
  1033. // MPL sequence support
  1034. template <typename ArgumentPack>
  1035. struct arg_list_iterator
  1036. {
  1037. typedef ::boost::mpl::forward_iterator_tag category;
  1038. // The incremented iterator
  1039. typedef ::boost::parameter::aux
  1040. ::arg_list_iterator<typename ArgumentPack::tail_type> next;
  1041. // dereferencing yields the key type
  1042. typedef typename ArgumentPack::key_type type;
  1043. };
  1044. template <>
  1045. struct arg_list_iterator< ::boost::parameter::aux::empty_arg_list>
  1046. {
  1047. };
  1048. }}} // namespace boost::parameter::aux
  1049. #include <boost/mpl/begin_end_fwd.hpp>
  1050. // MPL sequence support
  1051. namespace boost { namespace mpl {
  1052. template <>
  1053. struct begin_impl< ::boost::parameter::aux::arg_list_tag>
  1054. {
  1055. template <typename S>
  1056. struct apply
  1057. {
  1058. typedef ::boost::parameter::aux::arg_list_iterator<S> type;
  1059. };
  1060. };
  1061. template <>
  1062. struct end_impl< ::boost::parameter::aux::arg_list_tag>
  1063. {
  1064. template <typename>
  1065. struct apply
  1066. {
  1067. typedef ::boost::parameter::aux::arg_list_iterator<
  1068. ::boost::parameter::aux::empty_arg_list
  1069. > type;
  1070. };
  1071. };
  1072. }} // namespace boost::mpl
  1073. #include <boost/parameter/value_type.hpp>
  1074. #include <boost/mpl/has_key_fwd.hpp>
  1075. #include <boost/type_traits/is_void.hpp>
  1076. namespace boost { namespace mpl {
  1077. template <>
  1078. struct has_key_impl< ::boost::parameter::aux::arg_list_tag>
  1079. {
  1080. template <typename ArgList, typename Keyword>
  1081. struct apply
  1082. {
  1083. typedef typename ::boost::mpl::if_<
  1084. ::boost::is_void<
  1085. typename ::boost::parameter
  1086. ::value_type<ArgList,Keyword,void>::type
  1087. >
  1088. , ::boost::mpl::false_
  1089. , ::boost::mpl::true_
  1090. >::type type;
  1091. };
  1092. };
  1093. }} // namespace boost::mpl
  1094. #include <boost/mpl/count_fwd.hpp>
  1095. #include <boost/mpl/int.hpp>
  1096. namespace boost { namespace mpl {
  1097. template <>
  1098. struct count_impl< ::boost::parameter::aux::arg_list_tag>
  1099. {
  1100. template <typename ArgList, typename Keyword>
  1101. struct apply
  1102. {
  1103. typedef typename ::boost::mpl::if_<
  1104. ::boost::is_void<
  1105. typename ::boost::parameter
  1106. ::value_type<ArgList,Keyword,void>::type
  1107. >
  1108. , ::boost::mpl::int_<0>
  1109. , ::boost::mpl::int_<1>
  1110. >::type type;
  1111. };
  1112. };
  1113. }} // namespace boost::mpl
  1114. #include <boost/mpl/key_type_fwd.hpp>
  1115. #include <boost/mpl/identity.hpp>
  1116. namespace boost { namespace mpl {
  1117. template <>
  1118. struct key_type_impl< ::boost::parameter::aux::arg_list_tag>
  1119. {
  1120. template <typename ArgList, typename Keyword>
  1121. struct apply
  1122. {
  1123. typedef typename ::boost::mpl::eval_if<
  1124. ::boost::is_void<
  1125. typename ::boost::parameter
  1126. ::value_type<ArgList,Keyword,void>::type
  1127. >
  1128. , void
  1129. , ::boost::mpl::identity<Keyword>
  1130. >::type type;
  1131. };
  1132. };
  1133. }} // namespace boost::mpl
  1134. #include <boost/mpl/value_type_fwd.hpp>
  1135. namespace boost { namespace mpl {
  1136. template <>
  1137. struct value_type_impl< ::boost::parameter::aux::arg_list_tag>
  1138. : ::boost::mpl::key_type_impl< ::boost::parameter::aux::arg_list_tag>
  1139. {
  1140. };
  1141. }} // namespace boost::mpl
  1142. #include <boost/mpl/at_fwd.hpp>
  1143. namespace boost { namespace mpl {
  1144. template <>
  1145. struct at_impl< ::boost::parameter::aux::arg_list_tag>
  1146. : ::boost::mpl::key_type_impl< ::boost::parameter::aux::arg_list_tag>
  1147. {
  1148. };
  1149. }} // namespace boost::mpl
  1150. #include <boost/mpl/order_fwd.hpp>
  1151. #include <boost/mpl/void.hpp>
  1152. #include <boost/mpl/find.hpp>
  1153. #include <boost/mpl/distance.hpp>
  1154. namespace boost { namespace mpl {
  1155. template <>
  1156. struct order_impl< ::boost::parameter::aux::arg_list_tag>
  1157. {
  1158. template <typename ArgList, typename Keyword>
  1159. struct apply
  1160. {
  1161. typedef typename ::boost::mpl::find<ArgList,Keyword>::type Itr;
  1162. typedef typename ::boost::mpl::eval_if<
  1163. ::boost::is_void<
  1164. typename ::boost::parameter
  1165. ::value_type<ArgList,Keyword,void>::type
  1166. >
  1167. , ::boost::mpl::identity< ::boost::mpl::void_>
  1168. , ::boost::mpl::distance<
  1169. Itr
  1170. , ::boost::parameter::aux::arg_list_iterator<
  1171. ::boost::parameter::aux::empty_arg_list
  1172. >
  1173. >
  1174. >::type type;
  1175. };
  1176. };
  1177. }} // namespace boost::mpl
  1178. #endif // include guard