annotate DEPENDENCIES/generic/include/boost/spirit/home/karma/phoenix_attributes.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 (c) 2001-2011 Hartmut Kaiser
Chris@16 2 //
Chris@16 3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 5
Chris@16 6 #if !defined(BOOST_SPIRIT_KARMA_PHOENIX_ATTRIBUTES_OCT_01_2009_1128AM)
Chris@16 7 #define BOOST_SPIRIT_KARMA_PHOENIX_ATTRIBUTES_OCT_01_2009_1128AM
Chris@16 8
Chris@16 9 #if defined(_MSC_VER)
Chris@16 10 #pragma once
Chris@16 11 #endif
Chris@16 12
Chris@16 13 #include <boost/spirit/include/version.hpp>
Chris@16 14
Chris@16 15 // we support Phoenix attributes only starting with V2.2
Chris@16 16 #if SPIRIT_VERSION >= 0x2020
Chris@16 17
Chris@16 18 #include <boost/spirit/home/karma/detail/attributes.hpp>
Chris@16 19 #include <boost/spirit/home/karma/detail/indirect_iterator.hpp>
Chris@16 20 #include <boost/spirit/home/support/container.hpp>
Chris@16 21
Chris@16 22 #include <boost/spirit/include/phoenix_core.hpp>
Chris@16 23 #include <boost/utility/result_of.hpp>
Chris@16 24
Chris@16 25 ///////////////////////////////////////////////////////////////////////////////
Chris@16 26 namespace boost { namespace spirit { namespace traits
Chris@16 27 {
Chris@16 28 ///////////////////////////////////////////////////////////////////////////
Chris@16 29 // Provide customization points allowing the use of phoenix expressions as
Chris@16 30 // generator functions in the context of generators expecting a container
Chris@16 31 // attribute (Kleene, plus, list, repeat, etc.)
Chris@16 32 ///////////////////////////////////////////////////////////////////////////
Chris@16 33 template <typename Eval>
Chris@16 34 struct is_container<phoenix::actor<Eval> const>
Chris@16 35 : is_container<typename boost::result_of<phoenix::actor<Eval>()>::type>
Chris@16 36 {};
Chris@16 37
Chris@16 38 template <typename Eval>
Chris@16 39 struct container_iterator<phoenix::actor<Eval> const>
Chris@16 40 {
Chris@16 41 typedef phoenix::actor<Eval> const& type;
Chris@16 42 };
Chris@16 43
Chris@16 44 template <typename Eval>
Chris@16 45 struct begin_container<phoenix::actor<Eval> const>
Chris@16 46 {
Chris@16 47 typedef phoenix::actor<Eval> const& type;
Chris@16 48 static type call(phoenix::actor<Eval> const& f)
Chris@16 49 {
Chris@16 50 return f;
Chris@16 51 }
Chris@16 52 };
Chris@16 53
Chris@16 54 template <typename Eval>
Chris@16 55 struct end_container<phoenix::actor<Eval> const>
Chris@16 56 {
Chris@16 57 typedef phoenix::actor<Eval> const& type;
Chris@16 58 static type call(phoenix::actor<Eval> const& f)
Chris@16 59 {
Chris@16 60 return f;
Chris@16 61 }
Chris@16 62 };
Chris@16 63
Chris@16 64 template <typename Eval>
Chris@16 65 struct deref_iterator<phoenix::actor<Eval> const>
Chris@16 66 {
Chris@16 67 typedef typename boost::result_of<phoenix::actor<Eval>()>::type type;
Chris@16 68 static type call(phoenix::actor<Eval> const& f)
Chris@16 69 {
Chris@16 70 return f();
Chris@16 71 }
Chris@16 72 };
Chris@16 73
Chris@16 74 template <typename Eval>
Chris@16 75 struct next_iterator<phoenix::actor<Eval> const>
Chris@16 76 {
Chris@16 77 typedef phoenix::actor<Eval> const& type;
Chris@16 78 static type call(phoenix::actor<Eval> const& f)
Chris@16 79 {
Chris@16 80 return f;
Chris@16 81 }
Chris@16 82 };
Chris@16 83
Chris@16 84 template <typename Eval>
Chris@16 85 struct compare_iterators<phoenix::actor<Eval> const>
Chris@16 86 {
Chris@16 87 static bool
Chris@16 88 call(phoenix::actor<Eval> const&, phoenix::actor<Eval> const&)
Chris@16 89 {
Chris@16 90 return false;
Chris@16 91 }
Chris@16 92 };
Chris@16 93
Chris@16 94 template <typename Eval>
Chris@16 95 struct container_value<phoenix::actor<Eval> >
Chris@16 96 {
Chris@16 97 typedef phoenix::actor<Eval> const& type;
Chris@16 98 };
Chris@16 99
Chris@16 100 template <typename Eval>
Chris@16 101 struct make_indirect_iterator<phoenix::actor<Eval> const>
Chris@16 102 {
Chris@16 103 typedef phoenix::actor<Eval> const& type;
Chris@16 104 };
Chris@16 105
Chris@16 106 ///////////////////////////////////////////////////////////////////////////
Chris@16 107 // Handle Phoenix actors as attributes, just invoke the function object
Chris@16 108 // and deal with the result as the attribute.
Chris@16 109 ///////////////////////////////////////////////////////////////////////////
Chris@16 110 template <typename Eval, typename Exposed>
Chris@16 111 struct extract_from_attribute<phoenix::actor<Eval>, Exposed>
Chris@16 112 {
Chris@16 113 typedef typename boost::result_of<phoenix::actor<Eval>()>::type type;
Chris@16 114
Chris@16 115 template <typename Context>
Chris@16 116 static type call(phoenix::actor<Eval> const& f, Context& context)
Chris@16 117 {
Chris@16 118 return f(unused, context);
Chris@16 119 }
Chris@16 120 };
Chris@16 121 }}}
Chris@16 122
Chris@16 123 #endif
Chris@16 124 #endif