41
41
# pragma warning( push )
42
42
# pragma warning( disable : 4793 ) // complaint about native code generation
43
43
# pragma warning( disable : 4127 ) // "conditional expression is constant"
44
- #endif
44
+ #endif
45
45
46
46
// Define BOOST_FUNCTION_STD_NS to the namespace that contains type_info.
47
47
#ifdef BOOST_NO_STD_TYPEINFO
@@ -120,8 +120,11 @@ namespace network_boost {
120
120
bool is_volatile_qualified;
121
121
} obj_ref;
122
122
123
- // To relax aliasing constraints
124
- mutable char data;
123
+ // To relax aliasing constraints (HACK - I'm making data at
124
+ // least as big as the things above to avoid a placement-new
125
+ // error we're getting with gcc6. Not sure if that makes this
126
+ // comment now irrelevant)
127
+ mutable char data[sizeof (bound_memfunc_ptr_t )];
125
128
};
126
129
127
130
/* *
@@ -188,11 +191,11 @@ namespace network_boost {
188
191
struct reference_manager
189
192
{
190
193
static inline void
191
- manage (const function_buffer& in_buffer, function_buffer& out_buffer,
194
+ manage (const function_buffer& in_buffer, function_buffer& out_buffer,
192
195
functor_manager_operation_type op)
193
196
{
194
197
switch (op) {
195
- case clone_functor_tag:
198
+ case clone_functor_tag:
196
199
out_buffer.obj_ref = in_buffer.obj_ref ;
197
200
return ;
198
201
@@ -207,13 +210,13 @@ namespace network_boost {
207
210
208
211
case check_functor_type_tag:
209
212
{
210
- const detail::sp_typeinfo& check_type
213
+ const detail::sp_typeinfo& check_type
211
214
= *out_buffer.type .type ;
212
215
213
216
// Check whether we have the same type. We can add
214
217
// cv-qualifiers, but we can't take them away.
215
218
if (BOOST_FUNCTION_COMPARE_TYPE_ID (check_type, BOOST_SP_TYPEID (F))
216
- && (!in_buffer.obj_ref .is_const_qualified
219
+ && (!in_buffer.obj_ref .is_const_qualified
217
220
|| out_buffer.type .const_qualified )
218
221
&& (!in_buffer.obj_ref .is_volatile_qualified
219
222
|| out_buffer.type .volatile_qualified ))
@@ -240,9 +243,9 @@ namespace network_boost {
240
243
struct function_allows_small_object_optimization
241
244
{
242
245
BOOST_STATIC_CONSTANT
243
- (bool ,
246
+ (bool ,
244
247
value = ((sizeof (F) <= sizeof (function_buffer) &&
245
- (alignment_of<function_buffer>::value
248
+ (alignment_of<function_buffer>::value
246
249
% alignment_of<F>::value == 0 ))));
247
250
};
248
251
@@ -254,7 +257,7 @@ namespace network_boost {
254
257
A (a)
255
258
{
256
259
}
257
-
260
+
258
261
functor_wrapper (const functor_wrapper& f) :
259
262
F (static_cast <const F&>(f)),
260
263
A (static_cast <const A&>(f))
@@ -273,7 +276,7 @@ namespace network_boost {
273
276
274
277
// Function pointers
275
278
static inline void
276
- manage_ptr (const function_buffer& in_buffer, function_buffer& out_buffer,
279
+ manage_ptr (const function_buffer& in_buffer, function_buffer& out_buffer,
277
280
functor_manager_operation_type op)
278
281
{
279
282
if (op == clone_functor_tag)
@@ -299,11 +302,11 @@ namespace network_boost {
299
302
300
303
// Function objects that fit in the small-object buffer.
301
304
static inline void
302
- manage_small (const function_buffer& in_buffer, function_buffer& out_buffer,
305
+ manage_small (const function_buffer& in_buffer, function_buffer& out_buffer,
303
306
functor_manager_operation_type op)
304
307
{
305
308
if (op == clone_functor_tag || op == move_functor_tag) {
306
- const functor_type* in_functor =
309
+ const functor_type* in_functor =
307
310
reinterpret_cast <const functor_type*>(&in_buffer.data );
308
311
new (reinterpret_cast <void *>(&out_buffer.data )) functor_type (*in_functor);
309
312
@@ -318,7 +321,7 @@ namespace network_boost {
318
321
(void )f; // suppress warning about the value of f not being used (MSVC)
319
322
f->~Functor ();
320
323
} else if (op == check_functor_type_tag) {
321
- const detail::sp_typeinfo& check_type
324
+ const detail::sp_typeinfo& check_type
322
325
= *out_buffer.type .type ;
323
326
if (BOOST_FUNCTION_COMPARE_TYPE_ID (check_type, BOOST_SP_TYPEID (Functor)))
324
327
out_buffer.obj_ptr = &in_buffer.data ;
@@ -327,7 +330,7 @@ namespace network_boost {
327
330
} else /* op == get_functor_type_tag */ {
328
331
out_buffer.type .type = &BOOST_SP_TYPEID (Functor);
329
332
out_buffer.type .const_qualified = false ;
330
- out_buffer.type .volatile_qualified = false ;
333
+ out_buffer.type .volatile_qualified = false ;
331
334
}
332
335
}
333
336
};
@@ -340,23 +343,23 @@ namespace network_boost {
340
343
341
344
// Function pointers
342
345
static inline void
343
- manager (const function_buffer& in_buffer, function_buffer& out_buffer,
346
+ manager (const function_buffer& in_buffer, function_buffer& out_buffer,
344
347
functor_manager_operation_type op, function_ptr_tag)
345
348
{
346
349
functor_manager_common<Functor>::manage_ptr (in_buffer,out_buffer,op);
347
350
}
348
351
349
352
// Function objects that fit in the small-object buffer.
350
353
static inline void
351
- manager (const function_buffer& in_buffer, function_buffer& out_buffer,
354
+ manager (const function_buffer& in_buffer, function_buffer& out_buffer,
352
355
functor_manager_operation_type op, mpl::true_)
353
356
{
354
357
functor_manager_common<Functor>::manage_small (in_buffer,out_buffer,op);
355
358
}
356
-
359
+
357
360
// Function objects that require heap allocation
358
361
static inline void
359
- manager (const function_buffer& in_buffer, function_buffer& out_buffer,
362
+ manager (const function_buffer& in_buffer, function_buffer& out_buffer,
360
363
functor_manager_operation_type op, mpl::false_)
361
364
{
362
365
if (op == clone_functor_tag) {
@@ -396,7 +399,7 @@ namespace network_boost {
396
399
// object can use the small-object optimization buffer or
397
400
// whether we need to allocate it on the heap.
398
401
static inline void
399
- manager (const function_buffer& in_buffer, function_buffer& out_buffer,
402
+ manager (const function_buffer& in_buffer, function_buffer& out_buffer,
400
403
functor_manager_operation_type op, function_obj_tag)
401
404
{
402
405
manager (in_buffer, out_buffer, op,
@@ -405,7 +408,7 @@ namespace network_boost {
405
408
406
409
// For member pointers, we use the small-object optimization buffer.
407
410
static inline void
408
- manager (const function_buffer& in_buffer, function_buffer& out_buffer,
411
+ manager (const function_buffer& in_buffer, function_buffer& out_buffer,
409
412
functor_manager_operation_type op, member_ptr_tag)
410
413
{
411
414
manager (in_buffer, out_buffer, op, mpl::true_ ());
@@ -415,7 +418,7 @@ namespace network_boost {
415
418
/* Dispatch to an appropriate manager based on whether we have a
416
419
function pointer or a function object pointer. */
417
420
static inline void
418
- manage (const function_buffer& in_buffer, function_buffer& out_buffer,
421
+ manage (const function_buffer& in_buffer, function_buffer& out_buffer,
419
422
functor_manager_operation_type op)
420
423
{
421
424
typedef typename get_function_tag<functor_type>::type tag_type;
@@ -441,23 +444,23 @@ namespace network_boost {
441
444
442
445
// Function pointers
443
446
static inline void
444
- manager (const function_buffer& in_buffer, function_buffer& out_buffer,
447
+ manager (const function_buffer& in_buffer, function_buffer& out_buffer,
445
448
functor_manager_operation_type op, function_ptr_tag)
446
449
{
447
450
functor_manager_common<Functor>::manage_ptr (in_buffer,out_buffer,op);
448
451
}
449
452
450
453
// Function objects that fit in the small-object buffer.
451
454
static inline void
452
- manager (const function_buffer& in_buffer, function_buffer& out_buffer,
455
+ manager (const function_buffer& in_buffer, function_buffer& out_buffer,
453
456
functor_manager_operation_type op, mpl::true_)
454
457
{
455
458
functor_manager_common<Functor>::manage_small (in_buffer,out_buffer,op);
456
459
}
457
-
460
+
458
461
// Function objects that require heap allocation
459
462
static inline void
460
- manager (const function_buffer& in_buffer, function_buffer& out_buffer,
463
+ manager (const function_buffer& in_buffer, function_buffer& out_buffer,
461
464
functor_manager_operation_type op, mpl::false_)
462
465
{
463
466
typedef functor_wrapper<Functor,Allocator> functor_wrapper_type;
@@ -490,7 +493,7 @@ namespace network_boost {
490
493
wrapper_allocator.deallocate (victim,1 );
491
494
out_buffer.obj_ptr = 0 ;
492
495
} else if (op == check_functor_type_tag) {
493
- const detail::sp_typeinfo& check_type
496
+ const detail::sp_typeinfo& check_type
494
497
= *out_buffer.type .type ;
495
498
if (BOOST_FUNCTION_COMPARE_TYPE_ID (check_type, BOOST_SP_TYPEID (Functor)))
496
499
out_buffer.obj_ptr = in_buffer.obj_ptr ;
@@ -507,7 +510,7 @@ namespace network_boost {
507
510
// object can use the small-object optimization buffer or
508
511
// whether we need to allocate it on the heap.
509
512
static inline void
510
- manager (const function_buffer& in_buffer, function_buffer& out_buffer,
513
+ manager (const function_buffer& in_buffer, function_buffer& out_buffer,
511
514
functor_manager_operation_type op, function_obj_tag)
512
515
{
513
516
manager (in_buffer, out_buffer, op,
@@ -518,7 +521,7 @@ namespace network_boost {
518
521
/* Dispatch to an appropriate manager based on whether we have a
519
522
function pointer or a function object pointer. */
520
523
static inline void
521
- manage (const function_buffer& in_buffer, function_buffer& out_buffer,
524
+ manage (const function_buffer& in_buffer, function_buffer& out_buffer,
522
525
functor_manager_operation_type op)
523
526
{
524
527
typedef typename get_function_tag<functor_type>::type tag_type;
@@ -604,8 +607,8 @@ namespace network_boost {
604
607
*/
605
608
struct vtable_base
606
609
{
607
- void (*manager)(const function_buffer& in_buffer,
608
- function_buffer& out_buffer,
610
+ void (*manager)(const function_buffer& in_buffer,
611
+ function_buffer& out_buffer,
609
612
functor_manager_operation_type op);
610
613
};
611
614
} // end namespace function
@@ -645,7 +648,7 @@ class function_base
645
648
type_result.type .type = &BOOST_SP_TYPEID (Functor);
646
649
type_result.type .const_qualified = is_const<Functor>::value;
647
650
type_result.type .volatile_qualified = is_volatile<Functor>::value;
648
- get_vtable ()->manager (functor, type_result,
651
+ get_vtable ()->manager (functor, type_result,
649
652
detail::function::check_functor_type_tag);
650
653
return static_cast <Functor*>(type_result.obj_ptr );
651
654
}
@@ -659,7 +662,7 @@ class function_base
659
662
type_result.type .type = &BOOST_SP_TYPEID (Functor);
660
663
type_result.type .const_qualified = true ;
661
664
type_result.type .volatile_qualified = is_volatile<Functor>::value;
662
- get_vtable ()->manager (functor, type_result,
665
+ get_vtable ()->manager (functor, type_result,
663
666
detail::function::check_functor_type_tag);
664
667
// GCC 2.95.3 gets the CV qualifiers wrong here, so we
665
668
// can't do the static_cast that we should do.
@@ -887,6 +890,6 @@ namespace detail {
887
890
888
891
#if defined(BOOST_MSVC)
889
892
# pragma warning( pop )
890
- #endif
893
+ #endif
891
894
892
895
#endif // BOOST_FUNCTION_BASE_HEADER
0 commit comments