#ifndef SPROUT_BREED_TRANSFORM_WHEN_HPP #define SPROUT_BREED_TRANSFORM_WHEN_HPP #include #include #include #include #include #include #include #include #include #include namespace sprout { namespace breed { // // when // template struct when : public PrimitiveTransform { public: typedef Grammar first; typedef PrimitiveTransform second; typedef typename Grammar::breed_grammar breed_grammar; }; template struct when : public sprout::breed::when {}; template struct when : public sprout::breed::transform > { public: typedef Grammar first; typedef external_transform second; typedef typename Grammar::breed_grammar breed_grammar; public: template struct impl : public Data::template when::template impl {}; template struct impl : public Data::template when::template impl {}; }; template struct when : public sprout::breed::transform > { public: typedef Grammar first; typedef R second(Args...); typedef typename Grammar::breed_grammar breed_grammar; public: template struct impl : public sprout::breed::transform_impl { public: typedef typename std::conditional< sprout::breed::is_callable::value, sprout::breed::call, sprout::breed::make >::type which; typedef typename which::template impl::result_type result_type; public: SPROUT_CONSTEXPR result_type operator()( typename impl::expr_param e, typename impl::state_param s, typename impl::data_param d ) const { return typename which::template impl()(e, s, d); } }; }; // // is_callable // template struct is_callable > : public std::true_type {}; // // otherwise // template struct otherwise : public sprout::breed::when {}; // // external_transforms // template struct external_transforms { public: typedef sprout::types::type_tuple map_type; private: template struct map_pred { public: template struct apply : public std::is_same {}; }; public: template struct when : public sprout::breed::when< sprout::breed::_, sprout::types::deref< typename sprout::types::find_if >::type >::type > {}; }; } // namespace breed } // namespace sprout #endif // #ifndef SPROUT_BREED_TRANSFORM_WHEN_HPP