File indexing completed on 2025-01-19 09:47:51
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_SPIRIT_MAKE_CONS_OCTOBER_16_2008_1252PM
0009 #define BOOST_SPIRIT_MAKE_CONS_OCTOBER_16_2008_1252PM
0010
0011 #if defined(_MSC_VER)
0012 #pragma once
0013 #endif
0014
0015 #include <boost/mpl/eval_if.hpp>
0016 #include <boost/fusion/include/cons.hpp>
0017 #include <boost/type_traits/remove_const.hpp>
0018 #include <boost/type_traits/is_abstract.hpp>
0019 #include <boost/type_traits/is_function.hpp>
0020 #include <boost/type_traits/add_reference.hpp>
0021 #include <boost/utility/enable_if.hpp>
0022
0023 namespace boost { namespace spirit { namespace detail
0024 {
0025 template <typename T>
0026 struct as_meta_element
0027 : mpl::eval_if_c<is_abstract<T>::value || is_function<T>::value
0028 , add_reference<T>, remove_const<T> >
0029 {};
0030
0031 template <typename T>
0032 struct as_meta_element<T&> : as_meta_element<T>
0033 {};
0034
0035 template <typename T, int N>
0036 struct as_meta_element<T[N]>
0037 {
0038 typedef const T(&type)[N];
0039 };
0040
0041 namespace result_of
0042 {
0043 template <typename Car, typename Cdr = fusion::nil_>
0044 struct make_cons
0045 {
0046 typedef typename as_meta_element<Car>::type car_type; typedef typename fusion::cons<car_type, Cdr> type;
0047 };
0048 }
0049
0050 template <typename Car, typename Cdr>
0051 fusion::cons<typename as_meta_element<Car>::type, Cdr>
0052 make_cons(Car const& car, Cdr const& cdr)
0053 {
0054 typedef typename as_meta_element<Car>::type car_type;
0055 typedef typename fusion::cons<car_type, Cdr> result;
0056 return result(car, cdr);
0057 }
0058
0059 template <typename Car>
0060 fusion::cons<typename as_meta_element<Car>::type>
0061 make_cons(Car const& car)
0062 {
0063 typedef typename as_meta_element<Car>::type car_type;
0064 typedef typename fusion::cons<car_type> result;
0065 return result(car);
0066 }
0067
0068 #if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 0)
0069
0070
0071
0072 template <typename Car>
0073 fusion::cons<typename as_meta_element<Car>::type>
0074 make_cons(Car& car, typename enable_if<is_function<Car> >::type* = 0)
0075 {
0076 typedef typename as_meta_element<Car>::type car_type;
0077 typedef typename fusion::cons<car_type> result;
0078 return result(car);
0079 }
0080 #endif
0081 }}}
0082
0083 #endif