test_basic.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* Boost.Flyweight basic test.
  2. *
  3. * Copyright 2006-2008 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_basic.hpp"
  11. #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
  12. #include <boost/flyweight.hpp>
  13. #include "test_basic_template.hpp"
  14. using namespace boost::flyweights;
  15. struct basic_flyweight_specifier1
  16. {
  17. template<typename T>
  18. struct apply
  19. {
  20. typedef flyweight<T> type;
  21. };
  22. };
  23. struct basic_flyweight_specifier2
  24. {
  25. template<typename T>
  26. struct apply
  27. {
  28. typedef flyweight<
  29. T,tag<int>,
  30. static_holder_class<boost::mpl::_1>,
  31. hashed_factory_class<
  32. boost::mpl::_1,boost::mpl::_2,
  33. boost::hash<boost::mpl::_2>,std::equal_to<boost::mpl::_2>,
  34. std::allocator<boost::mpl::_1>
  35. >,
  36. simple_locking,
  37. refcounted
  38. > type;
  39. };
  40. };
  41. struct basic_flyweight_specifier3
  42. {
  43. template<typename T>
  44. struct apply
  45. {
  46. typedef flyweight<
  47. T,
  48. hashed_factory<
  49. boost::hash<boost::mpl::_2>,std::equal_to<boost::mpl::_2>,
  50. std::allocator<boost::mpl::_1>
  51. >,
  52. tag<int>
  53. > type;
  54. };
  55. };
  56. void test_basic()
  57. {
  58. test_basic_template<basic_flyweight_specifier1>();
  59. test_basic_template<basic_flyweight_specifier2>();
  60. test_basic_template<basic_flyweight_specifier3>();
  61. }