1 /*============================================================================= 2 Copyright (c) 2001-2011 Joel de Guzman 3 Copyright (c) 2005-2006 Dan Marsden 4 5 Distributed under the Boost Software License, Version 1.0. (See accompanying 6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 ==============================================================================*/ 8 #if !defined(BOOST_FUSION_AT_KEY_IMPL_20060223_2017) 9 #define BOOST_FUSION_AT_KEY_IMPL_20060223_2017 10 11 #include <string> 12 #include <boost/mpl/if.hpp> 13 #include <boost/type_traits/is_const.hpp> 14 15 namespace fields 16 { 17 struct name; 18 struct age; 19 } 20 21 namespace example 22 { 23 struct example_sequence_tag; 24 } 25 26 namespace boost { namespace fusion { 27 28 namespace extension 29 { 30 template<typename Tag> 31 struct at_key_impl; 32 33 template<> 34 struct at_key_impl<example::example_sequence_tag> 35 { 36 template<typename Sequence, typename Key> 37 struct apply; 38 39 template<typename Sequence> 40 struct apply<Sequence, fields::name> 41 { 42 typedef typename mpl::if_< 43 is_const<Sequence>, 44 std::string const&, 45 std::string&>::type type; 46 47 static type callboost::fusion::extension::at_key_impl::apply48 call(Sequence& seq) 49 { 50 return seq.name; 51 }; 52 }; 53 54 template<typename Sequence> 55 struct apply<Sequence, fields::age> 56 { 57 typedef typename mpl::if_< 58 is_const<Sequence>, 59 int const&, 60 int&>::type type; 61 62 static type callboost::fusion::extension::at_key_impl::apply63 call(Sequence& seq) 64 { 65 return seq.age; 66 }; 67 }; 68 }; 69 } 70 }} 71 72 #endif 73