1 // Boost.TypeErasure library 2 // 3 // Copyright 2011 Steven Watanabe 4 // 5 // Distributed under the Boost Software License Version 1.0. (See 6 // accompanying file LICENSE_1_0.txt or copy at 7 // http://www.boost.org/LICENSE_1_0.txt) 8 // 9 // $Id$ 10 11 #ifndef BOOST_TYPE_ERASURE_DEDUCED_HPP_INCLUDED 12 #define BOOST_TYPE_ERASURE_DEDUCED_HPP_INCLUDED 13 14 #include <boost/mpl/eval_if.hpp> 15 #include <boost/mpl/identity.hpp> 16 #include <boost/mpl/set.hpp> 17 #include <boost/mpl/empty.hpp> 18 #include <boost/type_erasure/detail/get_placeholders.hpp> 19 #include <boost/type_erasure/placeholder.hpp> 20 21 namespace boost { 22 namespace type_erasure { 23 24 /** 25 * A placeholder for an associated type. The type corresponding 26 * to this placeholder is deduced by substituting placeholders 27 * in the arguments of the metafunction and then evaluating it. 28 * 29 * When using @ref deduced in a template context, if it is possible for 30 * Metafunction to contain no placeholders at all, use the nested type, 31 * to automatically evaluate it early as needed. 32 */ 33 template<class Metafunction> 34 struct deduced : ::boost::type_erasure::placeholder 35 { 36 typedef typename ::boost::mpl::eval_if< 37 ::boost::mpl::empty< 38 typename ::boost::type_erasure::detail::get_placeholders< 39 Metafunction, 40 #ifndef BOOST_TYPE_ERASURE_USE_MP11 41 ::boost::mpl::set0<> 42 #else 43 ::boost::mp11::mp_list<> 44 #endif 45 >::type 46 >, 47 Metafunction, 48 ::boost::mpl::identity< 49 ::boost::type_erasure::deduced<Metafunction> 50 > 51 >::type type; 52 }; 53 54 } 55 } 56 57 #endif 58