Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | // Copyright (C) 2006 Arkadiy Vertleyb |
| 2 | // Use, modification and distribution is subject to the Boost Software |
| 3 | // License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) |
| 4 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 5 | #ifndef NDNBOOST_TYPEOF_NATIVE_HPP_INCLUDED |
| 6 | #define NDNBOOST_TYPEOF_NATIVE_HPP_INCLUDED |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 7 | |
| 8 | #ifndef MSVC_TYPEOF_HACK |
| 9 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 10 | #ifdef NDNBOOST_NO_SFINAE |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 11 | |
| 12 | namespace ndnboost { namespace type_of { |
| 13 | |
| 14 | template<class T> |
| 15 | T& ensure_obj(const T&); |
| 16 | |
| 17 | }} |
| 18 | |
| 19 | #else |
| 20 | |
| 21 | #include <ndnboost/type_traits/is_function.hpp> |
| 22 | #include <ndnboost/utility/enable_if.hpp> |
| 23 | |
| 24 | namespace ndnboost { namespace type_of { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 25 | # ifdef NDNBOOST_NO_SFINAE |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 26 | template<class T> |
| 27 | T& ensure_obj(const T&); |
| 28 | # else |
| 29 | template<typename T> |
| 30 | typename enable_if<is_function<T>, T&>::type |
| 31 | ensure_obj(T&); |
| 32 | |
| 33 | template<typename T> |
| 34 | typename disable_if<is_function<T>, T&>::type |
| 35 | ensure_obj(const T&); |
| 36 | # endif |
| 37 | }} |
| 38 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 39 | #endif//NDNBOOST_NO_SFINAE |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 40 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 41 | #define NDNBOOST_TYPEOF(expr) NDNBOOST_TYPEOF_KEYWORD(ndnboost::type_of::ensure_obj(expr)) |
| 42 | #define NDNBOOST_TYPEOF_TPL NDNBOOST_TYPEOF |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 43 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 44 | #define NDNBOOST_TYPEOF_NESTED_TYPEDEF_TPL(name,expr) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 45 | struct name {\ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 46 | typedef NDNBOOST_TYPEOF_TPL(expr) type;\ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 47 | }; |
| 48 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 49 | #define NDNBOOST_TYPEOF_NESTED_TYPEDEF(name,expr) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 50 | struct name {\ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 51 | typedef NDNBOOST_TYPEOF(expr) type;\ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | #endif//MSVC_TYPEOF_HACK |
| 55 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 56 | #define NDNBOOST_TYPEOF_REGISTER_TYPE(x) |
| 57 | #define NDNBOOST_TYPEOF_REGISTER_TEMPLATE(x, params) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 58 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 59 | #endif//NDNBOOST_TYPEOF_NATIVE_HPP_INCLUDED |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 60 | |