set.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // Copyright Daniel Wallin 2006.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_PARAMETER_SET_060912_HPP
  6. #define BOOST_PARAMETER_SET_060912_HPP
  7. #include <boost/parameter/config.hpp>
  8. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  9. #include <boost/mp11/list.hpp>
  10. namespace boost { namespace parameter { namespace aux {
  11. typedef ::boost::mp11::mp_list<> set0;
  12. }}} // namespace boost::parameter::aux
  13. #include <boost/mp11/algorithm.hpp>
  14. namespace boost { namespace parameter { namespace aux {
  15. template <typename S, typename K>
  16. struct insert_
  17. {
  18. using type = ::boost::mp11::mp_insert_c<S,0,K>;
  19. };
  20. }}} // namespace boost::parameter::aux
  21. #include <boost/mp11/integral.hpp>
  22. #include <boost/mp11/utility.hpp>
  23. #include <type_traits>
  24. namespace boost { namespace parameter { namespace aux {
  25. template <typename Set, typename K>
  26. struct has_key_
  27. {
  28. using type = ::boost::mp11::mp_if<
  29. ::boost::mp11::mp_empty<Set>
  30. , ::boost::mp11::mp_false
  31. , ::std::is_same<
  32. ::boost::mp11::mp_find<Set,K>
  33. , ::boost::mp11::mp_size<Set>
  34. >
  35. >;
  36. };
  37. }}} // namespace boost::parameter::aux
  38. #elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
  39. #include <boost/mpl/list.hpp>
  40. namespace boost { namespace parameter { namespace aux {
  41. typedef ::boost::mpl::list0<> set0;
  42. }}} // namespace boost::parameter::aux
  43. #include <boost/mpl/push_front.hpp>
  44. namespace boost { namespace parameter { namespace aux {
  45. template <typename Set, typename K>
  46. struct insert_ : ::boost::mpl::push_front<Set,K>
  47. {
  48. };
  49. }}} // namespace boost::parameter::aux
  50. #include <boost/mpl/bool.hpp>
  51. #include <boost/mpl/if.hpp>
  52. #include <boost/mpl/end.hpp>
  53. #include <boost/mpl/find.hpp>
  54. #include <boost/type_traits/is_same.hpp>
  55. namespace boost { namespace parameter { namespace aux {
  56. template <typename Set, typename K>
  57. struct has_key_
  58. {
  59. typedef typename ::boost::mpl::find<Set,K>::type iter;
  60. typedef typename ::boost::mpl::if_<
  61. ::boost::is_same<iter,typename ::boost::mpl::end<Set>::type>
  62. , ::boost::mpl::false_
  63. , ::boost::mpl::true_
  64. >::type type;
  65. };
  66. }}} // namespace boost::parameter::aux
  67. #else // !BOOST_PARAMETER_CAN_USE_MP11 && Borland workarounds not needed
  68. #include <boost/mpl/set/set0.hpp>
  69. namespace boost { namespace parameter { namespace aux {
  70. typedef ::boost::mpl::set0<> set0;
  71. }}} // namespace boost::parameter::aux
  72. #include <boost/mpl/insert.hpp>
  73. namespace boost { namespace parameter { namespace aux {
  74. template <typename Set, typename K>
  75. struct insert_ : ::boost::mpl::insert<Set,K>
  76. {
  77. };
  78. }}} // namespace boost::parameter::aux
  79. #include <boost/mpl/has_key.hpp>
  80. namespace boost { namespace parameter { namespace aux {
  81. template <typename Set, typename K>
  82. struct has_key_ : ::boost::mpl::has_key<Set,K>
  83. {
  84. };
  85. }}} // namespace boost::parameter::aux
  86. #endif // BOOST_PARAMETER_CAN_USE_MP11 || Borland workarounds needed
  87. #endif // include guard