passenger 4.0.19 → 4.0.20

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (65) hide show
  1. checksums.yaml +15 -0
  2. checksums.yaml.gz.asc +12 -0
  3. data.tar.gz.asc +7 -7
  4. data/NEWS +22 -0
  5. data/bin/passenger-install-apache2-module +2 -2
  6. data/bin/passenger-install-nginx-module +2 -2
  7. data/build/agents.rb +6 -0
  8. data/build/apache2.rb +1 -0
  9. data/build/basics.rb +2 -2
  10. data/build/cplusplus_support.rb +6 -1
  11. data/build/cxx_tests.rb +1 -0
  12. data/build/nginx.rb +1 -0
  13. data/build/packaging.rb +1 -1
  14. data/dev/copy_boost_headers.rb +1 -0
  15. data/doc/Users guide Apache.idmap.txt +56 -54
  16. data/doc/Users guide Apache.txt +22 -3
  17. data/doc/Users guide Nginx.idmap.txt +52 -50
  18. data/doc/Users guide Nginx.txt +22 -3
  19. data/ext/apache2/Configuration.hpp +4 -0
  20. data/ext/apache2/ConfigurationCommands.cpp +6 -0
  21. data/ext/apache2/ConfigurationFields.hpp +6 -4
  22. data/ext/apache2/ConfigurationSetters.cpp +11 -0
  23. data/ext/apache2/CreateDirConfig.cpp +1 -0
  24. data/ext/apache2/Hooks.cpp +2 -0
  25. data/ext/apache2/MergeDirConfig.cpp +7 -0
  26. data/ext/boost/type_traits/detail/common_type_imp.hpp +333 -0
  27. data/ext/boost/type_traits/detail/has_binary_operator.hpp +229 -0
  28. data/ext/boost/type_traits/detail/has_postfix_operator.hpp +202 -0
  29. data/ext/boost/type_traits/detail/has_prefix_operator.hpp +210 -0
  30. data/ext/boost/type_traits/detail/is_function_ptr_tester.hpp +654 -0
  31. data/ext/boost/type_traits/detail/is_mem_fun_pointer_tester.hpp +2759 -0
  32. data/ext/boost/type_traits/detail/wrap.hpp +18 -0
  33. data/ext/common/Constants.h +1 -1
  34. data/ext/common/Utils/StrIntUtils.cpp +1 -1
  35. data/ext/common/agents/HelperAgent/Main.cpp +18 -1
  36. data/ext/common/agents/HelperAgent/RequestHandler.h +3 -0
  37. data/ext/common/agents/SpawnPreparer.cpp +25 -0
  38. data/ext/common/agents/TempDirToucher.c +357 -0
  39. data/ext/common/agents/Watchdog/Main.cpp +38 -0
  40. data/ext/nginx/CacheLocationConfig.c +21 -1
  41. data/ext/nginx/CacheLocationConfig.c.erb +1 -1
  42. data/ext/nginx/ConfigurationCommands.c +10 -0
  43. data/ext/nginx/ConfigurationFields.h +18 -16
  44. data/ext/nginx/ConfigurationFields.h.erb +11 -6
  45. data/ext/nginx/CreateLocationConfig.c +4 -0
  46. data/ext/nginx/MergeLocationConfig.c +6 -0
  47. data/helper-scripts/node-loader.js +6 -2
  48. data/lib/phusion_passenger.rb +1 -1
  49. data/lib/phusion_passenger/{rails3_extensions → active_support3_extensions}/init.rb +10 -8
  50. data/lib/phusion_passenger/apache2/config_options.rb +5 -0
  51. data/lib/phusion_passenger/loader_shared_helpers.rb +61 -7
  52. data/lib/phusion_passenger/nginx/config_options.rb +4 -0
  53. data/lib/phusion_passenger/platform_info/apache.rb +6 -1
  54. data/lib/phusion_passenger/platform_info/compiler.rb +29 -2
  55. data/lib/phusion_passenger/platform_info/depcheck_specs/compiler_toolchain.rb +4 -4
  56. data/lib/phusion_passenger/platform_info/ruby.rb +7 -3
  57. data/lib/phusion_passenger/public_api.rb +4 -4
  58. data/lib/phusion_passenger/standalone/command.rb +10 -0
  59. data/lib/phusion_passenger/standalone/runtime_installer.rb +2 -2
  60. data/lib/phusion_passenger/standalone/start_command.rb +14 -8
  61. data/lib/phusion_passenger/utils/unseekable_socket.rb +52 -0
  62. data/resources/templates/standalone/config.erb +11 -0
  63. metadata +14 -15
  64. metadata.gz.asc +7 -7
  65. data/helper-scripts/touch-dir.sh +0 -48
@@ -0,0 +1,229 @@
1
+ // (C) Copyright 2009-2011 Frederic Bron, Robert Stewart, Steven Watanabe & Roman Perepelitsa.
2
+ //
3
+ // Use, modification and distribution are subject to the Boost Software License,
4
+ // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5
+ // http://www.boost.org/LICENSE_1_0.txt).
6
+ //
7
+ // See http://www.boost.org/libs/type_traits for most recent version including documentation.
8
+
9
+ #include <boost/config.hpp>
10
+ #include <boost/type_traits/ice.hpp>
11
+ #include <boost/type_traits/integral_constant.hpp>
12
+ #include <boost/type_traits/is_base_of.hpp>
13
+ #include <boost/type_traits/is_const.hpp>
14
+ #include <boost/type_traits/is_convertible.hpp>
15
+ #include <boost/type_traits/is_fundamental.hpp>
16
+ #include <boost/type_traits/is_integral.hpp>
17
+ #include <boost/type_traits/is_pointer.hpp>
18
+ #include <boost/type_traits/is_same.hpp>
19
+ #include <boost/type_traits/is_void.hpp>
20
+ #include <boost/type_traits/remove_cv.hpp>
21
+ #include <boost/type_traits/remove_pointer.hpp>
22
+ #include <boost/type_traits/remove_reference.hpp>
23
+
24
+ // should be the last #include
25
+ #include <boost/type_traits/detail/bool_trait_def.hpp>
26
+
27
+ // cannot include this header without getting warnings of the kind:
28
+ // gcc:
29
+ // warning: value computed is not used
30
+ // warning: comparison between signed and unsigned integer expressions
31
+ // msvc:
32
+ // warning C4018: '<' : signed/unsigned mismatch
33
+ // warning C4244: '+=' : conversion from 'double' to 'char', possible loss of data
34
+ // warning C4547: '*' : operator before comma has no effect; expected operator with side-effect
35
+ // warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
36
+ // warning C4804: '<' : unsafe use of type 'bool' in operation
37
+ // warning C4805: '==' : unsafe mix of type 'bool' and type 'char' in operation
38
+ // cannot find another implementation -> declared as system header to suppress these warnings.
39
+ #if defined(__GNUC__) && ((__GNUC__==3 && __GNUC_MINOR__>=1) || (__GNUC__>3))
40
+ # pragma GCC system_header
41
+ #elif defined(BOOST_MSVC)
42
+ # pragma warning ( push )
43
+ # pragma warning ( disable : 4018 4244 4547 4800 4804 4805 4913 )
44
+ #endif
45
+
46
+ namespace boost {
47
+ namespace detail {
48
+
49
+ // This namespace ensures that argument-dependent name lookup does not mess things up.
50
+ namespace BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl) {
51
+
52
+ // 1. a function to have an instance of type T without requiring T to be default
53
+ // constructible
54
+ template <typename T> T &make();
55
+
56
+
57
+ // 2. we provide our operator definition for types that do not have one already
58
+
59
+ // a type returned from operator BOOST_TT_TRAIT_OP when no such operator is
60
+ // found in the type's own namespace (our own operator is used) so that we have
61
+ // a means to know that our operator was used
62
+ struct no_operator { };
63
+
64
+ // this class allows implicit conversions and makes the following operator
65
+ // definition less-preferred than any other such operators that might be found
66
+ // via argument-dependent name lookup
67
+ struct any { template <class T> any(T const&); };
68
+
69
+ // when operator BOOST_TT_TRAIT_OP is not available, this one is used
70
+ no_operator operator BOOST_TT_TRAIT_OP (const any&, const any&);
71
+
72
+
73
+ // 3. checks if the operator returns void or not
74
+ // conditions: Lhs!=void and Rhs!=void
75
+
76
+ // we first redefine "operator," so that we have no compilation error if
77
+ // operator BOOST_TT_TRAIT_OP returns void and we can use the return type of
78
+ // (lhs BOOST_TT_TRAIT_OP rhs, returns_void_t()) to deduce if
79
+ // operator BOOST_TT_TRAIT_OP returns void or not:
80
+ // - operator BOOST_TT_TRAIT_OP returns void -> (lhs BOOST_TT_TRAIT_OP rhs, returns_void_t()) returns returns_void_t
81
+ // - operator BOOST_TT_TRAIT_OP returns !=void -> (lhs BOOST_TT_TRAIT_OP rhs, returns_void_t()) returns int
82
+ struct returns_void_t { };
83
+ template <typename T> int operator,(const T&, returns_void_t);
84
+ template <typename T> int operator,(const volatile T&, returns_void_t);
85
+
86
+ // this intermediate trait has member value of type bool:
87
+ // - value==true -> operator BOOST_TT_TRAIT_OP returns void
88
+ // - value==false -> operator BOOST_TT_TRAIT_OP does not return void
89
+ template < typename Lhs, typename Rhs >
90
+ struct operator_returns_void {
91
+ // overloads of function returns_void make the difference
92
+ // yes_type and no_type have different size by construction
93
+ static ::boost::type_traits::yes_type returns_void(returns_void_t);
94
+ static ::boost::type_traits::no_type returns_void(int);
95
+ BOOST_STATIC_CONSTANT(bool, value = (sizeof(::boost::type_traits::yes_type)==sizeof(returns_void((make<Lhs>() BOOST_TT_TRAIT_OP make<Rhs>(),returns_void_t())))));
96
+ };
97
+
98
+
99
+ // 4. checks if the return type is Ret or Ret==dont_care
100
+ // conditions: Lhs!=void and Rhs!=void
101
+
102
+ struct dont_care { };
103
+
104
+ template < typename Lhs, typename Rhs, typename Ret, bool Returns_void >
105
+ struct operator_returns_Ret;
106
+
107
+ template < typename Lhs, typename Rhs >
108
+ struct operator_returns_Ret < Lhs, Rhs, dont_care, true > {
109
+ BOOST_STATIC_CONSTANT(bool, value = true);
110
+ };
111
+
112
+ template < typename Lhs, typename Rhs >
113
+ struct operator_returns_Ret < Lhs, Rhs, dont_care, false > {
114
+ BOOST_STATIC_CONSTANT(bool, value = true);
115
+ };
116
+
117
+ template < typename Lhs, typename Rhs >
118
+ struct operator_returns_Ret < Lhs, Rhs, void, true > {
119
+ BOOST_STATIC_CONSTANT(bool, value = true);
120
+ };
121
+
122
+ template < typename Lhs, typename Rhs >
123
+ struct operator_returns_Ret < Lhs, Rhs, void, false > {
124
+ BOOST_STATIC_CONSTANT(bool, value = false);
125
+ };
126
+
127
+ template < typename Lhs, typename Rhs, typename Ret >
128
+ struct operator_returns_Ret < Lhs, Rhs, Ret, true > {
129
+ BOOST_STATIC_CONSTANT(bool, value = false);
130
+ };
131
+
132
+ // otherwise checks if it is convertible to Ret using the sizeof trick
133
+ // based on overload resolution
134
+ // condition: Ret!=void and Ret!=dont_care and the operator does not return void
135
+ template < typename Lhs, typename Rhs, typename Ret >
136
+ struct operator_returns_Ret < Lhs, Rhs, Ret, false > {
137
+ static ::boost::type_traits::yes_type is_convertible_to_Ret(Ret); // this version is preferred for types convertible to Ret
138
+ static ::boost::type_traits::no_type is_convertible_to_Ret(...); // this version is used otherwise
139
+
140
+ BOOST_STATIC_CONSTANT(bool, value = (sizeof(is_convertible_to_Ret(make<Lhs>() BOOST_TT_TRAIT_OP make<Rhs>()))==sizeof(::boost::type_traits::yes_type)));
141
+ };
142
+
143
+
144
+ // 5. checks for operator existence
145
+ // condition: Lhs!=void and Rhs!=void
146
+
147
+ // checks if our definition of operator BOOST_TT_TRAIT_OP is used or an other
148
+ // existing one;
149
+ // this is done with redefinition of "operator," that returns no_operator or has_operator
150
+ struct has_operator { };
151
+ no_operator operator,(no_operator, has_operator);
152
+
153
+ template < typename Lhs, typename Rhs >
154
+ struct operator_exists {
155
+ static ::boost::type_traits::yes_type check(has_operator); // this version is preferred when operator exists
156
+ static ::boost::type_traits::no_type check(no_operator); // this version is used otherwise
157
+
158
+ BOOST_STATIC_CONSTANT(bool, value = (sizeof(check(((make<Lhs>() BOOST_TT_TRAIT_OP make<Rhs>()),make<has_operator>())))==sizeof(::boost::type_traits::yes_type)));
159
+ };
160
+
161
+
162
+ // 6. main trait: to avoid any compilation error, this class behaves
163
+ // differently when operator BOOST_TT_TRAIT_OP(Lhs, Rhs) is forbidden by the
164
+ // standard.
165
+ // Forbidden_if is a bool that is:
166
+ // - true when the operator BOOST_TT_TRAIT_OP(Lhs, Rhs) is forbidden by the standard
167
+ // (would yield compilation error if used)
168
+ // - false otherwise
169
+ template < typename Lhs, typename Rhs, typename Ret, bool Forbidden_if >
170
+ struct trait_impl1;
171
+
172
+ template < typename Lhs, typename Rhs, typename Ret >
173
+ struct trait_impl1 < Lhs, Rhs, Ret, true > {
174
+ BOOST_STATIC_CONSTANT(bool, value = false);
175
+ };
176
+
177
+ template < typename Lhs, typename Rhs, typename Ret >
178
+ struct trait_impl1 < Lhs, Rhs, Ret, false > {
179
+ BOOST_STATIC_CONSTANT(bool,
180
+ value = (
181
+ ::boost::type_traits::ice_and<
182
+ operator_exists < Lhs, Rhs >::value,
183
+ operator_returns_Ret < Lhs, Rhs, Ret, operator_returns_void < Lhs, Rhs >::value >::value
184
+ >::value
185
+ )
186
+ );
187
+ };
188
+
189
+ // some specializations needs to be declared for the special void case
190
+ template < typename Rhs, typename Ret >
191
+ struct trait_impl1 < void, Rhs, Ret, false > {
192
+ BOOST_STATIC_CONSTANT(bool, value = false);
193
+ };
194
+
195
+ template < typename Lhs, typename Ret >
196
+ struct trait_impl1 < Lhs, void, Ret, false > {
197
+ BOOST_STATIC_CONSTANT(bool, value = false);
198
+ };
199
+
200
+ template < typename Ret >
201
+ struct trait_impl1 < void, void, Ret, false > {
202
+ BOOST_STATIC_CONSTANT(bool, value = false);
203
+ };
204
+
205
+ // defines some typedef for convenience
206
+ template < typename Lhs, typename Rhs, typename Ret >
207
+ struct trait_impl {
208
+ typedef typename ::boost::remove_reference<Lhs>::type Lhs_noref;
209
+ typedef typename ::boost::remove_reference<Rhs>::type Rhs_noref;
210
+ typedef typename ::boost::remove_cv<Lhs_noref>::type Lhs_nocv;
211
+ typedef typename ::boost::remove_cv<Rhs_noref>::type Rhs_nocv;
212
+ typedef typename ::boost::remove_cv< typename ::boost::remove_reference< typename ::boost::remove_pointer<Lhs_noref>::type >::type >::type Lhs_noptr;
213
+ typedef typename ::boost::remove_cv< typename ::boost::remove_reference< typename ::boost::remove_pointer<Rhs_noref>::type >::type >::type Rhs_noptr;
214
+ BOOST_STATIC_CONSTANT(bool, value = (trait_impl1 < Lhs_noref, Rhs_noref, Ret, BOOST_TT_FORBIDDEN_IF >::value));
215
+ };
216
+
217
+ } // namespace impl
218
+ } // namespace detail
219
+
220
+ // this is the accessible definition of the trait to end user
221
+ BOOST_TT_AUX_BOOL_TRAIT_DEF3(BOOST_TT_TRAIT_NAME, Lhs, Rhs=Lhs, Ret=::boost::detail::BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl)::dont_care, (::boost::detail::BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl)::trait_impl < Lhs, Rhs, Ret >::value))
222
+
223
+ } // namespace boost
224
+
225
+ #if defined(BOOST_MSVC)
226
+ # pragma warning ( pop )
227
+ #endif
228
+
229
+ #include <boost/type_traits/detail/bool_trait_undef.hpp>
@@ -0,0 +1,202 @@
1
+ // (C) Copyright 2009-2011 Frederic Bron, Robert Stewart, Steven Watanabe & Roman Perepelitsa.
2
+ //
3
+ // Use, modification and distribution are subject to the Boost Software License,
4
+ // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5
+ // http://www.boost.org/LICENSE_1_0.txt).
6
+ //
7
+ // See http://www.boost.org/libs/type_traits for most recent version including documentation.
8
+
9
+ #include <boost/config.hpp>
10
+ #include <boost/type_traits/ice.hpp>
11
+ #include <boost/type_traits/integral_constant.hpp>
12
+ #include <boost/type_traits/is_const.hpp>
13
+ #include <boost/type_traits/is_fundamental.hpp>
14
+ #include <boost/type_traits/is_pointer.hpp>
15
+ #include <boost/type_traits/is_same.hpp>
16
+ #include <boost/type_traits/is_void.hpp>
17
+ #include <boost/type_traits/remove_cv.hpp>
18
+ #include <boost/type_traits/remove_pointer.hpp>
19
+ #include <boost/type_traits/remove_reference.hpp>
20
+
21
+ // should be the last #include
22
+ #include <boost/type_traits/detail/bool_trait_def.hpp>
23
+
24
+ // avoid warnings
25
+ #if defined(__GNUC__) && ((__GNUC__==3 && __GNUC_MINOR__>=1) || (__GNUC__>3))
26
+ # pragma GCC system_header
27
+ #elif defined(BOOST_MSVC)
28
+ # pragma warning ( push )
29
+ # pragma warning ( disable : 4244 4913 )
30
+ #endif
31
+
32
+ namespace boost {
33
+ namespace detail {
34
+
35
+ // This namespace ensures that argument-dependent name lookup does not mess things up.
36
+ namespace BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl) {
37
+
38
+ // 1. a function to have an instance of type T without requiring T to be default
39
+ // constructible
40
+ template <typename T> T &make();
41
+
42
+
43
+ // 2. we provide our operator definition for types that do not have one already
44
+
45
+ // a type returned from operator BOOST_TT_TRAIT_OP when no such operator is
46
+ // found in the type's own namespace (our own operator is used) so that we have
47
+ // a means to know that our operator was used
48
+ struct no_operator { };
49
+
50
+ // this class allows implicit conversions and makes the following operator
51
+ // definition less-preferred than any other such operators that might be found
52
+ // via argument-dependent name lookup
53
+ struct any { template <class T> any(T const&); };
54
+
55
+ // when operator BOOST_TT_TRAIT_OP is not available, this one is used
56
+ no_operator operator BOOST_TT_TRAIT_OP (const any&, int);
57
+
58
+
59
+ // 3. checks if the operator returns void or not
60
+ // conditions: Lhs!=void
61
+
62
+ // we first redefine "operator," so that we have no compilation error if
63
+ // operator BOOST_TT_TRAIT_OP returns void and we can use the return type of
64
+ // (lhs BOOST_TT_TRAIT_OP, returns_void_t()) to deduce if
65
+ // operator BOOST_TT_TRAIT_OP returns void or not:
66
+ // - operator BOOST_TT_TRAIT_OP returns void -> (lhs BOOST_TT_TRAIT_OP, returns_void_t()) returns returns_void_t
67
+ // - operator BOOST_TT_TRAIT_OP returns !=void -> (lhs BOOST_TT_TRAIT_OP, returns_void_t()) returns int
68
+ struct returns_void_t { };
69
+ template <typename T> int operator,(const T&, returns_void_t);
70
+ template <typename T> int operator,(const volatile T&, returns_void_t);
71
+
72
+ // this intermediate trait has member value of type bool:
73
+ // - value==true -> operator BOOST_TT_TRAIT_OP returns void
74
+ // - value==false -> operator BOOST_TT_TRAIT_OP does not return void
75
+ template < typename Lhs >
76
+ struct operator_returns_void {
77
+ // overloads of function returns_void make the difference
78
+ // yes_type and no_type have different size by construction
79
+ static ::boost::type_traits::yes_type returns_void(returns_void_t);
80
+ static ::boost::type_traits::no_type returns_void(int);
81
+ BOOST_STATIC_CONSTANT(bool, value = (sizeof(::boost::type_traits::yes_type)==sizeof(returns_void((make<Lhs>() BOOST_TT_TRAIT_OP,returns_void_t())))));
82
+ };
83
+
84
+
85
+ // 4. checks if the return type is Ret or Ret==dont_care
86
+ // conditions: Lhs!=void
87
+
88
+ struct dont_care { };
89
+
90
+ template < typename Lhs, typename Ret, bool Returns_void >
91
+ struct operator_returns_Ret;
92
+
93
+ template < typename Lhs >
94
+ struct operator_returns_Ret < Lhs, dont_care, true > {
95
+ BOOST_STATIC_CONSTANT(bool, value = true);
96
+ };
97
+
98
+ template < typename Lhs >
99
+ struct operator_returns_Ret < Lhs, dont_care, false > {
100
+ BOOST_STATIC_CONSTANT(bool, value = true);
101
+ };
102
+
103
+ template < typename Lhs >
104
+ struct operator_returns_Ret < Lhs, void, true > {
105
+ BOOST_STATIC_CONSTANT(bool, value = true);
106
+ };
107
+
108
+ template < typename Lhs >
109
+ struct operator_returns_Ret < Lhs, void, false > {
110
+ BOOST_STATIC_CONSTANT(bool, value = false);
111
+ };
112
+
113
+ template < typename Lhs, typename Ret >
114
+ struct operator_returns_Ret < Lhs, Ret, true > {
115
+ BOOST_STATIC_CONSTANT(bool, value = false);
116
+ };
117
+
118
+ // otherwise checks if it is convertible to Ret using the sizeof trick
119
+ // based on overload resolution
120
+ // condition: Ret!=void and Ret!=dont_care and the operator does not return void
121
+ template < typename Lhs, typename Ret >
122
+ struct operator_returns_Ret < Lhs, Ret, false > {
123
+ static ::boost::type_traits::yes_type is_convertible_to_Ret(Ret); // this version is preferred for types convertible to Ret
124
+ static ::boost::type_traits::no_type is_convertible_to_Ret(...); // this version is used otherwise
125
+
126
+ BOOST_STATIC_CONSTANT(bool, value = (sizeof(is_convertible_to_Ret(make<Lhs>() BOOST_TT_TRAIT_OP))==sizeof(::boost::type_traits::yes_type)));
127
+ };
128
+
129
+
130
+ // 5. checks for operator existence
131
+ // condition: Lhs!=void
132
+
133
+ // checks if our definition of operator BOOST_TT_TRAIT_OP is used or an other
134
+ // existing one;
135
+ // this is done with redefinition of "operator," that returns no_operator or has_operator
136
+ struct has_operator { };
137
+ no_operator operator,(no_operator, has_operator);
138
+
139
+ template < typename Lhs >
140
+ struct operator_exists {
141
+ static ::boost::type_traits::yes_type check(has_operator); // this version is preferred when operator exists
142
+ static ::boost::type_traits::no_type check(no_operator); // this version is used otherwise
143
+
144
+ BOOST_STATIC_CONSTANT(bool, value = (sizeof(check(((make<Lhs>() BOOST_TT_TRAIT_OP),make<has_operator>())))==sizeof(::boost::type_traits::yes_type)));
145
+ };
146
+
147
+
148
+ // 6. main trait: to avoid any compilation error, this class behaves
149
+ // differently when operator BOOST_TT_TRAIT_OP(Lhs) is forbidden by the
150
+ // standard.
151
+ // Forbidden_if is a bool that is:
152
+ // - true when the operator BOOST_TT_TRAIT_OP(Lhs) is forbidden by the standard
153
+ // (would yield compilation error if used)
154
+ // - false otherwise
155
+ template < typename Lhs, typename Ret, bool Forbidden_if >
156
+ struct trait_impl1;
157
+
158
+ template < typename Lhs, typename Ret >
159
+ struct trait_impl1 < Lhs, Ret, true > {
160
+ BOOST_STATIC_CONSTANT(bool, value = false);
161
+ };
162
+
163
+ template < typename Lhs, typename Ret >
164
+ struct trait_impl1 < Lhs, Ret, false > {
165
+ BOOST_STATIC_CONSTANT(bool,
166
+ value = (
167
+ ::boost::type_traits::ice_and<
168
+ operator_exists < Lhs >::value,
169
+ operator_returns_Ret < Lhs, Ret, operator_returns_void < Lhs >::value >::value
170
+ >::value
171
+ )
172
+ );
173
+ };
174
+
175
+ // specialization needs to be declared for the special void case
176
+ template < typename Ret >
177
+ struct trait_impl1 < void, Ret, false > {
178
+ BOOST_STATIC_CONSTANT(bool, value = false);
179
+ };
180
+
181
+ // defines some typedef for convenience
182
+ template < typename Lhs, typename Ret >
183
+ struct trait_impl {
184
+ typedef typename ::boost::remove_reference<Lhs>::type Lhs_noref;
185
+ typedef typename ::boost::remove_cv<Lhs_noref>::type Lhs_nocv;
186
+ typedef typename ::boost::remove_cv< typename ::boost::remove_reference< typename ::boost::remove_pointer<Lhs_noref>::type >::type >::type Lhs_noptr;
187
+ BOOST_STATIC_CONSTANT(bool, value = (trait_impl1 < Lhs_noref, Ret, BOOST_TT_FORBIDDEN_IF >::value));
188
+ };
189
+
190
+ } // namespace impl
191
+ } // namespace detail
192
+
193
+ // this is the accessible definition of the trait to end user
194
+ BOOST_TT_AUX_BOOL_TRAIT_DEF2(BOOST_TT_TRAIT_NAME, Lhs, Ret=::boost::detail::BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl)::dont_care, (::boost::detail::BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl)::trait_impl< Lhs, Ret >::value))
195
+
196
+ } // namespace boost
197
+
198
+ #if defined(BOOST_MSVC)
199
+ # pragma warning ( pop )
200
+ #endif
201
+
202
+ #include <boost/type_traits/detail/bool_trait_undef.hpp>
@@ -0,0 +1,210 @@
1
+ // (C) Copyright 2009-2011 Frederic Bron, Robert Stewart, Steven Watanabe & Roman Perepelitsa.
2
+ //
3
+ // Use, modification and distribution are subject to the Boost Software License,
4
+ // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5
+ // http://www.boost.org/LICENSE_1_0.txt).
6
+ //
7
+ // See http://www.boost.org/libs/type_traits for most recent version including documentation.
8
+
9
+ #include <boost/config.hpp>
10
+ #include <boost/type_traits/ice.hpp>
11
+ #include <boost/type_traits/integral_constant.hpp>
12
+ #include <boost/type_traits/is_const.hpp>
13
+ #include <boost/type_traits/is_fundamental.hpp>
14
+ #include <boost/type_traits/is_integral.hpp>
15
+ #include <boost/type_traits/is_pointer.hpp>
16
+ #include <boost/type_traits/is_same.hpp>
17
+ #include <boost/type_traits/is_void.hpp>
18
+ #include <boost/type_traits/remove_cv.hpp>
19
+ #include <boost/type_traits/remove_pointer.hpp>
20
+ #include <boost/type_traits/remove_reference.hpp>
21
+
22
+ // should be the last #include
23
+ #include <boost/type_traits/detail/bool_trait_def.hpp>
24
+
25
+ // cannot include this header without getting warnings of the kind:
26
+ // gcc:
27
+ // warning: value computed is not used
28
+ // warning: comparison between signed and unsigned integer expressions
29
+ // msvc:
30
+ // warning C4146: unary minus operator applied to unsigned type, result still unsigned
31
+ // warning C4804: '-' : unsafe use of type 'bool' in operation
32
+ // cannot find another implementation -> declared as system header to suppress these warnings.
33
+ #if defined(__GNUC__) && ((__GNUC__==3 && __GNUC_MINOR__>=1) || (__GNUC__>3))
34
+ # pragma GCC system_header
35
+ #elif defined(BOOST_MSVC)
36
+ # pragma warning ( push )
37
+ # pragma warning ( disable : 4146 4804 4913 4244 )
38
+ #endif
39
+
40
+ namespace boost {
41
+ namespace detail {
42
+
43
+ // This namespace ensures that argument-dependent name lookup does not mess things up.
44
+ namespace BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl) {
45
+
46
+ // 1. a function to have an instance of type T without requiring T to be default
47
+ // constructible
48
+ template <typename T> T &make();
49
+
50
+
51
+ // 2. we provide our operator definition for types that do not have one already
52
+
53
+ // a type returned from operator BOOST_TT_TRAIT_OP when no such operator is
54
+ // found in the type's own namespace (our own operator is used) so that we have
55
+ // a means to know that our operator was used
56
+ struct no_operator { };
57
+
58
+ // this class allows implicit conversions and makes the following operator
59
+ // definition less-preferred than any other such operators that might be found
60
+ // via argument-dependent name lookup
61
+ struct any { template <class T> any(T const&); };
62
+
63
+ // when operator BOOST_TT_TRAIT_OP is not available, this one is used
64
+ no_operator operator BOOST_TT_TRAIT_OP (const any&);
65
+
66
+
67
+ // 3. checks if the operator returns void or not
68
+ // conditions: Rhs!=void
69
+
70
+ // we first redefine "operator," so that we have no compilation error if
71
+ // operator BOOST_TT_TRAIT_OP returns void and we can use the return type of
72
+ // (BOOST_TT_TRAIT_OP rhs, returns_void_t()) to deduce if
73
+ // operator BOOST_TT_TRAIT_OP returns void or not:
74
+ // - operator BOOST_TT_TRAIT_OP returns void -> (BOOST_TT_TRAIT_OP rhs, returns_void_t()) returns returns_void_t
75
+ // - operator BOOST_TT_TRAIT_OP returns !=void -> (BOOST_TT_TRAIT_OP rhs, returns_void_t()) returns int
76
+ struct returns_void_t { };
77
+ template <typename T> int operator,(const T&, returns_void_t);
78
+ template <typename T> int operator,(const volatile T&, returns_void_t);
79
+
80
+ // this intermediate trait has member value of type bool:
81
+ // - value==true -> operator BOOST_TT_TRAIT_OP returns void
82
+ // - value==false -> operator BOOST_TT_TRAIT_OP does not return void
83
+ template < typename Rhs >
84
+ struct operator_returns_void {
85
+ // overloads of function returns_void make the difference
86
+ // yes_type and no_type have different size by construction
87
+ static ::boost::type_traits::yes_type returns_void(returns_void_t);
88
+ static ::boost::type_traits::no_type returns_void(int);
89
+ BOOST_STATIC_CONSTANT(bool, value = (sizeof(::boost::type_traits::yes_type)==sizeof(returns_void((BOOST_TT_TRAIT_OP make<Rhs>(),returns_void_t())))));
90
+ };
91
+
92
+
93
+ // 4. checks if the return type is Ret or Ret==dont_care
94
+ // conditions: Rhs!=void
95
+
96
+ struct dont_care { };
97
+
98
+ template < typename Rhs, typename Ret, bool Returns_void >
99
+ struct operator_returns_Ret;
100
+
101
+ template < typename Rhs >
102
+ struct operator_returns_Ret < Rhs, dont_care, true > {
103
+ BOOST_STATIC_CONSTANT(bool, value = true);
104
+ };
105
+
106
+ template < typename Rhs >
107
+ struct operator_returns_Ret < Rhs, dont_care, false > {
108
+ BOOST_STATIC_CONSTANT(bool, value = true);
109
+ };
110
+
111
+ template < typename Rhs >
112
+ struct operator_returns_Ret < Rhs, void, true > {
113
+ BOOST_STATIC_CONSTANT(bool, value = true);
114
+ };
115
+
116
+ template < typename Rhs >
117
+ struct operator_returns_Ret < Rhs, void, false > {
118
+ BOOST_STATIC_CONSTANT(bool, value = false);
119
+ };
120
+
121
+ template < typename Rhs, typename Ret >
122
+ struct operator_returns_Ret < Rhs, Ret, true > {
123
+ BOOST_STATIC_CONSTANT(bool, value = false);
124
+ };
125
+
126
+ // otherwise checks if it is convertible to Ret using the sizeof trick
127
+ // based on overload resolution
128
+ // condition: Ret!=void and Ret!=dont_care and the operator does not return void
129
+ template < typename Rhs, typename Ret >
130
+ struct operator_returns_Ret < Rhs, Ret, false > {
131
+ static ::boost::type_traits::yes_type is_convertible_to_Ret(Ret); // this version is preferred for types convertible to Ret
132
+ static ::boost::type_traits::no_type is_convertible_to_Ret(...); // this version is used otherwise
133
+
134
+ BOOST_STATIC_CONSTANT(bool, value = (sizeof(is_convertible_to_Ret(BOOST_TT_TRAIT_OP make<Rhs>()))==sizeof(::boost::type_traits::yes_type)));
135
+ };
136
+
137
+
138
+ // 5. checks for operator existence
139
+ // condition: Rhs!=void
140
+
141
+ // checks if our definition of operator BOOST_TT_TRAIT_OP is used or an other
142
+ // existing one;
143
+ // this is done with redefinition of "operator," that returns no_operator or has_operator
144
+ struct has_operator { };
145
+ no_operator operator,(no_operator, has_operator);
146
+
147
+ template < typename Rhs >
148
+ struct operator_exists {
149
+ static ::boost::type_traits::yes_type check(has_operator); // this version is preferred when operator exists
150
+ static ::boost::type_traits::no_type check(no_operator); // this version is used otherwise
151
+
152
+ BOOST_STATIC_CONSTANT(bool, value = (sizeof(check(((BOOST_TT_TRAIT_OP make<Rhs>()),make<has_operator>())))==sizeof(::boost::type_traits::yes_type)));
153
+ };
154
+
155
+
156
+ // 6. main trait: to avoid any compilation error, this class behaves
157
+ // differently when operator BOOST_TT_TRAIT_OP(Rhs) is forbidden by the
158
+ // standard.
159
+ // Forbidden_if is a bool that is:
160
+ // - true when the operator BOOST_TT_TRAIT_OP(Rhs) is forbidden by the standard
161
+ // (would yield compilation error if used)
162
+ // - false otherwise
163
+ template < typename Rhs, typename Ret, bool Forbidden_if >
164
+ struct trait_impl1;
165
+
166
+ template < typename Rhs, typename Ret >
167
+ struct trait_impl1 < Rhs, Ret, true > {
168
+ BOOST_STATIC_CONSTANT(bool, value = false);
169
+ };
170
+
171
+ template < typename Rhs, typename Ret >
172
+ struct trait_impl1 < Rhs, Ret, false > {
173
+ BOOST_STATIC_CONSTANT(bool,
174
+ value = (
175
+ ::boost::type_traits::ice_and<
176
+ operator_exists < Rhs >::value,
177
+ operator_returns_Ret < Rhs, Ret, operator_returns_void < Rhs >::value >::value
178
+ >::value
179
+ )
180
+ );
181
+ };
182
+
183
+ // specialization needs to be declared for the special void case
184
+ template < typename Ret >
185
+ struct trait_impl1 < void, Ret, false > {
186
+ BOOST_STATIC_CONSTANT(bool, value = false);
187
+ };
188
+
189
+ // defines some typedef for convenience
190
+ template < typename Rhs, typename Ret >
191
+ struct trait_impl {
192
+ typedef typename ::boost::remove_reference<Rhs>::type Rhs_noref;
193
+ typedef typename ::boost::remove_cv<Rhs_noref>::type Rhs_nocv;
194
+ typedef typename ::boost::remove_cv< typename ::boost::remove_reference< typename ::boost::remove_pointer<Rhs_noref>::type >::type >::type Rhs_noptr;
195
+ BOOST_STATIC_CONSTANT(bool, value = (trait_impl1 < Rhs_noref, Ret, BOOST_TT_FORBIDDEN_IF >::value));
196
+ };
197
+
198
+ } // namespace impl
199
+ } // namespace detail
200
+
201
+ // this is the accessible definition of the trait to end user
202
+ BOOST_TT_AUX_BOOL_TRAIT_DEF2(BOOST_TT_TRAIT_NAME, Rhs, Ret=::boost::detail::BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl)::dont_care, (::boost::detail::BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl)::trait_impl < Rhs, Ret >::value))
203
+
204
+ } // namespace boost
205
+
206
+ #if defined(BOOST_MSVC)
207
+ # pragma warning ( pop )
208
+ #endif
209
+
210
+ #include <boost/type_traits/detail/bool_trait_undef.hpp>