| 1 |  | 
|---|
| 2 | #ifndef BOOST_MPL_SWITCH_HPP_INCLUDED | 
|---|
| 3 | #define BOOST_MPL_SWITCH_HPP_INCLUDED | 
|---|
| 4 |  | 
|---|
| 5 | // Copyright Aleksey Gurtovoy 2003-2004 | 
|---|
| 6 | // | 
|---|
| 7 | // Distributed under the Boost Software License, Version 1.0.  | 
|---|
| 8 | // (See accompanying file LICENSE_1_0.txt or copy at  | 
|---|
| 9 | // http://www.boost.org/LICENSE_1_0.txt) | 
|---|
| 10 | // | 
|---|
| 11 | // See http://www.boost.org/libs/mpl for documentation. | 
|---|
| 12 |  | 
|---|
| 13 | // $Source: /cvsroot/boost/boost/boost/mpl/switch.hpp,v $ | 
|---|
| 14 | // $Date: 2004/09/02 15:40:42 $ | 
|---|
| 15 | // $Revision: 1.3 $ | 
|---|
| 16 |  | 
|---|
| 17 | #include <boost/mpl/find_if.hpp> | 
|---|
| 18 | #include <boost/mpl/deref.hpp> | 
|---|
| 19 | #include <boost/mpl/lambda.hpp> | 
|---|
| 20 | #include <boost/mpl/apply.hpp> | 
|---|
| 21 | #include <boost/mpl/pair.hpp> | 
|---|
| 22 | #include <boost/mpl/aux_/na_spec.hpp> | 
|---|
| 23 | #include <boost/mpl/aux_/lambda_support.hpp> | 
|---|
| 24 |  | 
|---|
| 25 | namespace boost { namespace mpl { | 
|---|
| 26 |  | 
|---|
| 27 | template<  | 
|---|
| 28 |       typename BOOST_MPL_AUX_NA_PARAM(Body) | 
|---|
| 29 |     , typename BOOST_MPL_AUX_NA_PARAM(T) | 
|---|
| 30 |     > | 
|---|
| 31 | struct switch_ | 
|---|
| 32 | { | 
|---|
| 33 |     typedef typename find_if< | 
|---|
| 34 |           Body | 
|---|
| 35 |         , apply1< lambda< first<_1> >, T > | 
|---|
| 36 |         >::type iter_; | 
|---|
| 37 |          | 
|---|
| 38 |     typedef typename deref<iter_>::type pair_; | 
|---|
| 39 |     typedef typename lambda< typename second<pair_>::type >::type f_; | 
|---|
| 40 |     typedef typename apply1<f_,T>::type type; | 
|---|
| 41 |  | 
|---|
| 42 |     BOOST_MPL_AUX_LAMBDA_SUPPORT(2,switch_,(Body,T)) | 
|---|
| 43 | }; | 
|---|
| 44 |  | 
|---|
| 45 | BOOST_MPL_AUX_NA_SPEC(2, switch_) | 
|---|
| 46 |  | 
|---|
| 47 | }} | 
|---|
| 48 |  | 
|---|
| 49 | #endif // BOOST_MPL_SWITCH_HPP_INCLUDED | 
|---|