blob: 86a47b5dcf8f3189b5c1f7434f7b6d2c0dd65238 [file] [log] [blame]
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07001// 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 Thompson3d613fd2013-10-15 15:39:04 -070010#ifndef NDNBOOST_RANGE_DETAIL_EXTRACT_OPTIONAL_TYPE_HPP_INCLUDED
11#define NDNBOOST_RANGE_DETAIL_EXTRACT_OPTIONAL_TYPE_HPP_INCLUDED
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070012
13#if defined(_MSC_VER) && (_MSC_VER >= 1200)
14# pragma once
15#endif
16
17#include <ndnboost/config.hpp>
18
Jeff Thompson3d613fd2013-10-15 15:39:04 -070019#ifdef NDNBOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070020
Jeff Thompson3d613fd2013-10-15 15:39:04 -070021#define NDNBOOST_RANGE_EXTRACT_OPTIONAL_TYPE( a_typedef ) \
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070022 template< typename C > \
23 struct extract_ ## a_typedef \
24 { \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070025 typedef NDNBOOST_DEDUCED_TYPENAME C::a_typedef type; \
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070026 };
27
28#else
29
30namespace 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 Thompson3d613fd2013-10-15 15:39:04 -070039#define NDNBOOST_RANGE_EXTRACT_OPTIONAL_TYPE( a_typedef ) \
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070040 template< typename C, typename Enable=void > \
41 struct extract_ ## a_typedef \
42 {}; \
43 template< typename C > \
44 struct extract_ ## a_typedef< C \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070045 , NDNBOOST_DEDUCED_TYPENAME ndnboost::range_detail::exists< NDNBOOST_DEDUCED_TYPENAME C::a_typedef >::type \
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070046 > { \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070047 typedef NDNBOOST_DEDUCED_TYPENAME C::a_typedef type; \
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070048 };
49
50#endif
51
52#endif // include guard