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_IMPL_20060223_2017) 9 #define BOOST_FUSION_AT_IMPL_20060223_2017 10 11 #include <string> 12 #include <boost/mpl/if.hpp> 13 #include <boost/mpl/int.hpp> 14 #include <boost/type_traits/is_const.hpp> 15 16 namespace example 17 { 18 struct example_sequence_tag; 19 } 20 21 namespace boost { namespace fusion { 22 23 namespace extension 24 { 25 template<typename Tag> 26 struct at_impl; 27 28 template<> 29 struct at_impl<example::example_sequence_tag> 30 { 31 template<typename Sequence, typename Key> 32 struct apply; 33 34 template<typename Sequence> 35 struct apply<Sequence, mpl::int_<0> > 36 { 37 typedef typename mpl::if_< 38 is_const<Sequence>, 39 std::string const&, 40 std::string&>::type type; 41 42 static type callboost::fusion::extension::at_impl::apply43 call(Sequence& seq) 44 { 45 return seq.name; 46 }; 47 }; 48 49 template<typename Sequence> 50 struct apply<Sequence, mpl::int_<1> > 51 { 52 typedef typename mpl::if_< 53 is_const<Sequence>, 54 int const&, 55 int&>::type type; 56 57 static type callboost::fusion::extension::at_impl::apply58 call(Sequence& seq) 59 { 60 return seq.age; 61 }; 62 }; 63 }; 64 } 65 }} 66 67 #endif 68