1// 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
5#ifndef BOOST_TYPEOF_TYPEOF_HPP_INCLUDED
6#define BOOST_TYPEOF_TYPEOF_HPP_INCLUDED
7
8#if defined(BOOST_TYPEOF_COMPLIANT)
9# define BOOST_TYPEOF_EMULATION
10#endif
11
12#if defined(BOOST_TYPEOF_EMULATION) && defined(BOOST_TYPEOF_NATIVE)
13# error both typeof emulation and native mode requested
14#endif
15
16#include <boost/typeof/detail/requires_cxx11.hpp>
17#include <boost/config.hpp>
18#include <boost/config/workaround.hpp>
19
20#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1900) && !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) && !defined(BOOST_TYPEOF_EMULATION)
21# define BOOST_TYPEOF_DECLTYPE
22# ifndef BOOST_TYPEOF_NATIVE
23# define BOOST_TYPEOF_NATIVE
24# endif
25
26#elif defined(__COMO__)
27# ifdef __GNUG__
28# ifndef BOOST_TYPEOF_EMULATION
29# ifndef BOOST_TYPEOF_NATIVE
30# define BOOST_TYPEOF_NATIVE
31# endif
32# define BOOST_TYPEOF_KEYWORD typeof
33# endif
34# else
35# ifndef BOOST_TYPEOF_NATIVE
36# ifndef BOOST_TYPEOF_EMULATION
37# define BOOST_TYPEOF_EMULATION
38# endif
39# else
40# error native typeof is not supported
41# endif
42# endif
43
44#elif defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)
45# ifdef __GNUC__
46# ifndef BOOST_TYPEOF_EMULATION
47# ifndef BOOST_TYPEOF_NATIVE
48# define BOOST_TYPEOF_NATIVE
49# endif
50# define BOOST_TYPEOF_KEYWORD __typeof__
51# endif
52# else
53# ifndef BOOST_TYPEOF_NATIVE
54# ifndef BOOST_TYPEOF_EMULATION
55# define BOOST_TYPEOF_EMULATION
56# endif
57# else
58# error native typeof is not supported
59# endif
60# endif
61
62#elif defined(__GNUC__) || defined(__clang__)
63# ifndef BOOST_TYPEOF_EMULATION
64# ifndef BOOST_TYPEOF_NATIVE
65# define BOOST_TYPEOF_NATIVE
66# endif
67# define BOOST_TYPEOF_KEYWORD __typeof__
68# endif
69
70#elif defined(__MWERKS__)
71# if(__MWERKS__ <= 0x3003) // 8.x
72# ifndef BOOST_TYPEOF_EMULATION
73# ifndef BOOST_TYPEOF_NATIVE
74# define BOOST_TYPEOF_NATIVE
75# endif
76# define BOOST_TYPEOF_KEYWORD __typeof__
77# else
78# define BOOST_TYPEOF_EMULATION_UNSUPPORTED
79# endif
80# else // 9.x
81# ifndef BOOST_TYPEOF_EMULATION
82# ifndef BOOST_TYPEOF_NATIVE
83# define BOOST_TYPEOF_NATIVE
84# endif
85# define BOOST_TYPEOF_KEYWORD __typeof__
86# endif
87# endif
88#elif defined BOOST_CODEGEARC
89# ifndef BOOST_TYPEOF_EMULATION
90# ifndef BOOST_TYPEOF_NATIVE
91# define BOOST_TYPEOF_EMULATION_UNSUPPORTED
92# endif
93# else
94# define BOOST_TYPEOF_EMULATION_UNSUPPORTED
95# endif
96#elif defined BOOST_BORLANDC
97# ifndef BOOST_TYPEOF_EMULATION
98# ifndef BOOST_TYPEOF_NATIVE
99# define BOOST_TYPEOF_EMULATION_UNSUPPORTED
100# endif
101# else
102# define BOOST_TYPEOF_EMULATION_UNSUPPORTED
103# endif
104#elif defined __DMC__
105# ifndef BOOST_TYPEOF_EMULATION
106# ifndef BOOST_TYPEOF_NATIVE
107# define BOOST_TYPEOF_NATIVE
108# endif
109# include <boost/typeof/dmc/typeof_impl.hpp>
110# define MSVC_TYPEOF_HACK
111# endif
112#elif defined(_MSC_VER)
113# if (_MSC_VER >= 1310) // 7.1 ->
114# ifndef BOOST_TYPEOF_EMULATION
115# ifndef BOOST_TYPEOF_NATIVE
116# ifndef _MSC_EXTENSIONS
117# define BOOST_TYPEOF_EMULATION
118# else
119# define BOOST_TYPEOF_NATIVE
120# endif
121# endif
122# endif
123# ifdef BOOST_TYPEOF_NATIVE
124# include <boost/typeof/msvc/typeof_impl.hpp>
125# define MSVC_TYPEOF_HACK
126# endif
127# endif
128#elif defined(__HP_aCC)
129# ifndef BOOST_TYPEOF_NATIVE
130# ifndef BOOST_TYPEOF_EMULATION
131# define BOOST_TYPEOF_EMULATION
132# endif
133# else
134# error native typeof is not supported
135# endif
136
137#elif defined(__DECCXX)
138# ifndef BOOST_TYPEOF_NATIVE
139# ifndef BOOST_TYPEOF_EMULATION
140# define BOOST_TYPEOF_EMULATION
141# endif
142# else
143# error native typeof is not supported
144# endif
145
146#elif defined(BOOST_BORLANDC)
147# if (BOOST_BORLANDC < 0x590)
148# define BOOST_TYPEOF_NO_FUNCTION_TYPES
149# define BOOST_TYPEOF_NO_MEMBER_FUNCTION_TYPES
150# endif
151# ifndef BOOST_TYPEOF_NATIVE
152# ifndef BOOST_TYPEOF_EMULATION
153# define BOOST_TYPEOF_EMULATION
154# endif
155# else
156# error native typeof is not supported
157# endif
158#elif defined(__SUNPRO_CC)
159# if (__SUNPRO_CC < 0x590 )
160# ifdef BOOST_TYPEOF_NATIVE
161# error native typeof is not supported
162# endif
163# ifndef BOOST_TYPEOF_EMULATION
164# define BOOST_TYPEOF_EMULATION
165# endif
166# else
167# ifndef BOOST_TYPEOF_EMULATION
168# ifndef BOOST_TYPEOF_NATIVE
169# define BOOST_TYPEOF_NATIVE
170# endif
171# define BOOST_TYPEOF_KEYWORD __typeof__
172# endif
173# endif
174#elif defined(__IBM__TYPEOF__)
175# ifndef BOOST_TYPEOF_EMULATION
176# ifndef BOOST_TYPEOF_NATIVE
177# define BOOST_TYPEOF_NATIVE
178# endif
179# define BOOST_TYPEOF_KEYWORD __typeof__
180# endif
181#else //unknown compiler
182# ifndef BOOST_TYPEOF_NATIVE
183# ifndef BOOST_TYPEOF_EMULATION
184# define BOOST_TYPEOF_EMULATION
185# endif
186# else
187# ifndef BOOST_TYPEOF_KEYWORD
188# define BOOST_TYPEOF_KEYWORD typeof
189# endif
190# endif
191
192#endif
193
194#define BOOST_TYPEOF_UNIQUE_ID()\
195 BOOST_TYPEOF_REGISTRATION_GROUP * 0x10000 + __LINE__
196
197#define BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()\
198 <boost/typeof/incr_registration_group.hpp>
199
200#ifdef BOOST_TYPEOF_EMULATION_UNSUPPORTED
201# include <boost/typeof/unsupported.hpp>
202#elif defined BOOST_TYPEOF_EMULATION
203# define BOOST_TYPEOF_TEXT "using typeof emulation"
204# include <boost/typeof/message.hpp>
205# include <boost/typeof/typeof_impl.hpp>
206# include <boost/typeof/type_encoding.hpp>
207# include <boost/typeof/template_encoding.hpp>
208# include <boost/typeof/modifiers.hpp>
209# include <boost/typeof/pointers_data_members.hpp>
210# include <boost/typeof/register_functions.hpp>
211# include <boost/typeof/register_fundamental.hpp>
212
213#elif defined(BOOST_TYPEOF_NATIVE)
214# define BOOST_TYPEOF_TEXT "using native typeof"
215# include <boost/typeof/message.hpp>
216# ifdef BOOST_TYPEOF_DECLTYPE
217# include <boost/typeof/decltype.hpp>
218# else
219# include <boost/typeof/native.hpp>
220# endif
221#else
222# error typeof configuration error
223#endif
224
225// auto
226#define BOOST_AUTO(Var, Expr) BOOST_TYPEOF(Expr) Var = Expr
227#define BOOST_AUTO_TPL(Var, Expr) BOOST_TYPEOF_TPL(Expr) Var = Expr
228
229#endif//BOOST_TYPEOF_TYPEOF_HPP_INCLUDED
230