attr_cast.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #if !defined(SPIRIT_SUPPORT_ATTR_CAST_OCT_06_2009_00535PM)
  6. #define SPIRIT_SUPPORT_ATTR_CAST_OCT_06_2009_00535PM
  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/utility/enable_if.hpp>
  13. namespace boost { namespace spirit
  14. {
  15. ///////////////////////////////////////////////////////////////////////////
  16. // This one is the function that the user can call directly in order
  17. // to create a customized attr_cast component
  18. template <typename Expr>
  19. typename enable_if<proto::is_expr<Expr>
  20. , stateful_tag_type<Expr, tag::attr_cast> >::type
  21. attr_cast(Expr const& expr)
  22. {
  23. return stateful_tag_type<Expr, tag::attr_cast>(expr);
  24. }
  25. template <typename Exposed, typename Expr>
  26. typename enable_if<proto::is_expr<Expr>
  27. , stateful_tag_type<Expr, tag::attr_cast, Exposed> >::type
  28. attr_cast(Expr const& expr)
  29. {
  30. return stateful_tag_type<Expr, tag::attr_cast, Exposed>(expr);
  31. }
  32. template <typename Exposed, typename Transformed, typename Expr>
  33. typename enable_if<proto::is_expr<Expr>
  34. , stateful_tag_type<Expr, tag::attr_cast, Exposed, Transformed> >::type
  35. attr_cast(Expr const& expr)
  36. {
  37. return stateful_tag_type<Expr, tag::attr_cast, Exposed, Transformed>(expr);
  38. }
  39. }}
  40. #endif