test_set_factory.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* Boost.Flyweight test of set_factory.
  2. *
  3. * Copyright 2006-2013 Joaquin M Lopez Munoz.
  4. * Distributed under the Boost Software License, Version 1.0.
  5. * (See accompanying file LICENSE_1_0.txt or copy at
  6. * http://www.boost.org/LICENSE_1_0.txt)
  7. *
  8. * See http://www.boost.org/libs/flyweight for library home page.
  9. */
  10. #include "test_set_factory.hpp"
  11. #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
  12. #include <boost/flyweight/flyweight.hpp>
  13. #include <boost/flyweight/refcounted.hpp>
  14. #include <boost/flyweight/set_factory.hpp>
  15. #include <boost/flyweight/simple_locking.hpp>
  16. #include <boost/flyweight/static_holder.hpp>
  17. #include <functional>
  18. #include "test_basic_template.hpp"
  19. using namespace boost::flyweights;
  20. struct set_factory_flyweight_specifier1
  21. {
  22. template<typename T>
  23. struct apply
  24. {
  25. typedef flyweight<T,set_factory<> > type;
  26. };
  27. };
  28. struct set_factory_flyweight_specifier2
  29. {
  30. template<typename T>
  31. struct apply
  32. {
  33. typedef flyweight<
  34. T,
  35. static_holder_class<boost::mpl::_1>,
  36. set_factory_class<
  37. boost::mpl::_1,boost::mpl::_2,
  38. std::greater<boost::mpl::_2>,
  39. std::allocator<boost::mpl::_1>
  40. >
  41. > type;
  42. };
  43. };
  44. struct set_factory_flyweight_specifier3
  45. {
  46. template<typename T>
  47. struct apply
  48. {
  49. typedef flyweight<
  50. T,
  51. set_factory<
  52. std::greater<boost::mpl::_2>,
  53. std::allocator<boost::mpl::_1>
  54. >,
  55. static_holder_class<boost::mpl::_1>,
  56. tag<char>
  57. > type;
  58. };
  59. };
  60. void test_set_factory()
  61. {
  62. test_basic_template<set_factory_flyweight_specifier1>();
  63. test_basic_template<set_factory_flyweight_specifier2>();
  64. test_basic_template<set_factory_flyweight_specifier3>();
  65. }