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