Skip to content

Commit

Permalink
iox-eclipse-iceoryx#1614 Move UninitializedArray to internal, add sta…
Browse files Browse the repository at this point in the history
…tic_assert

Signed-off-by: Marika Lehmann <marika.lehmann@apex.ai>
  • Loading branch information
FerdinandSpitzschnueffler committed Nov 1, 2022
1 parent f14fddc commit 1f5f480
Show file tree
Hide file tree
Showing 18 changed files with 21 additions and 20 deletions.
1 change: 0 additions & 1 deletion .clang-tidy-diff-scans.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
./iceoryx_hoofs/test/moduletests/test_posix*
./iceoryx_hoofs/include/iceoryx_hoofs/design_pattern/builder.hpp

./iceoryx_hoofs/include/iceoryx_hoofs/containers/*
./iceoryx_hoofs/include/iceoryx_hoofs/internal/containers/*
./iceoryx_hoofs/test/moduletests/test_containers_*

Expand Down
2 changes: 1 addition & 1 deletion iceoryx_dust/include/iceoryx_dust/cxx/forward_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#ifndef IOX_DUST_CXX_FORWARD_LIST_HPP
#define IOX_DUST_CXX_FORWARD_LIST_HPP

#include "iceoryx_hoofs/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/cxx/helplets.hpp"
#include "iceoryx_hoofs/internal/containers/uninitialized_array.hpp"

#include <cstdint>
#include <iostream>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#define IOX_DUST_POSIX_WRAPPER_NAMED_PIPE_HPP

#include "iceoryx_hoofs/concurrent/lockfree_queue.hpp"
#include "iceoryx_hoofs/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/cxx/string.hpp"
#include "iceoryx_hoofs/design_pattern/creation.hpp"
#include "iceoryx_hoofs/internal/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/internal/posix_wrapper/ipc_channel.hpp"
#include "iceoryx_hoofs/internal/posix_wrapper/shared_memory_object.hpp"
#include "iceoryx_hoofs/internal/units/duration.hpp"
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The module structure is a logical grouping. It is replicated for `concurrent` an
|:---------------------:|:--------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|`vector` | | Heap and exception free implementation of `std::vector` |
|`list` | | Heap and exception free, relocatable implementation of `std::list` |
|`UninitializedArray` | | Wrapper class for an uninitialized C-style array which can be zeroed via a template parameter |
|`UninitializedArray` | i | Wrapper class for an uninitialized C-style array which can be zeroed via a template parameter |

### Vocabulary types (vocabulary)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
#ifndef IOX_HOOFS_CONCURRENT_LOCKFREE_QUEUE_HPP
#define IOX_HOOFS_CONCURRENT_LOCKFREE_QUEUE_HPP

#include "iceoryx_hoofs/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/cxx/optional.hpp"
#include "iceoryx_hoofs/internal/concurrent/lockfree_queue/index_queue.hpp"
#include "iceoryx_hoofs/internal/containers/uninitialized_array.hpp"

#include <atomic>

Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/include/iceoryx_hoofs/cxx/list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#ifndef IOX_HOOFS_CXX_LIST_HPP
#define IOX_HOOFS_CXX_LIST_HPP

#include "iceoryx_hoofs/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/cxx/helplets.hpp"
#include "iceoryx_hoofs/internal/containers/uninitialized_array.hpp"

#include <cstdint>
#include <iostream>
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/include/iceoryx_hoofs/cxx/optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#ifndef IOX_HOOFS_CXX_OPTIONAL_HPP
#define IOX_HOOFS_CXX_OPTIONAL_HPP

#include "iceoryx_hoofs/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/cxx/functional_interface.hpp"
#include "iceoryx_hoofs/cxx/requires.hpp"
#include "iceoryx_hoofs/internal/containers/uninitialized_array.hpp"

#include <new> // needed for placement new in the construct_value member function
#include <utility>
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/include/iceoryx_hoofs/cxx/stack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#ifndef IOX_HOOFS_CXX_STACK_HPP
#define IOX_HOOFS_CXX_STACK_HPP

#include "iceoryx_hoofs/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/cxx/algorithm.hpp"
#include "iceoryx_hoofs/cxx/optional.hpp"
#include "iceoryx_hoofs/internal/containers/uninitialized_array.hpp"

#include <cstdint>

Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/include/iceoryx_hoofs/cxx/string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#ifndef IOX_HOOFS_CXX_STRING_HPP
#define IOX_HOOFS_CXX_STRING_HPP

#include "iceoryx_hoofs/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/cxx/optional.hpp"
#include "iceoryx_hoofs/cxx/type_traits.hpp"
#include "iceoryx_hoofs/internal/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/internal/cxx/string_internal.hpp"

#include <algorithm>
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/include/iceoryx_hoofs/cxx/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
#ifndef IOX_HOOFS_CXX_VECTOR_HPP
#define IOX_HOOFS_CXX_VECTOR_HPP

#include "iceoryx_hoofs/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/cxx/algorithm.hpp"
#include "iceoryx_hoofs/cxx/attributes.hpp"
#include "iceoryx_hoofs/cxx/requires.hpp"
#include "iceoryx_hoofs/internal/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/log/logging.hpp"

#include <algorithm>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#ifndef IOX_HOOFS_CONCURRENT_FIFO_HPP
#define IOX_HOOFS_CONCURRENT_FIFO_HPP

#include "iceoryx_hoofs/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/cxx/optional.hpp"
#include "iceoryx_hoofs/internal/containers/uninitialized_array.hpp"

#include <atomic>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#ifndef IOX_HOOFS_CONCURRENT_SOFI_HPP
#define IOX_HOOFS_CONCURRENT_SOFI_HPP

#include "iceoryx_hoofs/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/cxx/type_traits.hpp"
#include "iceoryx_hoofs/internal/containers/uninitialized_array.hpp"
#include "iceoryx_platform/platform_correction.hpp"

#include <atomic>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ struct NotZeroedBuffer
template <typename ElementType, uint64_t Capacity, template <typename, uint64_t> class Buffer = NotZeroedBuffer>
class UninitializedArray
{
static_assert(Capacity > 0U, "The size of the UninitializedArray must be greater than 0!");

public:
using value_type = ElementType;
using iterator = ElementType*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#ifndef IOX_HOOFS_CONTAINERS_UNINITIALIZED_ARRAY_INL
#define IOX_HOOFS_CONTAINERS_UNINITIALIZED_ARRAY_INL

#include "iceoryx_hoofs/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/internal/containers/uninitialized_array.hpp"

namespace iox
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
#ifndef IOX_HOOFS_POSIX_WRAPPER_POSIX_CALL_HPP
#define IOX_HOOFS_POSIX_WRAPPER_POSIX_CALL_HPP

#include "iceoryx_hoofs/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/cxx/algorithm.hpp"
#include "iceoryx_hoofs/cxx/attributes.hpp"
#include "iceoryx_hoofs/cxx/expected.hpp"
#include "iceoryx_hoofs/cxx/string.hpp"
#include "iceoryx_hoofs/internal/containers/uninitialized_array.hpp"

#include <cstdint>
#include <cstring>
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/source/posix_wrapper/posix_access_rights.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// SPDX-License-Identifier: Apache-2.0

#include "iceoryx_hoofs/posix_wrapper/posix_access_rights.hpp"
#include "iceoryx_hoofs/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/internal/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/posix_wrapper/posix_call.hpp"
#include "iceoryx_platform/grp.hpp"
#include "iceoryx_platform/platform_correction.hpp"
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/source/posix_wrapper/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// SPDX-License-Identifier: Apache-2.0

#include "iceoryx_hoofs/posix_wrapper/thread.hpp"
#include "iceoryx_hoofs/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/internal/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/log/logging.hpp"
#include "iceoryx_hoofs/posix_wrapper/posix_call.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "test.hpp"

#include "iceoryx_hoofs/containers/uninitialized_array.hpp"
#include "iceoryx_hoofs/internal/containers/uninitialized_array.hpp"

namespace
{
Expand Down Expand Up @@ -150,15 +150,15 @@ TYPED_TEST(UninitializedArrayTest, EndReturnsIteratorToEndOfUninitializedArray)
{
::testing::Test::RecordProperty("TEST_ID", "52447fba-0c7f-40df-8b7f-64d8b3ffcc49");
auto& buffer = this->buffer;
EXPECT_EQ(buffer.end(), &buffer[0] + buffer.capacity());
EXPECT_EQ(buffer.end(), &buffer[buffer.capacity()]);
}

TYPED_TEST(UninitializedArrayTest, ConstEndReturnsIteratorToEndOfUninitializedArray)
{
::testing::Test::RecordProperty("TEST_ID", "2946ad83-b782-4c54-966b-c94b482335cc");
auto& buffer = this->buffer;
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) reuse of buffer to test const method
EXPECT_EQ(const_cast<const decltype(buffer)>(buffer).end(), &buffer[0] + buffer.capacity());
EXPECT_EQ(const_cast<const decltype(buffer)>(buffer).end(), &buffer[buffer.capacity()]);
}

TEST(UninitializedArrayTest, BeginAndEndIteratorNotEqualInNonEmptyUninitializedArray)
Expand All @@ -183,7 +183,7 @@ TEST(UninitializedArrayTest, BeginAndEndConstIteratorNotEqualInNonEmptyUninitial
new (&buffer[0]) Buffer::value_type(2);

// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) reuse of buffer to test const methods
EXPECT_NE(const_cast<Buffer&>(buffer).begin(), const_cast<Buffer&>(buffer).end());
EXPECT_NE(const_cast<const Buffer&>(buffer).begin(), const_cast<const Buffer&>(buffer).end());
}

TYPED_TEST(UninitializedArrayTest, BeginAndEndIteratorNotEqualInFullUninitializedArray)
Expand Down

0 comments on commit 1f5f480

Please sign in to comment.