17#include "comms/util/SizeToType.h" 
   30COMMS_MSVC_WARNING_PUSH
 
   31COMMS_MSVC_WARNING_DISABLE(4324) 
 
   46    template <
typename TDerived, 
typename TQueueType>
 
   54    using StorageType = comms::util::AlignedStorage<
sizeof(ValueType), std::alignment_of<ValueType>::value>;
 
   55    using StorageTypePtr = StorageType*;
 
   56    using ConstStorageTypePtr = 
const StorageType*;
 
   57    using SizeType = std::size_t;
 
   58    using Reference = ValueType&;
 
   59    using ConstReference = 
const ValueType&;
 
   60    using Pointer = ValueType*;
 
   61    using ConstPointer = 
const ValueType*;
 
   62    using LinearisedIterator = Pointer;
 
   63    using ConstLinearisedIterator = ConstPointer;
 
   64    using ReverseLinearisedIterator = std::reverse_iterator<LinearisedIterator>;
 
   65    using ConstReverseLinearisedIterator = std::reverse_iterator<ConstLinearisedIterator>;
 
   66    using LinearisedIteratorRange = std::pair<LinearisedIterator, LinearisedIterator>;
 
   67    using ConstLinearisedIteratorRange = std::pair<ConstLinearisedIterator, ConstLinearisedIterator>;
 
   69    StaticQueueBase(StorageTypePtr data, std::size_t capacity)
 
   77    StaticQueueBase(
const StaticQueueBase&) = 
delete;
 
   78    StaticQueueBase(StaticQueueBase&&) = 
delete;
 
   80    ~StaticQueueBase() noexcept
 
   85    StaticQueueBase& operator=(
const StaticQueueBase& other)
 
   92        assignElements(other);
 
   96    StaticQueueBase& operator=(StaticQueueBase&& other)
 
  103        assignElements(std::move(other));
 
  107    constexpr std::size_t capacity()
 const 
  112    std::size_t size()
 const 
  126        return (size() == 0);
 
  131        return (size() == capacity());
 
  140    ConstReference front()
 const 
  148        auto constThis = 
static_cast<const StaticQueueBase*
>(
this);
 
  149        return const_cast<Reference
>(constThis->back());
 
  152    ConstReference back()
 const 
  159        return (*
this)[m_count - 1];
 
  172        Reference element = front();
 
  177        if ((capacity() <= m_startIdx) ||
 
  183    void popFront(std::size_t count)
 
  186        while ((!empty()) && (count > 0)) {
 
  201        Reference element = back();
 
  207    void popBack(std::size_t count)
 
  210        while ((!empty()) && (count > 0)) {
 
  216    Reference operator[](std::size_t index)
 
  218        auto constThis = 
static_cast<const StaticQueueBase*
>(
this);
 
  219        return const_cast<Reference
>((*constThis)[index]);
 
  222    ConstReference operator[](std::size_t index)
 const 
  225        return elementAtIndex(index);
 
  228    Reference at(std::size_t index)
 
  230        auto constThis = 
static_cast<const StaticQueueBase*
>(
this);
 
  231        return const_cast<Reference
>(constThis->at(index));
 
  234    ConstReference at(std::size_t index)
 const 
  236        if (index >= size()) {
 
  237            throw std::out_of_range(std::string(
"Index is out of range"));
 
  239        return (*
this)[index];
 
  242    int indexOf(ConstReference element)
 const 
  244        ConstPointer elementPtr = &element;
 
  245        auto cellPtr = 
reinterpret_cast<ConstStorageTypePtr
>(elementPtr);
 
  246        if ((cellPtr < &m_data[0]) ||
 
  247            (&m_data[capacity()] <= cellPtr)) {
 
  252        auto rawIdx = cellPtr - &m_data[0];
 
  253        std::size_t actualIdx = capacity(); 
 
  254        if (rawIdx < m_startIdx) {
 
  255            actualIdx = (capacity() - m_startIdx) + rawIdx;
 
  258            actualIdx = rawIdx - m_startIdx;
 
  261        if (size() <= actualIdx)
 
  270    LinearisedIterator invalidIter()
 
  272        return reinterpret_cast<LinearisedIterator
>(&m_data[capacity()]);
 
  275    ConstLinearisedIterator invalidIter()
 const 
  277        return reinterpret_cast<LinearisedIterator
>(&m_data[capacity()]);
 
  280    ReverseLinearisedIterator invalidReverseIter()
 
  282        return ReverseLinearisedIterator(
 
  283            reinterpret_cast<LinearisedIterator
>(&m_data[0]));
 
  286    ConstReverseLinearisedIterator invalidReverseIter()
 const 
  288        return ReverseLinearisedIterator(
 
  289            reinterpret_cast<LinearisedIterator
>(&m_data[0]));
 
  292    LinearisedIterator lbegin()
 
  295            return invalidIter();
 
  298        return reinterpret_cast<LinearisedIterator
>(&m_data[0] + m_startIdx);
 
  301    ConstLinearisedIterator lbegin()
 const 
  306    ConstLinearisedIterator clbegin()
 const 
  309            return invalidIter();
 
  312        return reinterpret_cast<LinearisedIterator
>(&m_data[0] + m_startIdx);
 
  315    ReverseLinearisedIterator rlbegin()
 
  318            return invalidReverseIter();
 
  321        return ReverseLinearisedIterator(lend());
 
  324    ConstReverseLinearisedIterator rlbegin()
 const 
  329    ConstReverseLinearisedIterator crlbegin()
 const 
  332            return invalidReverseIter();
 
  334        return ConstReverseLinearisedIterator(lend());
 
  337    LinearisedIterator lend()
 
  340            return invalidIter();
 
  343        return lbegin() + size();
 
  346    ConstLinearisedIterator lend()
 const 
  351    ConstLinearisedIterator clend()
 const 
  354            return invalidIter();
 
  357        return clbegin() + size();
 
  360    ReverseLinearisedIterator rlend()
 
  363            return invalidReverseIter();
 
  366        return rlbegin() + size();
 
  369    ConstReverseLinearisedIterator rlend()
 const 
  374    ConstReverseLinearisedIterator crlend()
 const 
  377            return invalidReverseIter();
 
  380        return rlbegin() + size();
 
  390        auto rangeOne = arrayOne();
 
  391        auto rangeOneSize = std::distance(rangeOne.first, rangeOne.second);
 
  393        auto rangeTwo = arrayTwo();
 
  394        auto rangeTwoSize = std::distance(rangeTwo.first, rangeTwo.second);
 
  397        auto remSpaceSize = capacity() - size();
 
  399        if (rangeTwoSize <= remSpaceSize) {
 
  400            lineariseByMoveOneTwo(rangeOne, rangeTwo);
 
  404        if (rangeOneSize <= remSpaceSize) {
 
  405            lineariseByMoveTwoOne(rangeOne, rangeTwo);
 
  409        if (rangeOneSize < rangeTwoSize) {
 
  416    bool linearised()
 const 
  418        return (empty() || ((m_startIdx + size()) <= capacity()));
 
  421    LinearisedIteratorRange arrayOne()
 
  423        auto constThis = 
static_cast<const StaticQueueBase*
>(
this);
 
  424        auto constRange = constThis->arrayOne();
 
  426            LinearisedIteratorRange(
 
  427                const_cast<LinearisedIterator
>(constRange.first),
 
  428                const_cast<LinearisedIterator
>(constRange.second));
 
  431    ConstLinearisedIteratorRange arrayOne()
 const 
  433        auto begCell = &m_data[m_startIdx];
 
  434        auto endCell = std::min(&m_data[m_startIdx + size()], &m_data[capacity()]);
 
  436            ConstLinearisedIteratorRange(
 
  437                reinterpret_cast<ConstLinearisedIterator
>(begCell),
 
  438                reinterpret_cast<ConstLinearisedIterator
>(endCell));
 
  441    LinearisedIteratorRange arrayTwo()
 
  443        auto constThis = 
static_cast<const StaticQueueBase*
>(
this);
 
  444        auto constRange = constThis->arrayTwo();
 
  446            LinearisedIteratorRange(
 
  447                const_cast<LinearisedIterator
>(constRange.first),
 
  448                const_cast<LinearisedIterator
>(constRange.second));
 
  451    ConstLinearisedIteratorRange arrayTwo()
 const 
  454            auto iter = arrayOne().second;
 
  455            return ConstLinearisedIteratorRange(iter, iter);
 
  458        auto begCell = &m_data[0];
 
  459        auto endCell = &m_data[(m_startIdx + size()) - capacity()];
 
  462            ConstLinearisedIteratorRange(
 
  463                reinterpret_cast<ConstLinearisedIterator
>(begCell),
 
  464                reinterpret_cast<ConstLinearisedIterator
>(endCell));
 
  467    void resize(std::size_t newSize)
 
  470        if (capacity() < newSize) {
 
  474        if (size() <= newSize) {
 
  475            while (size() < newSize) {
 
  476                pushBackNotFull(ValueType());
 
  483        popBack(size() - newSize);
 
  486    LinearisedIterator erase(LinearisedIterator pos)
 
  490        auto rangeOne = arrayOne();
 
  491        auto rangeTwo = arrayTwo();
 
  494            [](LinearisedIterator pos, 
const LinearisedIteratorRange range) -> 
bool 
  496                return ((range.first <= pos) && (pos < range.second));
 
  500               isInRangeFunc(pos, rangeTwo));
 
  502        if (isInRangeFunc(pos, rangeOne)) {
 
  503            std::move_backward(rangeOne.first, pos, pos + 1);
 
  506            rangeOne = arrayOne();
 
  507            if (isInRangeFunc(pos, rangeOne)) {
 
  511            return rangeOne.first;
 
  514        if (isInRangeFunc(pos, rangeTwo)) {
 
  515            std::move(pos + 1, rangeTwo.second, pos);
 
  520            return arrayOne().second;
 
  523        static constexpr bool Invalid_iterator_is_used = 
false;
 
  524        static_cast<void>(Invalid_iterator_is_used);
 
  526        return invalidIter();
 
  529    Iterator erase(Iterator pos)
 
  533        Pointer elem = &(*pos);
 
  534        auto rangeOne = arrayOne();
 
  535        auto rangeTwo = arrayTwo();
 
  538            [](Pointer elemPtr, 
const LinearisedIteratorRange range) -> 
bool 
  540                return ((&(*range.first) <= elemPtr) && (elemPtr < &(*range.second)));
 
  544                isInRangeFunc(elem, rangeTwo));
 
  546        if (isInRangeFunc(elem, rangeOne)) {
 
  547            std::move_backward(rangeOne.first, elem, elem + 1);
 
  550            rangeOne = arrayOne();
 
  551            if (isInRangeFunc(elem, rangeOne)) {
 
  558        if (isInRangeFunc(elem, rangeTwo)) {
 
  559            std::move(elem + 1, rangeTwo.second, elem);
 
  567        static constexpr bool Invalid_iterator_is_used = 
false;
 
  568        static_cast<void>(Invalid_iterator_is_used);
 
  575        return Iterator(*
this, 
reinterpret_cast<LinearisedIterator
>(&m_data[0]));
 
  578    ConstIterator begin()
 const 
  583    ConstIterator cbegin()
 const 
  585        return ConstIterator(*
this, 
reinterpret_cast<ConstLinearisedIterator
>(&m_data[0]));
 
  590        return Iterator(*
this, 
reinterpret_cast<LinearisedIterator
>(&m_data[size()]));
 
  593    ConstIterator end()
 const 
  598    ConstIterator cend()
 const 
  600        return ConstIterator(*
this, 
reinterpret_cast<ConstLinearisedIterator
>(&m_data[size()]));
 
  603    template <
typename TOther>
 
  604    void assignElements(TOther&& other)
 
  606        static_assert(std::is_base_of<StaticQueueBase, typename std::decay<TOther>::type>::value,
 
  607            "Assignment works only on the same types");
 
  610        using DecayedQueueType = 
typename std::decay<
decltype(other)>::type;
 
  611        using NonRefQueueType = 
typename std::remove_reference<
decltype(other)>::type;
 
  613        using QueueValueType = 
 
  615                std::is_const<NonRefQueueType>::value
 
  617                const typename DecayedQueueType::ValueType,
 
  618                typename DecayedQueueType::ValueType
 
  623                std::is_rvalue_reference<
decltype(other)>::value
 
  625                typename std::add_rvalue_reference<QueueValueType>::type,
 
  626                typename std::add_lvalue_reference<QueueValueType>::type
 
  632        auto rangeOne = other.arrayOne();
 
  633        for (
auto iter = rangeOne.first; iter != rangeOne.second; ++iter) {
 
  634            pushBackNotFull(std::forward<ElemRefType>(*iter));
 
  637        auto rangeTwo = other.arrayTwo();
 
  638        for (
auto iter = rangeTwo.first; iter != rangeTwo.second; ++iter) {
 
  639            pushBackNotFull(std::forward<ElemRefType>(*iter));
 
  643    template <
typename U>
 
  644    void pushBack(U&& value)
 
  650        pushBackNotFull(std::forward<U>(value));
 
  653    template <
typename... TArgs>
 
  654    void emplaceBack(TArgs&&... args)
 
  660        emplaceBackNotFull(std::forward<TArgs>(args)...);
 
  663    template <
typename U>
 
  664    void pushFront(U&& value)
 
  671        pushFrontNotFull(std::forward<U>(value));
 
  674    template <
typename U>
 
  675    LinearisedIterator insert(LinearisedIterator pos, U&& value)
 
  679            return invalidIter();
 
  682        return insertNotFull(pos, std::forward<U>(value));
 
  685    bool operator==(
const StaticQueueBase& other)
 const 
  687        if (size() != other.size()) {
 
  691        auto rangeOne = arrayOne();
 
  692        auto rangeOneSize = std::distance(rangeOne.first, rangeOne.second);
 
  693        auto rangeTwo = arrayTwo();
 
  694        auto otherRangeOne = other.arrayOne();
 
  695        auto otherRangeOneSize = std::distance(otherRangeOne.first, otherRangeOne.second);
 
  696        auto otherRangeTwo = other.arrayTwo();
 
  698        auto firstCompSize = std::min(rangeOneSize, otherRangeOneSize);
 
  699        auto firstCompEnd = rangeOne.first + firstCompSize;
 
  701        auto currIter = rangeOne.first;
 
  702        auto otherCurrIter = otherRangeOne.first;
 
  703        if (!std::equal(currIter, firstCompEnd, otherCurrIter)) {
 
  707        currIter = firstCompEnd;
 
  708        otherCurrIter += firstCompSize;
 
  710        if (currIter != rangeOne.first) {
 
  711            otherCurrIter = otherRangeTwo.first;
 
  712            if (!std::equal(currIter, rangeOne.second, otherCurrIter)) {
 
  715            otherCurrIter += rangeOne.second - currIter;
 
  716            currIter = rangeTwo.first;
 
  719            currIter = rangeTwo.first;
 
  720            if (!std::equal(otherCurrIter, otherRangeOne.second, currIter)) {
 
  724            currIter += otherRangeOne.second - otherCurrIter;
 
  725            otherCurrIter = otherRangeOne.first;
 
  728        COMMS_ASSERT(std::distance(currIter, rangeTwo.second) == std::distance(otherCurrIter, otherRangeTwo.second));
 
  729        return std::equal(currIter, rangeTwo.second, otherCurrIter);
 
  732    bool operator!=(
const StaticQueueBase& other)
 const 
  734        return !(*
this == other);
 
  739    template <
typename U>
 
  740    void createValueAtIndex(U&& value, std::size_t index)
 
  743        Reference elementRef = elementAtIndex(index);
 
  744        auto elementPtr = 
new(&elementRef) ValueType(std::forward<U>(value));
 
  745        static_cast<void>(elementPtr);
 
  748    template <
typename U>
 
  749    void pushBackNotFull(U&& value)
 
  752        createValueAtIndex(std::forward<U>(value), size());
 
  756    template <
typename... TArgs>
 
  757    void emplaceBackNotFull(TArgs&&... args)
 
  760        Reference elementRef = elementAtIndex(size());
 
  761        auto elementPtr = 
new(&elementRef) ValueType(std::forward<TArgs>(args)...);
 
  762        static_cast<void>(elementPtr);
 
  766    template <
typename U>
 
  767    void pushFrontNotFull(U&& value)
 
  770        createValueAtIndex(std::forward<U>(value), capacity() - 1);
 
  771        if (m_startIdx == 0) {
 
  772            m_startIdx = capacity() - 1;
 
  781    template <
typename U>
 
  782    LinearisedIterator insertNotFull(LinearisedIterator pos, U&& value)
 
  786        auto rangeOne = arrayOne();
 
  787        auto rangeTwo = arrayTwo();
 
  789        if (pos == rangeOne.first) {
 
  790            pushFrontNotFull(std::forward<U>(value));
 
  791            return arrayOne().first;
 
  794        if (pos == rangeTwo.second) {
 
  795            pushBackNotFull(std::forward<U>(value));
 
  796            return arrayTwo().second - 1;
 
  799        auto isInRangeFunc = [](LinearisedIterator pos, 
const LinearisedIteratorRange range) -> 
bool 
  801                return ((range.first <= pos) && (pos < range.second));
 
  805                isInRangeFunc(pos, rangeTwo));
 
  807        if (isInRangeFunc(pos, rangeOne)) {
 
  808            pushFrontNotFull(std::move(front())); 
 
  810            std::move(rangeOne.first + 1, pos, rangeOne.first);
 
  811            *pos = std::forward<U>(value);
 
  815        if (isInRangeFunc(pos, rangeTwo)) {
 
  816            pushBackNotFull(std::move(back())); 
 
  817            std::move_backward(pos, rangeTwo.second - 1, rangeTwo.second);
 
  818            *pos = std::forward<U>(value);
 
  822        return invalidIter();
 
  825    Reference elementAtIndex(std::size_t index) {
 
  826        auto constThis = 
static_cast<const StaticQueueBase*
>(
this);
 
  827        return const_cast<Reference
>(constThis->elementAtIndex(index));
 
  830    ConstReference elementAtIndex(std::size_t index)
 const 
  832        std::size_t rawIdx = m_startIdx + index;
 
  833        while (capacity() <= rawIdx) {
 
  834            rawIdx = rawIdx - capacity();
 
  837        auto cellAddr = &m_data[rawIdx];
 
  838        return *(
reinterpret_cast<ConstPointer
>(cellAddr));
 
  841    template <
typename TIter>
 
  842    void lineariseByMove(
 
  843        const std::pair<TIter, TIter> firstRange,
 
  844        const std::pair<TIter, TIter> secondRange)
 
  846        auto movConstructFirstSize =
 
  848                std::size_t(std::distance(firstRange.first, firstRange.second)),
 
  849                capacity() - size());
 
  850        auto movConstructFirstEnd = firstRange.first + movConstructFirstSize;
 
  851        COMMS_ASSERT(movConstructFirstEnd <= firstRange.second);
 
  852        COMMS_ASSERT(movConstructFirstSize <= (firstRange.second - firstRange.first));
 
  854        auto newPlacePtr = secondRange.second;
 
  855        for (
auto iter = firstRange.first; iter != movConstructFirstEnd; ++iter) {
 
  856            auto ptr = 
new (&(*newPlacePtr)) ValueType(std::move(*iter));
 
  857            static_cast<void>(ptr);
 
  861        std::move(movConstructFirstEnd, firstRange.second, newPlacePtr);
 
  862        newPlacePtr += (firstRange.second - movConstructFirstEnd);
 
  864        auto movConstructTwoSize = 0;
 
  865        if (newPlacePtr < firstRange.first) {
 
  866            movConstructTwoSize =
 
  867                std::min(std::distance(newPlacePtr, firstRange.first),
 
  868                         std::distance(secondRange.first, secondRange.second));
 
  871        auto movConstructTwoEnd = secondRange.first + movConstructTwoSize;
 
  872        for (
auto iter = secondRange.first; iter != movConstructTwoEnd; ++iter) {
 
  873            auto ptr = 
new (&(*newPlacePtr)) ValueType(std::move(*iter));
 
  874            static_cast<void>(ptr);
 
  878        std::move(movConstructTwoEnd, secondRange.second, newPlacePtr);
 
  879        newPlacePtr += (secondRange.second - movConstructTwoEnd);
 
  881        for (
auto iter = std::max(newPlacePtr, firstRange.first); iter != firstRange.second; ++iter) {
 
  885        for (
auto iter = secondRange.first; iter != secondRange.second; ++iter) {
 
  890    void lineariseByMoveOneTwo(
 
  891        const LinearisedIteratorRange& rangeOne,
 
  892        const LinearisedIteratorRange& rangeTwo)
 
  894        lineariseByMove(rangeOne, rangeTwo);
 
  895        m_startIdx = std::distance(rangeTwo.first, rangeTwo.second);
 
  898    void lineariseByMoveTwoOne(
 
  899        const LinearisedIteratorRange& rangeOne,
 
  900        const LinearisedIteratorRange& rangeTwo)
 
  902        using RevIter = std::reverse_iterator<Pointer>;
 
  904            std::make_pair(RevIter(rangeTwo.second), RevIter(rangeTwo.first)),
 
  905            std::make_pair(RevIter(rangeOne.second), RevIter(rangeOne.first)));
 
  907        m_startIdx = (capacity() - std::distance(rangeOne.first, rangeOne.second)) - size();
 
  910    void lineariseByPopOne()
 
  916        ValueType tmp(std::move(front()));
 
  919        if (m_startIdx == 0) {
 
  920            using RevIter = std::reverse_iterator<LinearisedIterator>;
 
  922                RevIter(
reinterpret_cast<LinearisedIterator
>(&m_data[capacity()]));
 
  923            moveRange(rlbegin(), rlend(), target);
 
  924            m_startIdx = capacity() - size();
 
  926        pushFront(std::move(tmp));
 
  930    void lineariseByPopTwo()
 
  936        ValueType tmp(std::move(back()));
 
  939        if (m_startIdx != 0) {
 
  940            auto target = 
reinterpret_cast<LinearisedIterator
>(&m_data[0]);
 
  941            moveRange(lbegin(), lend(), target);
 
  944        pushBack(std::move(tmp));
 
  948    template <
typename TIter>
 
  949    void moveRange(TIter rangeBeg, TIter rangeEnd, TIter target)
 
  952        auto moveConstructSize =
 
  954                std::distance(rangeBeg, rangeEnd),
 
  955                std::distance(target, rangeBeg));
 
  957        TIter moveConstructEnd = rangeBeg + moveConstructSize;
 
  958        for (
auto iter = rangeBeg; iter != moveConstructEnd; ++iter) {
 
  959            auto ptr = 
new (&(*target)) ValueType(std::move(*iter));
 
  960            static_cast<void>(ptr);
 
  965        std::move(moveConstructEnd, rangeEnd, target);
 
  966        target += std::distance(moveConstructEnd, rangeEnd);
 
  968        for (
auto iter = std::max(target, rangeBeg); iter != rangeEnd; ++iter) {
 
  973    StorageTypePtr 
const m_data;
 
  974    const std::size_t m_capacity;
 
  975    std::size_t m_startIdx;
 
  980template <
typename TDerived, 
typename TQueueType>
 
  981class StaticQueueBase<T>::IteratorBase
 
  983    friend class StaticQueueBase<T>;
 
  986    IteratorBase(
const IteratorBase&) = 
default;
 
  988    ~IteratorBase() noexcept = default;
 
  991    using Derived = TDerived;
 
  992    using QueueType = TQueueType;
 
  993    using ArrayIterator = decltype(
std::declval<QueueType>().lbegin());
 
  994    using IteratorCategory = typename 
std::iterator_traits<ArrayIterator>::iterator_category;
 
  995    using iterator_category = IteratorCategory;
 
  996    using ValueType = typename 
std::iterator_traits<ArrayIterator>::value_type;
 
  997    using value_type = ValueType;
 
  998    using DifferenceType = typename 
std::iterator_traits<ArrayIterator>::difference_type;
 
  999    using difference_type = DifferenceType;
 
 1000    using Pointer = typename 
std::iterator_traits<ArrayIterator>::pointer;
 
 1001    using pointer = Pointer;
 
 1002    using ConstPointer =
 
 1003        typename 
std::add_pointer<
 
 1004            typename 
std::add_const<
 
 1005                typename 
std::remove_pointer<Pointer>::type
 
 1008    using Reference = typename 
std::iterator_traits<ArrayIterator>::reference;
 
 1009    using reference = Reference;
 
 1010    using ConstReference = typename 
std::add_const<Reference>::type;
 
 1012    IteratorBase(QueueType& queue, ArrayIterator iterator)
 
 1014          m_iterator(iterator)
 
 1018    Derived& operator=(
const IteratorBase& other)
 
 1021        m_iterator = other.m_iterator; 
 
 1022        return static_cast<Derived&
>(*this);
 
 1025    Derived& operator++()
 
 1028        return static_cast<Derived&
>(*this);
 
 1031    Derived operator++(
int)
 
 1033        IteratorBase copy(*
this);
 
 1035        return std::move(*(
static_cast<Derived*
>(©)));
 
 1038    Derived& operator--()
 
 1041        return static_cast<Derived&
>(*this);
 
 1044    Derived operator--(
int)
 
 1046        IteratorBase copy(*
this);
 
 1048        return std::move(*(
static_cast<Derived*
>(©)));
 
 1051    Derived& operator+=(DifferenceType value)
 
 1053        m_iterator += value;
 
 1054        return static_cast<Derived&
>(*this);
 
 1057    Derived& operator-=(DifferenceType value)
 
 1059        m_iterator -= value;
 
 1060        return static_cast<Derived&
>(*this);
 
 1063    Derived operator+(DifferenceType value)
 const 
 1065        IteratorBase copy(*
this);
 
 1067        return std::move(*(
static_cast<Derived*
>(©)));
 
 1070    Derived operator-(DifferenceType value)
 const 
 1072        IteratorBase copy(*
this);
 
 1074        return std::move(*(
static_cast<Derived*
>(©)));
 
 1077    DifferenceType operator-(
const IteratorBase& other)
 const 
 1079        return m_iterator - other.m_iterator;
 
 1082    bool operator==(
const IteratorBase& other)
 const 
 1084        return (m_iterator == other.m_iterator);
 
 1087    bool operator!=(
const IteratorBase& other)
 const 
 1089        return (m_iterator != other.m_iterator);
 
 1092    bool operator<(
const IteratorBase& other)
 const 
 1094        return m_iterator < other.m_iterator;
 
 1097    bool operator<=(
const IteratorBase& other)
 const 
 1099        return m_iterator <= other.m_iterator;
 
 1102    bool operator>(
const IteratorBase& other)
 const 
 1104        return m_iterator > other.m_iterator;
 
 1107    bool operator>=(
const IteratorBase& other)
 const 
 1109        return m_iterator >= other.m_iterator;
 
 1112    Reference operator*()
 
 1114        auto& constThisRef = 
static_cast<const IteratorBase&
>(*this);
 
 1115        auto& constRef = *constThisRef;
 
 1116        return const_cast<Reference
>(constRef);
 
 1119    ConstReference operator*()
 const 
 1121        auto begCell = 
reinterpret_cast<ArrayIterator
>(&m_queue.m_data[0]);
 
 1122        auto idx = m_iterator - begCell;
 
 1124        return m_queue[
static_cast<std::size_t
>(idx)];
 
 1127    Pointer operator->()
 
 1132    ConstPointer operator->()
 const 
 1137    QueueType& getQueue() {
 
 1141    typename std::add_const<QueueType&>::type getQueue()
 const 
 1146    ArrayIterator& getIterator() {
 
 1150    typename std::add_const<ArrayIterator>::type& getIterator()
 const 
 1158    ArrayIterator m_iterator; 
 
 1161template <
typename T>
 
 1162class StaticQueueBase<T>::ConstIterator :
 
 1163            public StaticQueueBase<T>::template
 
 1164                IteratorBase<typename StaticQueueBase<T>::ConstIterator, const StaticQueueBase<T> >
 
 1166    using Base = 
typename StaticQueueBase<T>::template
 
 1167        IteratorBase<typename StaticQueueBase<T>::ConstIterator, 
const StaticQueueBase<T> >;
 
 1170    using QueueType = 
typename Base::QueueType;
 
 1171    using ArrayIterator = 
typename Base::ArrayIterator;
 
 1173    ConstIterator(
const ConstIterator&) = 
default;
 
 1174    ~ConstIterator() noexcept = default;
 
 1176    ConstIterator(QueueType& queue, ArrayIterator iterator)
 
 1177        : Base(queue, iterator)
 
 1183template <
typename T>
 
 1184class StaticQueueBase<T>::Iterator :
 
 1185            public StaticQueueBase<T>::template
 
 1186                IteratorBase<typename StaticQueueBase<T>::Iterator, StaticQueueBase<T> >
 
 1188    using Base = 
typename StaticQueueBase<T>::template
 
 1189        IteratorBase<typename StaticQueueBase<T>::Iterator, StaticQueueBase<T> >;
 
 1192    using QueueType = 
typename Base::QueueType;
 
 1193    using ArrayIterator = 
typename Base::ArrayIterator;
 
 1195    Iterator(
const Iterator&) = 
default;
 
 1196    ~Iterator() noexcept = default;
 
 1198    Iterator(QueueType& queue, ArrayIterator iterator)
 
 1199        : Base(queue, iterator)
 
 1203    operator ConstIterator()
 const 
 1205        return ConstIterator(Base::getQueue(), Base::getIterator());
 
 1210template <
typename TWrapperElemType, 
typename TQueueElemType>
 
 1211class CastWrapperQueueBase : 
public StaticQueueBase<TQueueElemType>
 
 1213    using Base = StaticQueueBase<TQueueElemType>;
 
 1214    using WrapperElemType = TWrapperElemType;
 
 1216    using BaseValueType = 
typename Base::ValueType;
 
 1217    using BaseStorageTypePtr = 
typename Base::StorageTypePtr;
 
 1218    using BaseReference = 
typename Base::Reference;
 
 1219    using BaseConstReference = 
typename Base::ConstReference;
 
 1220    using BasePointer = 
typename Base::Pointer;
 
 1221    using BaseConstPointer = 
typename Base::ConstPointer;
 
 1222    using BaseLinearisedIterator = 
typename Base::LinearisedIterator;
 
 1223    using BaseConstLinearisedIterator = 
typename Base::ConstLinearisedIterator;
 
 1224    using BaseReverseLinearisedIterator = 
typename Base::ReverseLinearisedIterator;
 
 1225    using BaseConstReverseLinearisedIterator = 
typename Base::ConstReverseLinearisedIterator;
 
 1226    using BaseLinearisedIteratorRange = 
typename Base::LinearisedIteratorRange;
 
 1227    using BaseConstLinearisedIteratorRange = 
typename Base::ConstLinearisedIteratorRange;
 
 1231    class ConstIterator;
 
 1235    using ValueType = WrapperElemType;
 
 1236    using StorageType = comms::util::AlignedStorage<
sizeof(ValueType), std::alignment_of<ValueType>::value>;
 
 1237    using StorageTypePtr = StorageType*;
 
 1238    using Reference = ValueType&;
 
 1239    using ConstReference = 
const ValueType&;
 
 1240    using Pointer = ValueType*;
 
 1241    using ConstPointer = 
const ValueType*;
 
 1242    using LinearisedIterator = Pointer;
 
 1243    using ConstLinearisedIterator = ConstPointer;
 
 1244    using ReverseLinearisedIterator = std::reverse_iterator<LinearisedIterator>;
 
 1245    using ConstReverseLinearisedIterator = std::reverse_iterator<ConstLinearisedIterator>;
 
 1246    using LinearisedIteratorRange = std::pair<LinearisedIterator, LinearisedIterator>;
 
 1247    using ConstLinearisedIteratorRange = std::pair<ConstLinearisedIterator, ConstLinearisedIterator>;
 
 1249    CastWrapperQueueBase(StorageTypePtr data, std::size_t capacity)
 
 1250        : Base(reinterpret_cast<BaseStorageTypePtr>(data), capacity)
 
 1252        static_assert(
sizeof(ValueType) == 
sizeof(BaseValueType),
 
 1253            "The times must have identical size.");
 
 1256    ~CastWrapperQueueBase() noexcept = default;
 
 1258    CastWrapperQueueBase& operator=(const CastWrapperQueueBase& other) = default;
 
 1259    CastWrapperQueueBase& operator=(CastWrapperQueueBase&& other) = default;
 
 1263        return reinterpret_cast<Reference
>(Base::front());
 
 1266    ConstReference front()
 const 
 1268        return reinterpret_cast<ConstReference
>(Base::front());
 
 1273        return reinterpret_cast<Reference
>(Base::back());
 
 1276    ConstReference back()
 const 
 1278        return reinterpret_cast<Reference
>(Base::back());
 
 1281    Reference operator[](std::size_t index)
 
 1283        return reinterpret_cast<Reference
>(Base::operator[](index));
 
 1286    ConstReference operator[](std::size_t index)
 const 
 1288        return reinterpret_cast<ConstReference
>(Base::operator[](index));
 
 1291    Reference at(std::size_t index)
 
 1293        return reinterpret_cast<Reference
>(Base::at(index));
 
 1296    ConstReference at(std::size_t index)
 const 
 1298        return reinterpret_cast<ConstReference
>(Base::at(index));
 
 1301    int indexOf(ConstReference element)
 const 
 1303        return Base::indexOf(
reinterpret_cast<BaseConstReference
>(element));
 
 1306    LinearisedIterator invalidIter()
 
 1308        return reinterpret_cast<LinearisedIterator
>(Base::invalidIter());
 
 1311    ConstLinearisedIterator invalidIter()
 const 
 1313        return reinterpret_cast<ConstLinearisedIterator
>(Base::invalidIter());
 
 1316    ReverseLinearisedIterator invalidReverseIter()
 
 1318        return ReverseLinearisedIterator(
 
 1319            reinterpret_cast<LinearisedIterator
>(
 
 1320                Base::invalidReverseIter().base()));
 
 1323    ConstReverseLinearisedIterator invalidReverseIter()
 const 
 1325        return ConstReverseLinearisedIterator(
 
 1326            reinterpret_cast<ConstLinearisedIterator
>(
 
 1327                Base::invalidReverseIter().base()));
 
 1330    LinearisedIterator lbegin()
 
 1332        return reinterpret_cast<LinearisedIterator
>(Base::lbegin());
 
 1335    ConstLinearisedIterator lbegin()
 const 
 1337        return reinterpret_cast<ConstLinearisedIterator
>(Base::lbegin());
 
 1340    ConstLinearisedIterator clbegin()
 const 
 1342        return reinterpret_cast<ConstLinearisedIterator
>(Base::clbegin());
 
 1345    ReverseLinearisedIterator rlbegin()
 
 1347        return ReverseLinearisedIterator(
 
 1348            reinterpret_cast<LinearisedIterator
>(
 
 1349                Base::rlbegin().base()));
 
 1352    ConstReverseLinearisedIterator rlbegin()
 const 
 1354        return ConstReverseLinearisedIterator(
 
 1355            reinterpret_cast<ConstLinearisedIterator
>(
 
 1356                Base::rlbegin().base()));
 
 1359    ConstReverseLinearisedIterator crlbegin()
 const 
 1361        return ConstReverseLinearisedIterator(
 
 1362            reinterpret_cast<ConstLinearisedIterator
>(
 
 1363                Base::crlbegin().base()));
 
 1366    LinearisedIterator lend()
 
 1368        return reinterpret_cast<LinearisedIterator
>(Base::lend());
 
 1371    ConstLinearisedIterator lend()
 const 
 1373        return reinterpret_cast<ConstLinearisedIterator
>(Base::lend());
 
 1376    ConstLinearisedIterator clend()
 const 
 1378        return reinterpret_cast<ConstLinearisedIterator
>(Base::clend());
 
 1381    ReverseLinearisedIterator rlend()
 
 1383        return ReverseLinearisedIterator(
 
 1384            reinterpret_cast<LinearisedIterator
>(
 
 1385                Base::rlend().base()));
 
 1388    ConstReverseLinearisedIterator rlend()
 const 
 1390        return ConstReverseLinearisedIterator(
 
 1391            reinterpret_cast<ConstLinearisedIterator
>(
 
 1392                Base::rlend().base()));
 
 1395    ConstReverseLinearisedIterator crlend()
 const 
 1397        return ConstReverseLinearisedIterator(
 
 1398            reinterpret_cast<ConstLinearisedIterator
>(
 
 1399                Base::crlend().base()));
 
 1402    LinearisedIteratorRange arrayOne()
 
 1404        auto range = Base::arrayOne();
 
 1405        return LinearisedIteratorRange(
 
 1406            reinterpret_cast<LinearisedIterator
>(range.first),
 
 1407            reinterpret_cast<LinearisedIterator
>(range.second));
 
 1410    ConstLinearisedIteratorRange arrayOne()
 const 
 1412        auto range = Base::arrayOne();
 
 1413        return ConstLinearisedIteratorRange(
 
 1414            reinterpret_cast<ConstLinearisedIterator
>(range.first),
 
 1415            reinterpret_cast<ConstLinearisedIterator
>(range.second));
 
 1419    LinearisedIteratorRange arrayTwo()
 
 1421        auto range = Base::arrayTwo();
 
 1422        return LinearisedIteratorRange(
 
 1423            reinterpret_cast<LinearisedIterator
>(range.first),
 
 1424            reinterpret_cast<LinearisedIterator
>(range.second));
 
 1428    ConstLinearisedIteratorRange arrayTwo()
 const 
 1430        auto range = Base::arrayTwo();
 
 1431        return ConstLinearisedIteratorRange(
 
 1432            reinterpret_cast<ConstLinearisedIterator
>(range.first),
 
 1433            reinterpret_cast<ConstLinearisedIterator
>(range.second));
 
 1437    LinearisedIterator erase(LinearisedIterator pos)
 
 1439        return reinterpret_cast<LinearisedIterator
>(
 
 1441                reinterpret_cast<BaseLinearisedIterator
>(pos)));
 
 1444    Iterator erase(Iterator pos)
 
 1446        auto tmp = Base::erase(pos);
 
 1447        return *(
reinterpret_cast<Iterator*
>(&tmp));
 
 1452        auto tmp = Base::begin();
 
 1453        return *(
reinterpret_cast<Iterator*
>(&tmp));
 
 1456    ConstIterator begin()
 const 
 1458        auto tmp = Base::begin();
 
 1459        return *(
reinterpret_cast<ConstIterator*
>(&tmp));
 
 1462    ConstIterator cbegin()
 const 
 1464        auto tmp = Base::cbegin();
 
 1465        return *(
reinterpret_cast<ConstIterator*
>(&tmp));
 
 1471        auto tmp = Base::end();
 
 1472        return *(
reinterpret_cast<Iterator*
>(&tmp));
 
 1475    ConstIterator end()
 const 
 1477        auto tmp = Base::end();
 
 1478        return *(
reinterpret_cast<ConstIterator*
>(&tmp));
 
 1481    ConstIterator cend()
 const 
 1483        auto tmp = Base::cend();
 
 1484        return *(
reinterpret_cast<ConstIterator*
>(&tmp));
 
 1487    void pushBack(ConstReference value)
 
 1489        Base::pushBack(
reinterpret_cast<BaseConstReference
>(value));
 
 1492    void pushFront(ConstReference value)
 
 1494        Base::pushFront(
reinterpret_cast<BaseConstReference
>(value));
 
 1497    LinearisedIterator insert(LinearisedIterator pos, ConstReference value)
 
 1499        return reinterpret_cast<LinearisedIterator
>(
 
 1501                reinterpret_cast<BaseLinearisedIterator
>(pos),
 
 1502                reinterpret_cast<BaseConstReference
>(value)));
 
 1505    void assignElements(
const CastWrapperQueueBase& other)
 
 1507        Base::assignElements(
static_cast<const Base&
>(other));
 
 1510    void assignElements(CastWrapperQueueBase&& other)
 
 1512        Base::assignElements(
static_cast<Base&&
>(std::move(other)));
 
 1516template <
typename TWrapperElemType, 
typename TQueueElemType>
 
 1517class CastWrapperQueueBase<TWrapperElemType, TQueueElemType>::ConstIterator :
 
 1518                            public StaticQueueBase<TQueueElemType>::ConstIterator
 
 1520    using Base = 
typename StaticQueueBase<TQueueElemType>::ConstIterator;
 
 1522    ConstIterator(
const ConstIterator&) = 
default;
 
 1523    ConstIterator& operator=(
const ConstIterator&) = 
default;
 
 1524    ~ConstIterator() noexcept = default;
 
 1527    using ExpectedQueueType = const StaticQueueBase<TWrapperElemType>;
 
 1528    using ActualQueueType = const StaticQueueBase<TQueueElemType>;
 
 1529    using ValueType = TWrapperElemType;
 
 1530    using Reference = const ValueType&;
 
 1531    using ConstReference = const ValueType&;
 
 1532    using Pointer = const ValueType*;
 
 1533    using ConstPointer = const ValueType*;
 
 1534    using DifferenceType = typename Base::DifferenceType;
 
 1536    ConstIterator(ExpectedQueueType& queue, Pointer iterator)
 
 1537        : Base(reinterpret_cast<ActualQueueType&>(queue), iterator)
 
 1541    ConstIterator& operator++()
 
 1547    ConstIterator operator++(
int dummy)
 
 1549        auto tmp = Base::operator++(dummy);
 
 1550        return *(
static_cast<ConstIterator*
>(&tmp));
 
 1553    ConstIterator& operator--()
 
 1559    ConstIterator operator--(
int dummy)
 
 1561        auto tmp = Base::operator--(dummy);
 
 1562        return *(
static_cast<ConstIterator*
>(&tmp));
 
 1565    ConstIterator& operator+=(DifferenceType value)
 
 1567        Base::operator+=(value);
 
 1571    ConstIterator& operator-=(DifferenceType value)
 
 1573        Base::operator-=(value);
 
 1577    ConstIterator operator+(DifferenceType value)
 const 
 1579        auto tmp = Base::operator+(value);
 
 1580        return *(
static_cast<ConstIterator*
>(&tmp));
 
 1583    ConstIterator operator-(DifferenceType value)
 const 
 1585        auto tmp = Base::operator-(value);
 
 1586        return *(
static_cast<ConstIterator*
>(&tmp));
 
 1589    DifferenceType operator-(
const ConstIterator& other)
 const 
 1591        return Base::operator-(other);
 
 1594    Reference operator*()
 
 1596        auto& ref = Base::operator*();
 
 1597        return reinterpret_cast<Reference
>(ref);
 
 1600    ConstReference operator*()
 const 
 1602        auto& ref = Base::operator*();
 
 1603        return reinterpret_cast<ConstReference
>(ref);
 
 1606    Pointer operator->()
 
 1608        auto* ptr = Base::operator->();
 
 1609        return reinterpret_cast<Pointer
>(ptr);
 
 1612    ConstPointer operator->()
 const 
 1614        auto* ptr = Base::operator->();
 
 1615        return reinterpret_cast<ConstPointer
>(ptr);
 
 1619template <
typename TWrapperElemType, 
typename TQueueElemType>
 
 1620class CastWrapperQueueBase<TWrapperElemType, TQueueElemType>::Iterator :
 
 1621                            public StaticQueueBase<TQueueElemType>::Iterator
 
 1623    using Base = 
typename StaticQueueBase<TQueueElemType>::Iterator;
 
 1625    Iterator(
const Iterator&) = 
default;
 
 1626    Iterator& operator=(
const Iterator&) = 
default;
 
 1627    ~Iterator() noexcept = default;
 
 1630    using ExpectedQueueType = const StaticQueueBase<TWrapperElemType>;
 
 1631    using ActualQueueType = const StaticQueueBase<TQueueElemType>;
 
 1632    using ValueType = TWrapperElemType;
 
 1633    using Reference = ValueType&;
 
 1634    using ConstReference = const ValueType&;
 
 1635    using Pointer = ValueType*;
 
 1636    using ConstPointer = const ValueType*;
 
 1637    using DifferenceType = typename Base::DifferenceType;
 
 1639    Iterator(ExpectedQueueType& queue, Pointer iterator)
 
 1640        : Base(reinterpret_cast<ActualQueueType&>(queue), iterator)
 
 1644    Iterator& operator++()
 
 1650    Iterator operator++(
int dummy)
 
 1652        auto tmp = Base::operator++(dummy);
 
 1653        return *(
static_cast<Iterator*
>(&tmp));
 
 1656    Iterator& operator--()
 
 1662    Iterator operator--(
int dummy)
 
 1664        auto tmp = Base::operator--(dummy);
 
 1665        return *(
static_cast<Iterator*
>(&tmp));
 
 1668    Iterator& operator+=(DifferenceType value)
 
 1670        Base::operator+=(value);
 
 1674    Iterator& operator-=(DifferenceType value)
 
 1676        Base::operator-=(value);
 
 1680    Iterator operator+(DifferenceType value)
 const 
 1682        auto tmp = Base::operator+(value);
 
 1683        return *(
static_cast<Iterator*
>(&tmp));
 
 1686    Iterator operator-(DifferenceType value)
 const 
 1688        auto tmp = Base::operator-(value);
 
 1689        return *(
static_cast<Iterator*
>(&tmp));
 
 1692    DifferenceType operator-(
const Iterator& other)
 const 
 1694        return Base::operator-(other);
 
 1697    Reference operator*()
 
 1699        auto& ref = Base::operator*();
 
 1700        return reinterpret_cast<Reference
>(ref);
 
 1703    ConstReference operator*()
 const 
 1705        auto& ref = Base::operator*();
 
 1706        return reinterpret_cast<ConstReference
>(ref);
 
 1709    Pointer operator->()
 
 1711        auto* ptr = Base::operator->();
 
 1712        return reinterpret_cast<Pointer
>(ptr);
 
 1715    ConstPointer operator->()
 const 
 1717        auto* ptr = Base::operator->();
 
 1718        return reinterpret_cast<ConstPointer
>(ptr);
 
 1722template <
typename T>
 
 1723class StaticQueueBaseOptimised : 
public StaticQueueBase<T>
 
 1725    usign Base = StaticQueueBase<T>;
 
 1728    using StorageTypePtr = 
typename Base::StorageTypePtr;
 
 1730    StaticQueueBaseOptimised(StorageTypePtr data, std::size_t capacity)
 
 1731        : Base(data, capacity)
 
 1735    ~StaticQueueBaseOptimised() noexcept = default;
 
 1737    StaticQueueBaseOptimised& operator=(const StaticQueueBaseOptimised& other) = default;
 
 1738    StaticQueueBaseOptimised& operator=(StaticQueueBaseOptimised&& other) = default;
 
 1742class StaticQueueBaseOptimised<
std::int8_t> : public CastWrapperQueueBase<
std::int8_t, 
std::uint8_t>
 
 1744    using Base = CastWrapperQueueBase<std::int8_t, std::uint8_t>;
 
 1747    using StorageTypePtr = 
typename Base::StorageTypePtr;
 
 1749    StaticQueueBaseOptimised(StorageTypePtr data, std::size_t capacity)
 
 1750        : Base(data, capacity)
 
 1754    ~StaticQueueBaseOptimised() noexcept = default;
 
 1755    StaticQueueBaseOptimised& operator=(const StaticQueueBaseOptimised& other) = default;
 
 1756    StaticQueueBaseOptimised& operator=(StaticQueueBaseOptimised&& other) = default;
 
 1760class StaticQueueBaseOptimised<
std::int16_t> : public CastWrapperQueueBase<
std::int16_t, 
std::uint16_t>
 
 1762    using Base = CastWrapperQueueBase<std::int16_t, std::uint16_t>;
 
 1765    using StorageTypePtr = 
typename Base::StorageTypePtr;
 
 1767    StaticQueueBaseOptimised(StorageTypePtr data, std::size_t capacity)
 
 1768        : Base(data, capacity)
 
 1772    ~StaticQueueBaseOptimised() noexcept = default;
 
 1773    StaticQueueBaseOptimised& operator=(const StaticQueueBaseOptimised& other) = default;
 
 1774    StaticQueueBaseOptimised& operator=(StaticQueueBaseOptimised&& other) = default;
 
 1778class StaticQueueBaseOptimised<
std::int32_t> : public CastWrapperQueueBase<
std::int32_t, 
std::uint32_t>
 
 1780    using Base = CastWrapperQueueBase<std::int32_t, std::uint32_t>;
 
 1783    using StorageTypePtr = 
typename Base::StorageTypePtr;
 
 1785    StaticQueueBaseOptimised(StorageTypePtr data, std::size_t capacity)
 
 1786        : Base(data, capacity)
 
 1790    ~StaticQueueBaseOptimised() noexcept = default;
 
 1791    StaticQueueBaseOptimised& operator=(const StaticQueueBaseOptimised& other) = default;
 
 1792    StaticQueueBaseOptimised& operator=(StaticQueueBaseOptimised&& other) = default;
 
 1796class StaticQueueBaseOptimised<
std::int64_t> : public CastWrapperQueueBase<
std::int64_t, 
std::uint64_t>
 
 1798    using Base = CastWrapperQueueBase<std::int64_t, std::uint64_t>;
 
 1801    using StorageTypePtr = 
typename Base::StorageTypePtr;
 
 1803    StaticQueueBaseOptimised(StorageTypePtr data, std::size_t capacity)
 
 1804        : Base(data, capacity)
 
 1808    ~StaticQueueBaseOptimised() noexcept = default;
 
 1809    StaticQueueBaseOptimised& operator=(const StaticQueueBaseOptimised& other) = default;
 
 1810    StaticQueueBaseOptimised& operator=(StaticQueueBaseOptimised&& other) = default;
 
 1813template <typename T>
 
 1814class StaticQueueBaseOptimised<T*> : public CastWrapperQueueBase<T*, typename 
comms::util::SizeToType<sizeof(T*)>::Type>
 
 1816    using Base = CastWrapperQueueBase<T*, 
typename comms::util::SizeToType<
sizeof(T*)>::Type>;
 
 1819    using Base = 
typename Base::StorageTypePtr;
 
 1821    StaticQueueBaseOptimised(StorageTypePtr data, std::size_t capacity)
 
 1822        : Base(data, capacity)
 
 1826    ~StaticQueueBaseOptimised() noexcept = default;
 
 1827    StaticQueueBaseOptimised& operator=(const StaticQueueBaseOptimised& other) = default;
 
 1828    StaticQueueBaseOptimised& operator=(StaticQueueBaseOptimised&& other) = default;
 
 1846template <typename T, 
std::
size_t TSize>
 
 1847class StaticQueue : public details::StaticQueueBaseOptimised<T>
 
 1849    using Base = details::StaticQueueBaseOptimised<T>;
 
 1851    using StorageType = 
typename Base::StorageType;
 
 1854    using ValueType = 
typename Base::ValueType;
 
 1857    using value_type = ValueType;
 
 1860    using SizeType = 
typename Base::SizeType;
 
 1863    using size_type = SizeType;
 
 1866    using Reference = 
typename Base::Reference;
 
 1869    using reference = Reference;
 
 1872    using ConstReference = 
typename Base::ConstReference;
 
 1875    using const_reference = ConstReference;
 
 1878    using Pointer = 
typename Base::Pointer;
 
 1881    using pointer = Pointer;
 
 1884    using ConstPointer = 
typename Base::ConstPointer;
 
 1887    using const_pointer = ConstPointer;
 
 1890    using LinearisedIterator = 
typename Base::LinearisedIterator;
 
 1893    using ConstLinearisedIterator = 
typename Base::ConstLinearisedIterator;
 
 1896    using ReverseLinearisedIterator = 
typename Base::ReverseLinearisedIterator;
 
 1899    using ConstReverseLinearisedIterator = 
typename Base::ConstReverseLinearisedIterator;
 
 1902    using LinearisedIteratorRange = 
typename Base::LinearisedIteratorRange;
 
 1905    using ConstLinearisedIteratorRange = 
typename Base::ConstLinearisedIteratorRange;
 
 1908    class ConstIterator;
 
 1911    using const_iterator = ConstIterator;
 
 1917    using iterator = Iterator;
 
 1925        : Base(&m_array[0], TSize)
 
 1937    StaticQueue(
const StaticQueue& queue)
 
 1938        : Base(&m_array[0], TSize)
 
 1940        Base::assignElements(queue);
 
 1951    StaticQueue(StaticQueue&& queue)
 
 1952        : Base(&m_array[0], TSize)
 
 1954        Base::assignElements(std::move(queue));
 
 1966    template <std::
size_t TAnySize>
 
 1967    StaticQueue(
const StaticQueue<T, TAnySize>& queue)
 
 1968        : Base(&m_array[0], TSize)
 
 1970        Base::assignElements(queue);
 
 1981    template <std::
size_t TAnySize>
 
 1982    StaticQueue(StaticQueue<T, TAnySize>&& queue)
 
 1983        : Base(&m_array[0], TSize)
 
 1985        Base::assignElements(std::move(queue));
 
 1994    ~StaticQueue() noexcept
 
 2009    StaticQueue& operator=(
const StaticQueue& queue)
 
 2011        return static_cast<StaticQueue&
>(Base::operator=(queue));
 
 2024    StaticQueue& operator=(StaticQueue&& queue)
 
 2026        return static_cast<StaticQueue&
>(Base::operator=(std::move(queue)));
 
 2041    template <std::
size_t TAnySize>
 
 2042    StaticQueue& operator=(
const StaticQueue<T, TAnySize>& queue)
 
 2044        return static_cast<StaticQueue&
>(Base::operator=(queue));
 
 2058    template <std::
size_t TAnySize>
 
 2059    StaticQueue& operator=(StaticQueue<T, TAnySize>&& queue)
 
 2061        return static_cast<StaticQueue&
>(Base::operator=(std::move(queue)));
 
 2070    static constexpr std::size_t capacity()
 
 2082    std::size_t size()
 const 
 2084        return Base::size();
 
 2094        return Base::empty();
 
 2098    bool isEmpty()
 const 
 2110        return Base::full();
 
 2141    inline void pop_back()
 
 2155    void popBack(std::size_t count)
 
 2157        Base::popBack(count);
 
 2161    void pop_back(std::size_t count)
 
 2178    inline void pop_front()
 
 2190    void popFront(std::size_t count)
 
 2192        Base::popFront(count);
 
 2196    inline void pop_front(std::size_t count)
 
 2208    template <
typename U>
 
 2209    void pushBack(U&& value)
 
 2211        Base::pushBack(std::forward<U>(value));
 
 2222    template <
typename... TArgs>
 
 2223    void emplaceBack(TArgs&&... args)
 
 2225        Base::emplaceBack(std::forward<TArgs>(args)...);
 
 2229    template <
typename U>
 
 2230    inline void push_back(U&& value)
 
 2232        pushBack(std::forward<U>(value));
 
 2242    template <
typename U>
 
 2243    void pushFront(U&& value)
 
 2245        Base::pushFront(std::forward<U>(value));
 
 2249    template <
typename U>
 
 2250    inline void push_front(U&& value)
 
 2252        pushFront(std::forward<U>(value));
 
 2270    template <
typename U>
 
 2271    LinearisedIterator insert(LinearisedIterator pos, U&& value)
 
 2273        return Base::insert(pos, std::forward<U>(value));
 
 2285        return Base::front();
 
 2289    ConstReference front()
 const 
 2291        return Base::front();
 
 2302        return Base::back();
 
 2306    ConstReference back()
 const 
 2308        return Base::back();
 
 2321    Reference operator[](std::size_t index)
 
 2323        return Base::operator[](index);
 
 2327    ConstReference operator[](std::size_t index)
 const 
 2329        return Base::operator[](index);
 
 2343    Reference at(std::size_t index)
 
 2345        return Base::at(index);
 
 2349    ConstReference at(std::size_t index)
 const 
 2351        return Base::at(index);
 
 2363    int indexOf(ConstReference element)
 const 
 2365        return Base::indexOf(element);
 
 2374    LinearisedIterator invalidIter()
 
 2376        return Base::invalidIter();
 
 2380    ConstLinearisedIterator invalidIter()
 const 
 2382        return Base::invalidIter();
 
 2390    ReverseLinearisedIterator invalidReverseIter()
 
 2392        return Base::invalidReverseIter();
 
 2396    ConstReverseLinearisedIterator invalidReverseIter()
 const 
 2398        return Base::invalidReverseIter();
 
 2415    LinearisedIterator lbegin()
 
 2417        return Base::lbegin();
 
 2421    ConstLinearisedIterator lbegin()
 const 
 2423        return Base::lbegin();
 
 2427    ConstLinearisedIterator clbegin()
 const 
 2429        return Base::clbegin();
 
 2446    ReverseLinearisedIterator rlbegin()
 
 2448        return Base::rlbegin();
 
 2452    ConstReverseLinearisedIterator rlbegin()
 const 
 2454        return Base::rlbegin();
 
 2458    ConstReverseLinearisedIterator crlbegin()
 const 
 2460        return Base::crlbegin();
 
 2475    LinearisedIterator lend()
 
 2477        return Base::lend();
 
 2481    ConstLinearisedIterator lend()
 const 
 2483        return Base::lend();
 
 2487    ConstLinearisedIterator clend()
 const 
 2489        return Base::clend();
 
 2504    ReverseLinearisedIterator rlend()
 
 2506        return Base::rlend();
 
 2510    ConstReverseLinearisedIterator rlend()
 const 
 2512        return Base::rlend();
 
 2516    ConstReverseLinearisedIterator crlend()
 const 
 2518        return Base::crlend();
 
 2561    bool linearised()
 const 
 2563        return Base::linearised();
 
 2567    bool isLinearised()
 const 
 2569        return linearised();
 
 2591    LinearisedIteratorRange arrayOne()
 
 2593        return Base::arrayOne();
 
 2597    ConstLinearisedIteratorRange arrayOne()
 const 
 2599        return Base::arrayOne();
 
 2625    LinearisedIteratorRange arrayTwo()
 
 2627        return Base::arrayTwo();
 
 2631    ConstLinearisedIteratorRange arrayTwo()
 const 
 2633        return Base::arrayTwo();
 
 2649    void resize(std::size_t newSize)
 
 2651        Base::resize(newSize);
 
 2665    LinearisedIterator erase(LinearisedIterator pos)
 
 2667        return Base::erase(pos);
 
 2680    Iterator erase(Iterator pos)
 
 2682        auto iter = Base::erase(pos);
 
 2683        return *(
static_cast<Iterator*
>(&iter));
 
 2696        auto iter = Base::begin();
 
 2697        return *(
static_cast<Iterator*
>(&iter));
 
 2701    ConstIterator begin()
 const 
 2703        auto iter = Base::begin();
 
 2704        return *(
static_cast<ConstIterator*
>(&iter));
 
 2708    ConstIterator cbegin()
 const 
 2710        auto iter = Base::cbegin();
 
 2711        return *(
static_cast<ConstIterator*
>(&iter));
 
 2724        auto iter = Base::end();
 
 2725        return *(
static_cast<Iterator*
>(&iter));
 
 2729    ConstIterator end()
 const 
 2731        auto iter = Base::end();
 
 2732        return *(
static_cast<ConstIterator*
>(&iter));
 
 2736    ConstIterator cend()
 const 
 2738        auto iter = Base::end();
 
 2739        return *(
static_cast<ConstIterator*
>(&iter));
 
 2743    template <std::
size_t TAnySize>
 
 2744    bool operator==(
const StaticQueue<T, TAnySize>& other)
 const 
 2746        return Base::operator==(other);
 
 2750    template <std::
size_t TAnySize>
 
 2751    bool operator!=(
const StaticQueue<T, TAnySize>& other)
 const 
 2753        return Base::operator!=(other);
 
 2758    using ArrayType = std::array<StorageType, TSize>;
 
 2759    alignas(
alignof(T)) ArrayType m_array;
 
 2765template <
typename T, std::
size_t TSize>
 
 2766class StaticQueue<T, TSize>::ConstIterator : 
public StaticQueue<T, TSize>::Base::ConstIterator
 
 2768    using Base = 
typename StaticQueue<T, TSize>::Base::ConstIterator;
 
 2772    using IteratorCategory = 
typename Base::IteratorCategory;
 
 2775    using iterator_category = IteratorCategory;
 
 2778    using ValueType = 
typename Base::ValueType;
 
 2781    using value_type = ValueType;
 
 2784    using DifferenceType = 
typename Base::DifferenceType;
 
 2787    using difference_type = DifferenceType;
 
 2790    using Pointer = 
typename Base::Pointer;
 
 2793    using pointer = Pointer;
 
 2796    using ConstPointer = 
typename Base::ConstPointer;
 
 2799    using Reference = 
typename Base::Reference;
 
 2802    using reference = Reference;
 
 2805    using ConstReference = 
typename Base::ConstReference;
 
 2808    using QueueType = StaticQueue<T, TSize>;
 
 2811    using ConstLinearisedIterator = 
typename QueueType::ConstLinearisedIterator;
 
 2816    ConstIterator(
const QueueType& queue, ConstLinearisedIterator iterator)
 
 2817        : Base(queue, iterator)
 
 2822    ConstIterator(
const ConstIterator&) = 
default;
 
 2827    ConstIterator& operator=(
const ConstIterator& other)
 
 2829        return static_cast<ConstIterator&
>(Base::operator=(other));
 
 2833    ConstIterator& operator++()
 
 2835        return static_cast<ConstIterator&
>(Base::operator++());
 
 2839    ConstIterator operator++(
int dummyParam)
 
 2841        auto tmp = Base::operator++(dummyParam);
 
 2842        return *(
static_cast<ConstIterator*
>(&tmp));
 
 2846    ConstIterator& operator--()
 
 2848        return static_cast<ConstIterator&
>(Base::operator--());
 
 2852    ConstIterator operator--(
int dummyParam)
 
 2854        auto tmp = Base::operator--(dummyParam);
 
 2855        return *(
static_cast<ConstIterator*
>(&tmp));
 
 2860    ConstIterator& operator+=(DifferenceType value)
 
 2862        return static_cast<ConstIterator&
>(Base::operator+=(value));
 
 2867    ConstIterator& operator-=(DifferenceType value)
 
 2869        return static_cast<ConstIterator&
>(Base::operator-=(value));
 
 2876    ConstIterator operator+(DifferenceType value)
 const 
 2878        auto tmp = Base::operator+(value);
 
 2879        return *(
static_cast<ConstIterator*
>(&tmp));
 
 2886    ConstIterator operator-(DifferenceType value)
 const 
 2888        auto tmp = Base::operator-(value);
 
 2889        return *(
static_cast<ConstIterator*
>(&tmp));
 
 2895    DifferenceType operator-(
const ConstIterator& other)
 const 
 2897        return Base::operator-(other);
 
 2902    bool operator==(
const ConstIterator& other)
 const 
 2904        return Base::operator==(other);
 
 2909    bool operator!=(
const ConstIterator& other)
 const 
 2911        return Base::operator!=(other);
 
 2916    bool operator<(
const ConstIterator& other)
 const 
 2918        return Base::operator<(other);
 
 2923    bool operator<=(
const ConstIterator& other)
 const 
 2925        return Base::operator<=(other);
 
 2930    bool operator>(
const ConstIterator& other)
 const 
 2932        return Base::operator>(other);
 
 2937    bool operator>=(
const ConstIterator& other)
 const 
 2939        return Base::operator>=(other);
 
 2943    Reference operator*()
 
 2945        return Base::operator*();
 
 2949    ConstReference operator*()
 const 
 2951        return Base::operator*();
 
 2955    Pointer operator->()
 
 2957        return Base::operator->();
 
 2961    ConstPointer operator->()
 const 
 2963        return Base::operator->();
 
 2970template <
typename T, std::
size_t TSize>
 
 2971class StaticQueue<T, TSize>::Iterator : 
public StaticQueue<T, TSize>::Base::Iterator
 
 2973    using Base = 
typename StaticQueue<T, TSize>::Base::Iterator;
 
 2977    using IteratorCategory = 
typename Base::IteratorCategory;
 
 2980    using iterator_category = IteratorCategory;
 
 2983    using ValueType = 
typename Base::ValueType;
 
 2986    using value_type = ValueType;
 
 2989    using DifferenceType = 
typename Base::DifferenceType;
 
 2992    using difference_type = DifferenceType;
 
 2995    using Pointer = 
typename Base::Pointer;
 
 2998    using pointer = Pointer;
 
 3001    using ConstPointer = 
typename Base::ConstPointer;
 
 3004    using Reference = 
typename Base::Reference;
 
 3007    using reference = Reference;
 
 3010    using ConstReference = 
typename Base::ConstReference;
 
 3013    using QueueType = StaticQueue<T, TSize>;
 
 3016    using LinearisedIterator = 
typename QueueType::LinearisedIterator;
 
 3019    using ConstLinearisedIterator = 
typename QueueType::ConstLinearisedIterator;
 
 3024    Iterator(QueueType& queue, LinearisedIterator iterator)
 
 3025        : Base(queue, iterator)
 
 3030    Iterator(
const Iterator&) = 
default;
 
 3035    Iterator& operator=(
const Iterator& other)
 
 3037        return static_cast<Iterator&
>(Base::operator=(other));
 
 3041    Iterator& operator++()
 
 3043        return static_cast<Iterator&
>(Base::operator++());
 
 3047    Iterator operator++(
int dummyParam)
 
 3049        auto tmp = Base::operator++(dummyParam);
 
 3050        return *(
static_cast<Iterator*
>(&tmp));
 
 3054    Iterator& operator--()
 
 3056        return static_cast<Iterator&
>(Base::operator--());
 
 3060    Iterator operator--(
int dummyParam)
 
 3062        auto tmp = Base::operator--(dummyParam);
 
 3063        return *(
static_cast<Iterator*
>(&tmp));
 
 3068    Iterator& operator+=(DifferenceType value)
 
 3070        return static_cast<Iterator&
>(Base::operator+=(value));
 
 3075    Iterator& operator-=(DifferenceType value)
 
 3077        return static_cast<Iterator&
>(Base::operator-=(value));
 
 3084    Iterator operator+(DifferenceType value)
 const 
 3086        auto tmp = Base::operator+(value);
 
 3087        return *(
static_cast<Iterator*
>(&tmp));
 
 3094    Iterator operator-(DifferenceType value)
 const 
 3096        auto tmp = Base::operator-(value);
 
 3097        return *(
static_cast<Iterator*
>(&tmp));
 
 3103    DifferenceType operator-(
const Iterator& other)
 const 
 3105        return Base::operator-(other);
 
 3110    bool operator==(
const Iterator& other)
 const 
 3112        return Base::operator==(other);
 
 3117    bool operator!=(
const Iterator& other)
 const 
 3119        return Base::operator!=(other);
 
 3124    bool operator<(
const Iterator& other)
 const 
 3126        return Base::operator<(other);
 
 3131    bool operator<=(
const Iterator& other)
 const 
 3133        return Base::operator<=(other);
 
 3138    bool operator>(
const Iterator& other)
 const 
 3140        return Base::operator>(other);
 
 3145    bool operator>=(
const Iterator& other)
 const 
 3147        return Base::operator>=(other);
 
 3151    Reference operator*()
 
 3153        return Base::operator*();
 
 3157    ConstReference operator*()
 const 
 3159        return Base::operator*();
 
 3163    Pointer operator->()
 
 3165        return Base::operator->();
 
 3169    ConstPointer operator->()
 const 
 3171        return Base::operator->();
 
 3174    operator ConstIterator()
 const 
 3176        auto iter = 
static_cast<ConstLinearisedIterator
>(Base::getIterator());
 
 3177        const auto& queue = 
static_cast<QueueType&
>(Base::getQueue());
 
 3178        return ConstIterator(queue, iter);
 
 3188COMMS_MSVC_WARNING_POP
 
Replacement of std::aligned_storage due to deprecation since C++23.
This file contains classes required for generic custom assertion functionality.
#define COMMS_ASSERT(expr)
Generic assert macro.
Definition Assert.h:170
Contains various compiler related definitions.
Main namespace for all classes / functions of COMMS library.
Replacement to std::conditional.
Definition type_traits.h:29
Replacement to some types from standard type_traits.