attr_cast.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright (c) 2001-2011 Hartmut Kaiser
  2. //
  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. #ifndef BOOST_SPIRIT_SUPPORT_AUXILIARY_ATTR_CAST_HPP
  6. #define BOOST_SPIRIT_SUPPORT_AUXILIARY_ATTR_CAST_HPP
  7. #if defined(_MSC_VER)
  8. #pragma once
  9. #endif
  10. #include <boost/spirit/home/support/common_terminals.hpp>
  11. #include <boost/spirit/home/support/attributes.hpp>
  12. #include <boost/core/enable_if.hpp>
  13. #include <boost/proto/traits.hpp>
  14. namespace boost { namespace spirit
  15. {
  16. ///////////////////////////////////////////////////////////////////////////
  17. // This one is the function that the user can call directly in order
  18. // to create a customized attr_cast component
  19. template <typename Expr>
  20. typename enable_if<proto::is_expr<Expr>
  21. , stateful_tag_type<Expr, tag::attr_cast> >::type
  22. attr_cast(Expr const& expr)
  23. {
  24. return stateful_tag_type<Expr, tag::attr_cast>(expr);
  25. }
  26. template <typename Exposed, typename Expr>
  27. typename enable_if<proto::is_expr<Expr>
  28. , stateful_tag_type<Expr, tag::attr_cast, Exposed> >::type
  29. attr_cast(Expr const& expr)
  30. {
  31. return stateful_tag_type<Expr, tag::attr_cast, Exposed>(expr);
  32. }
  33. template <typename Exposed, typename Transformed, typename Expr>
  34. typename enable_if<proto::is_expr<Expr>
  35. , stateful_tag_type<Expr, tag::attr_cast, Exposed, Transformed> >::type
  36. attr_cast(Expr const& expr)
  37. {
  38. return stateful_tag_type<Expr, tag::attr_cast, Exposed, Transformed>(expr);
  39. }
  40. }}
  41. #endif