convert.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #include <boost/fusion/support/config.hpp>
  9. #if BOOST_WORKAROUND(BOOST_GCC, < 30500)
  10. #include <boost/core/enable_if.hpp>
  11. #include <boost/type_traits/is_const.hpp>
  12. #define BOOST_FUSION_WA_GCC34(type1, type2) \
  13. boost::lazy_disable_if<boost::is_const<Sequence>, type1, type2>
  14. #else
  15. #define BOOST_FUSION_WA_GCC34(type1, type2) type1, type2
  16. #endif
  17. namespace boost { namespace fusion
  18. {
  19. namespace extension
  20. {
  21. template <typename Tag>
  22. struct convert_impl;
  23. }
  24. namespace result_of
  25. {
  26. template <typename Tag, typename Sequence>
  27. struct convert
  28. {
  29. typedef typename
  30. extension::convert_impl<Tag>::template apply<Sequence>
  31. gen;
  32. typedef typename gen::type type;
  33. };
  34. }
  35. template <typename Tag, typename Sequence>
  36. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  37. inline typename BOOST_FUSION_WA_GCC34(result_of::convert<Tag, Sequence>)::type
  38. convert(Sequence& seq)
  39. {
  40. typedef typename result_of::convert<Tag, Sequence>::gen gen;
  41. return gen::call(seq);
  42. }
  43. template <typename Tag, typename Sequence>
  44. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  45. inline typename result_of::convert<Tag, Sequence const>::type
  46. convert(Sequence const& seq)
  47. {
  48. typedef typename result_of::convert<Tag, Sequence const>::gen gen;
  49. return gen::call(seq);
  50. }
  51. }}
  52. #undef BOOST_FUSION_WA_GCC34
  53. #endif