dynamic_binding.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Boost.TypeErasure library
  2. //
  3. // Copyright 2015 Steven Watanabe
  4. //
  5. // Distributed under the Boost Software License Version 1.0. (See
  6. // accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // $Id$
  10. #ifndef BOOST_TYPE_ERASURE_DYNAMIC_BINDING_HPP_INCLUDED
  11. #define BOOST_TYPE_ERASURE_DYNAMIC_BINDING_HPP_INCLUDED
  12. #include <boost/type_erasure/detail/dynamic_vtable.hpp>
  13. #include <boost/type_erasure/static_binding.hpp>
  14. namespace boost {
  15. namespace type_erasure {
  16. /**
  17. * Maps a set of placeholders to actual types.
  18. */
  19. template<class PlaceholderList>
  20. class dynamic_binding
  21. {
  22. public:
  23. template<class Map>
  24. dynamic_binding(const static_binding<Map>&)
  25. {
  26. impl.template init<Map>();
  27. }
  28. template<class Concept, class Map>
  29. dynamic_binding(const binding<Concept>& other, const static_binding<Map>&)
  30. {
  31. impl.template convert_from<Map>(*other.impl.table);
  32. }
  33. private:
  34. template<class Concept>
  35. friend class binding;
  36. typename ::boost::type_erasure::detail::make_dynamic_vtable<PlaceholderList>::type impl;
  37. };
  38. }
  39. }
  40. #endif