blob: d88b419c7cd8235007ae58da6342c76fd2f313de [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001// 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 Thompson3d613fd2013-10-15 15:39:04 -07005#ifndef NDNBOOST_TYPEOF_NATIVE_HPP_INCLUDED
6#define NDNBOOST_TYPEOF_NATIVE_HPP_INCLUDED
Jeff Thompsona28eed82013-08-22 16:21:10 -07007
8#ifndef MSVC_TYPEOF_HACK
9
Jeff Thompson3d613fd2013-10-15 15:39:04 -070010#ifdef NDNBOOST_NO_SFINAE
Jeff Thompsona28eed82013-08-22 16:21:10 -070011
12namespace 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
24namespace ndnboost { namespace type_of {
Jeff Thompson3d613fd2013-10-15 15:39:04 -070025# ifdef NDNBOOST_NO_SFINAE
Jeff Thompsona28eed82013-08-22 16:21:10 -070026 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 Thompson3d613fd2013-10-15 15:39:04 -070039#endif//NDNBOOST_NO_SFINAE
Jeff Thompsona28eed82013-08-22 16:21:10 -070040
Jeff Thompson3d613fd2013-10-15 15:39:04 -070041#define NDNBOOST_TYPEOF(expr) NDNBOOST_TYPEOF_KEYWORD(ndnboost::type_of::ensure_obj(expr))
42#define NDNBOOST_TYPEOF_TPL NDNBOOST_TYPEOF
Jeff Thompsona28eed82013-08-22 16:21:10 -070043
Jeff Thompson3d613fd2013-10-15 15:39:04 -070044#define NDNBOOST_TYPEOF_NESTED_TYPEDEF_TPL(name,expr) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070045 struct name {\
Jeff Thompson3d613fd2013-10-15 15:39:04 -070046 typedef NDNBOOST_TYPEOF_TPL(expr) type;\
Jeff Thompsona28eed82013-08-22 16:21:10 -070047 };
48
Jeff Thompson3d613fd2013-10-15 15:39:04 -070049#define NDNBOOST_TYPEOF_NESTED_TYPEDEF(name,expr) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070050 struct name {\
Jeff Thompson3d613fd2013-10-15 15:39:04 -070051 typedef NDNBOOST_TYPEOF(expr) type;\
Jeff Thompsona28eed82013-08-22 16:21:10 -070052 };
53
54#endif//MSVC_TYPEOF_HACK
55
Jeff Thompson3d613fd2013-10-15 15:39:04 -070056#define NDNBOOST_TYPEOF_REGISTER_TYPE(x)
57#define NDNBOOST_TYPEOF_REGISTER_TEMPLATE(x, params)
Jeff Thompsona28eed82013-08-22 16:21:10 -070058
Jeff Thompson3d613fd2013-10-15 15:39:04 -070059#endif//NDNBOOST_TYPEOF_NATIVE_HPP_INCLUDED
Jeff Thompsona28eed82013-08-22 16:21:10 -070060