8#ifndef INCLUDED_BSLTF_STDSTATEFULALLOCATOR
9#define INCLUDED_BSLTF_STDSTATEFULALLOCATOR
176#include <bslscm_version.h>
193#if BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
197# define COMPILING_BSLTF_STDSTATEFULALLOCATOR_H
199# undef COMPILING_BSLTF_STDSTATEFULALLOCATOR_H
228 bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION =
true,
229 bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT =
true,
230 bool PROPAGATE_ON_CONTAINER_SWAP =
true,
231 bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT =
true,
232 bool IS_ALWAYS_EQUAL =
false>
255#if !defined(BSLSTL_ALLOCATOR_TRAITS_SUPPORTS_ALL_CPP11_DEDUCTIONS)
263 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT>
270 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT>
283 template <
class BDE_OTHER_TYPE>
289 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
290 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
291 PROPAGATE_ON_CONTAINER_SWAP,
292 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
308 template <
class BDE_OTHER_TYPE>
311 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
312 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
313 PROPAGATE_ON_CONTAINER_SWAP,
314 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
315 IS_ALWAYS_EQUAL>& original);
332#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
339 template <
class ELEMENT_TYPE,
class... Args>
340 void construct(ELEMENT_TYPE *address, Args&&... arguments);
352 template <
class ELEMENT_TYPE>
353 void destroy(ELEMENT_TYPE *address);
356#if !defined(BSLSTL_ALLOCATOR_TRAITS_SUPPORTS_ALL_CPP11_DEDUCTIONS)
382template <
class TYPE1,
384 bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
385 bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
386 bool PROPAGATE_ON_CONTAINER_SWAP,
387 bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
388 bool IS_ALWAYS_EQUAL>
391 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
392 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
393 PROPAGATE_ON_CONTAINER_SWAP,
394 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
395 IS_ALWAYS_EQUAL>& lhs,
398 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
399 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
400 PROPAGATE_ON_CONTAINER_SWAP,
401 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
402 IS_ALWAYS_EQUAL>& rhs);
406template <
class TYPE1,
408 bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
409 bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
410 bool PROPAGATE_ON_CONTAINER_SWAP,
411 bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
412 bool IS_ALWAYS_EQUAL>
415 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
416 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
417 PROPAGATE_ON_CONTAINER_SWAP,
418 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
419 IS_ALWAYS_EQUAL>& lhs,
422 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
423 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
424 PROPAGATE_ON_CONTAINER_SWAP,
425 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
426 IS_ALWAYS_EQUAL>& rhs);
439 bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
440 bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
441 bool PROPAGATE_ON_CONTAINER_SWAP,
442 bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
443 bool IS_ALWAYS_EQUAL>
446 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
447 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
448 PROPAGATE_ON_CONTAINER_SWAP,
449 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
452: d_allocator_p(
bslma::Default::allocator(allocator))
457 bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
458 bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
459 bool PROPAGATE_ON_CONTAINER_SWAP,
460 bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
461 bool IS_ALWAYS_EQUAL>
462template <
class BDE_OTHER_TYPE>
465 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
466 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
467 PROPAGATE_ON_CONTAINER_SWAP,
468 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
472 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
473 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
474 PROPAGATE_ON_CONTAINER_SWAP,
475 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
476 IS_ALWAYS_EQUAL>& original)
477: d_allocator_p(original.allocator())
483 bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
484 bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
485 bool PROPAGATE_ON_CONTAINER_SWAP,
486 bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
487 bool IS_ALWAYS_EQUAL>
491 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
492 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
493 PROPAGATE_ON_CONTAINER_SWAP,
494 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
495 IS_ALWAYS_EQUAL>::allocate(
498 if (numElements > this->max_size()) {
499 BloombergLP::bsls::BslExceptionUtil::throwBadAlloc();
502 return static_cast<TYPE *
>(d_allocator_p->allocate(
506#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
508 bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
509 bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
510 bool PROPAGATE_ON_CONTAINER_SWAP,
511 bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
512 bool IS_ALWAYS_EQUAL>
513template <
class ELEMENT_TYPE,
class... Args>
517 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
518 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
519 PROPAGATE_ON_CONTAINER_SWAP,
520 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
521 IS_ALWAYS_EQUAL>::construct(
522 ELEMENT_TYPE *address, Args&&... arguments)
524 ::new (
static_cast<void*
>(address)) ELEMENT_TYPE(
530 bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
531 bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
532 bool PROPAGATE_ON_CONTAINER_SWAP,
533 bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
534 bool IS_ALWAYS_EQUAL>
537 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
538 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
539 PROPAGATE_ON_CONTAINER_SWAP,
540 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
548 bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
549 bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
550 bool PROPAGATE_ON_CONTAINER_SWAP,
551 bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
552 bool IS_ALWAYS_EQUAL>
553template <
class ELEMENT_TYPE>
556 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
557 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
558 PROPAGATE_ON_CONTAINER_SWAP,
559 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
560 IS_ALWAYS_EQUAL>::destroy(
561 ELEMENT_TYPE * address)
563 address->~ELEMENT_TYPE();
567 bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
568 bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
569 bool PROPAGATE_ON_CONTAINER_SWAP,
570 bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
571 bool IS_ALWAYS_EQUAL>
575 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
576 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
577 PROPAGATE_ON_CONTAINER_SWAP,
578 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
579 IS_ALWAYS_EQUAL>::size_type
581 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
582 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
583 PROPAGATE_ON_CONTAINER_SWAP,
584 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
596 std::size_t>::value));
598 static const std::size_t MAX_NUM_BYTES =
~std::size_t(0);
599 static const std::size_t MAX_NUM_ELEMENTS =
600 std::size_t(MAX_NUM_BYTES) /
sizeof(TYPE);
601 return MAX_NUM_ELEMENTS;
605 bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
606 bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
607 bool PROPAGATE_ON_CONTAINER_SWAP,
608 bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
609 bool IS_ALWAYS_EQUAL>
612 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
613 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
614 PROPAGATE_ON_CONTAINER_SWAP,
615 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
618 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
619 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
620 PROPAGATE_ON_CONTAINER_SWAP,
621 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
623select_on_container_copy_construction()
const
625 if (PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION) {
635 bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
636 bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
637 bool PROPAGATE_ON_CONTAINER_SWAP,
638 bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
639 bool IS_ALWAYS_EQUAL>
643 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
644 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
645 PROPAGATE_ON_CONTAINER_SWAP,
646 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
650 return d_allocator_p;
656template <
class TYPE1,
658 bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
659 bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
660 bool PROPAGATE_ON_CONTAINER_SWAP,
661 bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
662 bool IS_ALWAYS_EQUAL>
666 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
667 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
668 PROPAGATE_ON_CONTAINER_SWAP,
669 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
670 IS_ALWAYS_EQUAL>& lhs,
671 const StdStatefulAllocator<
673 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
674 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
675 PROPAGATE_ON_CONTAINER_SWAP,
676 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
677 IS_ALWAYS_EQUAL>& rhs)
679 return IS_ALWAYS_EQUAL || (lhs.allocator() == rhs.allocator());
682template <
class TYPE1,
684 bool PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
685 bool PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
686 bool PROPAGATE_ON_CONTAINER_SWAP,
687 bool PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
688 bool IS_ALWAYS_EQUAL>
692 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
693 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
694 PROPAGATE_ON_CONTAINER_SWAP,
695 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
696 IS_ALWAYS_EQUAL>& lhs,
697 const StdStatefulAllocator<
699 PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION,
700 PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT,
701 PROPAGATE_ON_CONTAINER_SWAP,
702 PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT,
703 IS_ALWAYS_EQUAL>& rhs)
705 return !IS_ALWAYS_EQUAL && (lhs.allocator() != rhs.allocator());
Definition bslma_allocator.h:457
std::size_t size_type
Definition bslma_allocator.h:499
Definition bsltf_stdstatefulallocator.h:233
std::ptrdiff_t difference_type
Definition bsltf_stdstatefulallocator.h:257
bslma::Allocator * allocator() const
Return the address of the allocator wrapped by this object.
Definition bsltf_stdstatefulallocator.h:648
bsl::integral_constant< bool, PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT > propagate_on_container_move_assignment
Definition bsltf_stdstatefulallocator.h:271
StdStatefulAllocator select_on_container_copy_construction() const
Definition bsltf_stdstatefulallocator.h:623
TYPE * allocate(bslma::Allocator::size_type numElements)
Definition bsltf_stdstatefulallocator.h:495
bsl::integral_constant< bool, PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT > propagate_on_container_copy_assignment
Definition bsltf_stdstatefulallocator.h:264
const TYPE * const_pointer
Definition bsltf_stdstatefulallocator.h:259
~StdStatefulAllocator()=default
StdStatefulAllocator(const StdStatefulAllocator &original)=default
std::size_t size_type
Definition bsltf_stdstatefulallocator.h:256
TYPE value_type
Definition bsltf_stdstatefulallocator.h:246
bsl::integral_constant< bool, PROPAGATE_ON_CONTAINER_SWAP > propagate_on_container_swap
Definition bsltf_stdstatefulallocator.h:267
void destroy(ELEMENT_TYPE *address)
Definition bsltf_stdstatefulallocator.h:560
void construct(ELEMENT_TYPE *address, Args &&... arguments)
Definition bsltf_stdstatefulallocator.h:521
BSLMF_NESTED_TRAIT_DECLARATION(StdStatefulAllocator, bslma::IsStdAllocator)
StdStatefulAllocator & operator=(const StdStatefulAllocator &rhs)=default
bsl::integral_constant< bool, IS_ALWAYS_EQUAL > is_always_equal
Definition bsltf_stdstatefulallocator.h:275
void deallocate(TYPE *address, bslma::Allocator::size_type numElements)
Definition bsltf_stdstatefulallocator.h:542
size_type max_size() const
Definition bsltf_stdstatefulallocator.h:586
TYPE * pointer
Definition bsltf_stdstatefulallocator.h:258
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2018
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition balxml_encoderoptions.h:68
Definition bsltf_allocargumenttype.h:92
bool operator!=(const AllocBitwiseMoveableTestType &lhs, const AllocBitwiseMoveableTestType &rhs)
bool operator==(const AllocBitwiseMoveableTestType &lhs, const AllocBitwiseMoveableTestType &rhs)
Definition bdldfp_decimal.h:5188
Definition bslmf_integralconstant.h:244
Definition bslmf_issame.h:146
static Allocator * defaultAllocator()
Definition bslma_default.h:889
Definition bslma_isstdallocator.h:201
Definition bsltf_stdstatefulallocator.h:285
StdStatefulAllocator< BDE_OTHER_TYPE, PROPAGATE_ON_CONTAINER_COPY_CONSTRUCTION, PROPAGATE_ON_CONTAINER_COPY_ASSIGNMENT, PROPAGATE_ON_CONTAINER_SWAP, PROPAGATE_ON_CONTAINER_MOVE_ASSIGNMENT, IS_ALWAYS_EQUAL > other
Definition bsltf_stdstatefulallocator.h:293