Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 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 | // |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 10 | #ifndef NDNBOOST_RANGE_DETAIL_EXTRACT_OPTIONAL_TYPE_HPP_INCLUDED |
| 11 | #define NDNBOOST_RANGE_DETAIL_EXTRACT_OPTIONAL_TYPE_HPP_INCLUDED |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 12 | |
| 13 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) |
| 14 | # pragma once |
| 15 | #endif |
| 16 | |
| 17 | #include <ndnboost/config.hpp> |
| 18 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 19 | #ifdef NDNBOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 20 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 21 | #define NDNBOOST_RANGE_EXTRACT_OPTIONAL_TYPE( a_typedef ) \ |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 22 | template< typename C > \ |
| 23 | struct extract_ ## a_typedef \ |
| 24 | { \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 25 | typedef NDNBOOST_DEDUCED_TYPENAME C::a_typedef type; \ |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 26 | }; |
| 27 | |
| 28 | #else |
| 29 | |
| 30 | namespace ndnboost { |
| 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. |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 39 | #define NDNBOOST_RANGE_EXTRACT_OPTIONAL_TYPE( a_typedef ) \ |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 40 | template< typename C, typename Enable=void > \ |
| 41 | struct extract_ ## a_typedef \ |
| 42 | {}; \ |
| 43 | template< typename C > \ |
| 44 | struct extract_ ## a_typedef< C \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 45 | , NDNBOOST_DEDUCED_TYPENAME ndnboost::range_detail::exists< NDNBOOST_DEDUCED_TYPENAME C::a_typedef >::type \ |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 46 | > { \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 47 | typedef NDNBOOST_DEDUCED_TYPENAME C::a_typedef type; \ |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | #endif |
| 51 | |
| 52 | #endif // include guard |