keyword.hpp 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  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 BOOST_PARAMETER_KEYWORD_HPP
  7. #define BOOST_PARAMETER_KEYWORD_HPP
  8. #include <boost/parameter/aux_/tag.hpp>
  9. #include <boost/parameter/aux_/default.hpp>
  10. #include <boost/parameter/keyword_fwd.hpp>
  11. #include <boost/parameter/config.hpp>
  12. #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
  13. #include <boost/core/enable_if.hpp>
  14. #include <utility>
  15. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  16. #include <boost/mp11/integral.hpp>
  17. #include <boost/mp11/utility.hpp>
  18. #include <type_traits>
  19. #else
  20. #include <boost/mpl/bool.hpp>
  21. #include <boost/mpl/if.hpp>
  22. #include <boost/mpl/eval_if.hpp>
  23. #include <boost/type_traits/is_same.hpp>
  24. #include <boost/type_traits/is_scalar.hpp>
  25. #include <boost/type_traits/is_const.hpp>
  26. #endif
  27. namespace boost { namespace parameter {
  28. // Instances of unique specializations of keyword<...> serve to
  29. // associate arguments with parameter names. For example:
  30. //
  31. // struct rate_; // parameter names
  32. // struct skew_;
  33. //
  34. // namespace
  35. // {
  36. // keyword<rate_> rate; // keywords
  37. // keyword<skew_> skew;
  38. // }
  39. //
  40. // ...
  41. //
  42. // f(rate = 1, skew = 2.4);
  43. template <typename Tag>
  44. struct keyword
  45. {
  46. typedef Tag tag;
  47. inline BOOST_CONSTEXPR keyword()
  48. {
  49. }
  50. template <typename T>
  51. inline BOOST_CONSTEXPR typename ::boost::lazy_enable_if<
  52. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  53. ::boost::mp11::mp_if<
  54. ::std::is_scalar<T>
  55. , ::boost::mp11::mp_true
  56. , ::boost::mp11::mp_if<
  57. ::std::is_same<
  58. typename Tag::qualifier
  59. , ::boost::parameter::in_reference
  60. >
  61. , ::boost::mp11::mp_true
  62. , ::std::is_same<
  63. typename Tag::qualifier
  64. , ::boost::parameter::forward_reference
  65. >
  66. >
  67. >
  68. #else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
  69. typename ::boost::mpl::eval_if<
  70. ::boost::is_scalar<T>
  71. , ::boost::mpl::true_
  72. , ::boost::mpl::eval_if<
  73. ::boost::is_same<
  74. typename Tag::qualifier
  75. , ::boost::parameter::in_reference
  76. >
  77. , ::boost::mpl::true_
  78. , ::boost::mpl::if_<
  79. ::boost::is_same<
  80. typename Tag::qualifier
  81. , ::boost::parameter::forward_reference
  82. >
  83. , ::boost::mpl::true_
  84. , ::boost::mpl::false_
  85. >
  86. >
  87. >::type
  88. #endif // BOOST_PARAMETER_CAN_USE_MP11
  89. , ::boost::parameter::aux::tag<Tag,T const&>
  90. >::type
  91. operator=(T const& x) const
  92. {
  93. typedef typename ::boost::parameter::aux
  94. ::tag<Tag,T const&>::type result;
  95. return result(x);
  96. }
  97. template <typename Default>
  98. inline BOOST_CONSTEXPR typename ::boost::enable_if<
  99. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  100. ::boost::mp11::mp_if<
  101. ::std::is_scalar<Default>
  102. , ::boost::mp11::mp_true
  103. , ::boost::mp11::mp_if<
  104. ::std::is_same<
  105. typename Tag::qualifier
  106. , ::boost::parameter::in_reference
  107. >
  108. , ::boost::mp11::mp_true
  109. , ::std::is_same<
  110. typename Tag::qualifier
  111. , ::boost::parameter::forward_reference
  112. >
  113. >
  114. >
  115. #else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
  116. typename ::boost::mpl::eval_if<
  117. ::boost::is_scalar<Default>
  118. , ::boost::mpl::true_
  119. , ::boost::mpl::eval_if<
  120. ::boost::is_same<
  121. typename Tag::qualifier
  122. , ::boost::parameter::in_reference
  123. >
  124. , ::boost::mpl::true_
  125. , ::boost::mpl::if_<
  126. ::boost::is_same<
  127. typename Tag::qualifier
  128. , ::boost::parameter::forward_reference
  129. >
  130. , ::boost::mpl::true_
  131. , ::boost::mpl::false_
  132. >
  133. >
  134. >::type
  135. #endif // BOOST_PARAMETER_CAN_USE_MP11
  136. , ::boost::parameter::aux::default_<Tag,Default const>
  137. >::type
  138. operator|(Default const& d) const
  139. {
  140. return ::boost::parameter::aux::default_<Tag,Default const>(d);
  141. }
  142. template <typename T>
  143. inline BOOST_CONSTEXPR typename ::boost::lazy_enable_if<
  144. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  145. ::boost::mp11::mp_if<
  146. ::boost::mp11::mp_if<
  147. ::std::is_same<
  148. typename Tag::qualifier
  149. , ::boost::parameter::out_reference
  150. >
  151. , ::boost::mp11::mp_true
  152. , ::std::is_same<
  153. typename Tag::qualifier
  154. , ::boost::parameter::forward_reference
  155. >
  156. >
  157. , ::boost::mp11::mp_if<
  158. ::std::is_const<T>
  159. , ::boost::mp11::mp_false
  160. , ::boost::mp11::mp_true
  161. >
  162. , ::boost::mp11::mp_false
  163. >
  164. #else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
  165. typename ::boost::mpl::eval_if<
  166. typename ::boost::mpl::if_<
  167. ::boost::is_same<
  168. typename Tag::qualifier
  169. , ::boost::parameter::out_reference
  170. >
  171. , ::boost::mpl::true_
  172. , ::boost::is_same<
  173. typename Tag::qualifier
  174. , ::boost::parameter::forward_reference
  175. >
  176. >::type
  177. , ::boost::mpl::if_<
  178. ::boost::is_const<T>
  179. , ::boost::mpl::false_
  180. , ::boost::mpl::true_
  181. >
  182. , ::boost::mpl::false_
  183. >::type
  184. #endif // BOOST_PARAMETER_CAN_USE_MP11
  185. , ::boost::parameter::aux::tag<Tag,T&>
  186. >::type
  187. operator=(T& x) const
  188. {
  189. typedef typename ::boost::parameter::aux
  190. ::tag<Tag,T&>::type result;
  191. return result(x);
  192. }
  193. template <typename Default>
  194. inline BOOST_CONSTEXPR typename ::boost::enable_if<
  195. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  196. ::boost::mp11::mp_if<
  197. ::boost::mp11::mp_if<
  198. ::std::is_same<
  199. typename Tag::qualifier
  200. , ::boost::parameter::out_reference
  201. >
  202. , ::boost::mp11::mp_true
  203. , ::std::is_same<
  204. typename Tag::qualifier
  205. , ::boost::parameter::forward_reference
  206. >
  207. >
  208. , ::boost::mp11::mp_if<
  209. ::std::is_const<Default>
  210. , ::boost::mp11::mp_false
  211. , ::boost::mp11::mp_true
  212. >
  213. , ::boost::mp11::mp_false
  214. >
  215. #else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
  216. typename ::boost::mpl::eval_if<
  217. typename ::boost::mpl::if_<
  218. ::boost::is_same<
  219. typename Tag::qualifier
  220. , ::boost::parameter::out_reference
  221. >
  222. , ::boost::mpl::true_
  223. , ::boost::is_same<
  224. typename Tag::qualifier
  225. , ::boost::parameter::forward_reference
  226. >
  227. >::type
  228. , ::boost::mpl::if_<
  229. ::boost::is_const<Default>
  230. , ::boost::mpl::false_
  231. , ::boost::mpl::true_
  232. >
  233. , ::boost::mpl::false_
  234. >::type
  235. #endif // BOOST_PARAMETER_CAN_USE_MP11
  236. , ::boost::parameter::aux::default_<Tag,Default>
  237. >::type
  238. operator|(Default& d) const
  239. {
  240. return ::boost::parameter::aux::default_<Tag,Default>(d);
  241. }
  242. template <typename Default>
  243. inline BOOST_CONSTEXPR
  244. ::boost::parameter::aux::lazy_default<Tag,Default const>
  245. operator||(Default const& d) const
  246. {
  247. return ::boost::parameter::aux
  248. ::lazy_default<Tag,Default const>(d);
  249. }
  250. template <typename Default>
  251. inline BOOST_CONSTEXPR
  252. ::boost::parameter::aux::lazy_default<Tag,Default>
  253. operator||(Default& d) const
  254. {
  255. return ::boost::parameter::aux::lazy_default<Tag,Default>(d);
  256. }
  257. template <typename T>
  258. inline BOOST_CONSTEXPR typename ::boost::lazy_enable_if<
  259. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  260. ::boost::mp11::mp_if<
  261. ::std::is_scalar<T>
  262. , ::boost::mp11::mp_false
  263. , ::boost::mp11::mp_if<
  264. ::std::is_same<
  265. typename Tag::qualifier
  266. , ::boost::parameter::in_reference
  267. >
  268. , ::boost::mp11::mp_true
  269. , ::std::is_same<
  270. typename Tag::qualifier
  271. , ::boost::parameter::forward_reference
  272. >
  273. >
  274. >
  275. #else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
  276. typename ::boost::mpl::eval_if<
  277. ::boost::is_scalar<T>
  278. , ::boost::mpl::false_
  279. , ::boost::mpl::eval_if<
  280. ::boost::is_same<
  281. typename Tag::qualifier
  282. , ::boost::parameter::in_reference
  283. >
  284. , ::boost::mpl::true_
  285. , ::boost::mpl::if_<
  286. ::boost::is_same<
  287. typename Tag::qualifier
  288. , ::boost::parameter::forward_reference
  289. >
  290. , ::boost::mpl::true_
  291. , ::boost::mpl::false_
  292. >
  293. >
  294. >::type
  295. #endif // BOOST_PARAMETER_CAN_USE_MP11
  296. , ::boost::parameter::aux::tag<Tag,T const>
  297. >::type
  298. operator=(T const&& x) const
  299. {
  300. typedef typename ::boost::parameter::aux
  301. ::tag<Tag,T const>::type result;
  302. return result(::std::forward<T const>(x));
  303. }
  304. template <typename T>
  305. inline BOOST_CONSTEXPR typename ::boost::lazy_enable_if<
  306. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  307. ::boost::mp11::mp_if<
  308. ::std::is_scalar<T>
  309. , ::boost::mp11::mp_false
  310. , ::boost::mp11::mp_if<
  311. ::std::is_same<
  312. typename Tag::qualifier
  313. , ::boost::parameter::consume_reference
  314. >
  315. , ::boost::mp11::mp_true
  316. , ::std::is_same<
  317. typename Tag::qualifier
  318. , ::boost::parameter::forward_reference
  319. >
  320. >
  321. >
  322. #else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
  323. typename ::boost::mpl::eval_if<
  324. ::boost::is_scalar<T>
  325. , ::boost::mpl::false_
  326. , ::boost::mpl::eval_if<
  327. ::boost::is_same<
  328. typename Tag::qualifier
  329. , ::boost::parameter::consume_reference
  330. >
  331. , ::boost::mpl::true_
  332. , ::boost::mpl::if_<
  333. ::boost::is_same<
  334. typename Tag::qualifier
  335. , ::boost::parameter::forward_reference
  336. >
  337. , ::boost::mpl::true_
  338. , ::boost::mpl::false_
  339. >
  340. >
  341. >::type
  342. #endif // BOOST_PARAMETER_CAN_USE_MP11
  343. , ::boost::parameter::aux::tag<Tag,T>
  344. >::type
  345. operator=(T&& x) const
  346. {
  347. typedef typename ::boost::parameter::aux::tag<Tag,T>::type result;
  348. return result(::std::forward<T>(x));
  349. }
  350. template <typename Default>
  351. inline BOOST_CONSTEXPR typename ::boost::enable_if<
  352. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  353. ::boost::mp11::mp_if<
  354. ::std::is_scalar<Default>
  355. , ::boost::mp11::mp_false
  356. , ::boost::mp11::mp_if<
  357. ::std::is_same<
  358. typename Tag::qualifier
  359. , ::boost::parameter::in_reference
  360. >
  361. , ::boost::mp11::mp_true
  362. , ::std::is_same<
  363. typename Tag::qualifier
  364. , ::boost::parameter::forward_reference
  365. >
  366. >
  367. >
  368. #else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
  369. typename ::boost::mpl::eval_if<
  370. ::boost::is_scalar<Default>
  371. , ::boost::mpl::false_
  372. , ::boost::mpl::eval_if<
  373. ::boost::is_same<
  374. typename Tag::qualifier
  375. , ::boost::parameter::in_reference
  376. >
  377. , ::boost::mpl::true_
  378. , ::boost::mpl::if_<
  379. ::boost::is_same<
  380. typename Tag::qualifier
  381. , ::boost::parameter::forward_reference
  382. >
  383. , ::boost::mpl::true_
  384. , ::boost::mpl::false_
  385. >
  386. >
  387. >::type
  388. #endif // BOOST_PARAMETER_CAN_USE_MP11
  389. , ::boost::parameter::aux::default_r_<Tag,Default const>
  390. >::type
  391. operator|(Default const&& d) const
  392. {
  393. return ::boost::parameter::aux::default_r_<Tag,Default const>(
  394. ::std::forward<Default const>(d)
  395. );
  396. }
  397. template <typename Default>
  398. inline BOOST_CONSTEXPR typename ::boost::enable_if<
  399. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  400. ::boost::mp11::mp_if<
  401. ::std::is_scalar<Default>
  402. , ::boost::mp11::mp_false
  403. , ::boost::mp11::mp_if<
  404. ::std::is_same<
  405. typename Tag::qualifier
  406. , ::boost::parameter::consume_reference
  407. >
  408. , ::boost::mp11::mp_true
  409. , ::std::is_same<
  410. typename Tag::qualifier
  411. , ::boost::parameter::forward_reference
  412. >
  413. >
  414. >
  415. #else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
  416. typename ::boost::mpl::eval_if<
  417. ::boost::is_scalar<Default>
  418. , ::boost::mpl::false_
  419. , ::boost::mpl::eval_if<
  420. ::boost::is_same<
  421. typename Tag::qualifier
  422. , ::boost::parameter::consume_reference
  423. >
  424. , ::boost::mpl::true_
  425. , ::boost::mpl::if_<
  426. ::boost::is_same<
  427. typename Tag::qualifier
  428. , ::boost::parameter::forward_reference
  429. >
  430. , ::boost::mpl::true_
  431. , ::boost::mpl::false_
  432. >
  433. >
  434. >::type
  435. #endif // BOOST_PARAMETER_CAN_USE_MP11
  436. , ::boost::parameter::aux::default_r_<Tag,Default>
  437. >::type
  438. operator|(Default&& d) const
  439. {
  440. return ::boost::parameter::aux
  441. ::default_r_<Tag,Default>(::std::forward<Default>(d));
  442. }
  443. public: // Insurance against ODR violations
  444. // Users will need to define their keywords in header files. To
  445. // prevent ODR violations, it's important that the keyword used in
  446. // every instantiation of a function template is the same object.
  447. // We provide a reference to a common instance of each keyword
  448. // object and prevent construction by users.
  449. static ::boost::parameter::keyword<Tag> const instance;
  450. // This interface is deprecated.
  451. static ::boost::parameter::keyword<Tag>& get()
  452. {
  453. return const_cast< ::boost::parameter::keyword<Tag>&>(instance);
  454. }
  455. };
  456. template <typename Tag>
  457. ::boost::parameter::keyword<Tag> const ::boost::parameter
  458. ::keyword<Tag>::instance = ::boost::parameter::keyword<Tag>();
  459. }} // namespace boost::parameter
  460. #else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
  461. #if !defined(BOOST_NO_SFINAE)
  462. #include <boost/mpl/bool.hpp>
  463. #include <boost/mpl/if.hpp>
  464. #include <boost/mpl/eval_if.hpp>
  465. #include <boost/core/enable_if.hpp>
  466. #include <boost/type_traits/is_same.hpp>
  467. #include <boost/type_traits/is_scalar.hpp>
  468. #include <boost/type_traits/is_const.hpp>
  469. #endif // BOOST_NO_SFINAE
  470. namespace boost { namespace parameter {
  471. // Instances of unique specializations of keyword<...> serve to
  472. // associate arguments with parameter names. For example:
  473. //
  474. // struct rate_; // parameter names
  475. // struct skew_;
  476. //
  477. // namespace
  478. // {
  479. // keyword<rate_> rate; // keywords
  480. // keyword<skew_> skew;
  481. // }
  482. //
  483. // ...
  484. //
  485. // f(rate = 1, skew = 2.4);
  486. template <typename Tag>
  487. struct keyword
  488. {
  489. typedef Tag tag;
  490. inline BOOST_CONSTEXPR keyword()
  491. {
  492. }
  493. template <typename T>
  494. #if defined(BOOST_NO_SFINAE)
  495. inline typename ::boost::parameter::aux::tag<Tag,T const&>::type
  496. #else
  497. inline BOOST_CONSTEXPR typename ::boost::lazy_enable_if<
  498. typename ::boost::mpl::eval_if<
  499. ::boost::is_scalar<T>
  500. , ::boost::mpl::true_
  501. , ::boost::mpl::eval_if<
  502. ::boost::is_same<
  503. typename Tag::qualifier
  504. , ::boost::parameter::in_reference
  505. >
  506. , ::boost::mpl::true_
  507. , ::boost::mpl::if_<
  508. ::boost::is_same<
  509. typename Tag::qualifier
  510. , ::boost::parameter::forward_reference
  511. >
  512. , ::boost::mpl::true_
  513. , ::boost::mpl::false_
  514. >
  515. >
  516. >::type
  517. , ::boost::parameter::aux::tag<Tag,T const&>
  518. >::type
  519. #endif // BOOST_NO_SFINAE
  520. operator=(T const& x) const
  521. {
  522. typedef typename ::boost::parameter::aux
  523. ::tag<Tag,T const&>::type result;
  524. return result(x);
  525. }
  526. template <typename Default>
  527. #if defined(BOOST_NO_SFINAE)
  528. inline ::boost::parameter::aux::default_<Tag,Default const>
  529. #else
  530. inline BOOST_CONSTEXPR typename ::boost::enable_if<
  531. typename ::boost::mpl::eval_if<
  532. ::boost::is_scalar<Default>
  533. , ::boost::mpl::true_
  534. , ::boost::mpl::eval_if<
  535. ::boost::is_same<
  536. typename Tag::qualifier
  537. , ::boost::parameter::in_reference
  538. >
  539. , ::boost::mpl::true_
  540. , ::boost::mpl::if_<
  541. ::boost::is_same<
  542. typename Tag::qualifier
  543. , ::boost::parameter::forward_reference
  544. >
  545. , ::boost::mpl::true_
  546. , ::boost::mpl::false_
  547. >
  548. >
  549. >::type
  550. , ::boost::parameter::aux::default_<Tag,Default const>
  551. >::type
  552. #endif // BOOST_NO_SFINAE
  553. operator|(Default const& d) const
  554. {
  555. return ::boost::parameter::aux::default_<Tag,Default const>(d);
  556. }
  557. template <typename T>
  558. #if defined(BOOST_NO_SFINAE)
  559. inline typename ::boost::parameter::aux::tag<Tag,T&>::type
  560. #else
  561. inline BOOST_CONSTEXPR typename ::boost::lazy_enable_if<
  562. typename ::boost::mpl::eval_if<
  563. typename ::boost::mpl::if_<
  564. ::boost::is_same<
  565. typename Tag::qualifier
  566. , ::boost::parameter::out_reference
  567. >
  568. , ::boost::mpl::true_
  569. , ::boost::is_same<
  570. typename Tag::qualifier
  571. , ::boost::parameter::forward_reference
  572. >
  573. >::type
  574. , ::boost::mpl::if_<
  575. ::boost::is_const<T>
  576. , ::boost::mpl::false_
  577. , ::boost::mpl::true_
  578. >
  579. , ::boost::mpl::false_
  580. >::type
  581. , ::boost::parameter::aux::tag<Tag,T&>
  582. >::type
  583. #endif // BOOST_NO_SFINAE
  584. operator=(T& x) const
  585. {
  586. typedef typename ::boost::parameter::aux
  587. ::tag<Tag,T&>::type result;
  588. return result(x);
  589. }
  590. template <typename Default>
  591. #if defined(BOOST_NO_SFINAE)
  592. inline ::boost::parameter::aux::default_<Tag,Default>
  593. #else
  594. inline BOOST_CONSTEXPR typename ::boost::enable_if<
  595. typename ::boost::mpl::eval_if<
  596. typename ::boost::mpl::if_<
  597. ::boost::is_same<
  598. typename Tag::qualifier
  599. , ::boost::parameter::out_reference
  600. >
  601. , ::boost::mpl::true_
  602. , ::boost::is_same<
  603. typename Tag::qualifier
  604. , ::boost::parameter::forward_reference
  605. >
  606. >::type
  607. , ::boost::mpl::if_<
  608. ::boost::is_const<Default>
  609. , ::boost::mpl::false_
  610. , ::boost::mpl::true_
  611. >
  612. , ::boost::mpl::false_
  613. >::type
  614. , ::boost::parameter::aux::default_<Tag,Default>
  615. >::type
  616. #endif // BOOST_NO_SFINAE
  617. operator|(Default& d) const
  618. {
  619. return ::boost::parameter::aux::default_<Tag,Default>(d);
  620. }
  621. template <typename Default>
  622. inline BOOST_CONSTEXPR
  623. ::boost::parameter::aux::lazy_default<Tag,Default const>
  624. operator||(Default const& d) const
  625. {
  626. return ::boost::parameter::aux
  627. ::lazy_default<Tag,Default const>(d);
  628. }
  629. template <typename Default>
  630. inline BOOST_CONSTEXPR
  631. ::boost::parameter::aux::lazy_default<Tag,Default>
  632. operator||(Default& d) const
  633. {
  634. return ::boost::parameter::aux::lazy_default<Tag,Default>(d);
  635. }
  636. public: // Insurance against ODR violations
  637. // Users will need to define their keywords in header files. To
  638. // prevent ODR violations, it's important that the keyword used in
  639. // every instantiation of a function template is the same object.
  640. // We provide a reference to a common instance of each keyword
  641. // object and prevent construction by users.
  642. static ::boost::parameter::keyword<Tag> const instance;
  643. // This interface is deprecated.
  644. static ::boost::parameter::keyword<Tag>& get()
  645. {
  646. return const_cast< ::boost::parameter::keyword<Tag>&>(instance);
  647. }
  648. };
  649. template <typename Tag>
  650. ::boost::parameter::keyword<Tag> const ::boost::parameter
  651. ::keyword<Tag>::instance = ::boost::parameter::keyword<Tag>();
  652. }} // namespace boost::parameter
  653. #endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING
  654. #include <boost/parameter/aux_/name.hpp>
  655. #include <boost/preprocessor/stringize.hpp>
  656. // Reduces boilerplate required to declare and initialize keywords without
  657. // violating ODR. Declares a keyword tag type with the given name in
  658. // namespace tag_namespace, and declares and initializes a reference in an
  659. // anonymous namespace to a singleton instance of that type.
  660. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  661. #define BOOST_PARAMETER_KEYWORD(tag_namespace, name) \
  662. namespace tag_namespace \
  663. { \
  664. struct name \
  665. { \
  666. static BOOST_CONSTEXPR char const* keyword_name() \
  667. { \
  668. return BOOST_PP_STRINGIZE(name); \
  669. } \
  670. using _ = BOOST_PARAMETER_TAG_PLACEHOLDER_TYPE(name); \
  671. using _1 = _; \
  672. BOOST_PARAMETER_TAG_MP11_PLACEHOLDER_BINDING(binding_fn, name); \
  673. BOOST_PARAMETER_TAG_MP11_PLACEHOLDER_VALUE(fn, name); \
  674. using qualifier = ::boost::parameter::forward_reference; \
  675. }; \
  676. } \
  677. namespace \
  678. { \
  679. ::boost::parameter::keyword<tag_namespace::name> const& name \
  680. = ::boost::parameter::keyword<tag_namespace::name>::instance; \
  681. }
  682. /**/
  683. #else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
  684. #define BOOST_PARAMETER_KEYWORD(tag_namespace, name) \
  685. namespace tag_namespace \
  686. { \
  687. struct name \
  688. { \
  689. static BOOST_CONSTEXPR char const* keyword_name() \
  690. { \
  691. return BOOST_PP_STRINGIZE(name); \
  692. } \
  693. typedef BOOST_PARAMETER_TAG_PLACEHOLDER_TYPE(name) _; \
  694. typedef BOOST_PARAMETER_TAG_PLACEHOLDER_TYPE(name) _1; \
  695. typedef ::boost::parameter::forward_reference qualifier; \
  696. }; \
  697. } \
  698. namespace \
  699. { \
  700. ::boost::parameter::keyword<tag_namespace::name> const& name \
  701. = ::boost::parameter::keyword<tag_namespace::name>::instance; \
  702. }
  703. /**/
  704. #endif // BOOST_PARAMETER_CAN_USE_MP11
  705. #endif // include guard