iceoryx_hoofs/cxx/vector.hpp🔗
Namespaces🔗
Name |
---|
iox building block to easily create free function for logging in a library context |
iox::cxx |
Classes🔗
Name | |
---|---|
class | iox::cxx::vector C++11 compatible vector implementation. We needed to do some adjustments in the API since we do not use exceptions and we require a data structure which can be located fully in the shared memory. |
Functions🔗
Name | |
---|---|
template <typename T ,uint64_t CapacityLeft,uint64_t CapacityRight> bool |
operator==(const iox::cxx::vector< T, CapacityLeft > & lhs, const iox::cxx::vector< T, CapacityRight > & rhs) |
template <typename T ,uint64_t CapacityLeft,uint64_t CapacityRight> bool |
operator!=(const iox::cxx::vector< T, CapacityLeft > & lhs, const iox::cxx::vector< T, CapacityRight > & rhs) |
Functions Documentation🔗
function operator==🔗
template <typename T ,
uint64_t CapacityLeft,
uint64_t CapacityRight>
bool operator==(
const iox::cxx::vector< T, CapacityLeft > & lhs,
const iox::cxx::vector< T, CapacityRight > & rhs
)
function operator!=🔗
template <typename T ,
uint64_t CapacityLeft,
uint64_t CapacityRight>
bool operator!=(
const iox::cxx::vector< T, CapacityLeft > & lhs,
const iox::cxx::vector< T, CapacityRight > & rhs
)
Source code🔗
// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
#ifndef IOX_HOOFS_CXX_VECTOR_HPP
#define IOX_HOOFS_CXX_VECTOR_HPP
#include "iceoryx_hoofs/cxx/requires.hpp"
#include <algorithm>
#include <cstdint>
#include <cstdio>
#include <utility>
namespace iox
{
namespace cxx
{
template <typename T, uint64_t Capacity>
class vector
{
public:
using value_type = T;
using iterator = T*;
using const_iterator = const T*;
vector() noexcept = default;
vector(const uint64_t count, const T& value) noexcept;
vector(const uint64_t count) noexcept;
vector(const vector& rhs) noexcept;
vector(vector&& rhs) noexcept;
~vector() noexcept;
vector& operator=(const vector& rhs) noexcept;
vector& operator=(vector&& rhs) noexcept;
iterator begin() noexcept;
const_iterator begin() const noexcept;
iterator end() noexcept;
const_iterator end() const noexcept;
T* data() noexcept;
const T* data() const noexcept;
// is undefined if the element at index does not exist.
T& at(const uint64_t index) noexcept;
const T& at(const uint64_t index) const noexcept;
// is undefined if the element at index does not exist.
T& operator[](const uint64_t index) noexcept;
const T& operator[](const uint64_t index) const noexcept;
T& front() noexcept;
const T& front() const noexcept;
T& back() noexcept;
const T& back() const noexcept;
uint64_t capacity() const noexcept;
uint64_t size() const noexcept;
bool empty() const noexcept;
void clear() noexcept;
template <typename... Targs>
bool resize(const uint64_t count, const Targs&... args) noexcept;
template <typename... Targs>
bool emplace(const uint64_t position, Targs&&... args) noexcept;
template <typename... Targs>
bool emplace_back(Targs&&... args) noexcept;
bool push_back(const T& value) noexcept;
bool push_back(T&& value) noexcept;
bool pop_back() noexcept;
iterator erase(iterator position) noexcept;
private:
using element_t = uint8_t[sizeof(T)];
alignas(T) element_t m_data[Capacity];
uint64_t m_size = 0u;
};
} // namespace cxx
} // namespace iox
template <typename T, uint64_t CapacityLeft, uint64_t CapacityRight>
bool operator==(const iox::cxx::vector<T, CapacityLeft>& lhs, const iox::cxx::vector<T, CapacityRight>& rhs) noexcept;
template <typename T, uint64_t CapacityLeft, uint64_t CapacityRight>
bool operator!=(const iox::cxx::vector<T, CapacityLeft>& lhs, const iox::cxx::vector<T, CapacityRight>& rhs) noexcept;
#include "iceoryx_hoofs/internal/cxx/vector.inl"
#endif // IOX_HOOFS_CXX_VECTOR_HPP
Updated on 18 December 2023 at 13:11:42 CET