diff options
author | Vlad Voicu <vladv@rosedu.org> | 2012-03-02 10:01:11 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2012-03-09 15:04:05 (GMT) |
commit | 1c8cd160b79b6bbcec72042bdb104ba530508a93 (patch) | |
tree | cff302b81e74c557fbc9e30fd43144d981b613d0 /3rdParty/Boost/src/boost/spirit/home/support/nonterminal/expand_arg.hpp | |
parent | 2944711aefec9a9dd66052440bc4f921910dd780 (diff) | |
download | swift-contrib-1c8cd160b79b6bbcec72042bdb104ba530508a93.zip swift-contrib-1c8cd160b79b6bbcec72042bdb104ba530508a93.tar.bz2 |
Added spirit to bundled boost
Diffstat (limited to '3rdParty/Boost/src/boost/spirit/home/support/nonterminal/expand_arg.hpp')
-rw-r--r-- | 3rdParty/Boost/src/boost/spirit/home/support/nonterminal/expand_arg.hpp | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/boost/spirit/home/support/nonterminal/expand_arg.hpp b/3rdParty/Boost/src/boost/spirit/home/support/nonterminal/expand_arg.hpp new file mode 100644 index 0000000..f037acc --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/support/nonterminal/expand_arg.hpp @@ -0,0 +1,88 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_SPIRIT_EXPAND_ARG_FEB_19_2007_1107AM) +#define BOOST_SPIRIT_EXPAND_ARG_FEB_19_2007_1107AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/mpl/bool.hpp> +#include <boost/mpl/or.hpp> +#include <boost/mpl/identity.hpp> +#include <boost/mpl/eval_if.hpp> +#include <boost/utility/result_of.hpp> +#include <boost/type_traits/is_scalar.hpp> +#include <boost/spirit/home/support/string_traits.hpp> + +namespace boost { namespace spirit { namespace detail +{ + /////////////////////////////////////////////////////////////////////////// + template <typename Context> + struct expand_arg + { + template <typename T> + struct result_type + { + // This is a temporary hack. The better way is to detect if T + // can be called given unused context. + typedef typename + mpl::eval_if< + mpl::or_<is_scalar<T>, traits::is_string<T> > + , mpl::identity<T const &> + , boost::result_of<T(unused_type, Context)> + >::type + type; + }; + + template <typename T> + struct result; + + template <typename F, typename A0> + struct result<F(A0)> + : result_type<A0> {}; + + template <typename F, typename A0> + struct result<F(A0&)> + : result_type<A0> {}; + + expand_arg(Context& context) + : context(context) + { + } + + template <typename T> + typename result_type<T>::type + call(T const& f, mpl::false_) const + { + return f(unused, context); + } + + template <typename T> + typename result_type<T>::type + call(T const& val, mpl::true_) const + { + return val; + } + + template <typename T> + typename result_type<T>::type + operator()(T const& x) const + { + return call(x, mpl::or_<is_scalar<T>, traits::is_string<T> >()); + } + + Context& context; + + private: + // silence MSVC warning C4512: assignment operator could not be generated + expand_arg& operator= (expand_arg const&); + }; + +}}} + +#endif |