1 | // Boost.Range library |
---|
2 | // |
---|
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) |
---|
7 | // |
---|
8 | // For more information, see http://www.boost.org/libs/range/ |
---|
9 | // |
---|
10 | #ifndef BOOST_RANGE_DETAIL_EXTRACT_OPTIONAL_TYPE_HPP_INCLUDED |
---|
11 | #define BOOST_RANGE_DETAIL_EXTRACT_OPTIONAL_TYPE_HPP_INCLUDED |
---|
12 | |
---|
13 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) |
---|
14 | # pragma once |
---|
15 | #endif |
---|
16 | |
---|
17 | #include <boost/config.hpp> |
---|
18 | |
---|
19 | #ifdef BOOST_NO_PARTIAL_TEMPLATE_SPECIALIZATION |
---|
20 | |
---|
21 | #define BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( a_typedef ) \ |
---|
22 | template< typename C > \ |
---|
23 | struct extract_ ## a_typedef \ |
---|
24 | { \ |
---|
25 | typedef BOOST_DEDUCED_TYPENAME C::a_typedef type; \ |
---|
26 | }; |
---|
27 | |
---|
28 | #else |
---|
29 | |
---|
30 | namespace boost { |
---|
31 | namespace range_detail { |
---|
32 | template< typename T > struct exists { typedef void type; }; |
---|
33 | } |
---|
34 | } |
---|
35 | |
---|
36 | // Defines extract_some_typedef<T> which exposes T::some_typedef as |
---|
37 | // extract_some_typedef<T>::type if T::some_typedef exists. Otherwise |
---|
38 | // extract_some_typedef<T> is empty. |
---|
39 | #define BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( a_typedef ) \ |
---|
40 | template< typename C, typename Enable=void > \ |
---|
41 | struct extract_ ## a_typedef \ |
---|
42 | {}; \ |
---|
43 | template< typename C > \ |
---|
44 | struct extract_ ## a_typedef< C \ |
---|
45 | , BOOST_DEDUCED_TYPENAME boost::range_detail::exists< BOOST_DEDUCED_TYPENAME C::a_typedef >::type \ |
---|
46 | > { \ |
---|
47 | typedef BOOST_DEDUCED_TYPENAME C::a_typedef type; \ |
---|
48 | }; |
---|
49 | |
---|
50 | #endif |
---|
51 | |
---|
52 | #endif // include guard |
---|