default_value_policy.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* Copyright 2006-2008 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_DETAIL_DEFAULT_VALUE_POLICY_HPP
  9. #define BOOST_FLYWEIGHT_DETAIL_DEFAULT_VALUE_POLICY_HPP
  10. #if defined(_MSC_VER)&&(_MSC_VER>=1200)
  11. #pragma once
  12. #endif
  13. #include <boost/flyweight/detail/value_tag.hpp>
  14. #include <boost/preprocessor/repetition/enum_params.hpp>
  15. /* Default value policy: the key is the same as the value.
  16. */
  17. namespace boost{
  18. namespace flyweights{
  19. namespace detail{
  20. template<typename Value>
  21. struct default_value_policy:value_marker
  22. {
  23. typedef Value key_type;
  24. typedef Value value_type;
  25. struct rep_type
  26. {
  27. /* template ctors */
  28. #define BOOST_FLYWEIGHT_PERFECT_FWD_NAME explicit rep_type
  29. #define BOOST_FLYWEIGHT_PERFECT_FWD_BODY(n) \
  30. :x(BOOST_PP_ENUM_PARAMS(n,t)){}
  31. #include <boost/flyweight/detail/perfect_fwd.hpp>
  32. operator const value_type&()const{return x;}
  33. value_type x;
  34. };
  35. static void construct_value(const rep_type&){}
  36. static void copy_value(const rep_type&){}
  37. };
  38. } /* namespace flyweights::detail */
  39. } /* namespace flyweights */
  40. } /* namespace boost */
  41. #endif