williamr@2: // -- Boost Lambda Library - actions.hpp ---------------------------------- williamr@2: williamr@2: // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi) williamr@2: // williamr@2: // Distributed under the Boost Software License, Version 1.0. (See williamr@2: // accompanying file LICENSE_1_0.txt or copy at williamr@2: // http://www.boost.org/LICENSE_1_0.txt) williamr@2: williamr@2: // For more information, see www.boost.org williamr@2: williamr@2: // ---------------------------------------------------------------- williamr@2: williamr@2: #ifndef BOOST_LAMBDA_ACTIONS_HPP williamr@2: #define BOOST_LAMBDA_ACTIONS_HPP williamr@2: williamr@2: namespace boost { williamr@2: namespace lambda { williamr@2: williamr@2: williamr@2: williamr@2: template class action; williamr@2: williamr@2: // these need to be defined here, since the corresponding lambda williamr@2: // functions are members of lambda_functor classes williamr@2: williamr@2: class assignment_action {}; williamr@2: class subscript_action {}; williamr@2: williamr@2: template class other_action; williamr@2: williamr@2: // action for specifying the explicit return type williamr@2: template class explicit_return_type_action {}; williamr@2: williamr@2: // action for preventing the expansion of a lambda expression williamr@2: struct protect_action {}; williamr@2: williamr@2: // must be defined here, comma is a special case williamr@2: struct comma_action {}; williamr@2: williamr@2: williamr@2: // actions, for which the existence of protect is checked in return type williamr@2: // deduction. williamr@2: williamr@2: template struct is_protectable { williamr@2: BOOST_STATIC_CONSTANT(bool, value = false); williamr@2: }; williamr@2: williamr@2: // NOTE: comma action is protectable. Other protectable actions williamr@2: // are listed in operator_actions.hpp williamr@2: williamr@2: template<> struct is_protectable > { williamr@2: BOOST_STATIC_CONSTANT(bool, value = true); williamr@2: }; williamr@2: williamr@2: williamr@2: namespace detail { williamr@2: williamr@2: // this type is used in return type deductions to signal that deduction williamr@2: // did not find a result. It does not necessarily mean an error, it commonly williamr@2: // means that something else should be tried. williamr@2: class unspecified {}; williamr@2: } williamr@2: williamr@2: // function action is a special case: bind functions can be called with williamr@2: // the return type specialized explicitly e.g. bind(foo); williamr@2: // If this call syntax is used, the return type is stored in the latter williamr@2: // argument of function_action template. Otherwise the argument gets the type williamr@2: // 'unspecified'. williamr@2: // This argument is only relevant in the return type deduction code williamr@2: template williamr@2: class function_action {}; williamr@2: williamr@2: template class function_action<1, T> { williamr@2: public: williamr@2: template williamr@2: static RET apply(A1& a1) { williamr@2: return function_adaptor::type>:: williamr@2: template apply(a1); williamr@2: } williamr@2: }; williamr@2: williamr@2: template class function_action<2, T> { williamr@2: public: williamr@2: template williamr@2: static RET apply(A1& a1, A2& a2) { williamr@2: return function_adaptor::type>:: williamr@2: template apply(a1, a2); williamr@2: } williamr@2: }; williamr@2: williamr@2: template class function_action<3, T> { williamr@2: public: williamr@2: template williamr@2: static RET apply(A1& a1, A2& a2, A3& a3) { williamr@2: return function_adaptor::type>:: williamr@2: template apply(a1, a2, a3); williamr@2: } williamr@2: }; williamr@2: williamr@2: template class function_action<4, T> { williamr@2: public: williamr@2: template williamr@2: static RET apply(A1& a1, A2& a2, A3& a3, A4& a4) { williamr@2: return function_adaptor::type>:: williamr@2: template apply(a1, a2, a3, a4); williamr@2: } williamr@2: }; williamr@2: williamr@2: template class function_action<5, T> { williamr@2: public: williamr@2: template williamr@2: static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5) { williamr@2: return function_adaptor::type>:: williamr@2: template apply(a1, a2, a3, a4, a5); williamr@2: } williamr@2: }; williamr@2: williamr@2: template class function_action<6, T> { williamr@2: public: williamr@2: template williamr@2: static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6) { williamr@2: return function_adaptor::type>:: williamr@2: template apply(a1, a2, a3, a4, a5, a6); williamr@2: } williamr@2: }; williamr@2: williamr@2: template class function_action<7, T> { williamr@2: public: williamr@2: template williamr@2: static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7) { williamr@2: return function_adaptor::type>:: williamr@2: template apply(a1, a2, a3, a4, a5, a6, a7); williamr@2: } williamr@2: }; williamr@2: williamr@2: template class function_action<8, T> { williamr@2: public: williamr@2: template williamr@2: static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7, williamr@2: A8& a8) { williamr@2: return function_adaptor::type>:: williamr@2: template apply(a1, a2, a3, a4, a5, a6, a7, a8); williamr@2: } williamr@2: }; williamr@2: williamr@2: template class function_action<9, T> { williamr@2: public: williamr@2: template williamr@2: static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7, williamr@2: A8& a8, A9& a9) { williamr@2: return function_adaptor::type>:: williamr@2: template apply(a1, a2, a3, a4, a5, a6, a7, a8, a9); williamr@2: } williamr@2: }; williamr@2: williamr@2: template class function_action<10, T> { williamr@2: public: williamr@2: template williamr@2: static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7, williamr@2: A8& a8, A9& a9, A10& a10) { williamr@2: return function_adaptor::type>:: williamr@2: template apply(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); williamr@2: } williamr@2: }; williamr@2: williamr@2: } // namespace lambda williamr@2: } // namespace boost williamr@2: williamr@2: #endif