1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 #if !defined(BOOST_SPIRIT_EXPAND_ARG_FEB_19_2007_1107AM)
8 #define BOOST_SPIRIT_EXPAND_ARG_FEB_19_2007_1107AM
14 #include <boost/mpl/bool.hpp>
15 #include <boost/mpl/or.hpp>
16 #include <boost/mpl/identity.hpp>
17 #include <boost/mpl/eval_if.hpp>
18 #include <boost/utility/result_of.hpp>
19 #include <boost/type_traits/is_scalar.hpp>
20 #include <boost/spirit/home/support/string_traits.hpp>
22 namespace boost { namespace spirit { namespace detail
24 ///////////////////////////////////////////////////////////////////////////
25 template <typename Context>
31 // This is a temporary hack. The better way is to detect if T
32 // can be called given unused context.
35 mpl::or_<is_scalar<T>, traits::is_string<T> >
36 , mpl::identity<T const &>
37 , boost::result_of<T(unused_type, Context)>
45 template <typename F, typename A0>
49 template <typename F, typename A0>
53 expand_arg(Context& context_)
59 typename result_type<T>::type
60 call(T const& f, mpl::false_) const
62 return f(unused, context);
66 typename result_type<T>::type
67 call(T const& val, mpl::true_) const
73 typename result_type<T>::type
74 operator()(T const& x) const
76 return call(x, mpl::or_<is_scalar<T>, traits::is_string<T> >());
82 // silence MSVC warning C4512: assignment operator could not be generated
83 expand_arg& operator= (expand_arg const&);