diff --git a/sprout/functional/bind/bind.hpp b/sprout/functional/bind/bind.hpp index f1152a47..805a3b92 100644 --- a/sprout/functional/bind/bind.hpp +++ b/sprout/functional/bind/bind.hpp @@ -288,14 +288,14 @@ namespace sprout { }; // - // bind_result + // res_binder // template - class bind_result; + class res_binder; template - class bind_result { + class res_binder { private: - typedef bind_result self_type; + typedef res_binder self_type; typedef typename sprout::index_pack::type bound_indexes; private: template @@ -385,11 +385,11 @@ namespace sprout { public: typedef Result result_type; template - explicit bind_result(Functor const& f, Args&&... args) + explicit res_binder(Functor const& f, Args&&... args) : f_(f) , bound_args_(sprout::forward(args)...) {} - bind_result(bind_result const&) = default; + res_binder(res_binder const&) = default; template result_type operator()(Args&&... args) { return call( @@ -428,33 +428,87 @@ namespace sprout { : public std::true_type {}; template - struct is_bind_expression > + struct is_bind_expression > : public std::true_type {}; namespace detail { + template + struct complete_placeholder { + public: + typedef BoundArg type; + }; + template + struct complete_placeholder< + Index, BoundArg, + typename std::enable_if<(sprout::is_placeholder::value == -1)>::type + > { + public: + typedef sprout::placeholder type; + }; + + template + struct binder_complete_placeholders_impl; + template + struct binder_complete_placeholders_impl, BoundArgs...> { + public: + typedef sprout::binder::type...)> type; + }; + template + struct binder_complete_placeholders + : public sprout::detail::binder_complete_placeholders_impl::type, BoundArgs...> + {}; + + template + struct res_binder_complete_placeholders_impl; + template + struct res_binder_complete_placeholders_impl, BoundArgs...> { + public: + typedef sprout::res_binder::type...)> type; + }; + template + struct res_binder_complete_placeholders + : public sprout::detail::res_binder_complete_placeholders_impl::type, BoundArgs...> + {}; + template struct bind_helper { public: typedef sprout::detail::maybe_wrap_member_pointer::type> maybe_type; typedef typename maybe_type::type func_type; - typedef sprout::binder::type...)> type; + typedef typename sprout::detail::binder_complete_placeholders::type...>::type type; +// typedef sprout::binder::type...)> type; }; - template - struct bindres_helper { + struct res_bind_helper { public: typedef sprout::detail::maybe_wrap_member_pointer::type> maybe_type; typedef typename maybe_type::type functor_type; - typedef sprout::bind_result::type...)> type; + typedef typename sprout::detail::res_binder_complete_placeholders::type...>::type type; +// typedef sprout::res_binder::type...)> type; }; } // namespace detail + // + // bind_result + // res_bind_result + // + template + struct bind_result { + public: + typedef typename sprout::detail::bind_helper::type type; + }; + template + struct res_bind_result { + public: + typedef typename sprout::detail::res_bind_helper::type type; + }; + // // bind // template - inline SPROUT_CONSTEXPR typename sprout::detail::bind_helper::type + inline SPROUT_CONSTEXPR typename sprout::bind_result::type bind(F&& f, BoundArgs&&... args) { typedef sprout::detail::bind_helper helper_type; typedef typename helper_type::maybe_type maybe_type; @@ -462,9 +516,9 @@ namespace sprout { return result_type(maybe_type::do_wrap(sprout::forward(f)), sprout::forward(args)...); } template - inline SPROUT_CONSTEXPR typename sprout::detail::bindres_helper::type + inline SPROUT_CONSTEXPR typename sprout::res_bind_result::type bind(F&& f, BoundArgs&&... args) { - typedef sprout::detail::bindres_helper helper_type; + typedef sprout::detail::res_bind_helper helper_type; typedef typename helper_type::maybe_type maybe_type; typedef typename helper_type::type result_type; return result_type(maybe_type::do_wrap(sprout::forward(f)), sprout::forward(args)...); @@ -479,7 +533,7 @@ namespace sprout { return sprout::bind(sprout::forward(f), sprout::forward(args)...); } template - inline SPROUT_CONSTEXPR typename sprout::detail::bindres_helper::type const + inline SPROUT_CONSTEXPR typename sprout::detail::res_bind_helper::type const cbind(F&& f, BoundArgs&&... args) { return sprout::bind(sprout::forward(f), sprout::forward(args)...); } diff --git a/sprout/functional/bind/placeholder.hpp b/sprout/functional/bind/placeholder.hpp index 541ac947..d1b7c4ae 100644 --- a/sprout/functional/bind/placeholder.hpp +++ b/sprout/functional/bind/placeholder.hpp @@ -10,6 +10,14 @@ namespace sprout { // template struct placeholder {}; + template<> + struct placeholder<-1> { + public: + template + SPROUT_CONSTEXPR operator sprout::placeholder() const { + return sprout::placeholder(); + } + }; namespace placeholders { namespace { @@ -43,6 +51,8 @@ namespace sprout { SPROUT_STATIC_CONSTEXPR sprout::placeholder<28> _28 = {}; SPROUT_STATIC_CONSTEXPR sprout::placeholder<29> _29 = {}; SPROUT_STATIC_CONSTEXPR sprout::placeholder<30> _30 = {}; + + SPROUT_STATIC_CONSTEXPR sprout::placeholder<-1> _ = {}; } // anonymous-namespace } // namespace placeholders using sprout::placeholders::_1; @@ -76,6 +86,8 @@ namespace sprout { using sprout::placeholders::_29; using sprout::placeholders::_30; + using sprout::placeholders::_; + // // is_placeholder //