convert.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #if !defined(FUSION_CONVERT_10022005_1442)
  7. #define FUSION_CONVERT_10022005_1442
  8. namespace boost { namespace fusion
  9. {
  10. namespace extension
  11. {
  12. template <typename Tag>
  13. struct convert_impl;
  14. }
  15. namespace result_of
  16. {
  17. template <typename Tag, typename Sequence>
  18. struct convert
  19. {
  20. typedef typename extension::convert_impl<Tag> gen;
  21. typedef typename
  22. gen::template apply<Sequence>::type
  23. type;
  24. };
  25. }
  26. template <typename Tag, typename Sequence>
  27. inline typename result_of::convert<Tag, Sequence>::type
  28. convert(Sequence& seq)
  29. {
  30. typedef typename result_of::convert<Tag, Sequence>::gen gen;
  31. return gen::call(seq);
  32. }
  33. template <typename Tag, typename Sequence>
  34. inline typename result_of::convert<Tag, Sequence const>::type
  35. convert(Sequence const& seq)
  36. {
  37. typedef typename result_of::convert<Tag, Sequence const>::gen gen;
  38. return gen::call(seq);
  39. }
  40. }}
  41. #endif