3 // Copyright Arno Schoedl & Neil Groves 2009.
4 // Use, modification and distribution is subject to the Boost Software
5 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // For more information, see http://www.boost.org/libs/range/
10 #ifndef BOOST_RANGE_DETAIL_EXTRACT_OPTIONAL_TYPE_HPP_INCLUDED
11 #define BOOST_RANGE_DETAIL_EXTRACT_OPTIONAL_TYPE_HPP_INCLUDED
17 #include <boost/config.hpp>
18 #include <boost/preprocessor/cat.hpp>
19 #include <boost/mpl/has_xxx.hpp>
21 #if !defined(BOOST_MPL_CFG_NO_HAS_XXX)
23 // Defines extract_some_typedef<T> which exposes T::some_typedef as
24 // extract_some_typedef<T>::type if T::some_typedef exists. Otherwise
25 // extract_some_typedef<T> is empty.
26 #define BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( a_typedef ) \
27 BOOST_MPL_HAS_XXX_TRAIT_DEF(a_typedef) \
28 template< typename C, bool B = BOOST_PP_CAT(has_, a_typedef)<C>::value > \
29 struct BOOST_PP_CAT(extract_, a_typedef) \
31 template< typename C > \
32 struct BOOST_PP_CAT(extract_, a_typedef)< C, true > \
34 typedef BOOST_DEDUCED_TYPENAME C::a_typedef type; \
39 #define BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( a_typedef ) \
40 template< typename C > \
41 struct BOOST_PP_CAT(extract_, a_typedef) \
43 typedef BOOST_DEDUCED_TYPENAME C::a_typedef type; \
48 #endif // include guard