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