blob: 4847baf81b69595a87654f37b99b7ce6db6c80b4 [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001// Copyright (C) 2004 Arkadiy Vertleyb
2// Distributed under the Boost Software License, Version 1.0. (See accompanying
3// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4
Jeff Thompson3d613fd2013-10-15 15:39:04 -07005#ifndef NDNBOOST_TYPEOF_TYPEOF_HPP_INCLUDED
6#define NDNBOOST_TYPEOF_TYPEOF_HPP_INCLUDED
Jeff Thompsona28eed82013-08-22 16:21:10 -07007
Jeff Thompson3d613fd2013-10-15 15:39:04 -07008#if defined(NDNBOOST_TYPEOF_COMPLIANT)
9# define NDNBOOST_TYPEOF_EMULATION
Jeff Thompsona28eed82013-08-22 16:21:10 -070010#endif
11
Jeff Thompson3d613fd2013-10-15 15:39:04 -070012#if defined(NDNBOOST_TYPEOF_EMULATION) && defined(NDNBOOST_TYPEOF_NATIVE)
Jeff Thompsona28eed82013-08-22 16:21:10 -070013# error both typeof emulation and native mode requested
14#endif
15
16#if defined(__COMO__)
17# ifdef __GNUG__
Jeff Thompson3d613fd2013-10-15 15:39:04 -070018# ifndef NDNBOOST_TYPEOF_EMULATION
19# ifndef NDNBOOST_TYPEOF_NATIVE
20# define NDNBOOST_TYPEOF_NATIVE
Jeff Thompsona28eed82013-08-22 16:21:10 -070021# endif
Jeff Thompson3d613fd2013-10-15 15:39:04 -070022# define NDNBOOST_TYPEOF_KEYWORD typeof
Jeff Thompsona28eed82013-08-22 16:21:10 -070023# endif
24# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070025# ifndef NDNBOOST_TYPEOF_NATIVE
26# ifndef NDNBOOST_TYPEOF_EMULATION
27# define NDNBOOST_TYPEOF_EMULATION
Jeff Thompsona28eed82013-08-22 16:21:10 -070028# endif
29# else
30# error native typeof is not supported
31# endif
32# endif
33
34#elif defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)
35# ifdef __GNUC__
Jeff Thompson3d613fd2013-10-15 15:39:04 -070036# ifndef NDNBOOST_TYPEOF_EMULATION
37# ifndef NDNBOOST_TYPEOF_NATIVE
38# define NDNBOOST_TYPEOF_NATIVE
Jeff Thompsona28eed82013-08-22 16:21:10 -070039# endif
Jeff Thompson3d613fd2013-10-15 15:39:04 -070040# define NDNBOOST_TYPEOF_KEYWORD __typeof__
Jeff Thompsona28eed82013-08-22 16:21:10 -070041# endif
42# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070043# ifndef NDNBOOST_TYPEOF_NATIVE
44# ifndef NDNBOOST_TYPEOF_EMULATION
45# define NDNBOOST_TYPEOF_EMULATION
Jeff Thompsona28eed82013-08-22 16:21:10 -070046# endif
47# else
48# error native typeof is not supported
49# endif
50# endif
51
52#elif defined(__GNUC__)
Jeff Thompson3d613fd2013-10-15 15:39:04 -070053# ifndef NDNBOOST_TYPEOF_EMULATION
54# ifndef NDNBOOST_TYPEOF_NATIVE
55# define NDNBOOST_TYPEOF_NATIVE
Jeff Thompsona28eed82013-08-22 16:21:10 -070056# endif
Jeff Thompson3d613fd2013-10-15 15:39:04 -070057# define NDNBOOST_TYPEOF_KEYWORD __typeof__
Jeff Thompsona28eed82013-08-22 16:21:10 -070058# endif
59
60#elif defined(__MWERKS__)
61# if(__MWERKS__ <= 0x3003) // 8.x
Jeff Thompson3d613fd2013-10-15 15:39:04 -070062# ifndef NDNBOOST_TYPEOF_EMULATION
63# ifndef NDNBOOST_TYPEOF_NATIVE
64# define NDNBOOST_TYPEOF_NATIVE
Jeff Thompsona28eed82013-08-22 16:21:10 -070065# endif
Jeff Thompson3d613fd2013-10-15 15:39:04 -070066# define NDNBOOST_TYPEOF_KEYWORD __typeof__
Jeff Thompsona28eed82013-08-22 16:21:10 -070067# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070068# define NDNBOOST_TYPEOF_EMULATION_UNSUPPORTED
Jeff Thompsona28eed82013-08-22 16:21:10 -070069# endif
70# else // 9.x
Jeff Thompson3d613fd2013-10-15 15:39:04 -070071# ifndef NDNBOOST_TYPEOF_EMULATION
72# ifndef NDNBOOST_TYPEOF_NATIVE
73# define NDNBOOST_TYPEOF_NATIVE
Jeff Thompsona28eed82013-08-22 16:21:10 -070074# endif
Jeff Thompson3d613fd2013-10-15 15:39:04 -070075# define NDNBOOST_TYPEOF_KEYWORD __typeof__
Jeff Thompsona28eed82013-08-22 16:21:10 -070076# endif
77# endif
78#elif defined __CODEGEARC__
Jeff Thompson3d613fd2013-10-15 15:39:04 -070079# ifndef NDNBOOST_TYPEOF_EMULATION
80# ifndef NDNBOOST_TYPEOF_NATIVE
81# define NDNBOOST_TYPEOF_EMULATION_UNSUPPORTED
Jeff Thompsona28eed82013-08-22 16:21:10 -070082# endif
83# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070084# define NDNBOOST_TYPEOF_EMULATION_UNSUPPORTED
Jeff Thompsona28eed82013-08-22 16:21:10 -070085# endif
86#elif defined __BORLANDC__
Jeff Thompson3d613fd2013-10-15 15:39:04 -070087# ifndef NDNBOOST_TYPEOF_EMULATION
88# ifndef NDNBOOST_TYPEOF_NATIVE
89# define NDNBOOST_TYPEOF_EMULATION_UNSUPPORTED
Jeff Thompsona28eed82013-08-22 16:21:10 -070090# endif
91# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070092# define NDNBOOST_TYPEOF_EMULATION_UNSUPPORTED
Jeff Thompsona28eed82013-08-22 16:21:10 -070093# endif
94#elif defined __DMC__
Jeff Thompson3d613fd2013-10-15 15:39:04 -070095# ifndef NDNBOOST_TYPEOF_EMULATION
96# ifndef NDNBOOST_TYPEOF_NATIVE
97# define NDNBOOST_TYPEOF_NATIVE
Jeff Thompsona28eed82013-08-22 16:21:10 -070098# endif
99# include <ndnboost/typeof/dmc/typeof_impl.hpp>
100# define MSVC_TYPEOF_HACK
101# endif
102#elif defined(_MSC_VER)
103# if (_MSC_VER <= 1300) // 6.5, 7.0
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700104# ifndef NDNBOOST_TYPEOF_EMULATION
105# ifndef NDNBOOST_TYPEOF_NATIVE
106# define NDNBOOST_TYPEOF_NATIVE
Jeff Thompsona28eed82013-08-22 16:21:10 -0700107# endif
108# include <ndnboost/typeof/msvc/typeof_impl.hpp>
109# define MSVC_TYPEOF_HACK
110# else
111# error typeof emulation is not supported
112# endif
113# elif (_MSC_VER >= 1310) // 7.1 ->
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700114# ifndef NDNBOOST_TYPEOF_EMULATION
115# ifndef NDNBOOST_TYPEOF_NATIVE
Jeff Thompsona28eed82013-08-22 16:21:10 -0700116# ifndef _MSC_EXTENSIONS
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700117# define NDNBOOST_TYPEOF_EMULATION
Jeff Thompsona28eed82013-08-22 16:21:10 -0700118# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700119# define NDNBOOST_TYPEOF_NATIVE
Jeff Thompsona28eed82013-08-22 16:21:10 -0700120# endif
121# endif
122# endif
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700123# ifdef NDNBOOST_TYPEOF_NATIVE
Jeff Thompsona28eed82013-08-22 16:21:10 -0700124# include <ndnboost/typeof/msvc/typeof_impl.hpp>
125# define MSVC_TYPEOF_HACK
126# endif
127# endif
128#elif defined(__HP_aCC)
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700129# ifndef NDNBOOST_TYPEOF_NATIVE
130# ifndef NDNBOOST_TYPEOF_EMULATION
131# define NDNBOOST_TYPEOF_EMULATION
Jeff Thompsona28eed82013-08-22 16:21:10 -0700132# endif
133# else
134# error native typeof is not supported
135# endif
136
137#elif defined(__DECCXX)
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700138# ifndef NDNBOOST_TYPEOF_NATIVE
139# ifndef NDNBOOST_TYPEOF_EMULATION
140# define NDNBOOST_TYPEOF_EMULATION
Jeff Thompsona28eed82013-08-22 16:21:10 -0700141# endif
142# else
143# error native typeof is not supported
144# endif
145
146#elif defined(__BORLANDC__)
147# if (__BORLANDC__ < 0x590)
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700148# define NDNBOOST_TYPEOF_NO_FUNCTION_TYPES
149# define NDNBOOST_TYPEOF_NO_MEMBER_FUNCTION_TYPES
Jeff Thompsona28eed82013-08-22 16:21:10 -0700150# endif
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700151# ifndef NDNBOOST_TYPEOF_NATIVE
152# ifndef NDNBOOST_TYPEOF_EMULATION
153# define NDNBOOST_TYPEOF_EMULATION
Jeff Thompsona28eed82013-08-22 16:21:10 -0700154# endif
155# else
156# error native typeof is not supported
157# endif
158#elif defined(__SUNPRO_CC)
159# if (__SUNPRO_CC < 0x590 )
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700160# ifdef NDNBOOST_TYPEOF_NATIVE
Jeff Thompsona28eed82013-08-22 16:21:10 -0700161# error native typeof is not supported
162# endif
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700163# ifndef NDNBOOST_TYPEOF_EMULATION
164# define NDNBOOST_TYPEOF_EMULATION
Jeff Thompsona28eed82013-08-22 16:21:10 -0700165# endif
166# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700167# ifndef NDNBOOST_TYPEOF_EMULATION
168# ifndef NDNBOOST_TYPEOF_NATIVE
169# define NDNBOOST_TYPEOF_NATIVE
Jeff Thompsona28eed82013-08-22 16:21:10 -0700170# endif
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700171# define NDNBOOST_TYPEOF_KEYWORD __typeof__
Jeff Thompsona28eed82013-08-22 16:21:10 -0700172# endif
173# endif
174#else //unknown compiler
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700175# ifndef NDNBOOST_TYPEOF_NATIVE
176# ifndef NDNBOOST_TYPEOF_EMULATION
177# define NDNBOOST_TYPEOF_EMULATION
Jeff Thompsona28eed82013-08-22 16:21:10 -0700178# endif
179# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700180# ifndef NDNBOOST_TYPEOF_KEYWORD
181# define NDNBOOST_TYPEOF_KEYWORD typeof
Jeff Thompsona28eed82013-08-22 16:21:10 -0700182# endif
183# endif
184
185#endif
186
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700187#define NDNBOOST_TYPEOF_UNIQUE_ID()\
188 NDNBOOST_TYPEOF_REGISTRATION_GROUP * 0x10000 + __LINE__
Jeff Thompsona28eed82013-08-22 16:21:10 -0700189
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700190#define NDNBOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()\
Jeff Thompsona28eed82013-08-22 16:21:10 -0700191 <ndnboost/typeof/incr_registration_group.hpp>
192
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700193#ifdef NDNBOOST_TYPEOF_EMULATION_UNSUPPORTED
Jeff Thompsona28eed82013-08-22 16:21:10 -0700194# include <ndnboost/typeof/unsupported.hpp>
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700195#elif defined NDNBOOST_TYPEOF_EMULATION
196# define NDNBOOST_TYPEOF_TEXT "using typeof emulation"
Jeff Thompsona28eed82013-08-22 16:21:10 -0700197# include <ndnboost/typeof/message.hpp>
198# include <ndnboost/typeof/typeof_impl.hpp>
199# include <ndnboost/typeof/type_encoding.hpp>
200# include <ndnboost/typeof/template_encoding.hpp>
201# include <ndnboost/typeof/modifiers.hpp>
202# include <ndnboost/typeof/pointers_data_members.hpp>
203# include <ndnboost/typeof/register_functions.hpp>
204# include <ndnboost/typeof/register_fundamental.hpp>
205
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700206#elif defined(NDNBOOST_TYPEOF_NATIVE)
207# define NDNBOOST_TYPEOF_TEXT "using native typeof"
Jeff Thompsona28eed82013-08-22 16:21:10 -0700208# include <ndnboost/typeof/message.hpp>
209# include <ndnboost/typeof/native.hpp>
210#else
211# error typeof configuration error
212#endif
213
214// auto
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700215#define NDNBOOST_AUTO(Var, Expr) NDNBOOST_TYPEOF(Expr) Var = Expr
216#define NDNBOOST_AUTO_TPL(Var, Expr) NDNBOOST_TYPEOF_TPL(Expr) Var = Expr
Jeff Thompsona28eed82013-08-22 16:21:10 -0700217
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700218#endif//NDNBOOST_TYPEOF_TYPEOF_HPP_INCLUDED