| | 1 | /*============================================================================= |
| | 2 | Copyright (c) 2005-2008 Hartmut Kaiser |
| | 3 | Copyright (c) 2005-2007 Joel de Guzman |
| | 4 | Copyright (c) 2011 Michael Caisse |
| | 5 | |
| | 6 | Distributed under the Boost Software License, Version 1.0. (See accompanying |
| | 7 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| | 8 | ==============================================================================*/ |
| | 9 | #ifndef PHOENIX_SEQUENCE_AT_KEY_HPP |
| | 10 | #define PHOENIX_SEQUENCE_AT_KEY_HPP |
| | 11 | |
| | 12 | #include <boost/fusion/include/at_key.hpp> |
| | 13 | #include <boost/spirit/home/phoenix/core/actor.hpp> |
| | 14 | #include <boost/spirit/home/phoenix/core/compose.hpp> |
| | 15 | #include <boost/type_traits/remove_reference.hpp> |
| | 16 | |
| | 17 | namespace boost { namespace phoenix |
| | 18 | { |
| | 19 | template <typename Key> |
| | 20 | struct at_key_eval |
| | 21 | { |
| | 22 | template <typename Env, typename Tuple> |
| | 23 | struct result |
| | 24 | { |
| | 25 | typedef typename Tuple::template result<Env>::type tuple; |
| | 26 | typedef typename |
| | 27 | fusion::result_of::at_key< |
| | 28 | typename remove_reference<tuple>::type, Key |
| | 29 | >::type |
| | 30 | type; |
| | 31 | }; |
| | 32 | |
| | 33 | template <typename RT, typename Env, typename Tuple> |
| | 34 | static RT |
| | 35 | eval(Env const& env, Tuple const& t) |
| | 36 | { |
| | 37 | return fusion::at_key<Key>(t.eval(env)); |
| | 38 | } |
| | 39 | }; |
| | 40 | |
| | 41 | template <typename Key, typename Tuple> |
| | 42 | inline actor<typename as_composite<at_key_eval<Key>, Tuple>::type> |
| | 43 | at_key(Tuple const& tup) |
| | 44 | { |
| | 45 | return compose<at_key_eval<Key> >(tup); |
| | 46 | } |
| | 47 | |
| | 48 | }} |
| | 49 | |
| | 50 | #endif |