annotate DEPENDENCIES/generic/include/boost/msm/mpl_graph/mpl_utils.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Copyright 2008-2010 Gordon Woodhull
Chris@16 2 // Distributed under the Boost Software License, Version 1.0.
Chris@16 3 // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 4
Chris@16 5 #ifndef BOOST_MSM_MPL_GRAPH_MPL_UTILS_HPP_INCLUDED
Chris@16 6 #define BOOST_MSM_MPL_GRAPH_MPL_UTILS_HPP_INCLUDED
Chris@16 7
Chris@16 8 #include <boost/mpl/fold.hpp>
Chris@16 9 #include <boost/mpl/map.hpp>
Chris@16 10 #include <boost/mpl/set.hpp>
Chris@16 11 #include <boost/mpl/insert.hpp>
Chris@16 12 #include <boost/mpl/if.hpp>
Chris@16 13 #include <boost/mpl/has_key.hpp>
Chris@16 14 #include <boost/mpl/at.hpp>
Chris@16 15 #include <boost/mpl/and.hpp>
Chris@16 16
Chris@16 17 namespace boost {
Chris@16 18 namespace msm {
Chris@16 19 namespace mpl_graph {
Chris@16 20 namespace mpl_utils {
Chris@16 21
Chris@16 22 // This is a grab bag of little metafunctions I expect already
Chris@16 23 // exist under some name I haven't looked for
Chris@16 24
Chris@16 25 // I figure there are probably better ways to do all of these things,
Chris@16 26 // but for now I'll just write some utilities to isolate my ignorance
Chris@16 27
Chris@16 28 template<typename Seq>
Chris@16 29 struct as_map :
Chris@16 30 mpl::fold<Seq,
Chris@16 31 mpl::map<>,
Chris@16 32 mpl::insert<mpl::_1, mpl::_2> >
Chris@16 33 {};
Chris@16 34 template<typename Seq>
Chris@16 35 struct as_set :
Chris@16 36 mpl::fold<Seq,
Chris@16 37 mpl::set<>,
Chris@16 38 mpl::insert<mpl::_1, mpl::_2> >
Chris@16 39 {};
Chris@16 40
Chris@16 41 template<typename AssocSeq, typename Key, typename Default>
Chris@16 42 struct at_or_default :
Chris@16 43 mpl::if_<typename mpl::has_key<AssocSeq, Key>::type,
Chris@16 44 typename mpl::at<AssocSeq, Key>::type,
Chris@16 45 Default>
Chris@16 46 {};
Chris@16 47
Chris@16 48 template<typename Seq1, typename Seq2>
Chris@16 49 struct set_equal :
Chris@16 50 mpl::fold<Seq2,
Chris@16 51 mpl::true_,
Chris@16 52 mpl::and_<mpl::_1,
Chris@16 53 mpl::has_key<typename as_set<Seq1>::type,
Chris@16 54 mpl::_2 > > >
Chris@16 55 {};
Chris@16 56
Chris@16 57 }
Chris@16 58 }
Chris@16 59 }
Chris@16 60 }
Chris@16 61
Chris@16 62 #endif // BOOST_MSM_MPL_GRAPH_MPL_UTILS_HPP_INCLUDED