123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- #ifndef BOOST_PHOENIX_FUNCTION_LAZY_SMART
- #define BOOST_PHOENIX_FUNCTION_LAZY_SMART
- namespace boost {
- namespace phoenix {
- namespace fcpp {
- struct SmartFunctoid {};
- struct smart_functoid0 : public SmartFunctoid {
- template <class Dummy, int i> struct crazy_accepts {
- static const bool args = false;
- };
- template <class Dummy> struct crazy_accepts<Dummy,0> {
- static const bool args = true;
- };
- static const int crazy_max_args = 0;
- };
- struct smart_functoid1 : public SmartFunctoid {
- template <class Dummy, int i> struct crazy_accepts {
- static const bool args = false;
- };
- template <class Dummy> struct crazy_accepts<Dummy,1> {
- static const bool args = true;
- };
- static const int crazy_max_args = 1;
- };
- struct smart_functoid2 : public SmartFunctoid {
- template <class Dummy, int i> struct crazy_accepts {
- static const bool args = false;
- };
- template <class Dummy> struct crazy_accepts<Dummy,1> {
- static const bool args = true;
- };
- template <class Dummy> struct crazy_accepts<Dummy,2> {
- static const bool args = true;
- };
- static const int crazy_max_args = 2;
- };
- struct smart_functoid3 : public SmartFunctoid {
- template <class Dummy, int i> struct crazy_accepts {
- static const bool args = false;
- };
- template <class Dummy> struct crazy_accepts<Dummy,1> {
- static const bool args = true;
- };
- template <class Dummy> struct crazy_accepts<Dummy,2> {
- static const bool args = true;
- };
- template <class Dummy> struct crazy_accepts<Dummy,3> {
- static const bool args = true;
- };
- static const int crazy_max_args = 3;
- };
- namespace impl {
- template <class F, bool b> struct NeededASmartFunctoidButInsteadGot {};
- template <class F> struct NeededASmartFunctoidButInsteadGot<F,true> {
- typedef F type;
- };
- template <bool b> struct Ensure;
- template <> struct Ensure<true> {};
- }
- template <class MaybeASmartFunctoid>
- struct functoid_traits {
- typedef typename boost::remove_reference<MaybeASmartFunctoid>::type MaybeASmartFunctoidT;
- typedef
- typename impl::NeededASmartFunctoidButInsteadGot<MaybeASmartFunctoidT,
- boost::is_base_and_derived<SmartFunctoid,
- MaybeASmartFunctoidT>::value>::type F;
- template <int i> struct accepts {
- static const bool args = F::template crazy_accepts<int,i>::args;
- };
- template <int i> struct ensure_accepts {
- static const bool ok = F::template crazy_accepts<int,i>::args;
- inline static void args() { (void) impl::Ensure<ok>(); }
- };
- static const int max_args = F::crazy_max_args;
- };
- template <typename F>
- struct smart_function0 : public smart_functoid0,
- public boost::phoenix::function<F>
- { };
- template <typename F>
- struct smart_function1 : public smart_functoid1,
- public boost::phoenix::function<F>
- {
- typedef F type;
- };
- template <typename F>
- struct smart_function2 : public smart_functoid2,
- public boost::phoenix::function<F>
- { };
- template <typename F>
- struct smart_function3 : public smart_functoid3,
- public boost::phoenix::function<F>
- { };
- }
- }
- }
- #endif
|