Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:05

0001 // Copyright 2008-2010 Gordon Woodhull
0002 // Distributed under the Boost Software License, Version 1.0. 
0003 // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0004 
0005 #ifndef BOOST_MSM_MPL_GRAPH_MPL_UTILS_HPP_INCLUDED
0006 #define BOOST_MSM_MPL_GRAPH_MPL_UTILS_HPP_INCLUDED
0007 
0008 #include <boost/mpl/fold.hpp>
0009 #include <boost/mpl/map.hpp>
0010 #include <boost/mpl/set.hpp>
0011 #include <boost/mpl/insert.hpp>
0012 #include <boost/mpl/if.hpp>
0013 #include <boost/mpl/has_key.hpp>
0014 #include <boost/mpl/at.hpp>
0015 #include <boost/mpl/and.hpp>
0016 
0017 namespace boost {
0018 namespace msm {
0019 namespace mpl_graph {
0020 namespace mpl_utils {
0021     
0022 // This is a grab bag of little metafunctions I expect already
0023 // exist under some name I haven't looked for
0024 
0025 // I figure there are probably better ways to do all of these things,
0026 // but for now I'll just write some utilities to isolate my ignorance
0027 
0028 template<typename Seq>
0029 struct as_map :
0030     mpl::fold<Seq, 
0031               mpl::map<>, 
0032               mpl::insert<mpl::_1, mpl::_2> >
0033 {};
0034 template<typename Seq>
0035 struct as_set :
0036     mpl::fold<Seq, 
0037               mpl::set<>, 
0038               mpl::insert<mpl::_1, mpl::_2> >
0039 {};
0040 
0041 template<typename AssocSeq, typename Key, typename Default>
0042 struct at_or_default :
0043     mpl::if_<typename mpl::has_key<AssocSeq, Key>::type,
0044              typename mpl::at<AssocSeq, Key>::type,
0045              Default>
0046 {};
0047 
0048 template<typename Seq1, typename Seq2>
0049 struct set_equal :
0050     mpl::fold<Seq2,
0051               mpl::true_,
0052               mpl::and_<mpl::_1, 
0053                         mpl::has_key<typename as_set<Seq1>::type, 
0054                                      mpl::_2 > > >
0055 {};
0056                                        
0057 }
0058 }
0059 }
0060 }              
0061 
0062 #endif // BOOST_MSM_MPL_GRAPH_MPL_UTILS_HPP_INCLUDED