set_factory.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* Copyright 2006-2009 Joaquin M Lopez Munoz.
  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. *
  6. * See http://www.boost.org/libs/flyweight for library home page.
  7. */
  8. #ifndef BOOST_FLYWEIGHT_SET_FACTORY_HPP
  9. #define BOOST_FLYWEIGHT_SET_FACTORY_HPP
  10. #if defined(_MSC_VER)
  11. #pragma once
  12. #endif
  13. #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
  14. #include <boost/detail/allocator_utilities.hpp>
  15. #include <boost/flyweight/assoc_container_factory.hpp>
  16. #include <boost/flyweight/factory_tag.hpp>
  17. #include <boost/flyweight/set_factory_fwd.hpp>
  18. #include <boost/mpl/aux_/lambda_support.hpp>
  19. #include <boost/mpl/if.hpp>
  20. #include <set>
  21. /* Particularization of assoc_container_factory_class using a set.
  22. */
  23. namespace boost{
  24. namespace flyweights{
  25. template<
  26. typename Entry,typename Key,
  27. typename Compare,typename Allocator
  28. >
  29. class set_factory_class:
  30. public assoc_container_factory_class<
  31. std::set<
  32. Entry,
  33. typename boost::mpl::if_<
  34. mpl::is_na<Compare>,
  35. std::less<Key>,
  36. Compare
  37. >::type,
  38. typename boost::mpl::if_<
  39. mpl::is_na<Allocator>,
  40. std::allocator<Entry>,
  41. Allocator
  42. >::type
  43. >
  44. >
  45. {
  46. public:
  47. typedef set_factory_class type;
  48. BOOST_MPL_AUX_LAMBDA_SUPPORT(
  49. 4,set_factory_class,(Entry,Key,Compare,Allocator))
  50. };
  51. /* set_factory_class specifier */
  52. template<
  53. typename Compare,typename Allocator
  54. BOOST_FLYWEIGHT_NOT_A_PLACEHOLDER_EXPRESSION_DEF
  55. >
  56. struct set_factory:factory_marker
  57. {
  58. template<typename Entry,typename Key>
  59. struct apply:
  60. mpl::apply2<
  61. set_factory_class<
  62. boost::mpl::_1,boost::mpl::_2,Compare,Allocator
  63. >,
  64. Entry,Key
  65. >
  66. {};
  67. };
  68. } /* namespace flyweights */
  69. } /* namespace boost */
  70. #endif