deduced.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Boost.TypeErasure library
  2. //
  3. // Copyright 2011 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_DEDUCED_HPP_INCLUDED
  11. #define BOOST_TYPE_ERASURE_DEDUCED_HPP_INCLUDED
  12. #include <boost/mpl/eval_if.hpp>
  13. #include <boost/mpl/identity.hpp>
  14. #include <boost/mpl/set.hpp>
  15. #include <boost/mpl/empty.hpp>
  16. #include <boost/type_erasure/detail/get_placeholders.hpp>
  17. #include <boost/type_erasure/placeholder.hpp>
  18. namespace boost {
  19. namespace type_erasure {
  20. /**
  21. * A placeholder for an associated type. The type corresponding
  22. * to this placeholder is deduced by substituting placeholders
  23. * in the arguments of the metafunction and then evaluating it.
  24. *
  25. * When using @ref deduced in a template context, if it is possible for
  26. * Metafunction to contain no placeholders at all, use the nested type,
  27. * to automatically evaluate it early as needed.
  28. */
  29. template<class Metafunction>
  30. struct deduced : ::boost::type_erasure::placeholder
  31. {
  32. typedef typename ::boost::mpl::eval_if<
  33. ::boost::mpl::empty<
  34. typename ::boost::type_erasure::detail::get_placeholders<
  35. Metafunction,
  36. #ifndef BOOST_TYPE_ERASURE_USE_MP11
  37. ::boost::mpl::set0<>
  38. #else
  39. ::boost::mp11::mp_list<>
  40. #endif
  41. >::type
  42. >,
  43. Metafunction,
  44. ::boost::mpl::identity<
  45. ::boost::type_erasure::deduced<Metafunction>
  46. >
  47. >::type type;
  48. };
  49. }
  50. }
  51. #endif